instruction_seed
stringlengths
292
48.7k
found_ngrams
listlengths
0
21
Given a list, L, of sets of numbers like this: [[1], [0,2,3], [3,1], [1,2,3]] Output a single list of numbers such that 2 numbers A and B appear next to each other at least once if and only if B in L[A]. That is all such pairs must exist in the output, and only such pairs may exist in the output, where the order of an...
[]
Carcassonne is a tile-based game, where the objective is to construct Roads, Cities and Monasteries, in order to score points. The game works by players taking turns to draw and place tiles to construct a landscape, then claiming roads, cities and monasteries. An example landscape is: There are \$19\$ distinct tiles (...
[]
Background An interesting way to solve a Sudoku puzzle is to represent it as a Boolean satisfiability problem, and then feed it to a SAT solver. A Boolean Satisfiability Problem (abbreviated as SAT problem) is a problem in which you are given a set of Boolean expressions, and you need to find a set of values for the va...
[]
Challenge Given some JSON data, calculate the maximum depth reached. (Both arrays and dictionaries increase the depth) Input/Output The program is expected to read a JSON string from stdin and as soon as the program receives a \n start calculating the max depth, printing it to stdout and terminating the program when do...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
Inspired by this SO answer about peak detection. Background Persistent homology is a fancy term for a fancy math concept, but in this case all we care about is how it can be used for peak detection. In the case of a 1-dimensional array we can describe the algorithm as follows: We are given an array as input. We begin b...
[ [ 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...
Background You have been given the task of calculating the number of landmines in a field. You must calculate the landmine score given a list/string of numbers and the landmine number. The landmine number tells you where landmines are. For each digit: if the left digit plus the right digit is equal to the landmine num...
[]
There is a challenge for multiplying two numbers so I guess this counts too Given as input a positive real number n compute its natural logarithm. Your answer should be within \$10^{-6}\$ for \$1 \leq n \leq 10\$ and within \$10^{-3}\$ for \$0.1 \leq n \leq 100\$. You don't need to handle numbers outside this range. Se...
[]
Background You have again x3 been given the task of calculating the number of landmines in a field. But this time, we have no landmine number, and some landmines have exploded. You must calculate the landmine score given a string of numbers. This is the landscape. You have no landmine number to start with. Instead, the...
[]
Conway's Game of Life is a cellular automaton "played" on an infinite grid, filled with cells that are either alive or dead. Once given an initial state, the board evolves indefinitely according to the following rules: Any live cell with 2 or 3 living neighbours lives to the next state Any dead cell with exactly 3 liv...
[]
Diagonalize a vector into a matrix. Input A vector, list, array, etc. of integers \$\mathbf{v}\$ of length \$n\$. Output A \$n \times n\$ matrix, 2D array, etc. \$A\$ such that for each element \$a_i \in \mathbf{v}\$, $$ A = \left( \begin{array}{ccc} a_1 & 0 & \cdots & 0 \\ 0 & a_2 & \cdots & 0 \\ \vdots & \vdots & ...
[]
Your task is it to output a number as a unary string. You get the number of a non-negative integer input in the range of 0 - 2'000'000'000. Rules You can choose any character for the digit you like. But it has to be the same everywhere and for every input. Output a unary string by outputting this character N times. N...
[]
Write a function (or a whole program) that outputs (or prints) the following ASCII art: Output: 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 1 2 3 4 5 4 3 2 1 1 2 3 4 5 6 5 4 3 2 1 1 2 3 4...
[]
On the Mathematica Stack Exchange, 100xln2 asks: I need a list of integers […] The list contains integers and is characterized by [three] parameters, lets call them k and j [and listmax], which should be variable. If k=1 and j=1 then the list would look like this: {1,3,5,7,9,11,....until listmax} If k=2 and j=3 then t...
[ [ 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 unique-disjointness matrix ( UDISJ(n) ) is a matrix on all pairs of subsets of {1...,n} with entries $$ U_{(A,B)}=\begin{cases} 0, ~ if ~ |A\cap B|=1\\ 1, ~ otherwise \end{cases} $$ Or a bit less mathematical, it is the 2n times 2n matrix with a 0 in all entries where both indices have exactly one common 1 bit in t...
[]
A powerful number is a positive integer \$n\$ such that for every prime \$p\$ that divides \$n\$, \$p^2\$ also divides \$n\$. Or equivalently, \$n\$ is powerful if and only if it can be written in the form \$n = a^2b^3\$, where \$a\$ and \$b\$ are positive integers. For example, \$972 = 2^2 \times 3^5\$ is powerful, be...
[]
This challenge was originally posted on codidact. At my job we have to sometimes lay out materials. Materials come in large long rolls and are cut into smaller pieces when being laid out. When we order the rolls we draw up a layout document which describes how we are going to cut them and layout the pieces. This tells...
[]
Most people would cut circular pizzas into circular sectors to divide them up evenly, but it's also possible to divide them evenly by cutting them vertically like so, where each piece has the same area (assume the pizza has no crust): Challenge Your task is to make a program or function that takes a positive integer \...
[]
Given a sequence of integers with length \$L\$ and an integer \$1 \le N \le L\$, an "\$N\$-rich" permutation is one whose the longest strictly increasing contiguous subsequence has length exactly \$N\$. For example, let our sequence be [0, 1, 2, 3]. There is exactly one \$1\$-rich permutation, given by [3, 2, 1, 0]. By...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
How to play the duck game This is a 2-player game. First, we start with a line of blue rubber ducks (represented here as circles): Now, in each turn, the current player can turn either one blue duck or two adjacent blue ducks red. So, a valid move would be indexes 2 and 3 (0-indexed): Then, the other player cou...
[]
Given a positive integer n, output a number meter formatted like this: 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 1 1 1 1 2 The input number is 20 in this example. More formally, the decimal representations of the numbers are arranged vertically, from most significant digits on the last row ...
[]
Problem You are tasked with creating a program that performs emoji encryption on a given string of emojis. In this encryption scheme, each emoji is replaced by a unique character (from a to z). Your program should take an emoji string as input and output the corresponding encrypted string. The mapping of emojis to char...
[]
Your task is to find out how often you need to "shuffle" a given list with the following operation until you get back the original list. start with a list: (1 2 3 4 5 6 7 8 9) split it into the elements at odd and even indices (1 3 5 7 9) (2 4 6 8) concatenate these two list (1 3 5 7 9 2 4 6 8) Input: A list Output: ...
[]
Brief description of the game In the game Otteretto Classic (which you can test directly in your browser; try it!) the player has to form palindromic sequences using adjacent cells on a square grid. Each cell has one of five possible colours, which we will denote by the letters \$\mathrm A, \ldots, \mathrm E\$. The use...
[]
Background Fibonacci numbers are defined as follows: $$ F_0 = 0, F_1 = 1, F_n = F_{n-1} + F_{n-2} $$ The Zeckendorf representation is a representation of positive integers as a sum of one or more non-adjacent Fibonacci numbers, using indices 2 and higher. It is known that such a representation is unique for every posit...
[]
Background Given an elementary cellular automaton rule number like, for example, 28 = 00011100… We can swap \$\color{red}{\text{the 2nd bit with the 5th bit}}\$ and \$\color{orange}{\text{the 4th bit with the 7th bit}}\$ to get a rule that acts the same way but mirrored horizontally. This gets us 01000110 = 70. We ca...
[]
Alternatively, guess who's doing a course on operating systems Round Robin scheduling is a way to schedule ready processes in an operating system. Each process in the queue is run for a certain amount of time (quantum), interrupted after that time (if not yet finished), and then added back to the ready queue for anothe...
[ [ 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...
Description Given a list of positive integers, write the shortest code to find the number count of the longest consecutive sequence of numbers within the list. Input A list of positive integers. You can assume the list is not empty and may contain duplicates. Output The length of the longest consecutive sequence of num...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
American odds (aka moneyline odds) are numbers like \$+150\$ or \$-400\$ used to express how much a winning bet would pay out. Convert odds to a fair win probability like this: Positive odds \$+n\$ with \$n \geq 100\$ correspond to $$p=\frac{100}{100+n},$$ producing a probability with \$0 < p \leq 1/2\$. Negative odds...
[]
Write a program or function that outputs all positive integers with distinct decimal digits (OEIS: A010784) Examples: 1 2 3 4 5 6 7 8 9 10 12 13 ... 96 97 98 102 103 ... 123456789 123456798 ... 9876543120 9876543201 9876543210 Rules You can output the list of numbers in any convenient format (string with separators, ...
[]
Inspired by this (off topic) post Given an array of numbers, find the largest sum over a subarray not containing two adjacent elements [1,2,3,4] -> 6 // [_,2,_,4] [1,2,3,4,5] -> 9 // [1,_,3,_,5] [2,2,1,1,2,1,1,2] -> 7 // [2,_,1,_,2,_,_,2] [3,1,4,1,5,9,2] -> 16 // [3,_,4,_,_,9,_] [9,8,7,9,9,8] ...
[]
Background Numeric Mahjong is a hypothetical variation of Japanese Mahjong, played with nonnegative integers instead of Mahjong tiles. Given a list of nonnegative integers, it is a winning hand if it satisfies the following: its length is \$3n+2\$ for some nonnegative integer \$n\$, and it can be partitioned into \$n\...
[]
Your challenge is to print any 100 consecutive digits of π. You must give the index at which that subsequence appears. The 3 is not included. For example, you could print any of the following: 1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679 (index 0) 821480865132823...
[]
In this challenge, we define a range similarly to Python's range function: A list of positive integers with equal differences between them. For example, [1, 2, 3] is a range from 1 to 3 with a skip count of 1, because there is a difference of 1 between each item, and [4, 7, 10, 13] is a range from 4 to 13 with a skip c...
[]
In this challenge, we define the complement of a list of positive integers as all positive integers not included in that list. For example, the complement of the even numbers [2, 4, 6, 8...] is the odd numbers [1, 3, 5, 7...]. Your challenge is to, given a monotonically increasing, infinite list of positive integers, ...
[]
This challenge is to list out all possible words which are built from a pattern of syllables. Words are composed by joining syllables together. Syllables are composed of a number of vowels with some number of consonants optionally to the left and/or right. Your code should take in: a list of consonants a list of vowel...
[]
In this challenge you will take a non-empty (finite) list of (possibly infinite) lists of positive integers, and your task is to output the longest one. An infinite list is longer than a finite list of any length, and any two infinite lists are equally long. You're guaranteed that there won't be any ties for longest be...
[]
Given a number \$n\$, you are to compute the sequence of positive numbers where for each number \$a\$, the \$n\$-times multiple \$n\cdot a\$ is missing. Example We always start with the sequence of all positive numbers: $$1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, \dots$$ For \$n=2\$, going left-to-right, we first encounter ...
[]
Not sure if it's correct to ask such a question on this site, but let's try. Let a(n) be a sequence of positive integer such that a(1) = 1. To reproduce the sequence a(n) through itself, use the following rule: if binary 1xyz is a term then so are 110xyz and 1XYZ where the last one is the same as 1xyz with rewrite 1 ->...
[]
You work at a beach. In the afternoon, the sun gets quite hot and beachgoers want to be shaded. So you put out umbrellas. When you put out umbrellas you want to shade the entire beach, with as few umbrellas as possible. Umbrellas come in many sizes. However, larger umbrellas are susceptible to being pulled away by the ...
[]
Task Here is an interesting math problem: Let's say that there are \$n\$ indistinguishable unlabeled objects in a bin. For every "round", pull \$k\$ objects randomly out of the bin with equal probability, and apply a label on each object (Nothing happens to objects already having a label). Then put these \$k\$ objects...
[]
We already have a challenge for polynomial interpolation: given a list of points, output the coefficients of the polynomial that passes through them. Hermite interpolation is a generalization of polynomial interpolation. Instead of just specifying the points that the polynomial passes through, we also specify the highe...
[]
We will think of a partition as a sequence of non-increasing integers. For a given partition into \$n_1, n_2, \dots, n_k\$ with \$n_1 \geq n_2 \dots n_{k-1} \geq n_k = n\$ we write it out with \$n_i\$ dots on row \$i\$. So for \$6, 1, 1\$ we would write six dots on the first row, one on the second and one on the third...
[]
Task Your boss is on another crusade for 'efficiency.' He wants to encourage the use of numbers with fewer syllables, so that they're easier to discuss in meetings. If you want to take some time off work, you're boss would prefer you take 9 days instead of 7. You're boss would prefer a credit card expense of $99,502 ov...
[]
Imagine there are \$n\$ people \$\{a_1, a_2, \ldots, a_n\}\$ who enter a room in order and sit down in \$n\$ seats, arranged in a row. Each of these people belong to some gang, indicated by an integer \$\{1, 2, \ldots, k\}\$. These gangs hate the members of the other gangs, so they want to sit as far away from those pe...
[ [ 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 well-known Urinal Protocol states that each person that takes a urinal will take the one furthest from any other taken urinal. But this fails to account for short urinals; in many cases, a person would prioritize taking a taller urinal in addition to distance. In the real world, you might struggle to find a restroo...
[]
The Rudin-Shapiro sequence is a sequence of \$1\$s and \$-1\$s defined as follows: \$r_n = (-1)^{u_n}\$, where \$u_n\$ is the number of occurrences of (possibly overlapping) \$11\$ in the binary representation of \$n\$. For example, \$r_{461} = -1\$, because \$461\$ in binary is \$111001101\$, which contains \$3\$ occu...
[]
We need to produce a block cipher round function with a 1 bit round key size and a 7 bit message size with the highest level of cryptographic security according to our measure of security. Introduction We are going to need new symmetric encryption functions. We are at the point where we cannot improve the performance o...
[]
One lane is closed, the vehicles have to thread their way in according to the zip-lock system: One car from one lane, the next car from the other lane, always taking turns. Input: Two vehicle queues, represented e.g. as strings, in which short cars are represented by individual symbols, lorries by several identical sym...
[]
It is a well-known fact that you can colour a two-dimensional map with four colours in such a way that two countries with a common border always have different colours. There have already been enough challenges on this topic. However, the prerequisite for this is that there must be no enclaves, i.e. non-contiguous area...
[]
Objective Given two non-negative integers encoded in unbounded-length Gray code, add them and output the result, where the result is also encoded in Gray code. Gray code There are many equivalent formulations of Gray code, but here's an intuitive one. The Gray code encodes each non-negative integer as an infinite bit-s...
[]
Challenge This challenge is based on the domino effect: Initially, each domino is located on one straight line and is in a vertical state. It can be dropped either to the left along the same straight line, or to the right. Then this domino will knock down the next one, and that one, perhaps, the other. The dominoes are...
[]
Given a string of ASCII text as input, encode it in BPSK31 using Varicode. You may either output an audio file in any common format, or play the audio over the device speakers. You may output at any sample rate and with any carrier frequency between 500 Hz and 2500 Hz. The sample rate and carrier frequency must be cons...
[]
You know what a monotonic sequence is: each element is bigger than its predecessor (monotonically rising) or as its successor (monotonically falling). Bitonic means you have two arms of the sequence, one monotonically rising, the other falling. For example, 1,3,5,7,6,4,2 is bitonic (rising until 7, then falling until t...
[]
In this challenge, an infinitely proportional sequence is defined as a infinite sequence of positive integers such that: All positive integers are contained infinitely many times within the sequence. As more and more terms are added to the sequence, for all positive integers \$n\$, the ratio of the number of \$n\$s to...
[]
OEIS sequence A003242 comprises the numbers of Carlitz compositions for any given positive integer. This is the number of integer partitions of the integer for which no two adjacent parts are equal. For example, for 4: Generate the possible integer partitions (and their permutations): [1,1,1,1], [1,1,2], [1,2,1], [2,1...
[]
Given an n non-negative integers, how many numbers must be changed so that each number x appears x times? You cannot add or remove elements, only replace them with other numbers. For example: 1 6 23 6 9 23 1 1 6 can be turned into: 1 6 2 6 6 2 6 6 6 with 5 changes, which is optimal. Test cases 0 => 1 1 2 3 => 1 5 5 5...
[]
Every Brazilian citizen has a national identification number associated with them, named CPF. This number has 11 digits (formatted as XXX.XXX.XXX-XX) and it's validated by the following (real) algorithm1: Take the 9 most significant digits of the number. Call it c. Multiply the n-th least significant digit of c by n+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 ] ]
I define mousetail's sequence as follows: If the nth element of the sequence is q, then n+1 must appear q times in the sequence The sequence is weakly monotonically increasing (i.e. no lower number may follow a higher number) f(1)=1 I'll show an example of how this works: the first element is 1 after the 1, come 1 2...
[]
Historic Tetris Achievement Blue Scuti became the first ever human to beat the classic game of Tetris on NES. Here's the Tetris Kill Screen Challenge Output the following Tetris Kill Screen board (10x20 blocks) EEEEEEEEEE EEEEEEEEEE EEEEEEEEEE EEEEEEEEEE EEEEEEEEEE EEEEEEEEEE EEEEEEEEEE EEEEEEEEEE EEEEEEEEEE EEEEGGEEE...
[]
Earlier I asked about this problem on stackoverflow (link), but now I also want to see the golfiest solutions Problem: Given an array of arbitrary numbers, what is the longest subarray that is repeated (appears more than once)? In case there are multiple distinct repeated subarrays that all have the longest length, the...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
Consider a function \$r\$ where $$ r(i,k)= \begin{cases} L_{i+1}-L_i, & \text{if}\ k =0\ \text{ (1st reduction)} \\ r(i,0)-r(\lfloor \log_2{k} \rfloor,k-2^{\lfloor \log_2{k} \rfloor}) & \text{if}\ k \geq 1\ \text{ (2nd reduction)} \end{cases} $$ where \$k<2^i\$ and \$L\$ is a finite sequence of integers. For example,...
[ [ 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 ] ]
Definitions The common methods to generate consecutive composites are $$\overbrace{(n+1)! + 2, \ (n+1)! + 3, \ \ldots, \ (n+1)! + (n+1)}^{\text{n composites}}$$ $$\overbrace{n!+2,n!+3,...,n!+n}^{\text{n-1 composites}}$$ $$\overbrace{n\#+2,n\#+3,…n\#+n}^{\text{n-1 composites (Primorials)}}$$ A less common method involv...
[]
Exposition In this challenge, I am talking about ARM assembly language. ARM is a 32-bit RISC processor; I'll use instruction set up to architecture v6. To load a constant ("immediate") value into a register, use the MOV instruction: MOV r8, #42 To load negative values, use the MVN instruction, with a bit-complement of...
[]
Even though the concept of phat-fingered-lights-out number should be pretty self-explanatory here is a definition: Given a nonnegative integer in binary representation a phat-fingered double-bit-flip or phatflip for short replaces a pair of adjacent, equal bits with their complement. For example given the number 0b1110...
[]
Input: You are given two numbers n and m. Create the snail: Given an n >= 3, fill an n * n grid with the numbers from 1 to n * n, starting at the top left, going clockwise to the middle like this (for n = 5): 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 Calculate the sum of the neightbour...
[]
Background As noted in this question, for all positive integers \$n>2\$ there exists at least one Egyptian fraction representation (EFR) of \$n\$ distinct positive integers \$a_{1} < a_{2} < \dots < a_{n}\$ such that $$ \sum_{k=1}^{n} \frac{1}{a_{k}} = 1. \tag{1} \label{1} $$ When \$n=3\$, for instance, we have $$ \fra...
[]
A list \$[a_1,a_2,a_3 \cdots a_n]\$ can be uniquely represented as an unordered list of its prefixes - \$ [[a_1],[a_1, a_2], [a_1,a_2,a_3] \cdots [a_1,a_2,a_3 \cdots a_n]] \$. This can be in any order - for example, \$[1, 2, 3]\$ could be represented by any of \$[[1],[1,2],[1,2,3]]\$, \$[[3,2,1],[2,1],[1]]\$, or \$[[2,...
[]
Challenge Given ASCII-encoded text input of any size, detect numbers between -1,000,000,000,000,000,000 and 1,000,000,000,000,000,000 exclusive and rewrite them with thousands separators. Use commas only and ignore leading zeroes. Leave the rest of the input unchanged. Test cases Input Output Description 123 123...
[]
Given a collection of coloured laces, what would be the probability, \$P\$, that Alice won't create any loops if, until impossible, they tie two uniformly chosen, free lace ends of differing colours together? For the avoidance of doubt: Each lace will be of only one colour and will have precisely two ends. Alice does ...
[]
I recently found this game and have been enjoying it. Basically, there is a grid of colored tiles and you act by clicking on empty spaces. When you click an empty space, the first tile (if any) in each of the four axis-aligned directions is selected. If any color appears more than once, all tiles of that color are dest...
[]
Here in Russia, we have a little-known card game with the name, when translated directly, means Rooster. The cards used are two full 54-card decks of playing cards from 2 through aces, with jokers. The game for each player divides into two stages. In the first stage, each player has 14 cards dealt, and with those cards...
[]
The Levenshtein distance between two strings is the minimum number of single character insertions, deletions and substitutions needed to transform one string into the other. Let us call insertions, deletions and substitutions "edit operations". We will say that any sequence of \$k\$ edit operations that transforms on...
[]
This challenge is about creating these neat "green spray paint" patterns: (more pictures below) Loosely explained, they are generated by starting with a black image and a point in the center. That point is successively moved by a randomly chosen offset or delta in x and y. Every pixel the point visits has 1 added t...
[]
Background This challenge is about A004001, a.k.a. Hofstadter-Conway $10000 sequence: $$ a_1 = a_2 = 1, \quad a_n = a_{a_{n-1}} + a_{n-a_{n-1}} $$ which starts with 1, 1, 2, 2, 3, 4, 4, 4, 5, 6, 7, 7, 8, 8, 8, 8, 9, 10, 11, 12, 12, 13, 14, 14, 15, 15, 15, 16, 16, 16, 16, 16, ... John Conway proved the following proper...
[]
Two Deterministic Finite Automata or DFAs can be checked to see if they accept same set of strings in polynomial time. See section 3.3 of this for a long list of methods and this SO question/answer for a much shorter list. Input Your input will be two DFAs. In order to be able to test your code, I have provided DFAs i...
[ [ 11, 220, 16, 17, 11, 220, 16, 19, 11, 220, 16, 21, 11 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ], [ 220, 16, 17, 11, 220, 16, 19, 11, 220, 16, ...
Background Penney's game is a two-player game about coin tossing. Player A announces a sequence of heads and tails of length \$n\$, then player B selects a different sequence of same length. The winner is the one whose sequence appears first as a substring (consecutive subsequence) in repeated coin toss. Conway's algor...
[ [ 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...
Frustration is a solitaire card game which is played by calling out the sequence: “Ace”, “Two”, “Three”, ... , "Nine", "Ten", “Jack”, “Queen”, “King”, “Ace”, “Two”, etc. With each call, you simultaneously flip over a card from a shuffled deck of 52 cards. You win the game if you get through the entire deck without ever...
[]
You are employed as Administrator in charge of Road Maintenance and Planning. The intelligence division of the Agency for Road Maintenance and Planning has come up with a brilliant and not at all inefficient way to take random sample pictures of the roads: missiles with cameras on them. In this genius and not at all w...
[]
Convert NFA to DFA as quickly as possible. Input Your input will be an NFA. In order to be able to test your code, it needs to be able to handle an NFA in the following format. This is taken directly from GAP (and slightly simplified). Automaton( Type, Size, Alphabet, TransitionTable, Initial, Accepting ) For the inp...
[ [ 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 ] ]
(This is A065825.) The sequence defaults apply, so you can pick another format other than this one. Given an input integer n, find the smallest number k so that there exists an n-item subset of {1,...,k} where no three items form an arithmetic progression. Procedure Here, we calculate A065825(9). We assume you have alr...
[]
You are given a list of at least two positive integers as input. The challenge is to find such a position of a cut that minimizes the absolute difference between the sums of the two parts (to the left and to the right of it). The position should be given as the index of the first element after the cut. This is tagged c...
[]
Given a list of 2 or more strictly positive integers, sum the first and last half of the list, with the middle element being counted only in the right half if the list has an odd number of elements Some examples of the middle element being counted in the right half: [1, 2, 3, 4] -> Left: [1, 2]; Right: [3, 4] ...
[ [ 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 Rubik's Snake (or Rubik's Twist) is a toy consisting of several triangular prisms strung together in a line in such a way that the pieces can be rotated about one another in 90 degree turns. Any snake can be described by an ordered sequence of rotations (format described below). Some sequences do not describe phy...
[]
Introduction A picross, also known as a nonogram, is a logic puzzle in which the player is given an initially blank grid and must shade in particular boxes on the grid to reveal an image. Numbers are written on the top and the left side, and they explain the image's coloration: each number corresponds to an unbroken li...
[]
Background Consider the shape \$T(n)\$ consisting of a triangular array of \$\frac{n(n+1)}{2}\$ unit regular hexagons: John Conway proved that \$n = 12k + 0,2,9,11\$ if and only if \$T(n)\$ can be tiled (i.e. exactly covered without overlapping) with \$T(2)\$. At the same time, he also proved that no coloring argument...
[]
Partially inspired by this question. Overview The execution of Goggle kids Code starts with an empty binary tape with 100 items, with the pointer starting at the index 0: 00000... ^ At the end of the execution, you can assume that the tape is implicitly outputted. Instructions Goggle kids Code is a simple language inv...
[]
Task Given the situation with this global pandemic, you've been enlisted to help maintain social distancing. Your challenge, should you choose to accept it, is to write a program that takes in the positions of a group of people and checks whether the group is following social distancing rules. Your program must output ...
[]
Congratulations to Neil for hitting 100k rep! As a tribute, we are going to study 'Neil numbers'. Neil's user ID is 17602 and there's something special about the binary representation of this number: $$17602_{10}=1\color{blue}{000}1\color{blue}{00}11\color{blue}{0000}1\color{blue}{0}_2$$ $$\begin{array}{c|c} 1&\color{b...
[]
Background The game Grand Theft Auto: San Andreas went down in history also thanks to its wide selection of cheats. They're almost 90 and anyone who has ever touched this game, no doubt has tried them all! One cheat is activated (on PC) typing in-game a secret keyword, and then boom, a jet pops out of thin air or perha...
[ [ 425, 11, 356, 11, 422, 11, 468, 11, 434, 11, 479, 11, 472 ], [ 11, 422, 11, 468, 11, 434, 11, 479, 11, 472, 11, 358, 11 ], [ 11, 356, 11, 422, 11, 468, 11, 434, 11, ...
Background Define a run in a list as a maximal contiguous subsequence of identical values. For example, the list 0 0 0 1 1 0 3 3 3 2 2 has five runs of lengths 3, 2, 1, 3, 2 respectively. (Think of run-length encoding.) Then define a cut operation as removing one item from each run of a list. Applied to the list above...
[]
The ball game is a game in which a number of players sit together in a circle. Each player is first assigned a number \$ n \$, either 1, 2, or 3. The game begins with any starting player, and proceeds clockwise around the circle. The current player with the ball throws it to the next player. Who the next player is sole...
[]
Background My user ID is 78410, or \$1 0 0 1 1 0 0 1 0 0 1 0 0 1 0 1 0_2\$. One interesting property of this number is that, in binary, it doesn't have three consecutive identical digits, and yet it has a substring \$100100100\$ which is three copies of \$100\$. So, I define a Bubbler number as a positive integer who...
[]
The 2020-05-29 xkcd comic showed us the numbers that Randall Munroe feels would be most likely to result from multiplication, other than the correct answers. The table does seem to have some sort of twisted logic to it. For your convenience, the Wrong Times Table is reproduced here in selectable format: +-----+-----+--...
[]
Carcassonne is a tile-based game, where the objective is to construct Roads, Cities and Monasteries, in order to score points. The game works by players taking turns to draw and place tiles to construct a landscape, then claiming roads, cities and monasteries. An example landscape is: There are \$19\$ distinct tiles (...
[]
June 2020 is a month in which June 1st corresponds to Monday, June 2nd corresponds to Tuesday, ... June 7th corresponds to Sunday. For reference, here's the cal of June 2020. June 2020 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ...
[]
Task Given a matrix of numbers \$M\$ with \$r\$ rows and \$c\$ columns, and the magnification factor \$n\$, build the matrix with \$rn\$ rows and \$cn\$ columns where the original elements are spaced \$n\$ units apart and the gaps are filled by piecewise linear interpolation: $$ \begin{bmatrix} a_{11} & a_{12} ...
[ [ 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...
Related Challenge: Single Digit Representations of Natural Numbers Task Write a program/function that when given a non-negative integer \$n \le 100000\$ outputs an expression which uses all the digits from \$0\$ to \$9\$ exactly once and evaluates to \$n\$ The expression outputted by your program may only use the opera...
[ [ 488, 220, 17, 488, 220, 18, 488, 220, 19, 488, 220, 20, 488 ], [ 18, 488, 220, 19, 488, 220, 20, 488, 220, 21, 488, 220, 22 ], [ 488, 220, 20, 488, 220, 21, 488, 220, ...
This challenge is a relatively simple concept that I'm surprised has not been done yet. You will be given only an integer as an input. Your task is to find the date that is this number of days from January 1st, 1984. This challenge is uniquely for the Gregorian calendar (which is standard almost everywhere). One restri...
[]
Task Write a program/function that when given a positive integer \$n\$ splits the numbers from \$1\$ to \$n\$ into two sets, so that no integers \$a, b, c\$, satisfying \$a^2 + b^2 = c^2\$ are all in the same set. For example, if \$3\$ and \$4\$ are in the first set, then \$5\$ must be in the second set since \$3^2+4^2...
[]
We've had Meta Regex Golf and Display OEIS Sequences. Now, it is time for Meta OEIS Golf. Challenge Given a sequence of integers, your program/function should output a program/function in the same language that then outputs the same sequence. A simple example in Python would be def f(sequence): # generate a dictionar...
[]