# All Questions

11,591 questions
Filter by
Sorted by
Tagged with
1answer
777 views

### Write the implementation to pass this test

Given the following test, implement an addOne function in C# so it passes, without any modification to the test. TIP: Yes, it is possible. ...
1answer
782 views

### Identify the compiler

The challenge You are given a function compile(s: String): Integer which returns 0 if s ...
15answers
5k views

### Write the longest sentence using keywords of a programming language [closed]

As the title said, the challenge is to write the longest sentence by only using the keywords of 1 programming language. For instance, using the keywords of C++, it is possible to write this sentence: ...
10answers
962 views

### Non-transitive dice game

Those of you who like Numberphile would be familiar with Dr. James Grime, who described a non-transitive dice game on his channel. The game consists of three 6-faced dice: Die 1: 3,3,3,3,3,6 Die 2: ...
5answers
306 views

### Gregorian to Noxu Time System Conversion

The world's changing to a new time system! We need to update our computer programs. Given an input of epoch time (number of seconds since January 1st, 1970 00:00), print out a time in the new Noxu ...
3answers
3k views

### Longest non-repeating Game-of-Life sequence

Given a positive integer N, determine the starting pattern on a N x N-grid that yield the longest non-repeating sequence under Game of Life-rules, and ends with a fixed pattern (cycle of length 1), ...
4answers
510 views

### Determine which of two ImageMagick .TXT images is more saturated

You have two images (64x64 pixels each): Your program must take the file names of each of them as command line arguments and determine which has more average saturation among their pixels. The ...
68answers
21k views

### Shortest program that throws StackOverflow Error [closed]

Write a program that throws a StackOverflow Error or the equivalent in the language used. For example, in java, the program should throw java.lang.StackOverflowError...
2answers
2k views

### Compact a Befunge program

Befunge is a 2-dimensional esoteric programming language. The basic idea is that (one-character) commands are placed on a 2-dimensional grid. Control flow walks across the grid, executing commands it ...
5answers
5k views

### “Sorry, young man, but it's Turtles all the way down!”

Execute a Lindenmayer System A Lindenmayer System (or L-system) is related to Thue and Post systems, and is used in botanical modeling and fractal generation. An L-system is described by string-...
17answers
2k views

### Test if given number if a Keith number

Since Fibonacci numbers and sequences seems like a popular subject for code golf I thought that it might be a fun challenge to code golf with Keith numbers. So I propose a challenge that is to create ...
21answers
6k views

### print 1 to 100 without using recursion and conditions [closed]

can we print 1 to 100 without using any if conditions and loops in c&c++? Conditon: main point is you must not use recursion...and doesnt hardcode code in it for e.g ...
3answers
956 views

### Interpret whatfuck

Smallfuck is a brainfuck-like language with 1-bit cells. It has the following instructions: ...
8answers
753 views

### Implementing bool() without any conditionals [closed]

Title says it all. Given some input, turn it into a boolean value (0 or 1), without using conditional statements (e.x. == > < <= >= != ~=), or any ...
8answers
2k views

### Simulate the Wireworld cellular automaton

Wireworld is a cellular automaton that was designed to be resemble electrons flowing through wires. Its simple mechanics allow the construction of digital circuits. It has even permitted the ...
7answers
2k views

### C: replace AES FIPS-197 SubBytes table by constant-time code

In FIPS-197 (the Advanced Encryption Standard, known as AES), it is made heavy use of SubBytes, which could be implemented as ...
30answers
7k views

### Emulate a 7-segment display

Task The task is to display any of the 128 possible states of a 7-segment display. Your program should accept a string of 7 characters ("bits") that are either 0 ...
17answers
1k views

### Cambridge Transposition

I'm sure most, if not all, of you have come across this at some point or another: Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the ...
11answers
1k views

### Shortest 8-bit xor cipher

8-bit XOR encryption takes a single byte and XORs every byte in the file by that byte. Here is a reference program in C++: ...
4answers
1k views

### Naming ionic compounds

An ionic compound is named like so: (metal name) (non-metal suffixed with -ide). Here is a list of all the suffixes that need to be replaced with ...
17answers
1k views

### Rolling three dice and show the probabilities

Roll 3 dice, count the two highest two values and add them to the result. Every 1 must be rolled once again. Now show the average throw after 1000000 tries and the probabilities for each result ...
4answers
591 views

### Convert the Binary Champernowne Constant to Decimal

The Champernowne constant is a transcendental decimal number whose digits are the concatination of all positive integers. C10 = 0.12345678910111213141516...10 ...
22answers
14k views

### Count from 1 to 100… in Roman Numerals

Write a program that count from 1 to 100 in Roman Numerals and print these numbers by standard output. Each one of the numbers must be separated by spaces. You cannot use any built in function to ...
3answers
3k views

### Bitwise Operators in Brainfuck

Your task is to create one brainfuck program for each of the following binary operators. Each program should take one or two 8-bit numbers (A and B) from input and calculate the specified operation: <...
4answers
361 views

### Prune connections

