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).

learn more… | top users | synonyms

-2
votes
0answers
70 views

Evenly Distribute students into rooms based on student study subjects and room limitations [on hold]

The problem is that I need an algorithm (preferably in PHP) to solve the following problem. I've looked at a lot of "bucket" algorithms but none seems to cover what I am after Students need to be ...
16
votes
2answers
496 views

Where are the runs in this infinite string? (CCCCCC Found!)

Starting with the string ABC, consider the result of repeatedly appending the last half of itself to itself (using the larger half if the length is odd). We get the progression: ABC ABCBC ABCBCCBC ...
-2
votes
0answers
94 views

*any* fractal drawing [on hold]

Write a code that draws any fractal (no ASCII-art). Be sure to document code, does't have to be in the actual code but please explain your code! Also try to have the smallest big-oh you can get. Don't ...
0
votes
0answers
7 views

Scheme - logical operator procedures [migrated]

I know Scheme and other Lisp dialects include logical operators such as 'and' and 'or', but, since I am currently learning Scheme, I am trying to program my own logical operators. So, for my attempts ...
18
votes
13answers
1k views

Khinchin's constant to as many decimal places as possible in 64 bytes or less

Khinchin's constant is a curious mathematical constant that, according to Wolfram MathWold, is "notoriously difficult to calculate to high precision". Here it is to 100 digits: ...
18
votes
5answers
4k views

Shortest expression for {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}

Given list of integers {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}. For those who interested these numbers are used in weekday calculation. Weekday = (m[n] + d + y + y>>2 + y/400 - y/100) % 7;, where ...
0
votes
2answers
321 views

Conway's Game of Life with smallest *set* of source characters [duplicate]

The goal of this challenge is to write a program that will simulate a single round of Conway's Game of Life on an existing grid. Input format: Input will be read from stdin. The input will consist ...
11
votes
2answers
449 views

Maximum number of PEP8 violations in a single line

Your task is to write a file which contains a line with many pep8 violations. The rules: We use pep8 version 1.5.7 and the default settings. Calling pep8 with other command line options or ...
3
votes
1answer
283 views

Make a Number Expression

Few years ago, an esoteric programming language named 아희(Aheui) was created. Well, actually you don't need to know about this language or Korean characters. Aheui uses stacks and a queue, but this ...
19
votes
2answers
1k views

Optimize paper folding to mitigate inkblots

Dark black ink has splattered all over your white sheet of printer paper! The obvious solution is to fold the paper so black and white parts meet and both become grey as the ink diffuses. Then unfold ...
3
votes
1answer
958 views

Optimal Minesweeper on the Largest Board

Overview: Your challenge is to write a program that will play minesweeper optimally, giving the best move in any position. Moreover, you must do this on the largest board possible. Game details: ...
0
votes
1answer
230 views

Babylon.js - loop through a scene and apply a simple fragment shader to all of the objects

You have a library - a fully loaded 2014 Babylon.js. You have a fragment shader - let's call it sample.fragment.fx. You have a scene - loaded ahead of time, possibly from a .babylon JSON file. Your ...
9
votes
3answers
430 views

mathpack numeric literals

