Questions tagged [code-golf]
Code-golf is a competition to solve a particular problem in the fewest bytes of source code.
12,373 questions
10
votes
11
answers
447
views
Arithmetic Continued Fractions (Euler's e and beyond)
Arithmetic Continued Fractions (Euler's e and beyond)
Given a, d, and n, compute the n-th convergent of an arithmetic continued fraction and transform it.
Continued fraction structure
The n-th ...
12
votes
3
answers
775
views
Play Beggar My Neighbor
Beggar my neighbor is a deterministic game in which 2 players get dealt half of a 52 card deck, and the objective is to obtain the entire deck.
On their turn, each player places the top card of their ...
23
votes
17
answers
2k
views
Draw the Gauss Star (Heptadecagram)
Background
In 1796, 18-year-old Carl Friedrich Gauss proved that a regular heptadecagon can be constructed with compass and straightedge — the first such discovery in over 2,000 years. The stonemason ...
2
votes
2
answers
362
views
Speak in Binary
Background
This video goes into ways you can humanize binary, including creating a more compact writing notation using . and | ...
4
votes
2
answers
200
views
Identify Redundant Infix Condition
Say there are three multisets A, B, C. An infix condition has form
<ON|FACING|NEAR> <a multiset>
where
ON requires ...
11
votes
4
answers
601
views
Minimum width to connect both sides
Given two sorted lists of same length \$\{a_i\}\$ and \$\{b_i\}\$, find the smallest \$w\$ such that it's possible to connect each pair of points \$(0,a_i)\$ and \$(w,b_i)\$ with paths such that
x-...
-1
votes
1
answer
166
views
Golf a number bigger than all other answers [duplicate]
You have to code in python, and the number generated by your code must be bigger than all other current submissions. You need to make your code as small as possible, it has to terminate but you can ...
-1
votes
1
answer
157
views
Generare a toothbrush diagram [closed]
Given a String of opening brackets and the letter G, such that it makes a applicative tree of the leaf node G and ( representing ...
8
votes
4
answers
673
views
Find a primitive polynomial
Objective
Given a prime number \$p\$ and an integer \$n \geq 2\$, find a degree-\$n\$ primitive polynomial modulo \$p\$.
Mathematical explanation
When we perform "modular arithmetic" over ...
14
votes
10
answers
1k
views
Polynomial Basis Conversion
The most common way to represent a polynomial is writing it as a linear combination of monomials, i.e., powers of the variable. For example, the polynomial \$p(x) = x^3 + 2x^2 + x + 1\$ is a linear ...
18
votes
19
answers
2k
views
Order a list by the difference of its elements
Task
Given an unsorted list of integers, order it in such a way that the absolute difference of every two adjacent elements will always be equal to 1:
\$|dx| = 1\$
There will be guaranteed one or more ...
11
votes
7
answers
637
views
Sticks expectation
This was originally a question from interviewstreet.com over a decade ago
You are given an array (or whatever - your choice of input) of positive integers \$y_1,\ldots,y_n\$ that represents \$n\$ line ...
18
votes
8
answers
1k
views
English to Dutch number order conversion
Introduction:
When saying numbers out loud, the order is slightly different in Dutch than in English. For a number like \$1234\$:
in English you'd say: one thousand, two hundred and thirty-four
in ...
11
votes
17
answers
957
views
Identify Redundant Regex
A redundant regular expression (regex) is defined here as a regex which has some amount of characters which can be removed while not affecting its functionality -- i.e. it matches the exact same set ...
8
votes
8
answers
1k
views
Validate DNA Sequences with Telomeres
This is inspired by this homework assignment.
Telomeres are regions of repetitive DNA sequences that occur at the ends of linear chromosomes in eukaryotes (such as humans and other mammals). In ...