Skip to main content

All Questions

Filter by
Sorted by
Tagged with
30 votes
25 answers
8k views

Print 4 billion if statements

Recently (okay, December 2023, I'm a little late) there's been a meme going around about a program checking if a 32-bit unsigned integer is even or odd using four billion if statements: ...
emanresu A's user avatar
  • 43.2k
8 votes
10 answers
2k views

Figure out which of your friends reveals confidential information to the media!

Exposition You send secret information to 100 of your friends, and the next day you discover that the information has been published! Who could have revealed it? To determine that, you number your ...
anatolyg's user avatar
  • 13.8k
8 votes
12 answers
2k views

Tic-tac-toe encode them all

I decided to create a complete guide to the great game of tic-tac-toe. I expected it to be extremely popular, so to save on paper while printing it I decided to encode all possible game positions. I ...
talex moved to Codidact's user avatar
0 votes
4 answers
265 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.7k
9 votes
3 answers
238 views

Convert to Chomsky normal form

Let a context-free language be specified by its production rules and start symbol, e.g. S -> AbB | C C -> b | c B -> AA | AC A -> a | ε Here and in the ...
Parcly Taxel's user avatar
  • 3,945
10 votes
4 answers
2k views

Output a 1-2-3-5-7... sequence

Follow-up of my previous challenge, inspired by @emanresu A's question, and proven possible by @att (Mathematica solution linked) For the purposes of this challenge, a 1-2-3-5-7... sequence is an ...
Tbw's user avatar
  • 2,163
21 votes
15 answers
2k views

Output a 1-2-3 sequence

For the purposes of this challenge, a 1-2-3 sequence is an infinite sequence of increasing positive integers such that for any positive integer \$n\$, exactly one of \$n, 2n,\$ and \$3n\$ appears in ...
Tbw's user avatar
  • 2,163
12 votes
7 answers
2k views

Horsey sightseeing

A knight's tour is a sequence of moves of a knight on a chessboard such that the knight visits every square only once. For those who are not aware of how knights in chess work, knights are capable of ...
totallyhuman's user avatar
  • 17.3k
19 votes
9 answers
997 views

Output an infinitely proportional sequence

In this challenge, an infinitely proportional sequence is defined as a infinite sequence of positive integers such that: All positive integers are contained infinitely many times within the sequence. ...
emanresu A's user avatar
  • 43.2k
17 votes
12 answers
1k views

Encode the input to exclude a given character (part 1)

Your task is to write 2 functions/programs. They may share code. The first function must, given a string and a character, output a new string that does not contain that character. The second function ...
mousetail's user avatar
  • 13k
6 votes
0 answers
218 views

Give the best Chaitin incompleteness bound

This was originally a pure mathematics question, but I think I've got the best chance for an answer here. The Challenge For concreteness, consider Peano Arithmetic (PA). For some language L of your ...
Charles Wang's user avatar
10 votes
9 answers
2k views

Make a super fair number

An even distribution number is a number such that if you select any of it's digits at random the probability of it being any particular value (e.g. 0 or ...
Wheat Wizard's user avatar
  • 99.6k
16 votes
3 answers
466 views

Convert numbers to dice patterns

The way points are assigned on a dice follows a regular pattern, the center dot is present if and only if the number is odd. To represent the even numbers, pairs of dots on opposite sides of the ...
bsoelch's user avatar
  • 6,035
19 votes
22 answers
3k views

Be big more often

Related You are a manager at a large number factory. You want to show everyone your business is doing well, by showing randomly chosen samples. Unfortunately, your business is not doing that well. But ...
The Empty String Photographer's user avatar
16 votes
5 answers
758 views

Prefix code generator

In this challenge, we consider an encoding from positive integers (up to a limit) to binary sequences. Some examples: ...
Bubbler's user avatar
  • 78.3k

15 30 50 per page
1
2 3 4 5
7