Skip to main content

Questions tagged [code-golf]

Code-golf is a competition to solve a particular problem in the fewest bytes of source code.

Filter by
Sorted by
Tagged with
4 votes
1 answer
140 views

Count the symmetries

Find the order (size) of the symmetry group of a finite set of integer points in d-dimensional space. Input You will be given the coordinates of a finite set of points in d-dimensional space, in any ...
aeh5040's user avatar
  • 1,334
9 votes
9 answers
777 views

Enter a personal identification number

In this challenge your code should allow the user to enter a four digit PIN. Rules If the user types a digit, your code should output a * symbol. If the user presses backspace it should delete the ...
Simd's user avatar
  • 3,255
5 votes
5 answers
224 views

Fractions nobody needs (because they can be reduced to a simpler form)

It happened in the 19th century. Georg was bored and started counting the rational numbers. Surprisingly, he discovered that there were no more of them than natural numbers. This insight made Georg ...
Sophia Antipolis's user avatar
21 votes
8 answers
2k views

Play the Final Fantasy Prelude

Play the initial section of the Final Fantasy Prelude. This is a 4-octave up-down arpeggio of the following chords: Cadd2, Amadd2, Cadd2, Amadd2, Fadd2, Gadd2, G♯maj7, A♯maj7 Rules: Actual sound must ...
G. Sliepen's user avatar
  • 1,201
-1 votes
1 answer
142 views

Implement a Monad

A monad is a type that wraps another type, that represents the available operations on the wrapped type. Monads have the following associated operations, where M is ...
bigyihsuan's user avatar
  • 10.6k
18 votes
11 answers
2k views

Count squares in my pi approximation

One way to approximate π is the following: Start by drawing a 2x2 square with a quarter-circle in it. Then, the area of the quarter-circle is π. We can approximate this area by filling it with ...
emanresu A's user avatar
11 votes
10 answers
2k views

Smallest prime q such that concatenation (p+q)"q is a prime

Let p, q, and c := (p + q)"q (where " denotes concatenation) be positive integers such that p and c are primes and q is the smallest prime such that c is prime. Such a prime triple (p, q, (p ...
Sophia Antipolis's user avatar
10 votes
1 answer
1k views

Not great at regexs. Trying to code-golf this beast of a regex WITHOUT using string replacement (for G-Zip purposes)

Here it is: ...
Overflow2341313's user avatar
-6 votes
4 answers
190 views

Branchless median of 5

Write code to compute the median of 5 positive 32 bit integers. Your code must be branchless. A branch, jump or transfer is an instruction in a computer program that can cause a computer to begin ...
Simd's user avatar
  • 3,255
14 votes
15 answers
2k views

Convert base-10 to base-0.1

Base-0.1 mean e.g. 123.45 means in decimal \$1\times 0.1^2+2\times 0.1^1+3\times 0.1^0+4\times 0.1^{-1}+5\times 0.1^{-2}\$. Input and output should match RegEx <...
l4m2's user avatar
  • 26.3k
10 votes
6 answers
1k views

ASCII 2D landscape

You are given an input string, called path, consisting of u, d and s characters (i.e. ...
mastaH's user avatar
  • 211
9 votes
13 answers
2k views

Function with memories of its past life

Task I need a function that accept string and return a function f1. That f1 function should also accept string and return a <...
talex moved to Codidact's user avatar
15 votes
10 answers
1k views

Sylvester primes

Sylvester's sequence can be defined recursively S(n) = S(n-1)*(S(n-1) + 1) for n >= 1 starting S(0) = 1. Since S(n) and S(n) + 1 have no common divisors, it follows that S(n) has at least one more ...
Sophia Antipolis's user avatar
16 votes
12 answers
3k views

Is it a date format of YYMMDD, MMDDYY, and/or DDMMYY?

The date format varies between countries; the arrangement of date, month and year can be categorized into these three: Year-month-date Month-date-year Date-month-year In Gregorian calendar it's year ...
鳴神裁四点一号's user avatar
12 votes
9 answers
1k views

How many ways can you make change?

The "third type of Euler Transform" takes an integer sequence that gives the number of objects of a given weight and outputs a sequences that gives the number of multisets of objects that ...
Peter Kagey's user avatar
  • 8,821

15 30 50 per page
1
2 3 4 5
806