Questions tagged [code-challenge]
A code challenge is a competition for creative ways to solve a programming puzzle with an objective winning criterion not covered by other scoring tags (e.g. code-golf).
912 questions
4
votes
1
answer
188
views
Through maze with a compressed guide
Given a wall maze of 50x50, exactly same generating algorithm, at different RNG, so every two positions are connected by exactly one path, etc.
Write two functions:
One takes the maze as input and ...
18
votes
3
answers
993
views
Cancel and minimize game
Here is a game: Start with the set {1,2,3,...,n} of natural numbers. At any turn of the game, you may pick two numbers from this set, a and b, then replace them with their product a*b. Since it is a ...
6
votes
2
answers
332
views
Unstablizable LaTeX
from Latexmk:
If you use cross-references, you often have to run LaTeX more than once ...
Sometimes cross-referenced locations change and you need to run LaTeX again to create the correct reference. ...
4
votes
8
answers
934
views
How many distinct characters can be used to implement Boolean Algebra in your programming language [closed]
I am interested in the following problem:
What is the minimum number of distinct characters used in any programming language that can implement Boolean Algebra?
In particular, what is the set that ...
3
votes
1
answer
303
views
Count number of families of sets satisfying a list of criteria
CHALLENGE
This problem has a math background.
For n=1,2,3,4 we want to count the number of families of sets with maximum n elements that satisfy many criteria of the form:
$$\bigoplus_{k\in A,A\in \...
22
votes
2
answers
2k
views
Fast leap year check
The task is to find parameters that make a fast leap year check correct for the widest range of years.
We assume the Proleptic Gregorian calendar, which extends the Gregorian calendar backward from ...
3
votes
2
answers
553
views
Largest possible relative error
Output
\$20\$ float64s with absolute value between 1 and 2 inclusive whose sum has the largest possible relative error. We can assume the true sum is not zero.
The sum is to be computed from left to ...
-3
votes
5
answers
400
views
Create the characters you can write on a MacOS US English Keyboard (as another OS will read them)
Introduction
This is a small challenge I came up with while trying to make some compact code for my younger brother to use. I don't think it's particularly interesting, but I believe it presents some ...
7
votes
2
answers
367
views
Convert maximum values to bit widths
Background
The newest version of the C standard, C23, adds preprocessor macros like INT_WIDTH, ULONG_WIDTH, and ...
1
vote
2
answers
351
views
The many ways to skin a `cat` [duplicate]
The well known cat command simply copies its stdin directly to stdout unchanged. But there are plenty of other commandline tools that exist...
What other commands ...
5
votes
13
answers
2k
views
Print the banned characters based on the most common characters
This is an answer-chaining post, so in this challenge every answer (except the first answer) depends on the previous answer.
The goal of this challenge is to output the restricted characters. Define \$...
4
votes
5
answers
1k
views
What is the smallest possible binary output you can generate
Here is a challenge:
What is the shortest possible compiled program? Writing one line programs are fun, but they often lean on language libraries that get pulled into the final bits. How lean can you ...
30
votes
44
answers
5k
views
Repeat your program to print Fibonacci numbers
Write a program fragment so that, when repeated N times it prints the Nth Fibonacci number. For example, if your program is print(x) then:
...
21
votes
10
answers
3k
views
How Turing complete is your language?
Find the maximum possible number of disjoint sets of characters, that are Turing complete subsets of your language.
Rules:
You can assume your Turing complete subset is contained in/called from a ...
12
votes
9
answers
945
views
Magic OEIS formulae (Cops' thread)
This is the cops' thread. See the robbers' thread here.
In this cops and robbers challenge, the cops will be tasked with writing an algorithm that computes some function of their choice, while the ...
2
votes
0
answers
272
views
making a binary string palindrome using xor operations [closed]
Problem
You are given a binary string A of length N.
You can perform the following type of operation on the string A:
Choose two different indices \$i\$ and \$j\$ (\$1 \le i\$, \$j \le N\$)
Change \$...
19
votes
17
answers
2k
views
Approximate my atomic weight
Each element on the periodic table of the elements has an atomic weight. For example, boron (element 5) has an atomic weight of 10.81. Your challenge is to write a program which takes as input the ...
26
votes
58
answers
4k
views
Range of ASCII values
Your task
Given a string, output the range of ASCII values.
Example
Let's say we have the string Hello.
We get the ASCII values:
...
3
votes
4
answers
924
views
A multidimensional strategy challenge
The wizard is determined to pose the most challenging challenge yet for which he believes the previous solution techniques will not work. He decides to go multidimensional.
If there is a number line ...
10
votes
1
answer
572
views
Turing Machine that outputs pi
Turing Machine Preliminaries
A Turing machine is specified by the following data
A finite set of symbols S = \$\{s_1,s_2,...\}\$
A finite set of states M = \$\{m_1,m_2,...\}\$
A partially defined ...
6
votes
4
answers
686
views
Strategy: The cunning cousin witch
The wizard has a cunning cousin who is a witch. She looks down on the wizard, regarding him and his puzzles as mathematically naive. On reading his latest puzzle, she scorned him for always asking ...
21
votes
12
answers
3k
views
Optimal strategy for wandering robots
If the agent is at the origin it always moves right when you choose it.
The goal is to get one agent to 10.
The cost is the sum of the square of the total number of moves (left or right) taken by each ...
5
votes
7
answers
918
views
Typo resistant pin codes [closed]
Background
I was working on a system where for convenience (not security) people could use four digit codes to identify themselves. I figured this is something that may actually be useful in many real ...
20
votes
11
answers
2k
views
Write a near crystalline program
A pristine program is a program that does not have any errors itself but will error if you modify it by removing any contiguous substring other than the entire program.
A crystalline program is sort ...
-14
votes
5
answers
479
views
12 with no 1234567890, but polyglot
This is my 12th question, so I thought of this idea.
Goal:
Output 12, with any preceding or trailing whitespace permitted
In as many languages as possible (where different versions or flags count as ...