instruction stringlengths 34 53.1k |
|---|
The Setup
Here you can find the full text of The Tragedy of Macbeth. If you view the source, and save it as text, you will notice it comes out to 206,244 total characters (including the whitespace at the end of the html).
The Challenge
Write a program which compresses the text linked above into the smallest possible... |
Write a full program to find whether the binary representation of a number is palindrome or not?
Sample Input
5
Sample Output
YES
Print YES if binary representation is palindrome and NO otherwise.
|
Write a function which takes n as a parameter, and returns the number of trailing zeros in n!.
Input Constraints
0 <= n <= 10^100
Output Constraints
Should be return the result in less than 10 seconds.
Test Input
1
213
45678
1234567
78943533
4567894123
121233112233112231233112323123
Test Output
0
51
11416
308638
19735... |
Create a program which sums all integers found in a string which is set as a variable in the program (thus, the program doesn't have to handle any input). The integer numbers are separated by non-numericals (anything but 0, 1, 2, 3, ..., 9).
Examples:
e7rde f ,fe 43 jfj 54f4sD = 7+43+54+4=108
5 = 5
64 545,5445-32JIFk... |
Graham's number ends in a 7. It is a massive number, in theory requiring more information to store than the size of the universe itself. However it is possible to calculate the last few digits of Graham's number.
The last few digits are:
02425950695064738395657479136519351798334535362521
4300354012602677162267216041981... |
You are given one-quarter of a map that is symmetrical over the x- and y-axes as input. The program should print the complete map.
The map can contain the following characters: -+/\|., and they should be turned as expected. The in data is always rectangular and small.
Example
$ cat in
+---
|./.
|/..
$ ./solution < in
... |
The numbers should be printed with leading zeroes in a field with length = (number of digits of N^2).
Input (N):
4
Output:
01 12 11 10
02 13 16 09
03 14 15 08
04 05 06 07
I am interested in the algorithm and the cleanliness of the implementation.
So, the white space does not count and the upper limit for N is 42.
|
Create the shortest function to convert a string of Roman numerals to an integer.
The rules for each letter can be found at the Wikipedia page. Letters above 1,000 will have parentheses placed around them to signal their higher value.
Requirements:
Must convert Roman numerals 1 to 500,000
Must complete in less than a... |
You are given a list of (x,y) grid coordinates. Your function should decide whether the figure obtained by coloring in the squares of the grid with the given coordinates is connected or not.
Squares adjacent diagonally are not considered connected.
Example input:
(0,0),(1,0),(2,0),(3,0),(3,1),(3,2),(2,2),
(1,2),(0,2),... |
Write the shortest program you can in any language that reads a context-free grammar from and the number of sentences to produce from stdin, and generates that many random sentences from the grammar.
Input
Input will come in the following format:
n <START>
{"<A>":["as<A>df","0<A>","<B><C>","A<A>", ...], "<B>":["1<C>1"... |
Find the number of partitions of a positive integer n. Hope someone uses the explicit finite formula for the partition function defined in Jan Hendrik Brunier and Ken Ono paper here.
Sample Input
8
Sample Output
22
N is less than or equal to 1000.
Write the complete program. More than anything I would like to see the ... |
Today marks the 15th anniversary of Garry Kasparov's defeat against Deep Blue. Speaking of chess...
Input is a string that represents an 8x8 chess board containing only empty squares (.) and queens (Q). Output the number of squares that any queen can move to the next move. Queens can move any number of squares vertical... |
Another problem from our internal golfing...this one around the holidays last year.
PROBLEM
Andy, Barb, Carl, Didi, Earl, and Fran are buying gifts for each other. Draw names for a gift exchange.
Each person buys one gift and receives one gift.
Nobody buys their own gift.
Running the solution multiple times should pro... |
Implement polynomial long division, an algorithm that divides two polynomials and gets the quotient and remainder:
(12x^3 - 5x^2 + 3x - 1) / (x^2 - 5) = 12x - 5 R 63x - 26
In your programs, you will represent polynomials as an array, with the constant term on the tail. for example, x^5 - 3x^4 + 2x^2 - x + 1 will become... |
Write the shortest function you can that takes two binary-coded decimal integers and a character indicating an arithmetic operation to perform and return the result.
Input Specification
You will be passed two 32-bit bit patterns representing unsigned BCD integers. In C or Java, for example, you would be passed an int ... |
Inspired by a recent question on SO...
Write a function to print a binary tree in the following format:
3
/ \
1 5
\ / \
2 4 6
The output should consist of a line of nodes, followed by a line of / and \ characters indicating relationships, followed by a line of nodes, etc.
You can assume all nodes are... |
The same task as Finding "sub-palindromes" but instead of finding substrings you must find subsequences that are not substrings.
eg1:
input: "12131331"
output:
"11", "33", "111", "121", "131", "313", "333", "1111", "1331", "11311", "13331"
or
"11", "33", "111", "333", "1111", "11311", "13331"
eg2:
input: "3333"
outp... |
Write a function f(a,b) that returns a mod b given the constraints:
you can't use division in any way
f(a,b) is always positive, eg: f(-1,5) = 4
it performs reasonably well for values of ~10e50 for a and b
|
Write a function f(a,b,c) that calculates a^b (mod c) in less than 10 seconds.
a, b < 10^100
c < 10000.
examples:
f(10^50, 10^50, 54123) = 46555
f(5^99, 10^99, 777) = 1
|
Compare two numbers N1 = abc, N2 = def by constructing a function f(a,b,c,d,e,f) that:
returns 1 if N1 > N2
returns -1 if N1 < N2
Note: You are not required to return any value for any other relation between N1 and N2. e.g. when they are equal or when their relation is undefined (complex numbers).
other constrains:
... |
Validate a proposed crossword grid.
Entries should be full programs that simply test a proposed grid
to determine if it meets a set of conditions for making crossword
solvers happy.
Input
The input will be the name of a file representing the crossword
grid. The input filename may be passed as an argument, on the
standa... |
Given a number N, write the shortest complete program to find the number of square-free integers below N.
Sample Input
100000
Sample Output
60794
Constraints:
Should work for all positive N below 1,000,000
Should not take more than 10 secs.
Please do not use built in functions, please.
|
Write a program to print Carmichael numbers. The challenge is to print the maximum number of them in less than 5 secs. The numbers should be in increasing order. Please do not use built in functions. Also please don't store the carmichael numbers in any form. To keep a common time measurement use Ideone. The program to... |
An angry bird is shot at an angle \$β\$ to the horizontal at a speed \$u\$. The ground is steep, inclined at an angle \$α\$. Find the horizontal distance \$q\$ that the bird traveled before it hit the ground.
Make a function \$f(α, β, u)\$ that returns the length \$q\$: the horizontal distance that the bird traveled b... |
A class has N student and the class room has N switches (all turned OFF and numbered 1 to N). Each student has an enrollment number assigned from 1 to N. Each student serially (by number) toggles the switches that has a number which is divisible by his/her enrollment number.
Example: Student 1 will turn all the switche... |
In the 196-algorithm one starts from an integer and then adds its reverse to it until a palindrome is reached, like this:
start -> 5280
5280 + 0825 = 6105
6105 + 5016 = 11121
11121 + 12111 = 23232
-end-
Write a function that counts how many even numbers are visited before the algorithm ends. Starting and ending number... |
Given the amplitude and period for a wave, print the wave. See sample output for more details. The total number of wave forms equals the period, and the height of each wave equals the amplitude. Amplitude and Period are less than 10. You can ignore the trailing spaces but not the leading spaces.
Sample Input
3 2
Sampl... |
In a standard dice (die) the numbers are arranged so that opposite faces add to seven.
Write the shortest possible program in your preferred language which outputs a random throw followed by 9 random tippings. A tipping is a quarter turn of the dice, e.g. if the dice is facing 5, all possible tippings are 1,3,4 and 6.
... |
Say that you have this folder structure on your coumputer:
/a
And you want to have these folders:
/a/b
/a/c
/b/b
You would need to create four directories, using mkdir for example:
mkdir /a/b
mkdir /a/c
mkdir /b
mkdir /b/b
Write a program that, given existing and required directory structures, will output the direct... |
http://en.wikipedia.org/wiki/Dissociated_press
Dissociated Press is an algorithm that generates random text from an existing text.
The algorithm starts by printing any N consecutive words (or letters) in the text. Then at every step it searches for any random occurrence in the original text of the last N words (or let... |
What is the shortest program that can predict the next time Friday will fall on the 13th day of the month?
Must be an complete functioning program (not just a function/subroutine)
Must print out date in the following format: YYYY-MM-DD
Allow user to provide a start date either as a command line argument or through STD... |
The Koch snowflake (also known as the Koch star and Koch island) is a mathematical curve and one of the earliest fractal curves to have been described. It is based on the Koch curve, which appeared in a 1904 paper titled "On a continuous curve without tangents, constructible from elementary geometry" (original French t... |
Write a filter that converts text from standard input to a representation of its Huffman tree on standard output. In as few characters as possible.
you're free to consider newlines or not
output format is free, as long as it's some human-readable encoding of a tree. s-exps, ascii-art and .png, all good. RPN, .dot, ... |
Write the shortest program which will take a string of numbers (of up to at least 20 length) as input, and display the output using the standard digital clock style numbers. For instance for input 81, a solution with ascii output would give:
_
|_| |
|_| |
Graphical output is also acceptable, if it helps.
|
Write a function which takes a date and returns the day of the week of the next February 29th after that date.
The input is a string in the ISO Extended format: YYYY-MM-DD (e.g. May 27th, 2010 would be "2010-05-27").
The output is a string which is the name of the day of the week (e.g. "Monday"). Capitalization doesn'... |
Write a program uses run-length encoding to shorten a list of non-negative integers it has to read in.
You can assume the non-negative integers can fit in 32bit signed integers.
Input Format
The length, n, of the list on the first line.
On the second line, a space-separated list of integers representing the list of int... |
For loops are used extensively in many languages, but what would you do if no languages supported them?
Create a way to execute a basic for loop without using any repetition structures (for, foreach, while, do, etc).
The basic for loop that you need to replicate is set up like this
for(i=0;i<1000;i++)
You must be able... |
Write a Notes and Crosses application.
User interface is optional.
You can output the computers move in text: eg 1x1 (meaning center square)
The computer must play an intelligent (extra marks for optimal) game.
Apart from its first move which should be random.
Player computer take turns at first move.
First player to w... |
Let's say that we are programming a game that lets you play Scrabble®.
We have a board with tiles placed on it, and empty cells are either normal or have multiplier properties (double or triple the points for a word or for a single letter).
Each tile has a value and blank tiles have no value.
Thee goal here is to wri... |
Write a fixed point combinator in as few characters as possible, in the language of your choice.
free form (i.e., whatever's shortest): whole program, actual function, code snippet
you may not use your standard library's if it has one
you may however extract it from other high-level functions it you'd rather do that t... |
A TicTacToe game can be represented by a string denoting the sequence of positions as the players make their move.
0 1 2
3 4 5
6 7 8
Assume X always plays first.
So a string of "012345678" denotes the game
X O X
O X O
X O X
Notice, the game is already won when Player X marks 6, at that point the game ends, granting... |
Write a function or program that outputs the following lines <input> time:
Hello World. Dlrow Olleh. Hwlrod Eoll.
Big Brown Fox. Xof Nworb Gib. Bbfgox Iro.
EDIT: It's "B rown F ox" not "brown fox".
This is code-golf so the program with the shortest bytecount wins!
|
Write the shortest program to build a cdb database, using the following syntax for input:
+klen,dlen:key->data
followed by a newline. Example:
+3,5:one->Hello
+3,7:two->Goodbye
(Unlike the real cdbmake, your program doesn't need to catch the empty-line-as-end-of-input case if you don't want to.) Your program needs t... |
Your task is to tack on a feature to a programming language, either by implementing a very clever library, or by processing the input text and/or tweaking the compilation process.
Ideas:
Add PHP-style presentation interleaving to C (e.g. <?c printf("Hello,"); ?> world!).
Add a null coalescing operator to one of those ... |
Produce only the name of a programming language using only the facilities of the language itself. The name of the language can only be invoked indirectly, i.e., from non custom environment variables, built-in functions or methods or the interpreter/compiler of the language. Output should be the name of the language onl... |
Write the shortest program that will attempt to connect to open ports on a remote computer and check if they are open. (It's called a Port Scanner)
Take input from command line arguments.
your-port-scanner host_ip startPort endPort
Assume, startPort < endPort (and endPort - startPort < 1000)
Output: All the open ports... |
Description
Create a fully working "Guess the number" game. The game is played by two players as follows:
player one chooses a number (A) between 1 and N
player two tries to guess A choosing a number (B) in the same range
the first player responds "higher" if A > B, "lower" if A < B or "correct" if A = B.
steps 2-3 ar... |
Note: After trying this myself, I soon realized what a mistake this was. Therfore, I am modifying the rules a bit.
The minimum required functionality:
Character classes (., \w, \W, etc.)
Multipliers (+, *, and ?)
Simple capture groups
Your challenge is to implement PCRE in the language of your choice subject to th... |
PROBLEM
Given two words, find the winner in a digital root battle.
Define the digital root of a word this way:
Each letter of the alphabet is assigned a number: A = 1, B = 2, C = 3, ..., Z = 26
Add the values for each letter to total the word. Take "CAT", for example. C+A+T = 3+1+20 = 24
Add all the single digits tha... |
Write a function that takes a number as an argument and makes it a palindrome by appending minimum number of digits. The number will be at max of 100 digits.
Sample Inputs
12
122
232
2323
1012121
Sample Outputs
121
1221
232
23232
101212101
|
Given a year and a month, find out the percentage of work days in said
month. Work days are Monday through Friday with no regard to holidays or
other special things. The Gregorian calendar is used.
Input
A year and month in ISO 8601 format (YYYY-MM). The year always has four
digits, the month always has two digits. ... |
Given a 20×20 grid of non-negative integers, find a 3×3 sub-grid where the
product of the sums of the individual lines hits the maximum. Spoken in
formulas:
Given the 3×3 sub-grid
$$\mathfrak{U} = \left(\begin{matrix}
x_{11} & x_{12} & x_{13} \\
x_{21} & x_{22} & x_{23} \\
x_{31} & x_{32} & x_{33}
\end{matrix}\right)$$... |
Problem:
Given a set of integers, find the sum of all positive integers in it.
Input:
t – number of test cases [t < 1000]
On each of next t lines, an integer N [-1000 ≤ N ≤ 1000]
Output
The program should output the sum of all the positive integers.
Check your code in online judge
Score
Score is equal to size of sour... |
Your task is to write a program to perform set operations. The operations and arguments are taken from command line in the format program operation [argument]. There are four operations:
1: clears the set. no arguments. exit code 0.
2 integer: adds the integer into the set. exit code 0.
3 integer: removes the integer ... |
Write a program to produce a file containing a crossword grid
that the user can print out and work the puzzle on.
Input
A filename representing a crossword grid file and
optionally a second filename representing a crossword numbering
file. The input should be accepted by a conventional means for
your programming envir... |
Create a BCD binary clock
in ASCII. As implied, it shall display time in six columns of dots:
(source: Wikimedia Commons)
Each column is a binary-coded digit, reading hours, minutes and seconds
from left to right. Hours are given in 24-hour format.
The time to display is read from the command-line or from stdin (whic... |
Write a program that, given a small positive even integer from standard input, calculates the probability that flipping that many coins will result in half as many heads.
For example, given 2 coins the possible outcomes are:
HH HT TH TT
where H and T are heads and tails. There are 2 outcomes (HT and TH) that are half ... |
I have designed a simple random generator that cycles two numbers in a chaotic way using a multiply and modulus method. It works great for that.
If I were to use it as a cipher generator it would however be vulnerable to a known plaintext attack, given that an attacker can reverse engineer the seed from a series of ran... |
Shamir's secret sharing scheme is a simple way of protecting a secret by splitting it into several parts needed to reconstruct it.
Your task is to implement Shamir's Secret Sharing reconstruction over the Finite Field defined by the prime 1928049029. If you have any doubts about what this means, just ask or see Finite ... |
I found the code below today after much hair pulling. Shorten it down (code golf) and fix the bug that I found (bonus).
#define LN_SOME_TEXT_FIELD 256
void GetSomeText(LPTSTR text)
{
TCHAR buf[LN_SOME_TEXT_FIELD + 1];
short i;
LPTSTR curChar;
curChar = text;
i = 0;
while (*cur... |
Write a program rotates some Cartesian coordinates through an angle about the origin (0.0,0.0). The angle and coordinates will be read from a single line of stdin in the following format:
angle x1,y1 x2,y2 x3,y3 ...
eg.
3.14159265358979 1.0,0.0 0.0,1.0 1.0,1.0 0.0,0.0
The results should be printed to stdout in the ... |
Input:
A three digit number
from stdin or as an argument
not all digits are the same
may start with one or two zero's
Process
Order the input-digits ascending and descending to form two new numbers.
Subtract the smallest from the largest. Use the difference as new input. NB: This process needs 3 digits, so 10 has to... |
Write the shortest possible program that draws a Bresenham line in ASCII art. Your program should take two integers x and y (command line or stdin, your choice) and draw an ASCII line which starts in the upper left and goes right x units and down y units. You must use _ and \ characters and place them in the correct ... |
Some time ago, I found this unused hash function (written in Java) in our codebase:
long hashPassword(String password)
{
password = password.toUpperCase();
long hash = 0;
int multiplier = 13;
for (int i = 0; i < password.length(); i++)
{
hash += hash * multiplier + (short)password.charAt(i);... |
Check printer function (or subroutine) - Convert to English text from the input value. 12.34 -> "twelve dollars and thirty four cents". For the range .01 to 9999.99 assuming valid input.
|
Input:
a positive number \$n\$, smaller than \$80\$, from stdin or as a command-line argument.
Output: A square chessboard pattern, the size of the input number. The dark fields are represented by the letter X, the white fields by a space. The top-left field should be X.
A complete program is required. This is code-gol... |
Challenge
Given two strings, work out if they both have exactly the same characters in them.
Example
Input
word, wrdo
This returns true because they are the same but just scrambled.
Input
word, wwro
This returns false.
Input
boat, toba
This returns true
Rules
Here are the rules!
Assume input will be at least 1 c... |
Challenge
Write a program which, given a 2-dimensional boolean array (equivalently, a monochromatic bitmap), outputs a series of polygons that describe the outline of the region that is “true” (1).
The input is provided as a sequence of '#' (hash), ' ' (space) and \n (newline) characters. Lines may differ in length, in... |
Challenge
Consider a square matrix of order N(N
rows and N columns). At each step you
can move one step to the right or one
step to the top. How many
possibilities are to reach (N,N) from
(0,0)?
Constraints
Assume input will be a positive integer N satisfying 1 <= N <= 125
No special characters, only 0-9
O... |
Given 4 numbers n1, n2, n3, n4, and a goal n5, obtain n5 using n1 through n4 combined with any operations.
Eg. Given four numbers 2,3,4,5 and the goal as 8, output (one of many) is 2-3+4+5
EDIT: This is a variation of a game played at my son's school. Paranthesis, powers, unary operations (log, factorial) are allowed; ... |
The 8 Puzzle is the smaller variant of the 15Puzzle (or the Sliding puzzle).
You have a 3x3 grid which is filled with numbers from 0-8 (0 denotes the blank tile) arranged in a random order.
Your task is to input a 3x3 grid and show the shortest solution (minimum moves) to get to the goal state. Display each boardstate... |
Read two strings from stdin.
Output Yes if one string is a rotated version of the other.
Otherwise output No
Testcases
Input
CodeGolf GolfCode
Output
Yes
Input
stackexchange changestackex
Output
Yes
Input
stackexchange changestack
Output
No
Input
Hello World
Output
No
|
The GolfScript language has one serious lack, no float or fixed point handling. Remedy this by creating a function F for converting an integer number, given as a string, to a string representing 1 / 10 000 000 000 of it's value. The function must handle both positive and negative values as well as leading 0s.
The follo... |
Challenge
In this task you have to write a program that will take input
an integer N (-1e9 <= N < 0 && 0 < N
<= +1e9), then compute T = (abs(N) %
M+1),if N is positive then output
the T-th character from the
beginning else output the T-th
character from the end of your source.
M is the size of your source ... |
Task
Given a String as input, your task is to output 42 only if the input String happens to be exactly the following :
abbcccddddeeeeeffffffggggggghhhhhhhhiiiiiiiiijjjjjjjjjjkkkkkkkkkkkllllllllllllmmmmmmmmmmmmmnnnnnnnnnnnnnnoooooooooooooooppppppppppppppppqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrsssssssssssssssssssttttttttttt... |
Find a way to make circles of a given radius using characters in a console. Please specify the font name and size. Also, please provide at least one example of the output.
For example:
Input:
3
Output:
******
** **
** **
* *
** **
** **
******
...Well, something better looking... |
Write a function that takes 4 points on the plane as input and returns true iff the 4 points form a square. The points will have integral coordinates with absolute values < 1000.
You may use any reasonable representation of the 4 points as input. The points are not provided in any particular order.
Shortest code wins... |
There is a well-known bijection between the permutations of \$n\$ elements and the numbers \$0\$ to \$n!-1\$ such that the lexicographic ordering of the permutations and the corresponding numbers is the same. For example, with \$n=3\$:
0 <-> (0, 1, 2)
1 <-> (0, 2, 1)
2 <-> (1, 0, 2)
3 <-> (1, 2, 0)
4 <-> (2, 0, 1)
5 <-... |
This is a somewhat different task. Calculate 1024 hexadecimal digits of π, beginning at the 1024th hexadecimal place.
Formally: Your program should complete in less then 1 minute and produce the following output:
25d479d8f6e8def7e3fe501ab6794c3b976ce0bd04c006bac1a94fb6409f60c45e5c9ec2196a246368fb6faf3e6c53b51339b2eb3b... |
This problem (see below) has been given as a High School Programming League code golf challenge. The shortest codes submitted during the contest were: 177 bytes in Ruby, 212 bytes in Python 2.5, 265 bytes in C. Can anyone make it shorter? Other programming languages are also allowed.
Problem formulation: Given 8 integ... |
Write the shortest program that takes a single integer as input and prints out a Suanpan abacus
Testcases
Input:
314159
Output:
|\======================================/|
|| (__) (__) (__) (__) (__) (__) ||
|| (__) (__) (__) (__) || || ||
|| || || || || || || ||
|| || || ||... |
source: Dilbert, September 8, 1992
I'm hoping to add a new twist on the classic "Hello World!" program.
Code a program that outputs Hello World! without:
String/Character literals
Numbers (any base)
Pre-built functions that return "Hello World!"
RegEx literals
With the exceptions of "O"† and 0.
†"O" is capitalize... |
In 1939 Juzuk described a way to generate the fourth powers of natural numbers.
Group the natural numbers like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...
Scratch each second group:
1 4 5 6 11 12 13 14 15 ...
The sum of the n remaining groups is n**4.
Input: none
Task: print the fourth powers upto 1... |
Write a program which parses the output of uptime and generates an anatomically suggestive progress bar (as shown) with a length equal to the current uptime in days:
$ uptime
23:01 up 34 days, 7:30, 5 users, load averages: 0.23 0.27 0.24
$ uptime|<command>
8==================================D
(34 days = 34 equal sig... |
Challenge
Write a program to compute the the first N (<= 10^3) digits of e.
Your program should take an integer N as input.
Input:
100
Output:
2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427
Input:
7
Output:
2.718282
Input:
1000
Output:
2.7182818284590452353602... |
Make the shortest proxy server.
Input/Output Specifications
Client:
Input: a port number (32-bit integer) (,) or (space) a url (see test cases)
Output: html source of the url
Server:
Input: port to listen to (32-bit integer)
Output: REC when input is received from the client, OK when finished sending the html source... |
While ><> is not a popular language, it can be good for golfing and has been used on this website. It was inspired by Befunge and has some similarities in its instructions.
Required Commands:
> < ^ v
Changes the direction of the instruction pointer (right, left, up, down)
/ \ | _ #
Mirrors; the pointer will change di... |
Draw the path of Langton's ant.
Description
Squares on a plane are colored variously either black or white. We arbitrarily identify one square as the "ant". The ant can travel in any of the four cardinal directions at each step it takes. The ant moves according to the rules below:
At a white square, turn 90° right, f... |
Your task is to write a program, in any language, that adds two floating point numbers together WITHOUT using any fractional or floating point maths. Integer maths is allowed.
Format
The format for the numbers are strings containing 1's and 0's which represent the binary value of a IEEE 754 32-bit float. For example th... |
Create a routine that takes an array of blocks in one numeric base system, and convert them to an array of blocks in another numeric base system. Both the from and to systems are arbitrary and should be accepted as a parameter. The input array can be an arbitrary length (If using a language where array lengths are no... |
Write a program that visualizes long division with ASCII art. Input consists of two integers, a numerator and a denominator, using the input format of your choice.
Examples:
1234 ÷ 56:
22
----
56|1234
112
---
114
112
---
2
1002012 ÷ 12:
83501
-------
12|1002012
96
---
... |
This golf requires a factorial calculation be split up among multiple threads or processes.
Some languages make this easier to coordinate than others, so it is lang agnostic.
Ungolfed example code is provided, but you should develop your own algorithm.
The goal of the contest is to see who can come up with the shorte... |
This problem is quite easy to do by brute force. In fact, it'll be reasonably fast to brute force as well. But where's the fun in that?
The Problem
Produce a list of all unique 5 digit number pairs that sum to 121212. However, each decimal digit must appear exactly once in either number. So a valid pair would be (9... |
The object of this puzzle is to take a deck of 52 cards and shuffle it so that each card is in a random position.
Given:
An array, deck, of 52 distinct integers representing the cards. When you start, deck contains exactly one of each card in some unknown order.
A function, int rand(min, max), that returns a random in... |
There is a well-known theorem that any permutation can be decomposed into a set of cycles. Your job is to write the shortest possible program to do so.
Input:
Two lines. The first contains a number N, the second contains N distinct integers in the range [0,N-1] separated by spaces. These integers represent a permuta... |
Implement a verbal arithmetic solver of several same sequence of numbers added together:
TWO
+ TWO
-----
FOUR
REPEAT
REPEAT
REPEAT
+ REPEAT
--------
ANDSTOP
SPEED
+ SPEED
-------
KILLS
There are some restrictions: each letter should represent different digits, and no letter can be zero.
Implement the s... |
I don't know who coined these words, and I'm not Irish, but I give you an Irish blessing:
May the road rise up to meet you
May the wind be always at your back
May the sun shine warm upon your face
The rains fall soft upon your fields
And until we meet again
May God hold you in the hollow of His hand
I was planning on ... |
Bounty is over, thephpdeveloper wins with Conway's Game of Life
The web platform today is advancing at a rapid rate. Features like CSS3 animations, transforms, drop shadows and gradients, <canvas>, <audio> and <video> tags, SVG, WebGL, and many more mean that you can do far more in the browser, and in far less code, t... |
The shortest code to generate the correct times on the clocks wins.
You are a seasoned time traveler and have been known to stop at many planets during your journies. Each planet rotates at a different rate and because of this, the length of a day is different than our usual 24-hour day. As a result, the planets use ... |
Given a square of positive, natural numbers write a program find a horizontal and a vertical path with the sum of numbers along them being maximal. A horizontal path goes from the first column to the last and has to increase its column position by one in each step. A vertical path goes from the first row to the last an... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.