# Questions tagged [code-golf]

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

11,752 questions
Filter by
Sorted by
Tagged with
2k views

### Generate the Crystal Maze™ time matrix

Behold! The Crystal Maze™ Time Matrix! ...
1 vote
154 views

### Start a program so that /proc/self/cmdline contains a binary representation of the input number

I am sorry for the very long description. But i think some information of how /proc/self/cmdline works and how it can be used to get a integer input was necessary. ...
1k views

### (Robbers) Fast and Golfiest Season 1: The Lord of the Strings

Fast and Golfiest Robbers Thread Welcome to the first season of Fast and Golfiest, a cops-and-robbers challenge! I designed this challenge to encourage competitive coding for efficiency (fastest ...
1k views

### (Cops) Fast and Golfiest Season 1: The Lord of the Strings

Fast and Golfiest Cops Thread Welcome to the first season of Fast and Golfiest, a cops-and-robbers challenge! I designed this challenge to encourage competitive coding for efficiency (fastest ...
3k views

### Code Golf for Golf

My first code golf question post! Hope u like it ;-) The task is simple. Write either an stdin-stdout program or a function. Input is a 2D array which contains only either characters or the integer <...
3k views

### Numbers that can be negated by reading backwards

Balanced ternary is a modified version of ternary (base 3), using the three digits 1,0 and -1...
1k views

### Output / Convert to unary number

Your task is it to output a number as a unary string. You get the number of a non-negative integer input in the range of 0 - 2'000'000'000. Rules You can choose any character for the digit you like. ...
1 vote
471 views

### Relations between interval and semitones

Output this table: -2* -1* - 0 - 1 2 -1* 0 1 - 2 3 4 1 2 3 - 4 5 6 3 4 - 5 - 6 7 5 6 - 7 - 8 9 6 7 8 - 9 10 11 8 9 10 - 11 12 13 10 11 - 12 - 13 14 You can output one string with two types of ...
2k views

### Chamber of Reflection

Background A ray of light is fired from the top left vertex of an MxN Chamber, where M a denotes the width and ...
2k views

Diagonalize a vector into a matrix. Input A vector, list, array, etc. of integers $\mathbf{v}$ of length $n$. Output A $n \times n$ matrix, 2D array, etc. $A$ such that for each element $a_i \... 0 votes 1 answer 74 views ### Find the sum of primes [duplicate] Given a number x, find the sum of all primes up to that number. The input will always be a positive number, bigger than 2. An upper limit isn't defined, so data types can be ignored. Use whichever you ... 9 votes 13 answers 982 views ### Landmine Number V Background You have again x4 been given the task of calculating the number of landmines in a field. But this time, the field is not a number field... it's a field of letters. Our landmine letter ... 7 votes 1 answer 239 views ### Reverse Conway's Game of Life Conway's Game of Life is a cellular automaton "played" on an infinite grid, filled with cells that are either alive or dead. Once given an initial state, the board evolves indefinitely ... 10 votes 13 answers 1k views ### Landmine Number IV Background You have again x3 been given the task of calculating the number of landmines in a field. But this time, we have no landmine number, and some landmines have exploded. You must calculate the ... 14 votes 19 answers 2k views ### Vanilla Natural Logarithm Challenge There is a challenge for multiplying two numbers so I guess this counts too Given as input a positive real number n compute its natural logarithm. Your answer ... 6 votes 6 answers 957 views ### Critical Calculations Background In the game stick ranger, there is an item which grants the character the ability to get critical hits. Each time a projectile hits an enemy, it has some probability to be a critical hit (... 22 votes 40 answers 3k views ### Sum of a range of a sum of a range of a sum of a range of a sum of a range of a sum of Inspired by the fact that a few related challenges to this could be answered by Vyxal in 0 Bytes using a special flag combination. Given only one input integer$n$, calculate$f(n,n)$where  f(x,... 11 votes 14 answers 2k views ### Landmine Number III Background You have again, again been given the task of calculating the number of landmines in a field. But this time, the field is foggy. You must calculate the landmine score given a list/string of ... 11 votes 6 answers 691 views ### Compute the maximal Ducci period Given an initial$n$-tuple$t_0=(t_{0,1},...,t_{0,n})$, we can obtain its corresponding Ducci sequence$\{t_0, t_1, ...\}$by the recurrence$\displaystyle t_{i+1}=\left(\left|t_{i,1}-t_{i,2}\...
2k views

Background You are planning your trip away from the Diamond City, and must travel through Diamond Road. However, Diamond Road branches away from Diamond City to different locations. Out of curiosity, ...
2k views

### Landmine Number II

Background You have again been given the task of calculating the number of landmines in a field. However, we have now travelled into the flatlands. You must calculate the landmine score given a list/...
2k views

### Landmine Number I

Background You have been given the task of calculating the number of landmines in a field. You must calculate the landmine score given a list/string of numbers and the landmine number. The landmine ...
686 views

A followup to this challenge by Jeremy Collprav, inspired by DLosc solving this in Regenerate. Some sections copied from the linked challenge. Linking chains We define a chain to be a string ...
1k views

Background We define the two types of chain to be a string that contains only dashes, "-", or only underscores, "_". We link two chains using one equals sign, "=". ...
2k views

### Draw the initial positions of Mölkky pins in ASCII art

Write a function (or a whole program) that outputs (or prints) an ASCII art of the initial position of Mölkky pins. Output : ...
2k views

### Reversed Squares

Given an integer n, your task is to determine whether it is a perfect square that when reversed, is still a perfect square. You may assume n is always positive. When numbers such as 100 (10x10) are ...
848 views

### Translate the keitai input method

The keitai input method is a method for writing Japanese kana on a 12-key phone keypad. Similar to Western keypads, each kana is assigned to a key; when the key is pressed multiple times, it cycles ...
714 views

### Detect Maxima Using Persistent Homology

Inspired by this SO answer about peak detection. Background Persistent homology is a fancy term for a fancy math concept, but in this case all we care about is how it can be used for peak detection. ...
3k views

### Output each second

With roughly one second (plus or minus 10 ms) between outputs, output anything. The first output must be at most one second after the start of the program, but can be as soon as right when the program ...
1k views

### Approximate e using small numbers

Given an input integer from 1, 2, ..., n, the task to write code to make a number as close as possible (as measured by absolute distance) to e using only the four ...
218 views

### Minimum partition with non-empty intersections

Given a set of intervals $\mathcal{I} = \{I_1, \ldots, I_m\}$, where each interval $I_j$ is represented by its bounds $(a_j, b_j)$, find a partition $\mathcal{T}$ of $\mathcal{I}$ of minimal ...
2k views

### XOR of independent Bernoulli variables

In probability theory, a Bernoulli variable is a random variable which has a single parameter $p$, and is equal to 1 with probability $p$, and 0 with probability $1-p$. In this challenge, there ...
294 views

### Wrt "Hello World" prgrm bt wth n vwls

Create A "Hello, World!" program but without any vowels. Winner is the program with the least bytes. Rules: No vowels are allowed in the code. Must print to STDOUT Must be a full program. ...
198 views

### Tips for golfing in (,) in-paren-comma

What tips do you have for golfing in (,)? I've found that there are so many ways to make code shorter, and I want more ways. I doubt there even are any tips for (,) that are applicable in the majority ...
2k views

### Vertices of a regular dodecahedron

A regular dodecahedron is one of the five Platonic solids. It has 12 pentagonal faces, 20 vertices, and 30 edges. Your task is to output the vertex coordinates of a regular dodecahedron. The size, ...
3k views

### Last odd digit of power of 2

Task Given $n$, output position of the last odd digit in the decimal representation of $2^n$ (counting from the end). Rules There are no odd digits for $n=1,2,3,6,11$ $(2, 4, 8, 64, 2048)$ - ...
1k views

A digit addition generator of an integer n is any integer x that satisfy the equation ...
2k views

### Sudoku as a SAT problem

Background An interesting way to solve a Sudoku puzzle is to represent it as a Boolean satisfiability problem, and then feed it to a SAT solver. A Boolean Satisfiability Problem (abbreviated as SAT ...
201 views

### Tips for golfing in Arturo

Arturo is a bytecode-compiled/interpreted, garbage-collected general-purpose language filling a role similar to JavaScript, Python and Ruby. It is centered around the concept of blocks, which hold ...
2k views

### What is the shortest regex for the month of January in a handful of the world's languages?

What is the shortest regular expression equivilant to the following? ...
2k views

### Render text in a slanted ASCII-art font

Given a text input such as: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG render the following output: ...
2k views

### Split a string on unnested commas

Create the shortest program/function/whatever that splits an inputted string along un-nested commas. A comma is considered nested if it is either within parentheses, brackets, or braces. Input and ...
981 views

### Can Bitshift Variations in C Minor be compressed down to less than 185 characters?

Bitshift Variations in C Minor by Robert Miles is a Code Golf music piece written in C (with some additional bash commands). It was originally presented in a 2016 Computerphile video Code Golf & ...
647 views

### Complete the landscape

Carcassonne is a tile-based game, where the objective is to construct Roads, Cities and Monasteries, in order to score points. The game works by players taking turns to draw and place tiles to ...
281 views

### My eight braille pattern progressive snake spinner

Introduction I would like to drawn a nice spinner by using eight braille patterns on two lines, drawing a square of 8x8 pixel, for showing a kind of snake growing and reducing: ...
1k views

Given a list, L, of sets of numbers like this: [, [0,2,3], [3,1], [1,2,3]] Output a single list of numbers such that 2 ...
2k views

### Output endless powers of 2 [duplicate]

In any programming language, make a program that outputs infinite subsequent powers of two, starting at any power of two with finite integer exponent. There does not need to be a seperator between ...
2k views

### Logarithmic Incrementation

In this challenge you will write a function that takes a list (ordered set) containing real numbers (the empty list is an exception, as it has nothing) and calculates f(x)=\begin{cases}1 & \text{...
The resultant of two polynomials is a polynomial in their coefficients that is zero if and only if $p$ and $q$ have a common root. It is a useful tool for eliminating variables from systems of ...