instruction
stringlengths
34
53.1k
Write a program that performs Polynomial Interpolation using true arbitrary precision rational numbers. The input looks like this: f(1) = 2/3 f(2) = 4/5 f(3) = 6/7 ... You may assume that there's exactly one whitespace before and after the = sign, all the numbers are either fractions or integers. You may also assume...
Write a program that takes an input such as: n,k which then computes: $$\binom n k = \frac {n!} {k!(n-k)!}$$ and then prints the result. A numerical example: Input: 5,2 Internal computation: $$\frac {5!} {3!\times2!}$$ Printed Output: 10 I'd like to see an answer that beats my python solution of 65 characters, but...
Often a task requires real arrays. Take for instance the task to implement Befunge or ><>. I tried to use the Array module for this, but it's really cumbersome, as it feels like I'm coding much too verbose. Can anybody help me how to solve such code-golf tasks less verbose and more functional?
Train a two-layer perceptron. You will find the Wikipedia article and these lecture slides useful. Use a sigmoid activation function for both the hidden and output layers, $$\sigma(x) = \frac{1}{1 + e^{-x}}$$ Your function should take in a list or array of input/output pairs and an integer specifying how many training...
I posted this to The Daily WTF coder challenge forum a few years ago but only got one response. I figure CodeGolf stack exchange might generate more interest! Description Write a program that runs when the rows and columns of the source code are transposed. In other words, imagine each character on each line is a cell...
There are two inputs, the first input is a map in 2D array, where 2 represents an obstacle and 0 represents a regular ground, and 1 represents the player's location (implies that the player is standing on ground), the second input is the player's movement range. A player can move on the map (horizontally, vertically, b...
The shortest code to pass all possibilities wins. In mathematics, the persistence of a number measures how many times a certain operation must be applied to its digits until some certain fixed condition is reached. You can determine the additive persistence of a positive integer by adding the digits of the integer and...
For any integer \$r\$, there exists a power of 2 each of whose last \$r\$ digits are either 1 or 2. Given \$r\$, find the smallest \$x\$ such that \$2^x\bmod{10^r}\$ consists of only 1 or 2. For \$r=2\$, \$x=9\$, since \$2^9=5\color{blue}{\textrm{12}}\$ For \$r=3\$, \$x=89\$, since \$2^{89}=618970019642690137449562\c...
In this task you will be given A (less than 10000 digits long) and B (less than 2^64), and you will need to compute the last digit of (A · A · A · ... · A (B times)). The inputs A and B are given in a single line separated by a blank; the inputs are terminated by EOF. Input 34543232321323243242434544533445343432434311...
Challenge In this task you would be given an integer N (less than 10^5), output the Farey sequence of order N. The input N is given in a single line,the inputs are terminated by EOF. Input 4 3 1 2 Output F4 = {0/1, 1/4, 1/3, 1/2, 2/3, 3/4, 1/1} F3 = {0/1, 1/3, 1/2, 2/3, 1/1} F1 = {0/1, 1/1} F2 = {0/1, 1/2, 1/1} ...
Write a program to test if a string is palindromic, with the added condition that the program be palindromic itself.
There are many formalisms, so while you may find other sources useful I hope to specify this clearly enough that they're not necessary. A RM consists of a finite state machine and a finite number of named registers, each of which holds a non-negative integer. For ease of textual input this task requires that the states...
Challenge In this task you have compute the number of ways we can distribute A balls into B cells with with every cell having at-least one ball. The inputs A and B are given in a single line separated by a blank,the inputs are terminated by EOF. You may like to check your solutions here. Input 0 0 1 0 12 4 6 3...
Challenge In this task you would be given an integer N (less than 10^6), output the number of terms in the Farey sequence of order N. The input N < 106 is given in a single line, the inputs are terminated by EOF. The challenge is to implement the fastest solution so that it can process a maximum of 106-1 values a...
Mr Jones wants to do a round-trip on his bicycle. He wants to visit several cities in arbitrary order, but his route must not cross it self, since he hates to be at the same place twice in his holidays. As he really loves cycling, the length of his route is completely irrelevant, but he dislikes to drive around the lan...
The shortest code to pass all possibilities wins Many grid based games have been made that start off with a grid of lights that are switched on. Pressing any of the lights causes that light and the four lights adjacent to it to be toggled. When a light is toggled, it is turned off or turned on, depending on if it was...
Write the shortest program to print the non-trivial powers ≤ 2^12 in order non-trivial power means the base and exponent are > 1 Leading whitespace is optional When there are multiple solutions, the order is not important, so 16 = 4^2, 2^4 is ok Sample output: 4 = 2^2 8 = 2^3 9 = 3^2 16 = 2^4, 4^...
Find the greatest gcd of the numbers \$n^m + k\$ and \$(n+1)^m + k\$ for given m and k. For example, for m=3, k=1 we have: \$n = 1\$: \$\gcd(1^3 + 1, 2^3 + 1) = 1\$ \$n = 2\$: \$\gcd(2^3 + 1, 3^3 + 1) = 1\$ \$\vdots\$ \$n = 5\$: \$\gcd(5^3 + 1, 6^3 + 1) = 7\$ (max) \$\vdots\$ \$n \to \infty\$ Input/Output Input i...
The general SAT (boolean satisfiability) problem is NP-complete. But 2-SAT, where each clause has only 2 variables, is in P. Write a solver for 2-SAT. Input: A 2-SAT instance, encoded in CNF as follows. The first line contains V, the number of boolean variables and N, the number of clauses. Then N lines follow, eac...
A perfect power is a positive integer that's equal to one positive integer, to the power of another positive integer (e.g. ab is a perfect power). Note that trivial solutions (e.g. b=1) are excluded; specifically, the definition requires a ≥ 2 and b ≥ 2. The task Write a full program that takes any number of positive i...
The following picture shows the problem: Write a function that, given an integer as the circle radius, calculates the number of lattice points inside the centered circle (including the boundary). The image shows: f[1] = 5 (blue points) f[2] = 13 (blue + red points) other values for your checking/debugging: f...
A positive number is said to be super power when it is the power of at least two different positive integers. Write a program that lists all super powers in the interval [1, 264) (i.e. between 1 (inclusive) and 264 (exclusive)). Sample Output 1 16 64 81 256 512 . . . 18443366605910179921 18444492376972984336 1844561819...
Write a short program, that would generate the longest possible error message, in a standard C++ compiler (gcc, cl.exe, icc, or clang). The score of each entry is the number of characters in the longest error message the compiler emitted. Types included in your source code and quoted by the compiler are counted as a si...
PHP has closures, let's play around with them. I have some arrays similar to, $wannabelist = array (1, 2, 3, 4, 5, 6). I want to do this: compr( expression($params), $wannabelist, $wannabilist2 ...). compr() should do the following: Take all the possible combinations of elements of the arrays given as parameters; Pass...
I found this task here. Given the ith (1<=i<=35) Fibonacci number F(i) calculate the sum of the ith till i+9th number F(i)+F(i+1)+...+F(i+9) and the last digit of the i+246th one F(i+246) I have been trying to solve this using python and some tricks(Binnet's formula and a tricky recurrence): f=lambda n:((1+5...
Back to basics! Create a "Hello World" program which prints, well, "Hello World". The winner this time though, is the one who gets the most interesting source code done. For instance, use obscure language features, make it obfuscated, or make the source code a peom or a piece of ASCII art. Your imagination and coding a...
This is a math problem which takes quite many things into question, making it rather challenging, and as you might have guessed, it's a code golf, so it should be as short as possible as well. The input, \$n\$, is any integer number (should at least support integers, but needn't be limited to). The output is the averag...
In this task, you have to write a program, that computes the prime factors of a number. The input is a natural number 1 < n < 2^32. The output is a list of the prime factors of the number in the following format. Exponents must be omitted if they are 1. Only output prime numbers. (Assuming the input is 131784): 131784...
Dealing with equations in the absence of a good equation editor is messy and unpleasant. For example, if I wanted to express an integral and its solution, it might look something like this: Integral[x^3 e^(-m x^2 b /2), dx] = -((2 + bmx^2)/(b^2*e^((bmx^2)/2)*m^2)) At integrals.wolfram.com, this is called "input form." ...
Challenge In this task you would be given an integer N you have to output the nearest prime to the integer. If the number is prime itself output the number. The input N is given in a single line,the inputs are terminated by EOF.The number of inputs would not exceed 10000 values. The challenge is to implement the ...
You are given a 16-bit machine and told to implement multiplication of arbitrary-sized integers. Your registers can only hold 16-bit numbers, and the biggest multiply instruction takes two 8-bit inputs and generates a 16-bit result. Your program must take as input two arbitrary-sized positive numbers and output their ...
In this task, you have to write a program, that reads a string with a length of up to 1024 characters and prints it out sorted. In order to make an interesting task from a boring one, I set a few restrictions: You must not change the contents of any variable. A variable can be assigned only once and must not be changed...
Background Of the 256 possible characters that a byte can represent, only a few of these are used under most circumstances. Couldn't we somehow take advantage of this, and make our text files smaller by eliminating the need for the rarely used letters? Many letters don't add any value in most situations, and can be rep...
Manchester coding is a telecom protocol used in radio communications that guarantees bit transitions at a regular interval so a receiver can recover the clock rate from the data itself. It doubles the bitrate, but is cheap and simple to implement. It is widely used by amateur radio operators. The concept is very simpl...
For 2 arrays each with X elements, what is the SHORTEST code to subtract every element in the second from every element in the first, 1 to 1 so, for example: A1 = [10,11,12] A2 = [1,2,3] A1 "-" A2 should == [9,9,9]
Write a program that print sum of as many Fibonacci numbers as possible. There is a limit in that your program should not run more than 10s on 2GHz single core PC. (equivalents are acceptable, for instance you have twice as many time on 1GHz PC). Memory consumption is not limited, but provide details, if you exceed nor...
Given equation of two lines in the format Ax+By=C, determine their intersection point. If they are parallel print 'parallel' without quotes. For input/output format refer sample input/output. Input 1x+1y=1 1x-1y=1 Output (1.00,0.00) Input 0x+1y=0 1x+0y=0 Output (0.00,0.00) -1000000 <= A,B,C <= 1000000. Note their ...
What are some tips for choosing the right language to golf? What factors affect the language to be chosen? Here are some example problem types: Problems that require I/O solution, either console or file Problems that require parsing Problems that requires you to write your solution as a function definition Math proble...
Inspired by this on Spiked Math: (source: spikedmath.com) In this code golf, you are going to write a numerical integrator. Instead of weighting, you first plot on a graphic canvas pixel-by-pixel or plot on a 2D array, then calculate the integral by counting the colored pixels. You are implementing a function with th...
Our task is to, for each letter of the (English) alphabet, write a program that prints the alphabet, in a language whose name starts with that letter. Input: none Output: abcdefghijklmnopqrstuvwxyz uppercase and trailing newline optional Rules: The scoring metric is the length of the programming language name, plus t...
Write a program to determine if the input polygon is convex. The polygon is specified with one line containing N, the number of vertices, then N lines containing the x and y coordinates of each vertex. The vertices will be listed clockwise starting from an arbitrary vertex. example 1 input 4 0 0 0 1 1 1 1 0 output c...
Your function must have an input that takes in an array containing 10000 random names, and must sort these names in alphabetical order. Names have a random length of up to 128 characters. ISO/IEC 8859-1 character set assumed to be used for the list of names. Usable list of names can be found at http://www.opensourcecf....
Given a list of intervals, perform the union of them, and reduce overlaps. That means, overlapping parts are reduced. ([a, b] U [c, d] = [a, d] if b > c) Assuming all a < b in all intervals [a, b]. Implement as a function of a list of input intervals -> list of output intervals. Shortest code wins. You cannot use any e...
Inspired by reddit. Write a program which plays Hangman. The program chooses a random word from a list of N words, where N > 2. The word list can be provided to the program in any way you choose. At each iteration Print out the state of the game using underscores for letters not yet discovered: H _ N _ _ _ N Prin...
The program must print the alphabet four times: first in the normal alphabetical order, second in the order of a qwerty keyboard, third in the order of a dvorak keyboard, and lastly in reverse alphabetical order. The output should resemble this: abcdefghijklmnopqrstuvwxyz qwertyuiopasdfghjklzxcvbnm pyfgcrlaoeuidhtnsqjk...
My dad is a retired teacher, and he used to give combined spelling and math quizzes, where the student would spell a word, and then 'score' the word by adding up the letters, where a=1, b=2, etc. (e.g. cat = 3+1+20=24). This made grading the quizzes easier, as he would just have to check for incorrect 'scores' rather ...
What general tips do you have for golfing in C? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to C (e.g. "remove comments" is not an answer). Please post one tip per answer. Also, please include if your tip applies to C89 and/or C99 and if it only works o...
Create a small acceptably efficient JS CSS selector engine. Please post size of script, and function to call preferable $(selector,context) style. EDIT: All major browsers support document.querySelectorAll which makes this question irrelevant.
Write a program that prints the shapes of one-sided polyominoes. Given input 4 (tetrominos), a sample output would be: * * * * * * ** ** ** * ** ** ** * * *** **** You are not restricted with respect to orientation, ordering or layout as long as polyominoes are not connected and no...
Given a maze on stdin and an entry point, write a program that prints a path to the exit on stdout. Any path is acceptable, as long as your program does not generate the trivial path (passing through every point in the maze) for every maze. In the input, walls are marked by a # and the entry point by a @. You may use a...
A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends ...
Now is the time to show off your abilities to write bad code. I am trying out a new sort of programming puzzle, most similar, I think, to the underhanded C contest. The main difference is that this is not nearly as nefarious: it's just some good clean fun. The goal of the puzzle is to pack as many bugs as you can into ...
Create a function, expression, or program which does the following: Take the prime factors of any number and sum them. For example, the prime factors of 28 are 2 2 7, summed to 11. Multiply the result by the number of prime factors for the given number. E.g, 28 has 3 prime factors which sum to 11. 11 * 3 is 33. Repeat...
Write a program that prints out the syntax error message of the compiler or interpreter. The error message should be misleading so that code maintainers will take days to find out that the error was faked, that means, you should obfuscate (and hide your intention). Also, the error must be as exact as possible, and shou...
Given the Cartesian coordinates of three points on a plane, find the equation of the circle through them all. The three points will not be on a straight line. Each line of input to your program will contain the x and y coordinates of three points, in the order A(x),A(y),B(x),B(y),C(x),C(y). These coordinates will be re...
Write a program that calculates amicable numbers, starting from [0,0], intil the maximum value for an integer is reached in the language you chose to write it in. Amicable numbers are two different numbers so related that the sum of the proper divisors of each is equal to the other number. (A proper divisor of a numb...
This task is part of the First Periodic Premier Programming Puzzle Push. You get a hierarchy of items in the following format: 2 Hat 1 Gloves which need to be put in boxes, like so: .------------. | Hat | | .--------. | | | Gloves | | | '--------' | '------------' In the input format the numbers start a box wi...
How to determine if a number is odd or even without mod -or- bitwise operations? This challenge is grossly inefficient, but challenges your ability to think outside the box for a creative solution. EDIT: Please create a function. Also, while regex is a fun response, the function should accept any valid number. BACKGRO...
You are given a bunch of weights, and your task is to build a small balanced mobile using those weights. The input is a list of integer weights in the range 1 through 9, inclusive. There may be duplicates. The output is an ascii picture of a mobile that, when hung, would balance. Perhaps best shown by example: input ...
The look and say sequence is a basic form of run length encoding. The sequence starts with the number 1 and each additional number encodes the number of digits that are repeated before each digit sequence. For example, "1" becomes "11", because there is one "1". Then "11" becomes "21", and so on. The first few numbers...
Below are a basic set of requirements. The following commands (for an interface to the game): attack <target>, <move> goto <place> buy <item> enum < targets, moves, places, items, stats > The following player stats: HP MP/SP (Mana/Stamina) XP Level Gold Items Scoring (Thanks to @Casey for this...
For a given positive integer number N, write a complete program to find the minimal natural M such that the product of digits of M is equal N. N is less than 1,000,000,000. If no M exists, print -1. Your code should not take more than 10 secs for any case. Sample Inputs 1 3 15 10 123456789 32 432 1296 Sample Outputs ...
This task is part of the First Periodic Premier Programming Puzzle Push and is intended as demonstration of the new king-of-the-hill challenge-type proposal. The task is the write a program to play the iterated prisoner's dilemma better than other entrants. Look, Vinny. We know your cellmate---what's his name? Yeah Mc...
This is a word game from a set of activity cards for children. Below the rules is code to find the best triplet using /usr/share/dict/words. I thought it was an interesting optimization problem, and am wondering if people can find improvements. Rules Choose one letter from each of the sets below. Choose a word using...
Create a self-replicating Hello World Program. (The program has the ability to use the compiler, if you want). For example: void main() { printf("Hello, World!"); DuplicateFile("main.exe", "main2.exe"); } Alternate challenge: A "quine" Hello World Program.
Figure out how to mess up another programmer's project by making a subtle, hard to find (but "harmless") "bug". (Double quotes FTW!) Try to keep them short; shorter ~= subtle. For example: #define true false Don't actually destroy the code directly. For example, from this: for(size_t i = 0; i < 10; ++i) To: for(siz...
Write a program which can compress/decompress randomly generated Lorem Ipsum text. Devise your own lossless algorithm. You may compress your data further using an existing algorithm afterwards, but you must cite the algorithm used. You may use dictionaries. The text does not necessarily start with Lorem ipsum dolor si...
This is a nice exercise for becoming more fluent in that programming language you've been meaning to learn, but have only tinkered with lightly. This involves working with objects, using or simulating closures, and stretching the type system. Your task is to write code to manage lazy lists, then use it to implement th...
Kira needs your help! Input format: Date [and/or Time] Name Gender Reason Output format: <Last Name, First Name> <will die/died> on the <DD><st/nd/rd/th> of <MMM, YYYY> [at <hh:mm:ss TT>]. <He/She> <will die/died> of <Reason>. Details, Details: Your program should account for at least the following date input for...
Equilibrium index of a sequence is an index such that the sum of elements at lower indexes is equal to the sum of elements at higher indexes. For example, in a sequence A: A[0]=-7 A[1]=1 A[2]=5 A[3]=2 A[4]=-4 A[5]=3 A[6]=0 3 is an equilibrium index, because: A[0]+A[1]+A[2]=A[4]+A[5]+A[6] 6 is also an equilibrium inde...
Finding a treasure hidden by pirates is really easy. Everything you need for this is a map. It is widely known that pirates draw maps by hand and describe the algorithm to find a place in the following way: "Stand near a lone palm tree, do 30 steps towards the forest, 15 towards the lake, ..." A journey through such ro...
As discussed in the Lounge room on Stack Overflow: if you can't implement the Quicksort algorithm given en.wikipedia.org/wiki/Quicksort in any language you have minimal knowledge of, you might want to consider a different profession. @sbi but SBI also noted that maybe BrainF*** was an exception. So, here's the puzzle...
You are tasked with planning a flying route for a local airplane delivery company. You need to route an airplane from point A to point B. You just can't start at A, point the airplane at B, and go, however, as the prevailing winds will blow you off course. Instead you need to figure out which direction you should po...
This one ought to be a little more of a challenge than your normal "compute these numbers" or "print this sequence of text" puzzles: Write a program that launches another program and when that other program tries to access a certain file the program causes it to open a different file. Example: The program launches No...
Write the "fastest" program to print an incrementing series of squares from a given input to a given input. Example input: -2 7 Example output: 4, 1, 0, 1, 4, 9, 16, 25, 36, 49 When using a "cryptic" language, please post the pseudocode, in addition to your program. The entries will be judged on the most efficient al...
This was written as part of the First Periodic Premier Programming Puzzle Push. The Game A starting and ending word of the same length are provided. The objective of the game is to change one letter in the starting word to form a different valid word, repeating this step until the ending word is reached, using the few...
I had fun solving this, so I offer this golf challenge. The objective of this golf is to find the largest prime number that can be constructed using the given instructions. You should accept 3x3 grid of single digits as input. (It's up to you how you want to do that, but specify that in your program.) You can move alon...
Write a program to find the sum of all odd numbers between a given range [a,b]. Input consists of a single line containing two integers a and b separated by a space. 0 ≤ a,b ≤ 1,000,000,000,000. Your program should not take more than 10 secs. Sample Inputs 1 5 4 8 1 8 0 5 Sample Outputs 9 12 16 9
Create a function that takes a natural number (starting from 0 inclusive), and returns a pair of positive integers, which are the numerator and denominator respectively. Use the diagonal traversal. Previous-counted numbers must be skipped. (you can memorize the set of skipped values) Diagram: Red are skipped values Va...
USGS's seismometers have just detected a major earthquake! Emergency response teams need a quick estimate of the number of people affected. Write a program to compute this estimate. Your program receives 2 inputs. The first is the details of the earthquake itself. The earthquake modeled as a line segment along which th...
This is a model of a forgiving HTML parser. Instead of parsing HTML and extracting attributes, in this code golf, the tag parser will be simple. Write a function that parses a tag structure and returns its parenthized form. An opening tag consists of one lowercase letter, and a closing tag consists of one uppercase let...
You all know the Newton method to approximate the roots of a function, don't you? My goal in this task is to introduce you into an interesting aspect of this algorithm. Newton's algorithm converges only for certain, but most of all complex input values. If you picture the convergence of the method for all input values...
Given two numbers r and n on separate lines, write a program to print n natural numbers starting from 1 onwards, excluding the r-th powers. For example, If r=2 and n=10, the results would be 2,3,5,6,7,8,10,11,12,13 4 and 9 were excluded because 4 is 2^2 and 9 is 3^2 Sample Input 2 10 Sample Output 2 3 5 6 7 8 10 11 12...
A software vendor friend of mine wants to clamp down the development environment by limiting access to the software's source code to only Remote Desktop access, disallowing any digital communication including clipboard, printer, network shares, and internet access from that environment. The reasoning is that they are c...
Johnny is trying to create crossword puzzles, but he is having difficulty making words match each other. He has come up with several simple word rectangles: that is, groups of words that form a rectangle where all horizontal and vertical paths form a word. //2x2 PA AM //2x3 GOB ORE //3x3 BAG AGO RED //3x4 MACE AGE...
Write a program that does one step of the computation of factorial, then, generate (quine) a new program, and performs the rest of the process in the new program The seed and spawned programs will have a variable n for the factorial to be computed and m for the accumulator. I don't care if you use scripted or compiled ...
Given the topography of land in ASCII picture format, figure out where lakes would go and fill them in. Assume an infinite amount of rain. example input # ## # #### # ######### ## ########### ## ############# #### ## #######...
Can you write a program that renders to screen a group of pixels exploding apart (as in a simple particle engine) and can you do this in any remarkably small number of characters (key strokes)? (Recall the game lemmings, when those little guys would explode and their little pixel pieces fly apart.) Someone programmed a...
Using two languages of your choice, write the smallest “mutual quine” you can. That is, write a program P in language A that outputs the source code for a program Q in language B, such that the output of program Q is identical to the source code for P. Empty files don't count, nor do "read the source file and print it"...
A073329 is a sequence where the \$n\$th term is the \$n\$th number with exactly \$n\$ distinct prime factors. For example, \$a(3) = 60\$ as the first \$3\$ integers with \$3\$ distinct prime factors are \$30 = 2 \times 3 \times 5\$, \$42 = 2\times3\times7\$ and \$60 = 2^2 \times 3 \times 5\$. You are to take a positive...
The challenge is to implement a 2-dimensional ray tracing program, text-based. Sources of white light are @ symbols. R, G and B are light filters. / and \ are mirrors with 80% reflectivity. ? is a light sensor. >, <, ^ and V combine light in the appropriate direction (e.g. if one red and one green came into a > the lig...
Show the random result of a dice toss if done with a cube shaped die, in ASCII. $ dice should result in one of ----- | | | o | | | ----- ----- |o | | | | o| ----- ----- |o | | o | | o| ----- ----- |o o| | | |o o| ----- ----- |o o| | o | |o o| ----- ----- |o o| |o o| |o o| -----
Today computers use millions of bytes of memory, and decimal or hexadecimal notations get less and less informative. Most human-readable formatting just display the number with the highest unit prefix. What about the rest? I devised a notation that I use for myself, and since then, I'm often faced with re-implementing ...
Inspired by the Morse code question, and the Twinkle Twinkle little star question, write a program to accept a letter and generate the morse code audio for that letter.
A Bingo card is five columns of five squares each, with the middle square designated "FREE". Numbers cannot duplicate. The five columns are populated with the following range of numbers: B:1-15 I:16-30 N:31-45 G:46-60 O:61-75 In as few characters as possible, output a string that can be interpreted as a randomized B...
The one-dimensional version of this problem was pretty easy, so here's a harder 2D version. You are given a 2D array of land heights on standard input, and you have to figure out where the lakes will form when it rains. The height map is just a rectangular array of the numbers 0-9, inclusive. 8888888888 5664303498 648...
Your program should compute the number of moves it takes a chess knight to reach each square of the chess board. The input will be two space-separated integers representing coordinates of the starting square (horizontal then vertical coordinate, 0-7 inclusive each). Your program should output a number grid containing...
The program must print the following block of text of LED numbers exactly. +-----------------------------------------------------------------+ | | | 000 1 222 333 4 4 555 666 777 888 999 AAA B CCC D EEE FFF | | 0 0 1 2 3 4 4 5 6 7 8 8 9 9...
Description Your task is to output a 'depthmap' - that is, a heightmap of an object but not seen from its top but from its front. For example, consider the following object as shown on the image. The height map is shown on the left. The corresponding depth map would be (as seen from standing at the arrow): 010 211 <-...
Challenge In this task you would be given an integer N (less than 106), find the minimum way in which you could sum to N using only Fibonacci numbers - this partition is called Zeckendorf representation. You could use any Fibonacci number more than once and if there is more than one representation output any. For exa...