preface In a very heated situation you have to go even further with golfing. (e.g. in a challenge where your answer is 100 characters long and it is just embarrassing that you couldn't make it 99) ...
1
vote
4answers
500 views

Rotate 2D Array [duplicate]

Given an input of a 2 dimensional array of integers, rotate the array 90 degrees clockwise. It should work for rectangular arrays of all sizes and proportions. The rotated array should be printed at ...
0
votes
1answer
407 views

Racketeer Taxi Driver

The Scenario You are a taxi driver in your city. You picked up a passenger from the airport and he told you the place he'd like to go. To earn more money, you need to drive as much as you can. ...
27
votes
5answers
2k views

To Vectory! – The Vector Racing Grand Prix

Vector racing is an addictive game that can be played with a pen and a sheet of square-ruled paper. You draw an arbitrary racetrack on the paper, define a start and end and then you steer your ...
3
votes
2answers
370 views

Deplane! Deplane! (Or: RGBRGBRGB => RRRGGGBBB?)

Imagine bytes in memory for an RGB image--R and G and B represented by bytes in sequence. If an image is NxM then the memory layout will be M repetitions for vertical scanlines of 3*N bytes in ...
17
votes
2answers
889 views

Mastermind strategy

I could only find code-golf challenges for Mastermind, so here's a code-challenge version that I would have liked to take on myself. An optimal strategy for the normal Mastermind game, MM(4,6), was ...
11
votes
2answers
493 views

Travelling Salesman

Your are given, as a list or vector or whatever, a bunch of 3-tuples or whatever, where the first two things are strings, and the third thing is a number. The strings are cities, and the number is ...
54
votes
41answers
9k views

Largest number in ten bytes of code

Your goal is to print (to the standard output) the largest number possible, using just ten characters of code. You may use any features of your language, except built-in exponentiation functions. ...
20
votes
3answers
878 views

Build a pair of spies that will throw stones into a river

Recently at the newly released Puzzling.SE, there was a problem about spies throwing stones into a river that was actually quite challenging: Two spies must pass each other two secret numbers (one ...
8
votes
0answers
497 views

Efficient error-free* encoding

The mission As is well known, the genetic material of all known creatures on Earth is encoded in DNA; using the four nucleotides adenine, thymine, cytosine, and guanine. (Commonly represented by ...
12
votes
3answers
2k views

Fastest player for Dots and Boxes

The challenge is to write a solver for the classic pencil and paper game Dots and Boxes . Your code should take two integers m and n as input which specifies the size of the board. Starting ...
18
votes
5answers
1k views

Leet to English Translation

Leet to English Translation Your challenge is to write a program to translate (English) leetspeak/lolspeak/txtspk into normal English. Your program should read from standard input and output to ...
13
votes
1answer
455 views

The Star-Spangled Code Challenge

The flag of the United States of America contains, in its canton, 50 stars, representing the 50 states. In the past, when there were fewer states, there were of course fewer stars, and they were ...
4
votes
5answers
158 views

Write biSp in point-free form using as few terms as possible

The Haskell function biSp has type signature biSp :: (a -> c) -> (b -> d) -> (c -> d -> e) -> a -> b -> e and (for those who prefer combinator calculus) can be defined as ...
-1
votes
3answers
142 views

Puzzle : Find minimum resource allocation on multiple of 10 or 12 only [closed]

I have two types of notebook . 10 problems could be solved in one page, in the first notebook. 12 problems could be solved in one page, in the second notebook. For given n problems I have to use ...
3
votes
2answers
497 views

Convert integer to string preserving order

The quest is to convert an integer to a string in such a way that 1. the order is preserved 2. using the least number of characters in the string. Let's say I have an integer X; the objective is to ...
7
votes
4answers
416 views

Build a drug testing scheduler

In this problem on Puzzling.SE, I ask a question about determining the amounts of drug to use in a clinical test to minimize total drug usage and fulfill the requirements of the testing procedure. ...
20
votes
12answers
3k views

Print the Golden Ratio

This was fun! However with only three digits, the fun was over way too soon. This challenge is similar, but we'll keep the fun going. The Challenge Print as many digits of the Golden Ratio φ as ...
17
votes
2answers
676 views

Recognize handwritten digits

Your task is to read an image containing a handwritten digit, recognize and print out the digit. Input: A 28*28 grayscale image, given as a sequence of 784 plain-text numbers from 0 to 255, separated ...
5
votes
2answers
331 views

Filter a large file in small memory

The challenge is a follow-up to Filter a large file quickly which had two submissions where were as fast as wc! This time the difficulty is that RAM is severely restricted which means that new ...
17
votes
9answers
1k views

Reverse order of words in a string inplace

The Task You are given a mutable string that matches [a-z]+( [a-z]+)*. You must mutate it into the string which contains the same words, but in reverse order, so that "hello there everyone" becomes ...
0
votes
2answers
195 views

Counting to now [closed]

This is the goal: count from 0 all the way to the current epoch time while the epoch time is still advancing in the fastest time possible. An example of how you'd do it could be as what is shown here ...
13
votes
3answers
878 views

Guess the word (aka Lingo)

The goal of this challenge is to write a program able to guess a word in the smallest possible number of attempts. It is based on the concept of the Lingo TV show ...
5
votes
1answer
143 views

Challenge: compress co-occuring columns into cartesian product

This challenge is inspired by a problem I encountered recently out in the real-world, though ultimately I cheated and found a workaround. Challenge The input is a space-separated table of characters ...
10
votes
8answers
2k views

Filter a large file quickly

The challenge is to filter a large file quickly. Input: Each line has three space separated positive integers. Output: All input lines A B, Tthat satisfy either of the following criterion. ...
10
votes
1answer
413 views

Monopoly Compression

Given a string representing the current state of a game of Monopoly at the beginning of a player's turn, compress all the necessary data into the smallest output. Answers will be judged by output size ...
19
votes
10answers
4k views

How high can you go? (A coding+algorithms challenge)

Now that everyone has developed their (often amazing) low level coding expertise for How slow is python really? (Or how fast is your language?) and How Slow Is Python Really (Part II)? it is time for ...
21
votes
15answers
2k views

Create a Flood Paint AI

In the game of Flood Paint, the goal of the game is to get the entire board to be the same colour in as few turns as possible. The game starts with a board that looks something like this: 3 3 5 4 1 ...
32
votes
7answers
2k views

Hunt the Wumpus

When I was a lad, kids would wander into computer stores and play Hunt the Wumpus until the staff kicked us out. It was a simple game, programmable on the home computers of the mid-1970s, machines so ...
4
votes
0answers
98 views

Using dictionaries, thesauruses, and similar databases, construct as large of a “See also” loop as possible [closed]

As I'm sure many of you know, synonyms can range from very similar to not-so-similar-but-I-can-see-how-it's-similar. It's common for dictionaries to use "See also" to denote occurrences of words that ...
19
votes
23answers
3k views

Valid Through The Ages

Inspired by this question on SO, your task is to produce a program that is valid in (at least) two major versions of your chosen language that produce different output. Rules Any language that has ...
14
votes
17answers
2k views

Draw a regular polygon

The goal of this code golf is to draw a regular polygon (one with equal side lengths) given the number of sides and radius (distance from center to vertex). The number of sides and the radius can be ...
23
votes
6answers
1k views

Write a Hangman Solver

You are required to write a Hangman solver. Testing against this English word list[1], the solver that solves the most number of words wins, with the number of total incorrect guesses being the ...
11
votes
4answers
1k views

Shortest code to write longest code

Your challenge is to create a shortest code in your language of choice which writes on a .txt file the longest code to multiply two numbers by taking two numbers as input and output the answer. NO ...
12
votes
1answer
837 views

Juggling by Numbers

Your task is to generate a valid juggling pattern by completing a given template. But first, you probably need to know how such a pattern is denoted. Introduction to Siteswap Siteswap is the ...
18
votes
6answers
1k views

Tower of Hanoi Sort

Write a function/subroutine to sort a list of integers, Tower of Hanoi style. You will be given a stack of integers. This is the main stack. You are also given two more helper stacks. These helper ...
19
votes
29answers
3k views

Sort-a-number. Sorta

Inspired by the ill-fated sorting-a-numbers-digits-without-using-an-array, but I thought it made a better code golf than SO question. Given a positive integer, sort the digits in that integer. ...
3
votes
1answer
411 views

Ration your integers and feed the people [closed]

It is wartime, and rationing is taking place in certain regions of your country. Your cities' region is one such region. The city chooses to give everyone the same amount, but in reality, larger ...