instruction
stringlengths
34
53.1k
Let me tell you about a simple number system. (which I made up just for this challenge) This system contains the functions (), [], {}, and <>. 1. () When () is given no arguments, it evaluates to 0. When () is given one or more arguments, it evaluates to the sum of the arguments. 2. [] When [] is given no arguments, it...
Thanksgiving in the United States is coming up on November 24th. Many people will have a large dinner with their families, traditionally including turkey and many side dishes. This typically means the family members must coordinate who's going to bring each of the various dishes. In this challenge, the goal is to write...
Once I wrote a JavaScript program that would take as input a string and a character and would remove all characters except for the first one and the character given as input, one by one. For example, computing this with inputs codegolf.stackexchange.com and e for the character yields: codegolf.stackexchange.com cdegolf...
Challenge Implement a program that given three strings a, b, and c, substitutes all instances of the substring b in a with c. In other words, implement Ruby's String#gsub with strings instead of regexes (a.gsub b, c). Rules Standard loopholes apply. You may not use a builtin that performs this exact task. This is code...
This challenge is inspired by this other challenge, which you may want to read first for some context. However, a competitive answer is likely to look very different, so after reading some posts on Meta I decided it was best posted as a separate question. The goal here is to write a polyglot program; that is, a program...
Background We already have a challenge about throwing SIGSEGV, so why not a challenge about throwing SIGILL? What is SIGILL? SIGILL is the signal for an illegal instruction at the processor, which happens very rarely. The default action after receiving SIGILL is terminating the program and writing a core dump. The sign...
Many old Game Boy games often required string input from the user. However, there was no keyboard. This was handled by presenting the user with a "keyboard screen" like so: The 'character pointer' would begin on letter A. The user would navigate to each desired character with the D-Pad's four buttons (UP, DOWN, LEFT a...
I'm new to Japanese Mahjong and have trouble calculating the scores. Please help me write a program to calculate it. Introduction (aka you can skip this boring part) Mahjong is a popular tile game in Asia. Different rules have evolved and systematically established in various regions. Japan, being an isolated island st...
You task for today: draw a dragon curve! In case you don't know what a Dragon Curve is, here is an introductory ViHart video (Really cool, please watch!) Your task: draw a dragon curve, iterated at least 9 times. You don't have to show iterations 1 through 9, you just have to show the final curve produced after complet...
Brief Problem Explanation Write a program to find the minimum distance between two points traveling only on rays emanating from the origin and circles centered on the origin. Explanation of Premise Now let's imagine we are on a plane, and on this plane we are only allowed to travel in special ways. We are allowed to tr...
Write a program that outputs as many characters as possible, with two conditions: The program must be 256 bytes or shorter The program must almost surely eventually halt. In other words, the only thing not permitted in response to this question is an infinite loop. For the purposes of this problem, any built-in psudo...
Background This question is similar to this one. I have provided all of the information needed below. If you are familiar with the other challenge then note that we are ranking all defenses instead of seeing the effectiveness of a single attack. This is important because it means that the tables are inverses of each ot...
Definitions: A line is a possibly empty sequence of characters terminated by a “newline character.” A “newline character” is a character that cannot be a component of the aforementioned character sequence. A line number comment is a character sequence that does not alter the meaning of source code in the programming l...
The Challenge Given a CSV input, output a proper unicode table using box characters. Formatting The table will be formatted using the following rules: Column width will be equal to the longest value of that column All table data will be left justified Each table will assume the first csv row to be the header The table...
What's great about golfing is not having to deal with errors. Except this time you won't get off so lightly! I need to do some arithmetic with certain limitations, and I wan't to know what goes wrong if anything. Challenge Given a list of signed integer values [n1..n11], give the following result or the first error tha...
Challenge description Let's start with some definitions: a relation is a set of ordered pairs of elements (in this challenge, we'll be using integers) For instance, [(1, 2), (5, 1), (-9, 12), (0, 0), (3, 2)] is a relation. a relation is called transitive if for any two pairs of elements (a, b) and (b, c) in this rel...
Let's take a look on a typical loop, which usually performs 8 iterations: for (int x=0; x<8; ++x); You have to make it infinite! It's a popularity-contest for all languages that support such form of for loop. So solution with highest score (upvotes minus downvotes) wins. If your language has the other form of for loo...
Remember those brute-force programs to crack password that show every combination they are trying? More precisely, at one point, the n first characters are fixed (they have been guessed successfully), and every possible character for the remaining ones is being tested. You've probably seen some in movies, or in some so...
Introduction A disk is a linear container with blocks indexed 0 through size-1. A file is a named list of block indexes used by that file. An example filesystem is expressed like this: 15 ALPHA=3,5 BETA=11,10,7 "The disk has 15 blocks, the first block of file ALPHA is the disk block at index 3..." The disk map could b...
Your challenge is to create a regex that matches every string permutation of itself, and nothing else. The match must also be case-sensitive. So, for example, if your regex is: ABC It should match (and only match) these strings: ABC ACB BAC BCA CAB CBA It shouldn't match things like: AABC (contains an extra A) ABCD (...
Output a full formal poof of such statements such as 1+2=3, 2+2=2*(1+1) etc. Introuction If you know Peano Arithmetic you can probably skip this section. Here's how we define the Natural Numbers: (Axiom 1) 0 is a number (Axiom 2) If `x` is a number, the `S(x)`, the successor of `x`, is a number. Hence, for example S(S...
You are a traveller crossing the desert between two towns. You cannot carry enough water to get across without stopping. This is a variation of a classic puzzle. The Rules A desert looks like this: a WxH grid of mostly empty space. The space marked S is where you start, E is where you want to end, and a square marked w...
Generate a cipher given a number and string Your task is simple. Given a string s and a number 0 <= n <= 9 as inputs, insert a pseudo-random printable ASCII character between each character of the string n times. Such that for each character of s there are n random characters between them. Spaces should be trimmed. Inp...
Wikipedia says about Polar Coordinates: In mathematics, the polar coordinate system is a two-dimensional coordinate system in which each point on a plane is determined by a distance from a reference point and an angle from a reference direction. This seems perfect for describing hexagonal grids. Take the following he...
Goal: A tree can be represented as a nested list: the list elements represent nodes, and a node is a pair of the node name and node children. Your program takes as input a nested list of pairs, and should output a pretty tree. Examples: Here are four example test cases below ["stump",[]] ["trunk",[["branch",[["leaf...
Today we're going to build a pyramid out of letters! Here's an example letter pyramid for the first 5 letters: Write the first 5 letters with a space between, first ascending and then descending. A B C D E D C B A Do the same thing for the first four letters on the line above, but with two extra leading spaces: A B...
Summary Implement FizzBuzz in Python, with the fewest possible tokens. Challenge Write a program that prints the decimal numbers from 1 to 100 inclusive. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print...
I love /usr/share/dict/words; it's so handy! I use it for all my programs, whenever I can! You're going to take advantage of this ever so useful file to use, by testing a word's individuality. Input A word; defined in this challenge as any string of characters /usr/share/dict/words in some format; you may hard code i...
This challenge is based on the game Layerz. Given, on stdin or as a function argument, a 2D rectangular array of cells where each cell contains either a blank (you may choose to use 0s instead of blanks at no penalty), a 1, a 2, a 3, or a 4; find a way to divide it into valid regions (as defined below) such that each n...
The challenge is to calculate the digit sum of the factorial of a number. Example Input: 10 Output: 27 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27 You can expect the input to be an integer above 0. Output can be of any type, but the answer sh...
Your task, if you choose to accept it, is simple. Objective You must make a program that, when run, prints some (as many as you want) terms in a sequence that you choose. The sequence must be a valid OEIS sequence. The twist is that when you take the characters from your code that make up your sequence, string them tog...
First line is made with ceil(n/2) elements where each element is: <space><odd-number><space> Second line is made with ceil(n/2) elements, but each element is / \ only. You may assume n >= 0 and n <= 10. Examples Input: 3 1 3 / \/ \ Input: 10 1 3 5 7 9 / \/ \/ \/ \/ \ Example in Python 3, 103 bytes: lambda a:p...
Inspired by Display a chain of little mountains with an odd number on the top of it! by @sygmei. Why have a chain of mountains when you can have one massive one? Make a program that takes an input number and prints a mountain with every odd number up to the input number. (Where "south west" means directly below and to ...
EDITS: Added link to the plain-text (multiple strings) test data Added BLANK,EDGE and TIE2 test cases (see Test Data section) (11/25) Updated the JSON test cases (some lines were ill-formatted) (11/24) Renju match gone bad ! (well, technically these guys are playing Go, but who cares) Wikisource TL;DR Take a 15x15 ...
Take a non-nested array as input. Turn it into a matrix by using the following method: Let's say my array is [1, 2, 3, 4, 5] First, I repeat that array 5 times: (the length) [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]] Then, I read it along the diagonals: [[1], [2, 1], [3...
Tamagotchi and Giga Pets were small electronic devices which simulated a little virtual pet. This pet had several stats, like health, hunger, etc. I recently wrote this example: import msvcrt,os,sys;d=m=100;h=s=t=p=0;f=10 while 1: os.system('cls'if os.name=='nt'else'clear');print("health:",d,"\nhunger:",h,"\nsleep:",...
Write a program with the following properties: When run as-is, the program produces no output (i.e. 0 bytes of output). There is a location within the program (of your choice: it could be at the start, end, or somewhere in the middle) with the following property: modifying the program via placing any string there will...
Introduction Today I went fishing alone with my canoe, unfortunately I fell asleep and the stream brought me away, I lost my oars, now it's night and I am lost in the ocean! I can't see the coast so I must be far away! I have my cell phone but is malfunctional because it got wet by the salty water, I can't talk or he...
Task Given a Boolean matrix, find one (or optionally more) subset(s) of rows which have exactly one True in each column. You may use any algorithm, but must support very large matrices, like the last example. One possible algorithm (Knuth's Algorithm X) While there is no requirement to use this algorithm, it may be you...
The Golfer Adventure This is the first challenge ! There will be more challenges later that will require data from the previous challenge :) Chapter 1 : The Vase Let's imagine a minute.. You are a powerful God, your powers are limitless but require one thing : Souls. Each soul is here represented by a byte, each byte y...
Introduction I'm a real big fan of the SBU (Short But Unique) challenges that crop up on PPCG all of the time. The CUSRS is a system designed to refactor strings, a CUSRS function takes 2 parameters and outputs 1 String. Challenge Produce a program, function, lambda or acceptable alternative to do the following: Given ...
Background An unlabelled tree may look like this: o / | \ o o o | / \ o o o To linearize this tree, we first label each node o with it's number of child nodes: 3 / | \ 1 0 2 | / \ 0 0 0 and then write the numbers in a list in a breath-first manner, meaning line by line and left to right: [3...
Your challenge is to write a program or function that hiccups a string. It should take a string as input (via any standard method), then follow these steps: Generate a (not necessarily uniformly) random integer n between 1 and 10, inclusive. Wait n seconds. Print the initial/next n chars of the input, or the rest of t...
...but hey, no need to be strict. Given a non-empty array of strictly positive integers, determine if it is: Monotone strictly decreasing. This means that each entry is strictly less than the previous one. Monotone non-increasing, but not strictly decreasing. This means that each entry is less than or equal to the pre...
A sculptor is tasked to creating icicle sculptures for the new museum in Greenland. He has been given specifications by his boss, which consists of two numbers: [s, m] or size and melt. Size must be an odd number. He was given some photos of real icicles: vvvvv [5, 0] vvv v vvvvvvv [7, 0] vvvvv vvv v vvv...
Your task is to, given an array of signed 32 bit integers, recompile it with its inverse deltas. For example, the list 1 3 4 2 8 holds the deltas: 2 1 -2 6 which are then negated, yielding: -2 -1 2 -6 and recompiled, yielding: 1 -1 -2 0 -6 as the final result. Input/Output You will be given a list/array/...
Challenge Write a full program/function to Demolish a given building at the rate 1 floor per second. INPUT Input is a building through STDIN(or whatever is called in your language) or through an ARGUMENT of a function. t=0 s | |#| {#} |# #| |# # #| |# # #| |# # #| TTTTTTT input consists of : | marks sta...
You will write a simple program that prints exactly 1 2 3 4 5 6 7 8 9 10 to STDOUT, Console, or your language's closest output method. No other visible output should be seen. Any other code executed must be back-end only. This is answer-chaining, so the catch is that you must include the previous answer's source code i...
Let's use the four basic operations, addition +, multiplication *, subtraction - and division / (float, not integer). Stewie's sequence is defined as follows: x = [x(1), x(2)] // Two initial numbers (one indexed) x(3) = x(1) + x(2) x(4) = x(2) * x(3) x(5) = x(3) - x(4) x(6) = x(4) / x(5) x(7) = x(5) + x(6) ... and s...
Given two positive integers X and Y, output any combination of the following three ASCII-art animals such that the output contains exactly X commas (,) and Y periods (.), if it is possible. Koala: 1 comma, 2 periods <.,.> Crab: 2 commas, 2 periods ,<..>, Commapillar: 3 or more commas, 1 period <,,,.> or <,,,,.> or ...
A polyglot is a program that can be run in 2 or more different programming languages. What general tips do you have for making polyglots, or choosing languages that are easy to write polyglots for a specific task? Please post the tips that could be applied in most situations. I.e. they shouldn't work only in polyglots ...
What general tips do you have for golfing in Nim? I'm looking for ideas which can be applied to code-golf problems and which are also at least somewhat specific to Nim (e.g. "remove comments" is not an answer). Please post one tip per answer.
After all the fun we've had with polyglot challenges in the (recent) past, how about a challenge where the output can be in two languages? Your answer needs to accept boolean input b and output the text "true" or "false". The same code needs to output, when run in another language, "waar" or "onwaar" or any other trans...
Introduction A xenodrome in base n is an integer where all of its digits in base n are different. Here are some OEIS sequences of xenodromes. For example, in base 16, FACE, 42 and FEDCBA9876543210 are some xenodromes (Which are 64206, 66 and 18364758544493064720 in base 10), but 11 and DEFACED are not. Challenge Given ...
B-splines are defined using a set of "knots", "control points", and degree. For the purposes of this challenge, the control points are not needed. The knots are simply a list of strictly increasing real values (note that real B-splines may have repeated knots, for the purposes of this challenge assume knots are all uni...
(This is part 1 in a two-part challenge.) Your task is to solve a Hexasweep puzzle. A Hexasweep puzzle is set out on a grid of diamonds arranged in hexagonal shapes, of which the board looks like a hexagon, like so: _____ /\ \ _____/ X\____\_____ /\ \ / XX /\ \ /X \____\/____/X \____\ \ X/...
This is a potato: @@ @@@@ @@@@@@ @@@@@@ @@@@ @@ More generally, a size N potato is defined as the following shape: If N is even, it is 2 centered @ symbols, followed by 4 centered @ symbols, followed by 6 centered @ symbols, all the way up to N centered @ symbols; then, N centered @ symbols, followed by N-2 ce...
Introduction Dobble/SpotIt is a card game, where people have to spot same symbol on pair of cards in shortest time, indicate it and move to next pair. Each card has multiple symbols (8 in normal version), but exactly one is common between each pair of cards. Example from physical copy of game: Challenge Write a progr...
An unspeakable number is a number which is divisible by seven or has seven as one of its digits. A children game is to count skipping unspeakable numbers 1 2 3 4 5 6 ( ) 8 9 10 11 12 13 ( ) 15 16 ( ) 18 ... Cantor's version of the game is the sequence defined by recursively filling in the sequence "1 2 3 4 5 6 ( ) 8.....
Given three sidelengths of a triangle, evaluate its aspect ratio AR given the following formula: where The closer to equilaterality a triangle is, the closer to 1 its aspect ratio is. The aspect ratio is bigger or equal to 1 for valid triangles. Inputs The input is three real positive numbers which can be encapsulate...
Background of Lucas Numbers The French mathematician, Edouard Lucas (1842-1891), who gave the name to the Fibonacci Numbers, found a similar series occurs often when he was investigating Fibonacci number patterns. The Fibonacci rule of adding the latest two to get the next is kept, but here we start from 2 and 1 (in th...
Source: Wikipedia For this challenge, you should write two programs which resemble the figure and ground of the above image, such that one of them prints figure and the other prints ground. Specifically: Write a program which takes no input and prints the string figure. The only allowed whitespace characters in your ...
Your challenge is to make an infinite loading screen, that looks like this: Or, to be more specific: Take no input. Output Loading..., with a trailing space, but no trailing newline. Infinitely cycle through the chars |, /, - and \: every 0.25 seconds, overwrite the last one with the next in the sequence. You can ov...
Write a program that can validate a PNG file. Your program should follow the PNG spec and must validate the PNG signature and the 4 critical chunks: IHDR, IDAT, PLTE and IEND. Your program must not validate the contents of ancillary chunks, except for their CRC checksums. Your program must validate the presence of the ...
Introduction In the game The Witness (possible spoilers ahead) there is a group of puzzles that involve drawing a Tetris piece with your line while making sure that the symbol for the Tetris piece your currently drawing stays contained within the shape you've drawn. For the image above the drawing works because the ...
Write a program or function that alters the file at a user-specified filename via replacing all instances of UNIX line endings with Windows line endings and vice versa. Clarifications: For the purposes of this problem, a UNIX line ending consists of the octet 0A in hexadecimal, except when it is immediately preceded b...
(Inspired while drawing on a dry erase board) Challenge: Given an input string containing characters that represent different colors of dry erase markers on a white board, output the order in which they were drawn, from first to last. Input: A string which contains dry erase marker colors which are represented by alpha...
Challenge Given a rectangular grid of printable ascii characters as a string or through standard input, write a function or program that collapses the non-space characters into a pile on the bottom. The rules: The output has the same dimensions and characters as the input. A non-space character at (row a,column b) can...
Given a nonempty array of positive integers, "increment" it once as follows: If all the array elements are equal, append a 1 to the end of the array. For example: [1] -> [1, 1] [2] -> [2, 1] [1, 1] -> [1, 1, 1] [3, 3, 3, 3, 3] -> [3, 3, 3, 3, 3, 1] Else, increment the first element in the array that is the array's mi...
Take a positive integer X. This number is part of the sequence we are interested in if the sum of all digits of X is a divisor of X, and if the product of all digits of X is a divisor of X. For example, 135 is such a number because 1 + 3 + 5 = 9 which divides 135 = 9 * 15 and 1 * 3 * 5 = 15 which also divides 135. This...
Challenge Create the shortest program that meets the requirements Requirements The code must generate a 5x5 grid of 0s, like so: 00000 00000 00000 00000 00000 The code must accept an input (column, row, character). The grid must change accordingly: Start: 00000 00000 00000 00000 00000 Input: (2,5,*) Output: 0*000 0...
A brace string is defined as a string consisting of the characters *()[] in which braces match correctly: [brace-string] ::= [unit] || [unit] [brace-string] [unit] ::= "" || "*" || "(" [brace-string] ")" || "[" [brace-string] "]" This is a valid brace-string: ((())***[]**)****[(())*]* But these are not: )( **...
What tips do you have for golfing in Wierd? Tips for golfing other languages don't seem to help one golf Wierd programs so I'm looking for ideas that can be applied to code golf problems that are specific to Weird - especially if it helps me reduce the size of this answer at "Hello, World!"
Playing tetris is fun. Watching an AI play tetris is also fun. Some tetris AIs will always ignore the possibility of maneuvering a piece under an overhang, which makes me sad. It means that the programmer said to himself, "What are all the possible places the tile could be at the top of the board, and from each place,...
Write a program which will take for input 2 integer arrays and return a truthy value if there exists an element which is present in both of arrays, or a falsy one otherwise. The obvious solution to this problem would be to iterate through each element in the first array and compare it against each element in the second...
Imagine this, we have an environment with a global scope containing just a single object, called codegolf. This object has a single child called stackexchange, which has a property called com. Accessing this property would look like codegolf.stackexchange.com. The challenge The input of your program/function will be a ...
N children, with no two sharing their exact size, are lined up in some order. Each can only compare heights with their immediate neighbours. When the teacher shouts "raise hands if you are the tallest", they do so if they are taller than both their neighbours, and they do so simultaneously. If only one raises their han...
Year of 2010, an Icelandic Vulcano, concisely named Eyjafjallajökull erupted, resulting in my long-planned flight being canceled. In case this ever happens again, I would really like to know in advance, so please help me build a simple visual alert system ! Input Take the Icelandic Meteorological Office volcanic activ...
You need to produce output that is non-deterministic. In this case, this will be defined to mean that the output will not always be the same result. Rules: A pseudo-random number generator that always has the same seed does not count. You can rely on the program being run at a different (unknown) time each execution. ...
Write a program or function which, given a non-empty sequence of right or left turns, outputs the length of the shortest self-avoiding path on a 2D lattice with those turns. The input should be taken as a string, with each character being R or L for a right or left turn respectively. The output should be an integer, th...
All Aboard the ASCII Train! o O O ___ ___ ___ ___ ___ ___ ___ ___ ___ o | C | | O | | D | | E | | | | G | | O | | L | | F | TS__[O] |___| |___| |___| |___| |___| |___| |___| |___| |___| {======|_|"""""|_|"""""|_|"""""|_|"""""|_|"""...
There’s a famous tricky algorithm for counting the number of set bits in a 32-bit unsigned integer: int popcount(unsigned x) { x = (x & 0x55555555) + ((x >> 1) & 0x55555555); x = (x & 0x33333333) + ((x >> 2) & 0x33333333); x = (x & 0x0F0F0F0F) + ((x >> 4) & 0x0F0F0F0F); x = (x & 0x00FF00FF) + ((x >> 8) & 0x...
Write a program which runs forever and allocates more and more memory on the heap the longer it runs, at least until you reach the limit of the operating system on the amount of memory that can be allocated. Many kernels won't actually reserve memory you allocate until you use it for something, so if your program is in...
My homework is to write a Martian essay (see below) between 729 and 810 words, inclusive. Your task is to write a program that will generate the essay. History Around the turn of the 20th century, spiritualist Catherine-Elise Müller allegedly communicated with Martians. During somnambulatory trances, she would write ...
Introduction Suppose we have a network of railroads. Each junction in the network is controlled by a switch, which determines whether an incoming train turns left or right. The switches are configured so that each time a train passes, the switch changes direction: if it was pointing left, it now points right, and vice ...
Write a Java method to check if a given string matches any value in a given enum. Your method will take two parameters, one a string and one an enum, and return true if the string representation of any of the enum's elements matches the given string, or false otherwise. Note that your method should still function norma...
Draw lines between every pair of distinct points for n points arranged in a circle, producing something like the below result. Shortest code (in bytes) wins! Your lines don't have to be transparent, but it looks better that way. The output must be a vector graphic, or be an image at least 600 pixels by 600 pixels (eith...
Alphabetize Integers For a given set of numbers, put them in alphabetical order when they are spelled out (i.e. 1: one, 2: two, 90: ninety, 19: nineteen). Your code should work for the range [-999999, 999999]. Output must have a delimiter between numbers. A space will work, as will a space and a comma as shown in the e...
I like the Hilbert Curve. Your task for this challenge is to take an image (strictly a square image where all the sides are a power of two pixels wide) and unravel it line by line in a zig-zagging fashion and ravel it back up in a pseudo-Hilbert curve. Unraveling To unravel you will start with the pixel in the upper l...
Long time lurker first time poster here. Write a program which takes 3 inputs: X, Y and Z. X = across (columns) Y = down (rows) Z = Location Marker The program should then print a visual grid X across and Y down. This grid will can be made of any character except "+". Each 'location' is given an index number, count...
Introduction A radix tree, also known as compressed trie or compressed prefix tree, is a tree-like data structure for storing a set of strings. The edges of the tree are labeled by nonempty strings, and each node is either terminal or nonterminal. The strings that the tree contains are exactly the labels of all paths f...
Write the shortest program which, when run with no arguments, stdin, or user input, triggers a core dump. Your code must behave this way when run on some common out-of-the-box Linux distribution. Other than installing support for your target language, you may not reconfigure the system to make it more fragile than it i...
Welcome to the grinder. Your task is to make big rocks into small rocks by grinding them. Take an input of a big rock of size n > 3 and grind it. Continue to grind the rocks by dumping them into the grinder until the size of all the rocks are 2. rocks are always grinded into equal even halves. If the result of a grin...
Given a string representing a series of aircraft marshalling hand signals, write a function or program to calculate the final position of an aircraft following these signals. N.B.: Co-ordinates in this challenge are represented as a pair of Cartesian co-ordinates, plus a compass direction heading: (x, y, h) where x is ...
Each term in the squaring sequence, \$x_n\$, is created by taking \$x_{n-1}\$, squaring it, and removing all but the first four digits. The sequence always begins with \$x_1 = 1111\$. Squaring this yields \$1234321\$, so \$x_2 = 1234\$ The first few terms are: 1111 1234 1522 2316 5363 ... The Challenge Your task is t...
The Definition Given an integer x, a version series is a set of digits (base 10) from which any x-length subset of consecutive members is unique compared to all other possible subsets of the same length (a unique "version"). The Task Write a function which, when passed some subset length x, produces a version series, c...
In the IRC protocol, raw messages look similar to this: command arg1 arg2 :arg3 with spaces :arg4 with spaces :arg5 In a shell environment (e.g. bash), that would be equivalent to: command arg1 arg2 "arg3 with spaces" "arg4 with spaces" arg5 The format specification is as follows: Raw messages will only contain prin...
I though this would be a good challenge : http://adventofcode.com/2016/day/1 Task description Given a sequence of rotations and distances following the pattern (L|R)[1-9][0-9]*, give the manhattan distance between the start and the ending points, that is the minimal number of vertical and horizontal moves on a grid. Ex...
For more information, watch this video, and go to A276523 for a related sequence. The Mondrian Puzzle (for an integer n) is the following: Fit non-congruent rectangles into a n*n square grid. What is the smallest difference possible between the largest and the smallest rectangle? For 6, the optimal difference for M(6) ...
Write a regex that works in at least 2 regex flavors (or versions), and match a different string in each flavor (or version) it is running in. The strings to be matched in this challenge are the first words of the Ubuntu code names, which are listed below. Your regex has to match from the top of the list. That is, if y...