instruction_seed
stringlengths
292
48.7k
found_ngrams
listlengths
0
21
Winner CJam, 74 bytes by Optimizer Task Take an input of an integer n through the console or a file. Find the sum of the nth prime, square, triangular number, and cube. Add to that the factorial of the first decimal place of the square root of n and the xth Fibonacci number, where x is the first digit of the square of...
[]
Introduction You have the misfortune of being stuck in a runaway car on an obstacle course. All of the car's features are non-responsive, save for the steering system, which is damaged. It can drive straight, or it can turn right. Can the car be guided to safety? Mechanics Your car begins in the upper-left corner of...
[]
Your job is to find the location (read index) of a given element X in an array gone through the following transformation process: Take a fully sorted integer array of size N (N is known implicitly) Take any random number of mutually exclusive even index pairs (as in that no index appears in more than 1 pair) from the ...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
The task is to draw a regular polygon of n sides using only a compass and an unmarked ruler. Input (n) is one of the following 10 numbers: 3, 4, 5, 6, 8, 10, 12, 15, 16, 17. Method: Because you only have a ruler and compass you can only draw points, lines and circles. A line can only be drawn: through two existing poi...
[]
Note: although this is tagged as Python, other languages are permitted Challenge What you have to do is write the shortest functions to perform the same actions as the following Python 2 built in functions: Range >>> range(1, 10, 1) [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> range(1, 10, 2) [1, 3, 5, 7, 9] >>> range(10, 5, -1) [1...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
Inspired by https://puzzling.stackexchange.com/q/626 In your adventures you arrive at a series of 7 bridges you have to cross. Underneath each bridge lives a troll. In order to cross the bridge, you must first give the troll a number of cakes as a percentage of the number of cakes you are carrying. Because these are k...
[]
Bulgarian Solitaire is a single-player game made popular by Martin Gardner in his mathematical column in Scientific American. You have N identical cards, split into piles. You take a card from each pile and form a new pile with the removed cards. You repeat this process until you reach a state you've already seen and s...
[]
In one of the more iconic xkcd strips, Randall Munroe visualised the timelines of several films in narrative charts: (Click for larger version.) Source: xkcd No. 657. Given a specification of the timeline of a movie (or some other narrative), you are to generate such a chart. This is a popularity contest, so the answe...
[]
Emulate the Professor's typing Background Unfortunately, the Professor is not able to use his keyboard properly: whenever he is meant to use the Shift key, he presses Caps Lock once before typing, and doesn't bother to correct himself. If there are two or more keys in a row that require Shift, he presses Caps Lock befo...
[]
So a colleaque came with this problem lately and I want to challange you to solve the problem in the code-golf style, shortest solution in any language wins. The Problem: Given is a random set of values, where the values themselfs are not the concern, but the amount (which is random as well)of values. To keep the post...
[]
From Erich Friedman's Math Magic, (problem #2 on that page) your challenge is to find the edge elimination number of a connected graph. A single edge elimination is the removal of an edge from a graph, without disconnecting the graph, except for creating lone vertices. For instance, in the graph below, the two leftmos...
[]
The goal of this challenge is to write a program which takes a string (of any length) as input and displays anagrams (see these examples of anagrams) of this string, made by taking words in a dictionary (either individually or in pairs), but the anagrams don't need to be perfect. An anagram is the result of a rearrange...
[]
I've got a tough one for you! My girlfriend recently came across a new show on MTV (USA). It's a terrible show, and everyone on it is trashy, but the "game" is pretty interesting. From Wikipedia: Are You The One? follows 20 people who are living together in Hawaii to find their perfect match. If the 10 men and 10 wo...
[]
Consider a randomized list of the integers 1 to N. You want to sort it using only the following actions: Swap the first and last list elements. (S) Pop off the first element and append it to the end of the list. (P) This is always possible because any list can be sorted with enough swaps of adjacent elements. Using S...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
Sometimes when you press a key on a keyboard, the letter doesn't always display on screen. Whether this is because of a dodgy connection or otherwise, you have decided to write a script to control the probability of a letter displaying on screen when the corresponding key is pressed. One day, you decide to buy a monke...
[]
Introduction Pi is 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089... Let's treat each digit as an instruction as to how to get to the next digit. The first digit is 3. Counting three digits after the first digit, we arrive at 1. One digit after this 1 is a 5. Five digits after that ...
[]
Challenge: implement calculation of a Delacorte Number in any language. Shortest code wins. For a given square matrix of distinct integers 1..n² (possible side length n at least between 3 and 27), its Delacorte Number is the sum of the products gcd(a, b) × distance²(a, b) for each distinct pair of integers {a, b}. The...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ], [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220...
Your job is to write a program (or two separate programs) in any language that: Can take a completed Sudoku board as input (in any logical format) and compress it into a string of characters Can take the compressed string as input and decompress it to get the exact same completed Sudoku board (output in any logical fo...
[]
You are given integers N and M, 1 <= N,M <= 10^6 and indexes i and j. Your job is to find the integer at position [i][j]. The sequence looks like this (for N=M=5, i=1, j=3 the result is 23): 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9 Shortest code wins. Good luck!
[]
Sequences You are given four number sequences, numbered 1 through 4. OEIS The location of 0's when the natural numbers are listed in binary. Here's an example of how to calculate the sequence: 0,1,10,11,100,101,110,111 ^ ^ ^^ ^ ^ 0 3 78 10 14 The start of the sequence goes like this: 0, 3, 7, ...
[]
One of the games of the French TV show Des chiffres et des lettres, called Le compte est bon ('The total is right'), consists of the following : You get a number A between 101 and 999 as well as six numbers E1,..,E6 chosen randomly, with possible repetitions, from {1,2,3,4,5,6,7,8,9,10,25,50,75,100} The goal is to get ...
[]
Your job is to convert decimals back into the sum of the square roots of integers. The result has to have an accuracy of at least 6 significant decimal digits. Input: A number indicating the number of square roots and a decimal indicating the number to approximate. Example input: 2 3.414213562373095 Output: Integers s...
[]
Your goal is to implement Möbius inversion, a linear operation on a sequence of numbers that is used in combinatorics and number theory. Fewest bytes wins. What is Möbius inversion? Given a (finite) integer sequence f_1, f_2, ..., f_N, we can compute its divisor-partial-sum g, whose nth element g_n is the sum of all te...
[]
Format The format is a 64 bit value x representing a IEEE-754 double-precision binary floating-point number (a.k.a "a double"). x is assumed to represent a real number (not a NaN or Infinity). Goal The goal is to print/output the shortest string containing a decimal representation for which x is the closest IEEE 754 re...
[]
Background Consider a (closed) chain of rods, each of which has integer length. How many distinct hole-free polyominoes can you form with a given chain? Or in other words, how many different non-self-intersecting polygons with axis-aligned sides can you form with a given chain? Let's look at an example. Consider a part...
[]
What better problem for PCG.SE than to implement PCG, A Better Random Number Generator? This new paper claims to present a fast, hard-to-predict, small, statistically optimal random number generator. Its minimal C implementation is just about nine lines: // *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / pcg-rand...
[]
Challenge Your task in this question is to write a program or a named function which takes a positive integer n (greater than 0) as input via STDIN, ARGV or function arguments and outputs an array via STDOUT or function returned value. Sounds simple enough ? Now here are the rules The array will only contain integers ...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220 ] ]
Your goal is to display ASCII art of a formation in ten-pin bowling where only some of the pins remain. Fewest bytes wins. The tens pins are in a triangular formation: O O O O O O O O O O Pins are labelled from 1 to 10 as: 7 8 9 10 4 5 6 2 3 1 Drawing pins as O and missing pins as ., the formation 1 3 5 6...
[]
Input A list of nonnegative integers. Output The largest nonnegative integer h such that at least h of the numbers in the list are greater than or equal to h. Test Cases [0,0,0,0] -> 0 [12,312,33,12] -> 4 [1,2,3,4,5,6,7] -> 4 [22,33,1,2,4] -> 3 [1000,2,2,2] -> 2 [23,42,12,92,39,46,23,56,31,12,43,23,54,23,56,73,35,73,42...
[]
Task Print 0 if an n*m maze cannot be solved Print 1 if an n*m maze can be solved (in 1 or more ways) (so I'm not asking for paths but if it's possible to solve!!!) Example Input array(2d): [[0,0,0,0,0,0,1],[0,0,0,0,0,1,0],[0,0,0,0,1,0,0],[1,0,0,0,0,0,0]] XXXXXXXXX XS XX X X X X X X XX FX XXXXXXXXX ...
[]
In this challenge, your task is to construct an undirected graph from a sequence of directives. There is one directive for each nonnegative integer, and each transforms a given graph into a new one. Directive 0: Add a new disconnected node. Directive 1: Add a new node, and connect it to every existing node. Directive ...
[]
The game BattleBlock Theater occasionally contains a puzzle which is a generalised version of Lights Out. You've got three adjacent blocks, each of which indicates a level between 1 and 4 inclusive with bars, e.g.: | |||| || If you touch a block, then that block as well as any adjacent block will increment its level (...
[]
This is a loose continuation of my earlier challenge on constructing graphs. Background An eccentric artist has hired you to estimate the structural integrity of his sculptures. He creates his works of art by taking a bunch of cube-shaped magnets, and dropping them one by one into a huge pile. To better analyze his met...
[]
This challenge was inspired by a question on Mathematica.SE. Say you've got a nested list/array of some arbitrary structure (the lists at each level don't necessarily have the same length). For simplicity, we'll assume that the nodes are non-negative integers or empty arrays. As an example [[[1, 3], 2], [1, 4], 12, [[0...
[]
In the game of Freecell, you are tasked with building four foundation piles in suit from ace to king, on a layout where you build downward in alternating colours. However, you can only build one card at a time, so you are given four "free cells" each of which can contain one card to help you move entire sequences. The ...
[]
Background In this challenge, a partition of a set S means a collection of nonempty subsets of S, which are mutually disjoint and whose union is S. We say that a partition p is finer than another partition q (and q is coarser than p), if it can be obtained from q by splitting some of its sets into smaller pieces. The j...
[]
Consider an array of bits, say 1 1 1 0 0 0 0 1 0 0 1 0 1 1 1 1 1 0 1 0 We call a contiguous subarray of length ≥ 5 a phase if at least 85% of the bits are the same and the first/last bits are both equal to the majority bit. Furthermore, we call a phase maximal if it is not a strict subarray of some other phase. Here a...
[]
I want to try a new form of code golf here. Similar to bonuses, not all parts of the challenge have to be completed, but each answer has to implement a subset of certain size (and there is a core that every answer has to implement). So besides the golfing this challenge also involves choosing a set of features that go ...
[]
Input Your input in this challenge is a list of integer pairs. They represent the southwest corners of unit squares on the plane, and the list represents their union as a subset of the plane. For example, the list [(0,0),(1,0),(0,1),(1,1),(2,1),(1,2),(2,2)] represents the red-colored set in this picture: Output Yor o...
[]
All those questions that are duplicates... Ignored and marginalized by society. It is just not... right. We have to do something. There surely must be love for them too. They feel appreciated if a piece of code outputs a link to a duplicate question. But the duplicate questions are not so easily impressed. They are swe...
[]
Your program or function should output all the 36 4-perfect numbers in increasing order separated by newlines. An n positive integer is a k-perfect number (multiply perfect number) if the sum of its divisors including itself (i.e. the sigma function of n) equals k*n. For example 120 is a 3-perfect number because 1 + 2...
[ [ 488, 220, 17, 488, 220, 18, 488, 220, 19, 488, 220, 20, 488 ], [ 220, 18, 488, 220, 19, 488, 220, 20, 488, 220, 21, 488, 220 ], [ 16, 488, 220, 17, 488, 220, 18, 488, ...
Introduction I want to find the substring with the most 1's in a sequence of 0's and 1's. Input Your program has two inputs, the sequence and the substring length. The sequence is any number of 0's and 1's: 01001010101101111011101001010100010101101010101010101101101010010110110110 The substring length is any positive ...
[]
This code-golf challenge is based on the following puzzle: You have an odd number of tokens whose weights are known whole numbers, and they don't all have the same weight. Show that there's a token you can remove so that the remaining tokens can't be split into two equal-size sets that have the same total weight. Her...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
In this pixelated font of uppercase letters of the alphabet, all the characters are 5 units wide and 5 tall. ███ ████ ███ ████ █████ █████ ████ █ █ █████ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ ██ █████ ████ █ █ █ ████ ████ █ ██ █████ █ ...
[]
This is based on xkcd #153. Make a program or named function which takes 2 parameters, each of which is a string or a list or array of bytes or characters. The second parameter will only contain characters drawn from lrfu (or the equivalent ASCII bytes). It should be interpreted as a series of instructions to be perfor...
[]
Background This is a continuation of my earlier challenge, where the task was to compute the shape of a sculpture obtained by dropping magnets into a huge pile. Good news: the eccentric artist liked your work, and has another project for you. He still works with magnetic sculptures, but has decided to expand his art st...
[]
In statistics, sometimes it's useful to know whether two data samples come from the same underlying distribution. One way to do this is to use the two-sample Kolmogorov-Smirnov test. Your task will be to write a program that reads in two unsorted nonnegative integer arrays and calculates the main statistic used in the ...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
Here is a simple, bite-sized (byte-sized?) code golf: given a non-empty list of positive integers less than 10, print a block-diagonal matrix, where the list specifies the size of the blocks, in order. The blocks must consist of positive integers less than 10. So if you're given as input [5 1 1 2 3 1] Your output coul...
[]
The Hamming(7,4) code goes back to 1950. Back then Richard Hamming worked as a mathematician at Bell Labs. Every Friday Hamming set the calculating machines to perform a series of calculation, and collected the results on the following Monday. Using parity checks, these machines were able to detect errors during the co...
[]
Scenario: Imagine a situation where you wish to share a unique alphanumeric code. Perhaps it is a one-time-use coupon code you hand write on business cards, or some other scenario where it is desirable to have a code where mis-keying the entry is unlikely to produce valid result and the another valid code is not readil...
[ [ 425, 11, 356, 11, 422, 11, 468, 11, 434, 11, 479, 11, 472 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ], [ 11, 356, 11, 422, 11, 468, 11, 434, 11, ...
Story: Lucy asked George what his Lucky Number was. After some contemplation, George replied that he had several Lucky Numbers. After some brief confusion, Lucy asked George what his first n Lucky Numbers are. George then asked you, his buddy, to write him a program to do the work for him. The Challenge: You will write...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
Background A Davenport-Schinzel sequence has two positive integer parameters d and n. We will denote the set of all Davenport-Schinzel sequences for given parameters by DS(d,n). Consider all sequences of the natural numbers 1 to n, inclusive, which satisfy: No two consecutive numbers in the sequence are identical. The...
[]
One of the key parts of PNG's compression algorithm is the Paeth transformation, which transforms the image in a way that makes it compress better (usually). In this challenge, your task is to write a program to compute a Paeth transformation. The operation of a Paeth transformation is described below. The Paeth Transf...
[]
I have $15 in my pocket. Likewise, I am in a store which doesn't give change. While browsing, I spot an item that costs $10 (tax included). Can I buy that item without losing any money? In this case, the answer is yes. No matter how my $15 is divided up (one 10 and one 5, or three 5s, or something else), I will alw...
[]
... Ah sorry, no popcorn here, just POPCNT. Write the shortest program or function which takes in a number n and output all integers from 0 to 2n - 1, in ascending order of number of 1 bits in the binary representation of the numbers (popcount). No duplicates allowed. The order of numbers with the same popcount is impl...
[]
Introduction I want to build a ladder. For this, I have scavenged from the junkyard two long boards with holes in them, and I want to place the steps into these holes. However, the holes are not evenly placed, so the steps will be a little wonky, and I find it hard to estimate the amount of rod I need for them. Your jo...
[]
Here's a pixelated 5 by 7 font for the digits 0 through 9: .███. █...█ █...█ █...█ █...█ █...█ .███. ..█.. ███.. ..█.. ..█.. ..█.. ..█.. █████ .███. █...█ ....█ ...█. ..█.. .█... █████ .███. █...█ ....█ ..██. ....█ █...█ .███. █..█. █..█. █..█. █████ ...█. ...█. ...█. █████ █.... █.... .███. ....█ █...█ .███. .██...
[]
The Shotgun numbers are a sequence with a rather simple definition but some interesting structure. Start with the natural numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ... Now take all numbers at indices divisible by 2, group them into pairs, and swap the numbers in each pair: 1, 2, 3...
[ [ 11, 220, 16, 17, 11, 220, 16, 19, 11, 220, 16, 21, 11 ], [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, ...
You should write a program or function which outputs or returns the sum of the digits in base b representation of the first n natural power of a in ascending order. Example for a = 2, b = 3 and n = 4 The base10 numbers are 2^0, 2^1, 2^2 and 2^3. Their base3 representations are 1, 2, 11, 22. The digit sums are 1, 2, 2,...
[]
99 (pronounced "ninety-nine") is a brand new Esoteric programming language (not to be confused with 99, note the italics). Your task in this challenge is to write an interpreter for 99 that is as short as possible. The submission with the fewest bytes wins. Tiebreaker goes to the submission posted first. Since this que...
[]
Given a number N, output a NxN right angled triangle, where each row i is filled with numbers up to i. Example n = 0 (no output) n = 4 1 1 2 1 2 3 1 2 3 4 n = 10 1 1 2 1 2 3 . . . 1 2 3 4 5 6 7 8 9 10 (no alignment needed) n = N 1 1 2 1 2 3 . . . 1 2 3 4 .... N There is no trailing space at the end of each line. Lea...
[]
Write a function or complete program that takes a positive number n and performs n steps of an iterative algorithm for calculating π that has quadratic convergence (i.e. it approximately doubles the number of accurate digits at every iteration) then returns or prints out 2n correct digits (including the beginning 3). O...
[]
The challenge is really simple: given a number, you split its digits into an array of smaller numbers such that the resulting numbers are non-decreasing. The catch is that you have to split it such that the array length is maximal. Confused? You are given a positive integer via STDIN (or closest alternative), command-...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
Write a program or function that takes in a list of positive integers. Each of these integers represents the side length of a square on a 2D plane. Each square can be moved to any integer coordinates in the plane, but it can't rotate and it can't overlap other squares. Using a different printable ASCII character for ea...
[ [ 16, 11, 220, 16, 11, 220, 17, 11, 220, 18, 11, 220, 20 ] ]
Given a polynomial, determine whether it's prime. A polynomial is ax^n + bx^(n-1) + ... + dx^3 + ex^2 + fx + g, where each term is a constant number (the coefficient) multiplied by a nonnegative integer power of x. The highest power with a nonzero coefficient is called the degree. For this challenge, we only consider p...
[ [ 87, 61, 24, 12, 23, 87, 61, 23, 10, 22, 87, 61, 22 ] ]
My friend and I have this game that we play with words. It is a fun pastime and it involves "canceling out" letters in a word until there is nothing left. I am really tired of him being so much faster than me at it, so it is your job to implement it and let me finally beat him. Obviously, since I have to make the progr...
[]
The SUDSI sequence (sum, difference, swap, increment) is a curious integer sequence that appears to exhibit rather chaotic behavior. It can be generated as follows: Let S be an infinite list of the natural numbers: 1 2 3 4 5 6 .... Let Si denote the one-indexed ith element of S. So initially, S1 is 1, S2 is 2, etc. (t...
[]
This challenge is specific to languages of the APL family. Although it might be solvable in other languages, please do not expect this to be easy as it depends on some specific concepts of this language family. Many array oriented languages have the concept of a box (also called enclosure). A box encapsulates an array,...
[]
Background One source of ennui in tabletop role-playing games is dealing with rolls involving many dice. Casting a Disintegration spell may be instantaneous, but rolling and adding together 40 dice certainly isn't! A number of suggestions for handling this are discussed at rpg.stackexchange.com. Some of them, however, ...
[]
I've just bought a new jigsaw puzzle but, as a programmer, I'm too lazy to do it by myself. So I've devised a way to encode the pieces, and now I need a way to solve the puzzle itself. Challenge A puzzle piece will have from 2 to 4 connecting corners, defined by a letter; and a color, defined by a number. a B 1 c D...
[]
Write a program or function that takes a base n and a number x, and returns or outputs the n-ary Gray code of x. Rules n is an integer in the range 2 <= n <= 16. x is an integer in the range 0 <= n < 2**32. The inputted numbers can either be two integer arguments if you write a function, or two arguments to ARGV or a ...
[]
For this challenge, an ASCII art quilt will be a block of text 24 characters wide and 18 lines tall, containing the characters =-<>/\ in a quilt-like pattern that is horizontally and vertically symmetrical. Example quilt: ======================== ------------------------ //\\//\\\//\/\\///\\//\\ <<><<>>>>><<>><<<<<>><>...
[ [ 16, 11, 220, 16, 17, 11, 220, 16, 19, 11, 220, 16, 21 ] ]
Write a program, that determines whether the multiplication table of the given finite magma represents a group. A magma is a set with a binary operation that is closed, that means for all \$a,b\$ in \$G\$, \$a*b\$ is again in \$G\$ (Closedness) Let \$(G, * )\$ be a magma. \$(G, * )\$ is a group if for all \$a,b,c\$ ...
[]
My challenges tend to be a little bit hard and unattractive. So here something easy and fun. Alcuin's sequence Alcuin's sequence A(n) is defined by counting triangles. A(n) is the number of triangles with integer sides and perimeter n. This sequence is called after Alcuin of York. The first few elements of this seque...
[]
Did you know that the Euclidean algorithm is capable of generating traditional musical rhythms? We'll see how this works by describing a similar, but slightly different algorithm to that in the paper. Pick a positive integer n, the total number of beats, and a positive integer k, the number of beats which are sounded (...
[]
Edit: Bounty puzzle at the end of the question. Given a set of 1-digit numbers, you should determine how tall a tower they can construct. The digits live on a horizontal plane with a ground level where they can stand. No digit wants to be confused with a multi-digit number, so they always have an empty space on both ...
[]
A brick wall is a rectangle made of horizontal 1-by-n bricks stacked into rows. Here's a wall of height 4 and width 8, with brick sizes shown on the right. [______][______] 4 4 [__][____][__][] 2 3 2 1 [][______][____] 1 4 3 [____][______][] 3 4 1 This wall is unsteady because it has a fault, a place where...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
You should write a program or function which given a starting order of distinct one-digit positive integers and the length of the track as input outputs or returns the finish order of the numbers. The input [5,1,2,6,7] and 14 defines the following race: -------------- 76215 -> -------------- Rules of the race The tra...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
Identicons are small images of geometric patterns that represent the hash value of a string. Stack Exchange uses the identicons from Gravatar as each user's default avatar image. In this challenge, we will use the Gravatar identicons as well to generate some text to golf. Challenge This stack snippet (a minified versio...
[]
Almost the polar opposite if this challenge, and I suspect it will be slightly easier. Your task is to take two integers in the format a/b (Forming a rational number) then output the number in decimal exactly. For example, if you were to input 1/3, it would output: 0.33333333333333333 And would keep on printing 3s unt...
[]
Your task is to create many programs. The first outputs 1, the second outputs 2, etc. The higher you can go, the better! However, all of these programs must be made the same list of characters. You can choose which characters to put in the list. Each program can only use a character as many times as it appears in the l...
[]
Express a number Back in the 60s, the French invented the TV game show "Des Chiffres et des Lettres" (Digits & Letters). The goal of the Digits-part of the show was to come as close as you can to a certain 3-digit target number, using some semi-randomly selected numbers. The contestants could use the following operator...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 16, 11, 220, 16, 11, 220, 17, 11, 220, 18, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11,...
Edit: I will award a 100-reputation bounty for the first solver of the bonus puzzle at the end of the question! I will add the bounty to the question only when the answer appears as this bounty has no deadline. Given a non-decreasing list of one-digit positive integers, you should determine how deep dungeon the digit...
[ [ 220, 16, 11, 220, 16, 11, 220, 17, 11, 220, 18, 11, 220 ] ]
Someone built a really fancy clock using Fibonacci numbers, which looks really nice but is fairly unusable. Just the way we like it! Let's recreate this. The clock is made up of 5 sections corresponding to the first five Fibonacci numbers, starting from 1 (i.e. 1, 1, 2, 3, 5): ccbeeeee ccaeeeee dddeeeee dddeeeee dddeee...
[ [ 220, 16, 11, 220, 16, 11, 220, 17, 11, 220, 18, 11, 220 ], [ 16, 11, 220, 16, 11, 220, 17, 11, 220, 18, 11, 220, 20 ] ]
The Sierpinski triangle is a set of points on the plane which is constructed by starting with a single triangle and repeatedly splitting all triangles into four congruent triangles and removing the centre triangle. The right Sierpinski triangle has corners at (0,0), (0,1) and (1,0), and looks like this: Some equivale...
[]
Introduction Arithmetic Gaol is a special facility that incarcerates positive integers. However, recently, the positive integers have been trying to escape. Therefore the wardens have decided to, um, eliminate some of the positive integers to send a message to the other integers. They have hired a software engineer to ...
[]
This challenge is inspired by a puzzle I played, consisting of foam pieces like these: which have to be assembled into 3D cubes, like these: The puzzle pieces can be viewed as grids of 5 * 5 squares, whose middle 3 * 3 squares are always solid, while the 16 squares on the edges can be solid or empty. A piece will be ...
[]
Finding the Deadlock When programming a multithreading application one must take good care to avoid deadlocking the various threads when accessing shared resources. A deadlock occurs when a thread attempts to access a resource that's locked in another thread at the same time that the other thread is trying to access a ...
[]
The contest is over! Intro This is an interactive king-of-the-hill contest where the controller is fully contained in a Stack Snippet at the bottom of the question. The controller automatically reads the answers and plays through games. Anyone can run it at any time right in their browser. The mechanics of this contest...
[]
Consider the process of: Taking a non-negative integer N. e.g. 27. Spliting it into integers N - floor(N/2) and floor(N/2) (a 'bigger' and 'smaller' half) and writing them in that order. e.g.27 becomes 14 13. Removing the space to join the integers into a new, much larger integer. e.g. 14 13 becomes 1413. Repeating st...
[]
Introduction My niece wants to make a race car track. She has wooden parts that fit together to form the track. Each part is square shaped and contains a different shape. I'll use the pipe drawing characters to illustrate: │: the road that goes vertically ─: the road that goes horizontally ┌ ┐ └ ┘: the roads that turn...
[]
Your task in this challenge is to analyize a given "Matchstick Equation" like this one... ... and to find out whether it can be turned into a valid equation by rearranging the matches. If so, you are to output the least number of moves to do so and the resulting equation. Input The input is a String that can be read f...
[]
A Young diagram is an arrangement of boxes in left-justified rows and top-justified columns. For each box, all the spaces above it and to its left are occupied. XXXXX XXX XXX X The hook length of a box is the number of boxes to its right in its row, and below it in its column, also counting itself once. For example, t...
[]
Introduction The number 101 is a palindrome, since it reads the same backwards and forwards. The number 105 is not. However, 105 in base eight is written as 151, which is palindromic. On the other hand, 103 is not a palindrome in any base from 2 to 101. Hence, 103 is strictly non-palindromic. The precise definition is:...
[ [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220 ] ]
Please excuse the punny title. This is a question is inspired by A Curious Property of 82000. In it, the author points out that the number 82000 is binary in base 2, 3, 4, and 5. The post then poses the question "is there a number that is binary in bases 2, 3, 4, 5, and 6"? (For those curious, I've checked values ...
[ [ 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11, 323, 220 ], [ 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11, 323 ], [ 11, 220, 18, 11, 220, 19, 11, 220, 20, 1...
Introduction This challenge is about three (bad) sorting algorithms: Bogosort, and two others variants that I came up with (but have probably been thought of by others at some point in time): Bogoswap (AKA Bozosort) and Bogosmart. Bogosort works by completely shuffling the array randomly and checking if it becomes sor...
[]
Randall Munroe's book "xkcd, volume 0" uses a rather odd number system for the page numbers. The first few page numbers are 1, 2, 10, 11, 12, 20, 100, 101, 102, 110, 111, 112, 120, 200, 1000, 1001, ... This looks a bit like ternary, but notice that he skips from 20 straight to 100, from 120 to 200 and from 200 to 1000...
[]
Your task is to determine whether a graph is planar. A graph is planar if it can embedded in the plane, or in other words if it can be drawn without any crossing edges. Input: You will be given an undirected graph in your choice of the following formats: Edge list, e.g. [(0, 1), (0, 2), (0, 3)] Adjacency map, e.g. {0:...
[]
A linear Diophantine equation in two variables is an equation of the form ax + by = c, where a, b and c are constant integers and x and y are integer variables. For many naturally occurring Diophantine equations, x and y represent quantities that cannot be negative. Task Write a program or function that accepts the coe...
[]
Background The Random Domino Automaton is a toy model for earthquakes, inspired by cellular automata. In this challenge, your task is to simulate a simplified version of this model, and collect data out of it. The automaton is defined on an array A of k bits, representing a fault line on which earthquakes may occur. Th...
[]