instruction_seed stringlengths 292 48.7k | found_ngrams listlengths 0 21 |
|---|---|
Challenge
Write a function/program that outputs either the n'th element, or the first n elements, in the well known number sequence:
1, 2, 4, 8, 16 ...
Oh, wait... I forgot the first few numbers:
1, 1, 1, 1, 2, 4, 8, 16 ...
Heck, I'll add a few more for good measure:
1, 1, 1, 1, 2, 4, 8, 16, 33, 69, 146, 312... | [] |
Here is continuation of this question, this time lets compress/generate Mario in colors!
Image size is 64x64 (above one is zoomed). The required output is valid <img ...> tag with exact same image in dataURI form, working on chrome, firefox and safari (and IE4 - joke ;). In snippet below you can find example tag in r... | [] |
The previous neural net golfing challenges (this and that) inspired me to pose a new challenge:
The challenge
Find the smallest feedforward neural network such that, given any 4-dimensional input vector \$(a,b,c,d)\$ with integer entries in \$[-10,10]\$, the network outputs \$\textrm{sort}(a,b,c,d)\$ with a coordinate-... | [
[
408,
90,
1653,
11035,
1291,
4833,
59,
2359,
26056,
7265,
90,
1653,
15170
],
[
59,
408,
90,
1653,
11035,
1291,
17960,
2359,
26056,
7265,
90,
1653,
15170
]
] |
We haven't had any nice, easy challenges in a while, so here we go.
Given a list of integers each greater than \$0\$ and an index as input, output the percentage of the item at the given index of the total sum of the list.
Output should be whatever the natural representation for floats/integers is in your language (una... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
21, 21, 23, 20, 5, 25, 31, 24, ?
Inspired by this Puzzle, given an integer \$n>0\$ , print out the following sequence until you reach a non-Integer (spoilered, in case you want to solve the puzzle yourself first)
\$a_0 = n\$
\$a_{4k+1} = a_{4k} \cdot(4k+1) \$
\$a_{4k+2} = a_{4k+1} + (4k+2)\$
\$a_{4k+3} = a_{4k+2} - (... | [] |
Fermat's polygonal number theorem states that every positive integer can be expressed as the sum of at most \$n\$ \$n\$-gonal numbers. This means that every positive integer can be expressed as the sum of up to three triangle numbers, four square numbers, five pentagonal numbers etc. Your task is to take a positive int... | [] |
Convert a large int (e. g. 1234567890) into a string containing the usual decimal prefixes k, M, G, T, etc. for kilo, mega, giga, tera, etc. The result shall be groups of three digits, interspersed by the prefixes (e. g. 1G234M567k890), so that it is easy to glance the order of magnitude of the number without counting... | [] |
Inspired by this lumosity mini game, Pinball Recall
We start with a rectangular grid (viewed from above) with several bumpers as follows. Entrances/exits are numbered counter-clockwise starting from the leftmost of the bottom of the grid, as number 0.
24 23 22 21 20 19 18 17 16 15
25 . . . . . / . . . . 14... | [] |
The Hadamard transform works similarly to the Fourier transform: it takes a vector and maps it to its frequency components, which are the Walsh functions. Instead of sine waves in the Fourier transform, the Walsh functions are discrete "square waves" so to speak. This makes it easier to compute.
The size of a Hadamard ... | [] |
We all know the age-old debate - should strings be length-prefixed or should they be null-terminated? Well, you've run into a blob of binary data and apparently whoever made it decided that the best solution would be a compromise and length-terminated their strings.
For the purposes of this challenge, a length-terminat... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
The Objective
Build a random number generator whose range is \$\left[0,1\right) \cap \mathbb{Q} .\$
This is, build a random number generator that can produce any value that's:
at least \$0 \,;\$
not \$1\$ or greater; and
expressible as the ratio of two integers.
What's the fuss?
This RNG is weird. Its range is nowhe... | [] |
Inspired by this challenge from puzzling.SE.
Polyominoes are fun - you can fill all sorts of shapes with them. But as soon as you have limits on what polyominoes you can use, you sadly start running into shapes you can't fill.
Today we'll be looking at the L tromino - a shape made up of three conjoined squares, in such... | [] |
Back again, stealing another question from stackoverflow.
You are given a list of integers >= 0. Generate in order square 1-matrices where the side length is given by the list entry of the current index and fill the rest with 0s.
So given a list 2,4,1,3 print this to stdout:
1 1 0 0 0 0 0 0 0 0
1 1 0 0 0 0 0 0 0 0
0 0 ... | [] |
You are given a matrix of forward and back slashes, for instance:
//\\
\//\
//\/
A slash cuts along the diagonal of its cell corner-to-corner, splitting it in two pieces.
Pieces from adjacent (horizontally or vertically) cells are glued together.
Your task is to count the number of resulting pieces. For the same examp... | [] |
The (slightly harder, but still easy) sequel of Generate input for this hardware.
Background
I have a hardware that has a 32-bit input register. The register has the following characteristics:
The 32-bit register consists of eight 4-bit fields.
Each 4-bit field holds a value in signed-magnitude; it can hold an integer... | [
[
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 probably know what a Turing Machine is but do you know what is a Turning Machine (lathe)?
Ok you already know.. and what about a Golf Turning Machine ??
Ok I tell you..
A Golf Turning Machine is a full program or function taking a list/array (or any convenient method) representing the Profile (P) of a turned piece ... | [] |
Input
This task takes no input.
Output
Your code should compute and print (or return)
\$\pi^y\$ for all \$y = \frac11, \frac12, \frac13, \frac14, \frac15, \frac16, \frac17, \frac18, \frac19, \frac1{10}, \frac1{11}, \frac1{12}\$. The first 20 digits of the output (truncated and without any rounding) should be correct i... | [] |
In convolutional neural networks, one of the main types of layers usually implemented is called the Pooling Layer. Sometimes, the input image is big (and therefore time consuming especially if you have a big input set) or there is sparse data. In these cases, the objective of the Pooling Layers is to reduce the spatial... | [
[
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
A spanning tree (Wikipedia) of an undirected graph is a subgraph that is a tree which includes all of the vertices of the original graph. The following is an example of a spanning tree of a 4-by-4 grid graph.
Task
Given two positive integers w and h, output any valid spanning tree of the grid graph which ha... | [] |
Introduction
The Fibonacci sequence is a mathematical sequence in which each term is the sum of the \$2\$ terms before it; the first two terms are \$0\$ and \$1\$. The first few terms are \$0, 1, 1, 2, 3, 5, 8, 13\$. However, it is possible to make variations of this sequence, where each term is the sum of the, say \$3... | [
[
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
],
[
11,
220,
16,
11,
220,
17,
11,
220,
18,
11... |
Print the ASCII version of a random grid.
################################################################################
# # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # #
# # ############# # # ... | [] |
I have a piece of paper whose shape is a regular n-gon with side length 1. Then I fold it through some of its diagonals. What is the area of the shape formed by the (former) edges of the regular polygon?
Illustration
Suppose n = 8, i.e. an octagon-shaped paper. Let's name the vertices from A to H (left picture). Then I... | [] |
Description
Your input is a list of integers \$[a_1, \dots, a_n]\$.
A magic triplet is a triplet \$(a_i, a_j, a_k)\$ of values from this list, such that
the indices \$\{i, j, k\}\$ are all distinct,
the values are in ascending order (\$a_i \leq a_j \leq a_k\$), and
the sum of two of the values equals the third.
Your ... | [] |
Introduction
The Cartesian product of two lists is calculated by iterating over every element in the first and second list and outputting points. This is not a very good definition, so here are some examples: the Cartesian product of [1, 2] and [3, 4] is [(1, 3), (1, 4), (2, 3), (2, 4)]. The product of [1] and [2] is [... | [] |
Background
The Look and Say Sequence is built up by reading off the digits of previous entries in the sequence, counting the number of digits in groups of the same digit. For example:
1 => 11 # (one 1)
11 => 21 # (two 1s)
21 => 1211 # (one 2, then one 1)
1211 => 111221 # (one 1, then one 2, then two 1s)
This sequence ... | [] |
Disclaimer: This challenge inspired by me trying to find pairs in a large pile of socks.
Disclaimer: This is looking for a very different process and output to Help me sort my socks!. Please don't claim it as a duplicate until you've read both ;)
So, I have a huge pile of socks. Of course I keep them categorized by c... | [] |
Please note: this is a restricted-source challenge — see details below!
Each natural number \$n\$ has 10 faces: its decimal representations in bases \$1\$ through to \$10\$. For example, the 10 faces of \$12\$ are \$[111111111111, 1100, 110, 30, 22, 20, 15, 14, 13, 12]\$, and the 10 faces of \$4\$ are \$[1111, 100, 11,... | [
[
220,
15,
11,
220,
16,
11,
220,
16,
11,
220,
18,
11,
220
]
] |
I have a fixed length vector of 4 elements. The inputs of which are always 0 or 2^n for n = 1 to 15 (so n = 0 excluded i.e. 2^0 = 1 will not appear)
x = [32, 4, 4, 8]
the result should be
x = [32, 8, 8, 0]
The way it works is that values that are the same will get combined, but one it's combined it can not be combined... | [] |
Write a function or program which takes as input a set of distinct, non-negative integers \$\{x_1, \ldots, x_n\}\$ and outputs the smallest gap between any two values in the set, i.e. \$\min_{i\neq j}|x_i-x_j|\$.
Scoring
This is not code golf. Your score is the smallest gap of the set of code points of characters in yo... | [] |
Inspired by Help me pair my socks, and the fact that I have some pairs of socks where the left sock is distinct from the right.
Background
Again, I have a huge pile of socks. And a machine that can give the list of labels of the socks for me. This time, the labels follow these rules:
Some socks have left and right ve... | [] |
Introduction
An elementary cellular automaton is a cellular automaton that is 1-dimensional and has 2 states, 1 and 0. These cellular automata are categorized based on a simple code: the Wolfram code, invented by Stephen Wolfram (yes, the Wolfram | Alpha guy). It works like this:
First, you the set of all possible sta... | [] |
Introduction
Big 2 is a card game popular in East Asia and South East Asia, in which 4 players are dealt 13 cards each (ie, an equal division of a standard deck without jokers). The goal is to empty your hand before any of the other players. Players take turns playing combinations of a Big 2 subset of standard poker ha... | [] |
Golfeek is the working name of an esolang I'm occasionally working on. One distinctive feature of this language is that each statement is encoded as a sequence of bits rather than a sequence of bytes.
Instead of just showing a long binary sequence, the 'gutter' of the source editor contains a representation of each sta... | [] |
Flip flop is a memory / arithmetic game that I played in high school. Some number of players stand in a circle. The players take turns. On the nth turn, the current player checks:
What is the largest power of 7 dividing n?
How many instances of the digit 7 does the decimal representation of n contain?
What is the larg... | [] |
The \$d\$-dimensional vector space \$\mathbb{F}_2^d\$ over the field with two elements \$\mathbb{F}_2\$ is the set of vectors of \$d\$ bits. Addition of vectors is bitwise xor. A linear dependence is a set of vectors whose total (xor them all together) is \$0\$. Every set of \$d+1\$ vectors in \$\mathbb{F}_2^d\$ contai... | [] |
The Challenge
Given a finite list of integers, split it into the fewest partitions possible such that no partition contains a number more than once.
Rules
Input can be in any format and any order.
Output can be in any format, as long as it's clear that each group is separate.
This is code-golf, so lowest score wins!
Ex... | [] |
\$GF(9)\$ or \$GF(3^2)\$ is the smallest finite field whose order isn't a prime or a power of two. Finite fields of prime order aren't particurlarly interesting and there are already challenges for \$GF(2^8)\$ (link) and \$GF(2^{64})\$ (link).
Challenge
First define nine elements of the field. These must be distinct in... | [] |
(Inspired by the Keg utility of this challenge)
Given a non-empty input string, e.g. s c 1= e(a"E"), split the input into even-odd chunks.
Example (Feel free to suggest more)
I can only think of this test case, fee free to suggest more.
This input string, when mapped to its code points, yields the list [115, 32, 99, 32... | [] |
If \$f,g\colon \mathbb{Z}_{\geq 1} \to \mathbb{R}\$, the Dirichlet convolution of \$f\$ and \$g\$ is defined by
\$ \qquad\qquad\qquad \displaystyle (f*g)(n) = \sum_{d|n}f(d)g(n/d).\$
This question asked about computing Dirchlet convolution of functions.
The identity element of the Dirichlet convolution is the functi... | [
[
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
]
] |
As the trip through the solar system on your way to rescue Santa gets a little droll, so perhaps some optimizations to your Intcode Computer are in order. Namely, making it as small as possible because you've got nothing better to do with your time.
Check out Advent of Code if you haven't already, the guy that makes th... | [] |
Given a sequence \$S\$ with length \$n\$ of exactly one each of whole numbers from \$1\$ to \$n\$, your task is to return a number \$\sigma\$ indicating how shuffled it is.
Definition of shuffledness
Humans perceive shuffling randomness locally [Citation Needed], so the shuffledness of a sequence is based on the abilit... | [
[
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
]
] |
Significantly harder version of Spanning tree of a rectangular grid.
Background
A spanning tree (Wikipedia) of an undirected graph is a subgraph that is a tree which includes all of the vertices of the original graph. The following is an example of a spanning tree of a 4-by-4 grid graph.
Task
Given two positive intege... | [] |
Given a sequence of base-10 digits, output the longest list of integers that contains all the digits exactly once, in the order in which they appeared in the input, without repeating any integers.
Examples
Input: 12345
Output: [1, 2, 3, 4, 5]
Input: 12123
Output: [1, 2, 12, 3]
Input: 10010
Output: [100, 1, 0]
Input:... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
In this task you are expected to provide a list output given an input tq program. The tq programs will not contain whitespace inside them.
What is tq, in the first place?
tq is a lazy-evaluated language that is designed with the idea that array items should be accessable during the definition of them. In tq, there is n... | [] |
Challenge
Write a program or function that converts a 32 bit binary number to its quad-dotted decimal notation (often used for representing IPv4)
Quad-dotted decimal
A quad-dotted decimal is formed like so:
Split the binary representation into its 4 individual bytes
Convert each byte into denary
place "." between each... | [] |
Given two nonempty arrays of natural numbers \$a\$ and \$b\$, return the shortest nonempty array of pairs of natural numbers \$q\$ such that the sequence of first elements of \$q\$ consists of a whole number of repeated copies of \$a\$, and the sequence of second elements of \$q\$ consists of a whole number of repeated... | [
[
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
]
] |
If \$f(x) = x + \sum_{i>1} a_ix^i\$ and \$g(x)=x+\sum_{i>1}b_ix^i\$ then there is a composite power series \$f(g(x))\$ also of this form. Given a power series \$f\$ the goal is to find a compositional inverse \$f^{-1}\$ so that \$f(f^{-1}(x))=x\$.
One approach to this is recursive: start with a guess \$g_1(x)=x\$ for 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
]
] |
In musical notation, groups of notes shorter than one beat are joined together by a line at the bottom called a beam. Here are a few bars of music with the beams highlighted:
(Taken from Second Suite in F by Gustav Holst; you can hear how these notes sound at 0:13 in this video.)
You may notice that beam #6 is above t... | [] |
The challenge - given a numeric list L and an integer N as inputs, write a function that:
finds the bucket sizes for L such that it is split into N whole buckets of equal or near-equal size, and
returns for each element in L the minimum of that element's bucket.
Example -
L=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
N=... | [
[
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... |
The challenge is to implement a program or function (subsequently referred to as "program") that takes a nonnegative integer \$n\$ as input and returns \$n\over\sqrt{2}\$ (the input divided by the square root of two) as output, rounded to a nonnegative integer.
You may take your input and output in any reasonable forma... | [] |
This challenge is about the number of orderings which contain at most \$n\$ classes and at most \$k\$ of the \$k^{\text{th}}\$ class.
One way to represent such an ordering is as a sequence of positive integers with these three restrictions:
A number may only appear after all lower numbers have appeared
All numbers whi... | [] |
Challenge:
Your challenge is to write an interpreter for Whitespace. Given a string consisting of spaces, tabs, newlines, and potentially other characters, as well as possible inputs for the Whitespace program itself, output the result of the given Whitespace program.
Here is an overview of the Whitespace language and ... | [] |
Alice and Bob are perfect logicians trapped on an island with a puzzle generator. Although they can instantly solve the Riemann hypothesis and P=NP just by thinking about it, rather than doing anything useful, they amuse themselves by giving each other puzzles. The setup is as follows: a positive integer n is chosen by... | [] |
The sequence
Given an integer \$n>0\$, we define \$a(n)\$ as the lowest positive integer such that there exists exactly \$n\$ positive integers smaller than \$a(n)\$ whose sum of digits is equal to the sum of the digits of \$a(n)\$.
Edit: this sequence has since been published as A332046
First terms
n | a(n) | sum of... | [] |
Task
Given the x,y coordinates (coordinates are guaranteed to be integers) of the vertices of two simple polygons in clockwise or anti-clockwise order. Output a Truthy value if both the polygons are similar otherwise a Falsy value
A simple polygon is a polygon that does not intersect itself and has no holes. That is, i... | [] |
CodeDrawing one-liner
Teaser
Behold this formidable drawing:
Can you draw this in a single stroke? Give it a try.
Can you do this one, now:
Give it a try.
How it works
These "make this drawing with one pen stroke" problems are graph-theory problems with a rather simple solution. For each vertex, compute its degree. I... | [
[
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
]
] |
Context
In this challenge, a random walk is a stochastic process in which a particle at a position with integer coordinates (or a drunk man) moves at each integer time step (that is, at t = 1, 2, 3, ...) by taking a step of size 1 to any of its neighbouring positions, with the direction of the step being aligned with t... | [] |
Background
We define a circular step sequence of order \$n\$ as follows:
$$
a_1, a_2, \dots, a_n = \text{Permutation of } 1 \dots n \\
b_i = \min ( |a_{i+1} - a_i|, n-|a_{i+1} - a_i| ), 1 \le i < n \\
\text{Circular step sequence} \stackrel{\text{def}}{=} b_1, b_2, \dots, b_{n-1}
$$
Informally, it is the \$n-1\$ distan... | [
[
64,
62,
16,
11,
264,
62,
17,
11,
1124,
67816,
11,
264,
1089
]
] |
My robot for generating Mad Libs-style sequence challenges has gone rogue! To defeat it, I need you to write code that can solve all the challenges it can crank out.
Your input is three selections for the blanks A, B, C, each from (1,2,3), specifying the sequence challenge to solve, and the number \$n\$ that's the inpu... | [
[
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
],
[
11,
220,
16,
11,
220,
17,
11,
220,
18,
11... |
This is a simple game of getting rid of those damn numbers.
You start with the numbers from 1 to 19, written in a grid of 9 by 3:
1 2 3 4 5 6 7 8 9
1 1 1 2 1 3 1 4 1
5 1 6 1 7 1 8 1 9
You may notice that the number 10 is missing, this because the number zero would be hard to get rid of later on.
The two rules are:
I... | [] |
Task
Given a set of n unique elements and a multiset l of positive numbers that add up to n, find all the ways of partitioning those unique elements into disjoint sets with sizes given by the elements of l.
(A multiset is a set that allows repeated elements)
The point here is that we are taking everything in the output... | [] |
Given an positive integer n (including 0 if you decide to support it), output all numbers in the generated sequence up to the index n. For the current test cases of the current challenge numbers are one-indexed. Feel free to submit 0-indexed answers though.
Base sequence
We start from this sequence (NOT, but quite simi... | [] |
Inspiring myself on a recent challenge, we ought to compute a sequence that is very close to A160242.
Task
Your task is to generate the sequence \$ \{s_i\}_{i=0}^\infty \$:
1, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, ...
Which is more easily understandable in this format:
1 2 1
1 2... | [] |
This code-golf challenge will have you computing OEIS sequence A300154.
Consider a spiral on an infinite hexagonal grid. a(n) is the number of cells in the part of the spiral from 1st to n-th cell that are on the same [row*] or diagonal (in any of three directions) as the n-th cell along the spiral, including that cel... | [] |
Let's consider the sequence of the binary representation of positive integers (without any leading zero):
1 2 3 4 5 6 7 8 9 10 11 12 ...
1 10 11 100 101 110 111 1000 1001 1010 1011 1100 ...
If we join them together, we get:
1101110010111011110001001101010111100 ...
If we now look for the pattern... | [] |
In the shortest amount of code in any programming language, filter out the duplicate items in an array of which the order is irrelevant.
Here are some test cases:
[1, 2, 2, 3, 1, 2, 4] => [1, 2, 3, 4]
['a', 'a', 'b', 'a', 'c', 'a', 'd'] => ['a', 'b', 'c', 'd']
I also should note that there currently aren't any open q... | [] |
Sequel of Counting valid Binary Sudoku rows.
Background
Binary Sudoku, also known as Takuzu, Binario, and Tic-Tac-Logic, is a puzzle where the objective is to fill a rectangular grid with two symbols (0s and 1s for this challenge) under the following constraints:
Each row/column cannot have a substring of 000 or 111, ... | [] |
As input you will receive
An integer \$a\$
A list of integers that is infinite and strictly-monotonic1.
Your program should check in finite time if \$a\$ appears the list.
You should output one of two distinct values. One if \$a\$ appears in the list and the other if \$a\$ does not.
This is code-golf so answers wi... | [] |
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... | [] |
This a simple question.
The start day is a Saturday and let the input be a non-negative number x.
The output should be the number of weekdays (Mon-Fri) in the next x days inclusive.
For example, if x = 3 then the output should be 2. For x from 0 onwards the output should be:
0,0,1,2,3,4,5,5,5,6,7,8,9,10,10,10,11,...
—... | [] |
Challenge
Given a matrix of digits (0-9), find the smallest (in terms of area) rectangular matrix of digits where one or more copies of itself, possibly rotated, can tile the original matrix. Reflection is not allowed (think of a collection of tiles on a wall or floor).
Input can be taken in any reasonable ways to repr... | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.