instruction_seed
stringlengths
292
48.7k
found_ngrams
listlengths
0
21
Description All cubic equations can be solved, and every cubic has at least one solution. The goal of this challenge is to find the real solutions to a given cubic using inputs, and (obviously) the smallest program size. Rules The solution must find the real solutions of a cubic correctly, using any method. The cubic m...
[ [ 61, 18, 488, 44241, 61, 17, 488, 20716, 488, 294, 284, 220, 15 ], [ 706, 61, 18, 488, 44241, 61, 17, 488, 20716, 488, 294, 284, 220 ] ]
inspired by Longest Increasing Substring Task Given a list of non-negative integers, output the length of its longest alternating subsequence. An alternating sequence is a sequence of numbers which alternates between strictly increasing and strictly decreasing. [], [999], [9, 1], and [0, 5, 0, 3, 2, 4] are examples of ...
[]
Given an array of \$n\$ positive integers we will say its self-sum order is the number of ways to add elements from it to make \$n\$. We will count ways as distinct up to associativity. So \$1+(2+3)\$ and \$(1+2)+3\$ are not counted as separate ways to make 6, but \$2+4\$ and \$4+2\$ are counted as separate. Two sums...
[]
Determine whether a given sequence could be a winning sequence for the game shut the box. Background There are a few variants to this game, so I'll clarify the rules here. Play begins with 12 tiles (1 through 12) face up. Each turn the player rolls two six sided dice, and must then flip over one or more tile(s) which 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 ] ]
Ruby has a strange operator, .., called flip-flop (not to be confused with the range operator, which looks the same). Used in a loop, flip-flop takes two conditions as operands and will return false until the first operand is truthy, then return true until the second operand is truthy, whereupon it returns true one mor...
[]
From the infinite triangular array of positive integers, suppose we select every 2nd numbers on every 2nd row as shown below: $$ \underline{1} \\ \;2\; \quad \;3\; \\ \;\underline{4}\; \quad \;5\; \quad \;\underline{6}\; \\ \;7\; \quad \;8\; \quad \;9\; \quad 10 \\ \underline{11} \quad 12 \quad \underline{13} \quad 14 ...
[]
The look-say sequence is a sequence of lists of numbers where each element is the previous element with run length encoding. Run length encoding is the process of grouping together like elements and then giving the element and the size of the group for each group. So for example: 1 1 1 2 2 1 To run length encode thi...
[]
A Young diagram is a rectangular binary mask whose every row and every column are sorted in descending order. It is easy to check that every rectangular binary mask can be formed by xor-ing together a finite number of Young diagrams. This decomposition is by no means unique, but there will be a minimum number of Young ...
[]
There exists a bijection between the natural and rational numbers that works (approximately) like this: You create a 1-indexed 2-dimensional grid. In every field of this grid with position (x, y), put the number x / y. You start at (1,1) and iterate over the field in the following way: However, this task is not abou...
[]
Background HQ0-9+-INCOMPUTABLE?! is a half-joke programming language introduced in Internet Problem Solving Contest 2011, Problem H. HQ9+ is an esoteric programming language specialized for certain tasks. For example, printing “Hello, world!” or writing a quine (a program that prints itself) couldn’t be any simpler. U...
[]
Given a non negative integer number tell if it can be erased by repeatedly removing all occurrences of the length of that number from it including overlapping matches. Erasing means cancel all its digits. For example the number 4440 is not lengthy because after removing all 4's you obtain 0 which cannot be erased. Nei...
[]
Inspiration There is a problem on the most recent AMC 12B test, the one held on November 16, 2022, which goes like this: (AMC 12B 2022, Question 17) How many \$4\times4\$ arrays whose entries are \$0\$s and \$1\$s are there such that the row sums (the sum of the entries in each row) are \$1\$, \$2\$, \$3\$, and \$4\$,...
[]
I like to play (The Settlers of) Catan on Board Game Arena with totally random number tokens. These tokens determine the production rate of the terrain tiles beneath: There are 18 number tokens, two each of 3, 4, 5, 6, 8, 9, 10, 11 and one each of 2 and 12. A valid arrangement of these tokens on the board (19 hexes in...
[]
Description Inspired by this question, write a program/function to encode a number and a program (possibly the same as the first) to decode a bitstream in variable-length encoding as follows (taken from that question's answer, slightly modified): Represent the string x using the following encoding: $$0, x_k, \dots, 0,...
[]
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Fen is a magician Elf. He can cast spells on an array of numbers to produce another number or array of numbers. One of his inventions is the Wick spell. He loves to use this spell because "once this spell is applied, a combination of p...
[ [ 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 ] ]
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Fen is a magician Elf. He can cast spells on an array of numbers to produce another number or array of numbers. One of his inventions is the Wick spell. He likes this magic so much that he's cast it on every single array in sight. Now ...
[ [ 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 ] ]
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. The Elves like playing number games. One day, Bin (a friend of Fen) suggests a new game: given a positive integer n, each Elf says a number which has exactly n runs of ones in binary. The first Elf must say the smallest number, and the...
[]
Introduction In the binary representation of a \$k-\$bit \$(k>1)\$ square number \$n^2, \$ not all bits can be \$1\$. The maximum number of \$1\$-bits (Hamming weight, \$B\$ for short) is given in A357658, but only up to \$k=95\$ bits. An example of a \$99\$-bit square is \$B(796095014224053^2)=87\$. The records in A35...
[]
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. It's Hanukkah! Unfortunately, it appears some of the candles in your menorah have been blown out. You've got a lighter on hand, but it doesn't work quite right. Whenever you use your lighter at position k, the candles at positions k-1,...
[]
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details. Santa and the Elves are secretly preparing for a new tourist train service, called "North Pole Railroads". The train will travel through various sightseeing spots near the North Pole. As a part of this project, they want to know how ma...
[]
Title is an homage to this classic challenge In Pip, the Scalar data type encompasses strings and numbers. A Scalar value is truthy in most cases. It is falsey only if: It is the empty string ""; or It is some representation of the number zero. A Scalar is considered to be a representation of zero if: It consists of...
[]
Given a list of lists of positive integers, output a subset of them so their union forms a continuous non-empty range with no numbers missing. For example, consider this input: [ [1, 2, 3, 5], [2, 4, 6], [7, 9, 11] ] The union of the first 2 forms a continuous sequence: [1, 2, 3, 4, 5, 6] with no numbers miss...
[ [ 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 the title of the Toggle some bits and get a square challenge. In that challenge you output how many bits should be toggled, in order for the base-10 representation of the binary to become a square number. Challenge: In this challenge, you'll be given a bit-matrix \$M\$ and an integer \$n\$ as inputs. Output...
[]
In this challenge you will be tasked with implementing a sequence of natural numbers such that: Each number appears a natural number of times No two numbers appear the same number of times No two numbers appear in the sequence next to each other more than once. For some examples, the sequence 1,2,3,1,4,5,1,6,7,1,8,9,...
[]
Your function must accept 2 strings which are correct numbers. It needs to sum them up (without rounding and floating point errors) and return the result (which is also a correct number) without any leading zeros in the integer part, trailing zeros in the decimal part and without minus if the answer is 0 i.e. -0 is not...
[]
Suppose we have a sequence \$P\$. Every element \$P_n\$ represents the distance between the \$n^{th}\$ prime number and the average of the next two prime numbers. For example, \$P_1\$ would be the distance between the first prime number (2) and the average of the next two prime numbers (3 and 5), so \$P_1 = \frac{3+5}{...
[]
It can be proven that there's exactly one string of infinite length that remain same after base64 encoding Vm0wd2QyUXlVWGxWV0d4V1YwZ... Given a position, output the character on that position. Your program would be run on AMD Ryzen 5 5500U@4GHz given 4GB memory and 1 minute (may decrease if RAM turns out to be hard lim...
[]
Given a base as input, output all pan-digital numbers. A number is pan-digital if it includes every digit in that base at least once, possibly multiple times. Every number is considered to contain an infinite number of leading 0s. sequence rules apply. Given a base, you may either: Given an index, output the n-th pan-...
[ [ 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...
You are given a matrix of size m x n where each cell can contain either 1 or 0. You need to find the largest square submatrix that contains only 1's. The output should be the area of the largest square submatrix. For example, given the following matrix: 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 0 1 0 The largest square submat...
[]
Your task is to create a program or function, that when given an input list of nonnegative integers of length \$l \ge 2\$ and a nonnegative integer \$c\$ where \$2 \le c \le l\$, group the list into \$c\$ "clusters." What this means is, the average (population) variance* of all the groups should be as low as possible. ...
[]
Challenge Given a non-negative integer, find the sum of its digits. Rules Your program must take a non-negative integer as input. Your program should output the sum of the digits of the input integer. Your program should be able to handle inputs up to 10^100. Examples If the input is 123, the output should be 6 (1...
[]
Description Given an unsorted array of integers, find the smallest positive integer that does not appear in the array. Your task is to write the shortest code possible to solve this problem. Input A non-empty or empty array of integers, where the integers may be negative, zero, or positive. Output The smallest positive...
[ [ 11, 220, 16, 11, 220, 17, 11, 220, 18, 11, 220, 20, 11 ] ]
Typically, when we want to represent a magnitude and direction in 2D space, we use a 2-axis vector. These axes are typically called X and Y: This isn't always convenient, however. The game BattleTech is played on a hexagonal grid, and it's convenient for the axes to line up with the sides of the hexagons. To represent...
[ [ 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 ] ]
Given a permutation, we can define its high-water marks as the indices in which its cumulative maximum increases, or, equivalently, indices with values bigger than all previous values. For example, the permutation \$ 4, 2, 3, 7, 8, 5, 6, 1 \$, with a cumulative maximum of \$ 4, 4, 4, 7, 8, 8, 8, 8 \$ has \$1, 4, 5\$ as...
[]
It's easier to put this into coding terminology, so here we go: First find the average, median, mode, and range. Then, put those values in another array, then find the new average, median, mode, and range. Bonus -10 bytes (yeah, negative bytes, because there's already answers) for programs that can handle this many ti...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
Take the sequence of all natural numbers in binary, (1, 10, 11, ..) then write them vertically beside each-other like this (least significant bit on top; 0s have been replaced with spaces): 1 1 1 1 1 1 1 1 1 11 11 11 11 1111 1111 11111111 11 Notice there are areas of connected 1s in the...
[]
Nerdle is a Wordle variant, in which instead of words, the answers are equations. Each equation entered in the game must be a valid one. Examples: 13³-1=2196, (1/1)²*8=8, (((3)))²=9 The task is to generate and output to a .txt file, one equation per line, all possible 10 character equations that could be an answer for ...
[ [ 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...
Voronoi diagram is a partition of a plane (or part of plane) into regions close to each of a given set of objects ("seeds"). Here we’ll be dealing with discrete arrays or even rather with ASCII-art: 2 2 4 4 4 4 1 1 1 1 1 1 1 3 3 3 3 2 2 4 4 4 1 1 1 1 1 1 1 3 3 3 3 3 2 2 4 4 4 1 1 1 1 1 1 3 3 3 3 3 3 2 2 2 4 1 1 1 1 1 1...
[]
This question is an extension of Who's that Polygon? to arbitrary numbers of sides. A fundamental polygon for a surface is an polygon with a prescribed pairing for all its \$2n\$ sides, each marked with an arrow, such that identifying the sides according to this pairing and the arrow directions produces the surface (up...
[ [ 220, 16, 11, 220, 16, 11, 220, 17, 11, 220, 18, 11, 220 ] ]
This challenge arises from a claim made in a MathOverflow answer and a paper linked in that answer which seems to back up the claim: Searching for triangular embeddings is much quicker than enumerating over all embeddings… In fact, Jungerman was able to find a triangular embedding of \$K_{18}-K_3\$ in about half an ho...
[]
This is a sequel to Ragged list pattern matching. In this challenge, the wildcard may match a sequence of items of any length instead of just a single item. Given a pattern and a ragged list of integers, your task is to decide whether the pattern matches the ragged list. The pattern is also represented by a ragged list...
[]
Problem author: https://stats.ioinformatics.org/people/5815 You are given a system with a hidden permutation of the numbers \$1, 2, 3, \ldots, n\$. Your task is to guess this permutation by asking the system a series of questions. Each question consists of providing the system with a permutation of the numbers \$1, 2, ...
[]
(Inspired by this challenge.) Given six real values in three pairs: \$(x_1, x_2), (y_1, y_2),\$ and \$(x_0, y_0)\$, where \$x_1 < x_0 < x_2\$ and \$y_1 < y_0 < y_2\$, create a function which maps between \$(x_1, x_2)\$ and \$(y_1, y_2)\$ which also passes through \$(x_0,y_0)\$. In other words, make some function $$f: ...
[]
You are a contractor for a company who designs electrical circuits for the various products they make. One day, the company accidentally gets a huge shipment of one-ohm resistors and absolutely nothing else, and give you the task of putting them to good use in the newest products they're making. Your task is to build a...
[]
Write a program that takes a sorted integer array, shuffles all the elements in such a way that for every i there must exist a j such that, one of the following is satisfied: a[i] < a[j] < a[i+1] a[i] > a[j] > a[i+1] i and j are within the bounds of array. If there are not many distinct elements, you must show an err...
[ [ 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...
A weird number is a number that the sum of proper divisors is greater than the number itself and no subset of proper divisors sum to that number. Examples: 70 is a weird number because its proper divisors (1, 2, 5, 7, 10, 14, and 35) sum to 74, which is greater than 70, and no combination of these numbers sum to 70. 1...
[]
Write a function or program that takes in a list and produces a list of the local extremes. In a list [x_0, x_1, x_2...] a local extreme is an x_i such that x_(i-1) < x_i and x_(i+1) < x_i or x_(i-1) > x_i and x_(i+1) > x_i. Notice that the first and last elements of the list can never be local extremes. So for some ex...
[]
The challenge is to find the shortest implementation of the game of life in 3D (example). These are the rules: Cells (in this case, cubes) with only 1 or less neighbours die, as if by lonliness. If exactly 5 cells surround an empty cell, they breed and fill it. If a cell has 8 or more neighbours, it dies from overcrowd...
[]
Create a Sudoku solution CHECKER There are oodles of Sudoku SOLVERS here, but I want you to create a solution CHECKER as small as humanly possible (code-golf). A valid entry will be able to either take a 9x9 array as an argument (passed by reference, serialized on the command line, or however you want to take it) or...
[]
Create a deterministic program to play nd tic-tac-toe with the other contestants. Your program should work when n (width) and d (dimension number) are in these ranges: n∈[3,∞)∩ℕ ie a natural number greater than 2 d∈[2,∞)∩ℕ ie a natural number greater than 1 n = 3; d = 2 (32 ie 3 by 3): [][][] [][][] [][][] n = 3; ...
[]
Your challenge is to take input like this (a Hello World program): ++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++. And output a prompt (which will be "> "): > The user can then enter anything at the prompt. Your simple debugger must have these commands: S - ...
[ [ 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 ] ]
I once needed to write a function that calculates the block entropy of a given symbol series for a given block size and was surprised how short the result was. Thus I am challenging you to codegolf such a function. I am not telling you what I did for now (and in which language), but I will in a week or so, if nobody ca...
[]
Suppose we define an infinite matrix M, on N^2 -> {0, 1} (where N starts from 1 instead of 0) in this manner: M(1, 1) = 0. For every x > 1, M(x, 1) = 1 if x is prime, and 0 otherwise. For every y > 1, M(1, y) = the yth term in the Thue-Morse sequence. For every x, y > 1, M(x, y) = M(x, y-1) + M(x-1, y) mod 2. The top...
[]
Aristotle's number puzzle is the challenge of populating each of 19 cells in a hexagonal grid with a unique integer between 1 and 19 such that the total along every axis is 38. You can picture the game board looking like this: And the puzzle, in essence, is the solution to the following set of fifteen equations: ((a +...
[]
The Kolmogorov complexity of a string s is defined as the length of the shortest program P that outputs s. If the length of P is shorter than the length of s, then s is said to be compressible, otherwise s is incompressible. Most strings are incompressible ... Write the shortest program that outputs this string (withou...
[]
Your task is to generate a valid juggling pattern by completing a given template. But first, you probably need to know how such a pattern is denoted. Introduction to Siteswap Siteswap is the established notation for juggling patterns. It works by dividing the pattern into beats. At each beat your left and right hand a...
[]
I challenge you to generate the following sequence till 100 terms through any programming language in shortest characters possible. The sequence is like this :- 1 2 3 4 5 10 20 30 40 50 100 200 300 400 500 ........ The output needs to be like this (above) only, nothing extra. Remember, You can use + and - only and...
[]
This is a follow up to How slow is Python really? (Or how fast is your language?). It turns out it was a bit too easy to get a x100 speedup for my last question. For those who have enjoyed the challenge but want something harder where they can really use their low level skills, here is part II. The challenge is to get...
[]
In Chinese Checkers, a piece can move by hopping over any other piece, or by making a sequence of such hops. Your task is to find the longest possible sequence of hops. Input A sequence of 121 zeroes or ones, each representing a place on a board. A zero means the place is empty; a one means the place is occupied. Posit...
[]
Task You must write a program or function in the language of your choice which accurately counts the number of terminal cycles of a simple directed graph. This particular kind of directed graph is represented as an array of n integers, each with an independently-chosen random value between 1 and n (or 0 and n-1, if you...
[ [ 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...
Task: Your task is to create a program that, when given a number of strands and number of iterations of a braid, will tell where each strand goes. Rules are as follows: The number of strands will always be odd, and between 3 and 6000 (inclusive) When you start, the strands will be divided into 2 (almost) equal bunches...
[]
The Task Write a function L() that takes two Tuple arguments of coordinates in the form (x, y), and returns their respective linear function in the form (a, c), where a is the co-efficent of the x term and c is the y-intercept. You can assume that the input will not be a line perpendicular the the x axis, and that the ...
[]
Turns out there are some distant aliens who know English (and have coincidentally standardized on 8-bit computer architectures). Yet they have never heard of ASCII, nor even alphabetical order. It is believed that these aliens are picking up information from Earth. Yet they are doing so with digital equipment that re...
[]
Your job is to simulate a mathematically perfect game of 2048. The idea is to find the theoretical upper limit of how far a 2048 game can go, and find how to get there. To get an idea of what this looks like, play with this 2x2 clone and try to score 68 points. If you do, you will end up with a 2, 4, 8, and 16 tile. It...
[]
Your task is to play the roles of both characters in this scene from Inception. In it, Cobb gives Ariadne a challenge: You have two minutes to design a maze that takes one minute to solve. Some liberties will be taken on that description. Most importantly, this challenge is not time-based, rather scores are based on ...
[]
In the highly underrated Steampunk novel The Difference Engine, the equivalent of cinema houses delivered a pixelated moving image displayed by tiles which could be flipped mechanically. The control engine for orchestrating the movement of the these tiles was a large noisy machine controlled by a deck of punched cards....
[]
From now on considering the word "fuck" to be non-profane would be a good idea Make the smallest compiler or an interpreter for the Brainfuck variant, Boolfuck. It has to be executable in Windows, DOS, or a Unix operating system (so Linux, Mac, OpenBSD etc). Boolfuck is very similar to Brainfuck, and a complete definit...
[]
Your task is to read an image containing a handwritten digit, recognize and print out the digit. Input: A 28*28 grayscale image, given as a sequence of 784 plain-text numbers from 0 to 255, separated by space. 0 means white and 255 means black. Output: The recognized digit. Scoring: I will test your program with 1000 o...
[]
Alice and Bob like to play a card game, with a deck of cards numbered with consecutive nonnegative integers. Alice has a very particular way of shuffling the deck, though. First, she takes the top card from the deck and puts it at the bottom of the deck. Then she removes the next card, and starts a pile with it. Then, ...
[ [ 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...
Introduction From Esolangs.org : Pi is based on the brainfuck language and uses the same instructions as it. Pi works by calculating pi digits and introducing errors in some random digits of them, encoding obfuscated brainfuck instructions. Instructions are encoded as below: '>' '<' '+' '-' '.' ',' '[' ']' 0 ...
[]
Write a program which takes an integer argument and outputs the number of degree n monic polynomials with coefficients that are -1,1 or 0 which have a root which is a root of unity. To make it a little cleaner, only count polynomials with leading coefficient of 1. You can use any language you like as long as it is fr...
[]
A nonogram is a two-dimensional logic puzzle that looks something like this (screenshots from the game Pixelo, my favourite nonogram game): The goal of the game is to figure out what image those numbers are encoding. The rules are simple: A number on a column or row means that somewhere in that column or row, that man...
[]
Introduction The Fibonacci Linear Feedback Shift Register (LFSR) is a digital circuit which generates a stream of random-looking bits. It consists of several 1-bit flip-flops in a row, with certain positions designated as 'tapped'. In each iteration, the values in the tapped positions are XORed together (i.e., summed...
[]
Me thinks there aren't enough easy questions on here that beginners can attempt! The challenge: Given a random input string of 1's and 0's such as: 10101110101010010100010001010110101001010 Write the shortest code that outputs the bit-wise inverse like so: 01010001010101101011101110101001010110101
[]
The challenge: Write a function, that delivers following output: "1 2 3 4 5 4 3 2 1". Kids stuff? Of course. But here's the point: You only can use: 1 for loop, 2 int variables. You must not use: IF terms, another function, ... Do not hardcode the output There are also some more restrictions to make this harder: No ...
[]
You dudes, the Most Excellent Adventure is a home brew roleplaying game system based on the Bill & Ted Films, plays gnarly air guitar riff. In this game system, when you draw from your dice pool (you have between 1 and 12 ten-sided dice, with faces labelled 0-9) you need to connect the results as a phone number on you...
[]
Dark black ink has splattered all over your white sheet of printer paper! The obvious solution is to fold the paper so black and white parts meet and both become grey as the ink diffuses. Then unfold and refold until your paper is all equally grey. Finding the best way to make these folds is your task in this coding ch...
[]
Given a number, starting with 1, create new numbers (children) by taking the last digit, n, and concatenating 1 through n+1. This seems to be a much better explanation of the sequence A071159. Integers whose decimal expansion start with 1, do not contain zeros and each successive digit to the right is at most one gr...
[]
The scenario I drive along a road with my car and it begins to rain. The raindrops are falling on my window randomly and now i ask myself, where is the biggest connected wet area? The task To make it easier, the window is split in a matrix of 10*10 squares. Your job is to find the biggest connected water-drop-area on t...
[]
The Challenge For a given set of n integers, write a program which will output its lexicographic index. The Rules The input must only be a set of unique non-negative integers separated by spaces. You should output the lexicographic index (range 0 to n!-1 inclusive) of the permutation. No permutation libraries or permu...
[]
This question originates in this reddit thread by reddit user taho_teg but it is expanded to a more general 'puzzle'. You have a centrifuge with 24 holes for the vials uniformly distributed in a circle around the central axis. If you now have a number of vials and you want to start the centrifuge, you need to make sure...
[]
Challenge Find the smallest cover of bases (e.g., moduli) whose sets of quadratic residue can be tested via table-lookup to definitively determine whether or not a given non-negative integer n is a perfect square. The bases must all be less than or equal to the square root of the maximum value of n. The answer with the...
[]
The Challenge The challenge is that I have a standard mechanical push button lock and you need to find out every possible code that could unlock it. With a standard mechanical push button lock you have all single digit numerals and sometimes a few letters. With this specific push button lock there are specific rules. R...
[ [ 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 ] ]
After @MartinBüttner achieved exactly 10,000 reputation, we now have three full rows of 10k users on the users page! Now, since we're all programmers here, we like to automate things instead of doing them manually. Your challenge is to write a program to automatically congratulate new 10k users. Specification Input The...
[]
An ant walks along the edges (not faces) of a wireframe cube. Each vertex it encounters presents it with a fork from which two new edges branch off. The ant chooses which way to turn -- left or right. These direction are relative to the ant, who is facing the vertex and is outside the cube. Your goal is to determine, f...
[]
Write the shortest code to reverse the bit order of a 32-bit integer. Rules: Input is assumed to be a valid integer or string equivalent if your language doesn't support numerical values (e.g. Windows Batch). Output must be a valid integer or string equivalent if your language doesn't support numerical values (e.g. Wi...
[]
Your challenge is to find the smoothest number over a given range. In other words, find the number whose greatest prime factor is the smallest. A smooth number is one whose largest prime factor is small. Numbers of this type are useful for the fast Fourier transform algorithm, cryptanalysis, and other applications. For...
[]
Prior to the discovery of fingerprints and DNA testing, the British police used an anthropometric system to identify repeat offenders. Certain parts of the bodies of criminals were measured and stored in records -- these parts of the body were assumed to not change in size after adulthood. This system was known as bert...
[]
Given an integer n (where n < 10001) as input, write a program that will output the first n Ulam numbers. An Ulam number is defined as follows: U1 = 1, U2 = 2. For n > 2, Un is the smallest integer which is greater than Un-1 that is the sum of two distinct earlier terms in exactly one way. For example, U3 is 3 (2+1...
[]
In Gödel, Escher, Bach, Douglas Hofstadter introduces an integer sequence which is commonly referred to as the figure-figure sequence: 2, 4, 5, 6, 8, 9, 10, 11, 13, 14, 15, 16, 17, 19, 20, 21, 22, 23, 24, 25, ... You may enjoy working out the definition of the sequence yourself as part of the challenge, but if you can...
[]
Introduction This is one of my favorite math puzzles. Given a digit (say 3) and the number of times to use that digit (say 5), generate 10 expressions which result to 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10 using just +, −, ×, ÷, ^ and √ (root) (brackets are allowed to group operations). For example: (3^3 + 3)/(3 + 3) = (33 -...
[ [ 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...
Output all numbers in certain range containing certain digits Task Take an input of digits through console, prompt, or a file (in the decimal number system). These digits should be separated by spaces. Take an input of the "maximum" through console, prompt, or a file If you use a file, the program must output "[Data t...
[]
Statement of problem Given a set of unique, consecutive primes (not necessarily including 2), generate the products of all combinations of first powers of these primes — e.g., no repeats — and also 1. For example, given the set { 2, 3, 5, 7 }, you produce { 1, 2, 3, 5, 6, 7, 10, 14, 15, 21, 30, 35, 42, 70, 105, 210 } b...
[]
Pi is an irrational number, which means that its decimal representation never terminates or repeats itself. Pi truncated to 41 decimal digits (40 places) is 3.1415926535897932384626433832795028841971. If we ignore the decimal point and list the digits as a sequence of positive integers, avoiding duplicates, we get 3 1 ...
[]
Suppose your alarm wakes you up one morning, but you hit snooze so you can sleep for 8 more minutes. When it rings again you grudgingly get up and take a shower, which you estimate takes 15 to 17 minutes. You then brush your teeth for exactly 2 minutes, and get dressed, which takes about 3 to 5 minutes. Finally, you ea...
[]
Consider the digits of any integral base above one, listed in order. Subdivide them exactly in half repeatedly until every chunk of digits has odd length: Base Digits Subdivided Digit Chunks 2 01 0 1 3 012 012 4 0123 0 1 2 3 5 01234...
[]
Introduction When a room has bare, parallel walls, it can create unpleasant repeating acoustic reflections (echoes). A diffuser is a device mounted on a wall which creates a blocky surface of many different heights. This has the effect of breaking up the reflected sound into many smaller reflections (each with a diff...
[]
I've created a new language called "EasyFlow." Your task is to simplify writing BrainFlow programs by compiling EasyFlow to BrainFlow. That is, you take an EasyFlow program and output a BrainFlow program which does the same thing. EasyFlow is defined as follows: The program starts out with a list of variables. A varia...
[]
Consider these 15 ASCII playing card patterns (ace through Joker, and the back side), where X is a placeholder for the suit symbol: (they look better with less line spacing) ------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- ------------- -...
[]
This is intended to be an easy, bite-size code-golf. The mex (minimal excluded number) of a finite collection of numbers is the smallest non-negative integer 0, 1, 2, 3, 4, ... that does not appear in the collection. In other words, it's the minimum of the complement. The mex operation is central to the analysis of imp...
[]