Questions tagged [code-golf]
Code-golf is a competition to solve a particular problem in the fewest bytes of source code.
12,022
questions
3
votes
7
answers
181
views
Keyboard Ping Pong
Keyboard Ping Pong
This question was inspired by this post from CaucasianJames on X.
Challenge
Given a string of letters, determine if the word "ping-pongs" across the keyboard. (Letters ...
6
votes
10
answers
417
views
Is it an option for the ls utility specified in POSIX.1-2017?
The ls utility lists specified directory content. It is infamous for stupidly lots of options which is known for anti-pattern design of implementing software (...
10
votes
14
answers
904
views
Is this a Hadamard matrix?
Hadamard matrices is a square matrix whose entries are either +1 or −1 and whose rows are mutually orthogonal.
In other words, it means that each pair of rows has matching entries in exactly half of ...
0
votes
5
answers
57
views
Code Golf Tips for code-golfing in Elixir [duplicate]
What general tips do you have for golfing in Elixir? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Elixir (e.g. "remove ...
14
votes
19
answers
673
views
Rolling median of all K-length ranges
Given an array of integers of length N and an odd integer K, return N - K + 1 integers, where the ith integer represents the median of a K-length subarray starting from i.
You may write a full program ...
2
votes
0
answers
68
views
Detect revokes in Jass
Jass is a trick-taking game for four players and the national card game of Switzerland. It is played with a 36-card deck, four suits each with ranks 6, 7, 8, 9, 10, J, Q, K, A. We will be using French ...
9
votes
0
answers
107
views
Plot the ground path of a satellite
If you model a satellite as a free point orbiting a body, you can pretty easily see it has 6 degrees of freedom: three for the X, Y, and Z position, and three for the X, Y, and Z velocity. However, ...
9
votes
12
answers
651
views
Minimum number of select-all/copy/paste steps for a string containing n copies of the original
This challenge is based on this Mathematics answer.
Write the shortest program or function that, when given some natural number \$n\$, outputs \$S(n)\$, which is the minimum number of steps for ...
26
votes
38
answers
2k
views
Segments of a string, doubling in length
Simple task today. Given a string whose length is one less than a whole power of 2, divide it into segments with doubling length.
For example for the string ...
9
votes
8
answers
1k
views
Sort Number Array
Given array \$A\$ \$(a_0, a_1,... , a_n) \$ as a permutation of \$(0, 1,...,n)\$ where \$n ≥ 2\$. Sort array \$A\$ into array \$(0, 1,...,n\$) with \$2\$ caveats:
\$1\$ swap is counted when swapping ...
7
votes
7
answers
790
views
Parity of a number with missing digits
It turns out that you need every digit of a number to determine its parity, if it is written in an odd base.
Your programs should take input as a number between 2 and 36 inclusive, and a nonempty ...
22
votes
6
answers
1k
views
Output the Steiner system S(5,8,24)
Output 759 "rows", each of which consists of 8 distinct integers in the range 0,1,...,23, with the property that every set of 5 integers in the range 0,1,...,23 is contained in exactly one ...
23
votes
10
answers
1k
views
Binary Slashes Display
(easy mode of Seven Slash Display)
Given a positive integer (or alternatively, a string/list of bits of its binary representation) output it with this diagonal ASCII-art formation:
(output for 53 / <...
16
votes
15
answers
2k
views
Transpose these notes!
In this challenge, you should take input as a number between 0 and 11 inclusive and a (possibly empty) list of the following strings/notes:
...
12
votes
13
answers
4k
views
NaN is not equal to NaN
In many programming languages, the floating-point value NaN, or "not a number", in some programming languages generated by the expression ...