John is writing a program that finds the best route from A to B using public transport. For a given pair of origin and destination the program calculates a set of routes with departure time and ...
45answers
3k views

4answers
2k views

### Four weights to produce integer scale differences from 0 through 40 pounds

Just-in-time edit: I decided to reveal part of the answer and highlight a single aspect of the challenge. Show how 4 weights, of 1, 3, 9, and 27 lbs. can be used to produce "weight differences" from ...
2answers
443 views

### “Defragmenting” a list

A fragmented file is a file which is seperated into several parts on a harddrive, because it can't fit into a certain space. On all harddrives, there are files called unmovable files, which are ...
2answers
431 views

### Pseudosort a list in 2*n comparisons

Write a program that takes a list of n space-separated integers, and outputs a permutation of that list using a maximum of 2*n comparisons. It should loop this until an empty line is input. ...
3answers
557 views

### There Was A Stream

Challenge Write a program that generates the song "There Was A Stream", detailed below. Description The song "There Was a Stream" is a camping song. It takes N parameters and generates a song of ...
3answers
2k views

### Write a java code to detect the JVM version

The objective is to write java code that detects the JVM version relying in compatibility changes, side effects, bugs and/or undefined behavior that works in a way in one version and another way in ...
9answers
683 views

### Calculate the correlation coefficient

Given a series of numbers for events X and Y, calculate Pearson's correlation coefficient. The probability of each event is equal, so expected values can be calculated by simply summing each series ...
3answers
4k views

### Secret Santa Challenge [duplicate]

Possible Duplicate: Holiday Gift Exchange Background: Secret Santa is a Western Christmas tradition in which members of a group or community are randomly assigned a person to whom they ...
4answers
2k views

### Calculate e^x and ln(x)

Given a floating point x (x<100), return e^x and ln(x)...
5answers
3k views

### Normal distribution values

Write the shortest program possible which outputs a table of Normal distribution values phi(z) = Integral[t from -infty to z of e^(-t^2/2) /sqrt(2 pi) dt] for <...
47answers
5k views

### Russian Roulette

Write a program which plays Russian Roulette! If the program is started, there should be a 5 in 6 chance of it ending normally after printing "I survived!" there should be a 1 in 6 chance of the ...
43answers
3k views

### Shortest power set implementation

Problem definition Print out the powerset of a given set. For example: [1, 2, 3] => [[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]] Each element is to ...
9answers
3k views

### Who's that Pokémon?

Input: an integer N between 1 and 151 Output: the Nth Pokemon. Rules You may use one data file. You may not use any already made data decompression algorithms. This includes libraries and other ...
2answers
1k views

### Underhanded launcher [closed]

Your goal is to write a super-secret program which launches another (independent) program. You don't have to provide the payload in your answer, it can be any program name your program will launch. ...
11answers
2k views

### Fast inverse square root

Inspired by http://meta.codegolf.stackexchange.com/questions/547/write-a-code-golf-problem-in-which-script-languages-are-at-a-major-disadvantage question on meta, I've decided to make a question which ...
2answers
702 views

### Generate Esolangs

Given a file named hello_world that contains 2-100 bytes of printable ASCII, create a Turing-complete language in which ...
1answer
349 views

### Scale from key and mode

Most of you probably know the C major scale: C D E F G A B C The major scale is characterised by the intervals between adjacent notes, which measured in ...
67answers
6k views

### Play a sound, any sound [closed]

Your program has to make the computer produce a sound, any sound. Shortest code wins, not sooner than 10 days after the first valid answer. If there is a tie, the one submitted sooner, wins. The ...
2answers
808 views

### Implement DES key expansion

I wanted to make a challenge to do the full DES encryption algorithm, but that may be a bit too involved to get a ton of participation. This challenge is to simply generate the 16 48-bit subkeys used ...
0answers
2k views

### Best Scoring Scrabble Board

Challenge Your challenge is simply to write a program in the language of your choosing that when run, determines the highest possible score for a board of Scrabble - For the sake of this challenge, a ...
14answers
975 views

### Match up to 10 in an array

Challenge Given an array of single digit number, work out if any 2 of them add up to 10 and print them out Example Input (1,2,3,4,5,5,6,7) This returns ...
7answers
1k views

### Swap 2 objects, without using a temporary variable [closed]

There are two objects: Object1, Object2 You can easily swap them by: Object3 = Object1 Object1 = Object2 Object2 = Object3 ...
3answers
758 views

### Compiled quine variant

Thinking about various quine puzzles here, I got an idea for another one: Compose a program that outputs its own compiled code to a file (or multiple files, if the compiled code is). (This means that ...
4answers
1k views

### Cryptographic quine variant

Create a program that prints the MD5 sum of its source in the form: MD5 sum of my source is: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx No cheating - you can't just read ...
26answers
3k views

### Smile! Just smile

It's well known that Brainf*ck is very bad at Kolmogorov-complexity problems, for example, it requires around 100 characters just to print "Hello world". However, there might be texts where Brainf*ck ...

15 30 50 per page