instruction_seed
stringlengths
292
48.7k
found_ngrams
listlengths
0
21
Related: Landau's function (OEIS A000793) Background Landau's function \$g(n)\$ is defined as the largest order of permutation of \$n\$ elements, which is equal to \$\max(\operatorname{lcm}(a_1,a_2,\cdots,a_i))\$ where \$a_1,a_2,\cdots,a_i\$ is an integer partition of \$n\$. We can extend this to define "iterations" of...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
Background A little while ago, someone posted an interesting puzzle on Math.SE: What is the smallest digraph (directed graph) G where the following eight graphs are all distinct: G, the original graph Reflexive closure of G Symmetric closure of G Transitive closure of G Reflexive symmetric closure of G Symmetric tran...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
Background An L-shape is defined as a polyomino which can be made by extending two rectangular legs in orthogonal directions from a full square (called a pivot). The size of the square should be at least 1, and the lengths of the two legs should also be at least 1. These are some examples of L-shapes: Pivot size 1, two...
[]
Sandbox, Codidact A rewrite of this question with a simpler input format and guidelines. Challenge Deadfish uses a single accumulator, on which all commands are to be performed. It has the following commands: Command Description i increment the accumulator d decrement the accumulator s square the value of t...
[]
Given a rod of length n inches and a list of prices that contains prices of all pieces of size smaller than n. Determine the maximum value obtainable by cutting up the rod and selling the pieces. For example, if length of the rod is 8 and the values of different pieces are given as following, then the maximum obtainabl...
[]
An unrooted binary tree is an unrooted tree (a graph that has single connected component and contains no cycles) where each vertex has exactly one or three neighbors. It is used in bioinformatics to show evolutionary relationships between species. If such a tree has \$n\$ internal nodes, it necessarily has \$n+2\$ leav...
[]
Background Elias omega coding is a universal code which can encode positive integers of any size into a stream of bits. Given a positive integer \$N\$, the encoding algorithm is as follows: Start with a single zero in the output. If \$N=1\$, stop. Prepend the binary digits of \$N\$ to the current output. Let \$N\$ be ...
[]
Given an array \$A\$ of positive integers between \$1\$ and \$9\$ inclusive and a positive integer \$n\$, remove all integers in \$A\$ which appear more than \$n\$ times. For example: [1,2,3,2,3,2,4,1,2], n = 2 Occurrence: 1 1 1 2 2 3 1 2 4 Keep? 1 1 1 1 1 0 1 1 0 Kept values: [1,2,3,2,3, 4,1 ]...
[]
Given a non-empty sequence of non-negative integers, output any permutation of it in which no two adjacent elements have a sum that is divisible by 3. If it is impossible, either crash the program, return an empty sequence, or output nothing. The asymptotic time complexity must be linear in the size of the input sequen...
[]
All integers \$n > 0\$ can be expressed in the form $$n = \prod_{\text{prime } p} p^e = 2^{e_2} 3^{e_3} 5^{e_5} 7^{e_7} \cdots$$ This form is also known as it's prime factorisation or prime decomposition, and each integer has a unique prime factorisation. As the bases are fixed, it is possible to reconstruct an integer...
[]
Background For the purpose of this challenge, all numbers and their string representations are assumed to be in decimal (base 10). I tried to find proper terminology for this challenge, but I do not think there is any, so I made it up. A self-replicating number is a number that appears as a substring in any of its mult...
[]
The primorial \$p_n\#\$ is the product of the first \$n\$ primes. The sequence begins \$2, 6, 30, 210, 2310\$. A Fortunate number, \$F_n\$, is the smallest integer \$m > 1\$ such that \$p_n\# + m\$ is prime. For example \$F_7 = 19\$ as: $$p_7\# = 2\times3\times5\times7\times11\times13\times17 = 510510$$ Adding each num...
[]
Create all arrays of non-negative integers of length N where the array sum is equal to T. The output order of arrays does not matter. Possible solutions are e.g. N = 5, T = 2: 1 1 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 1 0 1 1 0 0 0 1 0 1 0 0 1 0 0 1 0 0 1 1 0 0 0 1 0 1 0 0 0 1 1 2 0 0 0 0 0 2 0 0 0 0 0 2 0 0 0 ...
[]
Related: Zeroes at the end of a factorial Today, we are going to calculate how many zeroes are there at the end of \$n!\$ (the factorial of \$n\$) in base \$m\$. Or in other words: For given integers \$n\$, and, \$m\$. Calculate the integer \$p\$ which is the highest power of \$m\$ dividing \$n!\$: \$p \in \mathbb{N}_0...
[]
This fastest-code challenge is based partly on this MSE question and exists to extend some OEIS sequences, and create others. If I extend or create sequences based on this challenge, I'll link to this challenge so that folks can see where the values come from. If you'd like direct credit, include your first and last na...
[]
In this code golf challenge, you'll be computing the placement of (open) circles of areas \$\pi, 2\pi, 3\pi, \dots\$ when greedily placed along integer points in a square spiral in such a way that no two overlap. A square spiral is a sequence in \$\mathbb Z^2\$ that starts at \$(0,0)\$ and successively wraps around the...
[]
Fibonacci coding is a universal code, which can encode positive integers of any size in an unambiguous stream of bits. To encode an integer \$ n \$: Find the largest Fibonacci number less than or equal to \$ n \$; subtract this number from \$ n \$, keeping track of the remainder If the number subtracted was the \$ i \...
[]
AND THE WINNER IS.... Command Master's "Ball Pulling"! Note: Competition is over, but more submissions are welcome! Ball game is a game I invented where two players start with 100 energy each. Every turn, each player independently chooses an amount of energy to spend. Whoever spends more energy brings the ball 1 uni...
[]
Introduction Note that I learned it from a Numberphile Video, where Neil Sloane explains it better. I recommend you to watch his Video. But for a quick Introduction: The Levine Sequence is made from the Levine's Triangle, which is made as follows: First you have \$0\$ ones, and \$1\$ twos. Then you read the list back...
[]
Ash has a bit of an interesting float division algorithm. It's designed to never return NaN, and things like signed zero and infinity need to be handled. How it works: Assume the inputs are positive for the rules below. One input being negative will always result in the output being negative, and both being negative wi...
[]
Background Flow Free is a series of puzzle games whose objective is to connect all the same-colored pairs of dots on the grid. Flow Free: Warps introduces the "warping" mechanic: a line connecting two dots can go through the border of the grid, which makes it re-enter through the opposite side of the grid (torus topolo...
[]
Inspired by this question on Stackoverflow. The task Let's have two lists/arrays of integers: L1 and L2 of equal length. You need to identify in L2 the position of first occurrence of each number and remove from L1 the values on the corresponding positions. Then print/output the modified L1. Any reasonable input/ouput...
[]
An \$n\times n\$ Latin Square is a grid containing exactly \$n\$ distinct values where the values in each row and column are distinct. For example, $$\begin{matrix} A & B & C \\ C & A & B \\ B & C & A \\ \end{matrix}$$ is a Latin square as no row or column contains a repeated value. You are to take a positive integer \...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
The age-old question - is it better to walk or run? There are two trains of thought. If you run, you cause the rain to effectively hit you from the front, which increases your surface area and basically causes you to run into the raindrops, getting hit with more water. However, if you walk, you spend longer in the rain...
[ [ 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 list of positive digits, return that list with consecutive elements grouped together. For example: [1, 2, 3, 5, 6, 5, 4, 4, 1] -> [[1, 2, 3], [5, 6, 5, 4], [4], [1]] Essentially, all adjacent elements whose absolute difference is 1 should be grouped together. The input array will only ever contain positive dig...
[ [ 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...
This challenge is inspired by the game No More Jockeys. The input is a list of tuples of natural numbers (potentially including 0), in some appropriate input format. Starting with player 0 and alternating with player 1, each player chooses some number which is contained within at least one remaining tuple, and all tupl...
[]
Given a list of non-negative integers, return whether or not that list is all the same number. Rules Input and output can be taken/given in any reasonable and convenient format Truthy/Falsey values can be represented as any value of your choice as long as it's reasonable and relatively consistent (e.g. 1 for falsey an...
[]
Gelatin is a worse version of Jelly. It is a tacit programming language that always takes a single integer argument and that has 7 (or maybe 16) commands. You are to take in a Gelatin program and its argument and output the result. Gelatin Gelatin programs will always match the following regex: ^[+_DSa\d~]*$ i.e. they...
[]
a.k.a. You Can Output Anything With Labyrinth Or Hexagony™ Challenge In a recent restricted-source challenge, I could print any character with only half of the allowed digits with very small character count, by abusing the "digit commands" and modulo-256 output function. Now, it's about time to make a general metagolfe...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
Bob has a startup that is developing a product that uses “advanced AI” and “black magic” to automatically code-golf computer programs. Unfortunately, Bob is running out of cash and desperately needs money from investors to keep his company running. Each investor that Bob has contacted wishes to schedule a meeting with ...
[]
Introduction In this TED-Ed video (which I'd recommend watching first), a puzzle is presented. 27 unit cubes must be painted with one of red, green, or purple on each face, so that they can be reassembled into a large 3x3x3 cube that shows only red on the outside, then a different arrangement that shows only green, and...
[]
Gelatin is a worse version of Jelly. It is a tacit programming language that always takes a single integer argument and that has 7 (or maybe 16) commands. Gelatin Gelatin programs will always match the following regex: ^[+_DSa\d~]*$ i.e. they will only contain +_DSa0123456789~ characters. The commands in Gelatin are: ...
[]
A challenge many developers face when drawing a graph from scratch to plot some data is generating its ticks. In below graph, there are 6 horizontal ticks (1750, 1800, 1830, 1860, 1880 and 1900) and 11 vertical ticks (0, 10, 20, 30, 40, 50, 60, 70, 80, 90 and 100). The horizontal bounds of the above graph goes from 17...
[]
Background The Collatz (or 3x+1) map (A006370) is defined as the following: $$ a(n) = \begin{cases} n/2, & \text{if $n$ is even} \\ 3n+1, & \text{if $n$ is odd} \end{cases} $$ Now, let's define the sequence \$s_0\$ as the infinite sequence of positive integers \$1, 2, 3, 4, \cdots\$, and define \$s_k\$ as the result...
[ [ 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...
Inspired by a discussion from the Esolangs.org unofficial Discord Server. Instructions A chess cycle is an arrangement of a chess board where each piece must attack one other piece, and only one other piece, and each piece is attacked exactly once. The effective idea to to "connect" pieces with each other, forming a si...
[]
Background Inspired by this video by Matt Parker A Faro shuffle is a perfect riffle shuffle where the deck is exactly interleaved with its other half. This is how to perform one: the deck of 52 cards is split into two piles of 26 cards each the two piles are interleaved. In the case of an "in" shuffle, the bottom card...
[ [ 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 ] ]
Introduction When playing Mario Kart the other day, an interesting question popped up when a Grand Prix with my 2 roommates, 9 AI drivers and myself seemed to be fairly close and therefore exciting until the very end. We asked ourselves: How close can the point difference between first and last place (#1 and #12) after...
[]
Lucky numbers (A000959) are numbers generated by applying the following sieve: Begin with the list of natural numbers: 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, ... Now, remove every second element (\$n = 2\$, the smallest element in the list aside from 1): 1, 3, ...
[ [ 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 blackbox function \$f : \mathbb N \to \mathbb N\$, a list of positive integers \$L\$, and a list of indices \$I\$, apply \$f(x)\$ to the elements of \$L\$ at the indices specified in \$I\$. For example, \$f(x) = x^2, L = [7, 6, 3, 9, 1, 5, 2, 8, 4]\$ and \$I = [3, 5, 8]\$ (using 1 indexing), we apply \$f(x)\...
[]
Related: Calculate \$f^n(x)\$, Polynomialception Challenge Given a polynomial \$f(x) = a_0 + a_1 x + a_2 x^2 + \cdots + a_k x^k\$ of order \$k\$, we can compute its composition with itself \$f\left(f(x)\right) = f \circ f(x) =: f^2(x)\$, which evaluates to another polynomial of order \$k^2\$. The challenge is to revers...
[]
Inspired by this: http://nolandc.com/smalljs/mouse_reveal/ (source). A valid answer: Takes a number \$w\$ and (assumed non-negative) integer \$x\$. Starts with an integer list with a length of \$2^w\$, initially filled with zeroes. For each number \$n\$ from \$0\$ to \$w-1\$ (inclusive), divides the list into sub-list...
[]
Given a non-empty list of integers between 1 and 9 inclusive, find the longest contiguous sublist such that the number of occurrences of each element (of the sublist) within the sublist is equal (not the number of consecutive occurrences, just the total count). You may return any non-empty subset of the solutions. Exam...
[]
In this king-of-the-hill challenge, you will be making a python 3 bot to play the card game judgement! Sandbox Rules Judgement is a hand based game similar to games like rummy. In each round, 7 cards are dealt to each player, a trump suit is chosen (trump suits are chosen sequentially from the list Spades/Hearts/Diamon...
[]
An addition-subtraction chain, is a sequence \$a_1, a_2, a_3, ... ,a_n\$, such that \$a_1=1\$ and for all \$i > 1\$, there exist \$j,k<i\$ such that \$a_i = a_j \pm a_k\$. Your task, is given a number \$x\$, find the shortest addition-subtraction chain, such that \$a_n = x\$. Rules You can assume the input is a valid ...
[]
Do you know the optical effect of a tridimensional hand painted whit horizontal lines? Examples This challenge consists of making something like that effect with ascii, and transforming one 2d input into a "3d" output. The algorithm To perform this transformation, you first replace all 1 with a ¯ and all 0 with a _. In...
[]
There is a boy named Peter. Peter is a picky eater and doesn't like to eat the same kind of cookie again on the same day. Peter gets a present, The present is a box of cookies! The box contains \$K\$ types of cookies. Also, it contains different amount of each type of cookie. Peter, being the picky eater he is, Wants t...
[]
Introduction Dr. Leslie Lamport, of the eponymous Lamport one-time signature scheme, is getting rather old. But he can't die until his most famous algorithm gets all the kinks ironed out! In particular, that scheme had one internal component he was never satisfied with: We hope that someone can find a more elegant met...
[ [ 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 Link-a-Pix is a puzzle on a rectangular grid, where the objective is to reveal the hidden pixel art by the following rules: Connect two cells with number N with a line spanning N cells, so that the two cells are at the two ends of the line. The number 1 is considered connected to itself (which makes it an e...
[]
Task Given a non-empty list of positive digits, group them into sublists of equal sum. You may output any subset of solutions with maximal number of sublists (equivalently, minimal sum). The input may contain repeat elements. There may not exist any solution but the singleton list containing the input itself. The outpu...
[]
Take this array: [1, 2, 6, 4, 4, 1, 0, 0, 2, 0, 4, 1, 4, 2, 4, 8, 1, 2, 4] There are quite a few places where [1, ..., 2, ..., 4] appears, where ... is any number of items. These include [1, 2, 6, 4], [1, 0, 0, 2, 0, 4], [1, 0, 0, 2, 0, 4, 1, 4], and [1, 2, 4]. The shortest of these is simply [1, 2, 4]. Task: Given t...
[]
Inspired by this Numberphile video. What is planing? In order to 'plane' a sequence of digits, you need to: Identify the lengths of the 'runs' (adjacently repeated digits) in the sequence. Non-repeated digits count as runs of one. Decrease the length of each run by one. Runs of length 1 become length 0. Reconstruct t...
[]
If you convert a chemical formula to lower case, it may become ambiguous: co can be both CO or Co. Given an input consisting of a-z0-9, where 0 can only stand behind 0-9. Check whether it's ambiguous, unambiguous, or impossible. Return 3 different values for them. Shortest code wins. Examples: co - ambiguous 2h83o6...
[]
Program the sequence \$R_k\$: all numbers that are sum of square roots of some(maybe one) natural numbers \$\left\{\sum_{i\in A}\sqrt i\middle|A\subset \mathbb{N}\right\}\$, in ascending order without duplication. Outputting zero is optional. You should do one of: Take an index k and output \$R_k\$, either 0 or 1 inde...
[]
Given an integer \$1 < n < 10 \$ generate a table like below. For \$n = 5\$, 1 2 3 4 5 2 2 3 4 5 3 3 3 4 5 4 4 4 4 5 5 5 5 5 5 For \$n = 8\$, 1 2 3 4 5 6 7 8 2 2 3 4 5 6 7 8 3 3 3 4 5 6 7 8 4 4 4 4 5 6 7 8 5 5 5 5 5 6 7 8 6 6 6 6 6 6 7 8 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 Shortest code wins! Trailing whitespace allowed ...
[]
But Is It Art? is an esolang created by ais523, where one step is break the program into orthogonally connected "tiles": A BBBB A B B AA CC A CC Each separate letter shows a different tile. Interestingly, programs in But Is It Art? only rely on the orientations of the tiles themselves, not their placement. This means...
[]
Multi-dimensional chess is an extension of normal chess that is played on an 8x8x8x8... "board". In normal 2D chess, a knight's move is a movement by a vector of \$ \begin{bmatrix} \pm 2 \\ \pm 1 \end{bmatrix} \$ or \$ \begin{bmatrix} \pm 1 \\ \pm 2 \end{bmatrix} \$, as long as it doesn't cause the knight to go outside...
[]
Mr. Binary Counterman, son of Mr. Boolean Masker & Mrs. Even Oddify, follows in his parents’ footsteps and has a peculiar way of keeping track of the digits. When given a list of booleans, he counts the 1s and 0s separately, numbering the 1s with the odds & the 0s with the evens. For example, when he looks at 1 1 0 0 1...
[]
Background Binomial transform is a transform on a finite or infinite integer sequence, which yields another integer sequence. The binomial transform of a sequence \$\{a_n\}\$ is given by $$s_n = \sum_{k=0}^{n}{(-1)^k \binom{n}{k} a_k}$$ It has an interesting property that applying the transform twice will yield the ori...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 16, 11, 220, 16, 11, 220, 17, 11, 220, 18, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11,...
Your challenge is to write a function/program that takes a matrix of integers m and a number n as input and: Splits m into n by n chunks Replaces each chunk with the most common value in that chunk (In case of a tie, any of the tied values is fine). Outputs the resulting matrix. Note: You can take either the size ...
[]
Inspired by Wzl Determine if a given square binary matrix has exactly one row or column consisting of entirely 1s, and the rest of the matrix is 0s. For example, these are all true: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 ...
[]
In November 2019, Alon Ran published a particularly lovely sequence in the OEIS, A329126: \$a(n)\$ is the lexicographically earliest string of digits which yields a multiple of \$n\$ when read in any numeric base. 1, 110, 101010, 111100, 100010001000100010, 1111110, 10000010000010000010000010000010000010, 11111111000,...
[]
Background Minkowski addition is a binary operation on two sets of points (usually geometric objects) in the Euclidean space. The Minkowski sum of two sets \$A\$ and \$B\$ is formally defined as follows: $$ A+B = \{\mathbf{a}+\mathbf{b}\,|\,\mathbf{a} \in A,\ \mathbf{b} \in B\} $$ To say in plain English, given the ori...
[]
Recursively prime-encoded integers Consider \$11681169775023850 = 2 \times 5 \times 5 \times 42239 \times 5530987843\$. This isn't a nice prime factorisation, as \$42239\$ and \$5530987843\$ make it difficult to store this factorisation in a small manner. Being primes, we can't then factorise them, but we can factorise...
[]
Input a non-empty array with \$n\$ positive integers. Test if the input array contains every integer in \$1\cdots n\$. In case you prefer 0-indexed numbers, you may choose to input an array of non-negative integers, and test if the input array contains every integer in \$0\cdots (n-1)\$ instead. All testcases and formu...
[]
Given an array \$A\$ of size \$n\$. You have to find the number of subsets such that their product is in the form of \$p_1 \times p_2 \times p_3 \dots\$ where \$p_1, p_2, p_3, \dots\$ are prime numbers. No prime number should appear more than once, i.e. the product is "squarefree". Example: Lets pick an array \$A\$ of ...
[]
As some of you may remember, Peter, who was a picky eater is now puzzled Peter. This time Peter got some puzzles as a present from his Aunt. He has tried a lot, but has failed to solve the puzzles. Peter needs your help to solve them. Each one of the puzzle has 2 pieces. To solve the puzzle, you must tell the number of...
[]
Totally not inspired by Lyxal repeatedly mentioning elevators in chat :P Challenge In short: simulate some people filling up an elevator and then leaving it. The elevator is simplified as a grid, where each person can occupy one cell of the grid. The height and width of the grid is the input parameter. The width is alw...
[]
I have to fill in 2fa codes all day. They're 6-digit strings. One day I noticed that not once did any of these codes contain 6 unique digits, like 198532 There was always at least one double, like 198539 (here it's 9). For any given uniformly random string of \$N\$ digits in the set \$\{0,1,2,3,4,5,6,7,8,9\}\$, what is...
[]
A complete Boolean function is a function such that, an amount of them can be used to express any Boolean function. For example, NAND \$\left[\begin{matrix}\text{input1}&0&0&1&1\\\text{input2}&0&1&0&1\\\text{output}&1&1&1&0\end{matrix}\right]\$ is complete. Inputs may be reused any number of times, and the functions ca...
[]
I'd like to roll up the ability scores for my Dungeons and Dragons character. But I'd also like them to be balanced (and slightly better than average). Typically, a character's stats are created by rolling four 6-sided dice, adding together the three highest results, and doing this 6 times. A 6 sided die has the number...
[]
This challenge was inspired by this tweet. Idea Consider a circle with n evenly spaced dots around the perimeter, where each dot has a postive integer value: Now connect the dots with non-intersecting chords: Next consider our score, which is the sum of the products of these pairs. When n is odd, the extra orphan do...
[ [ 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 ] ]
Challenge Given a graph (a structure consisting of nodes and vertices), classify it according to a few categories. Specifically, you will be given an unweighted directed graph, which is a set of nodes and edges from one node to another (but not necessarily both ways). You can take this in any reasonable and consistent ...
[]
The Torian, \$x!x\$, of a non-negative integer \$x\$ can be recursively defined as $$ x!0 = x \\ x!n = \prod^x_{i=1} i!(n-1) = 1!(n-1) \times 2!(n-1) \times \cdots \times x!(n-1) $$ The Torian is then equal to \$x!x\$ for a given \$x\$. This sequence begins \$0, 1, 2, 24, 331776, ...\$ for \$x = 0, 1, 2, 3, 4, ...\$ Al...
[]
Related: What's my telephone number? which asks to calculate the terms of A000085, the number of possible ordinal transforms of length n. Background Ordinal transform is a transformation on an integer sequence. For a sequence \$a=(a_0, a_1, a_2, \cdots)\$, the \$n\$-th term of the ordinal transform \$ord(a)_n\$ is defi...
[ [ 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 screen consisted of some LED segments like such: _ _ _ _ _ |_|_|..._|_|_| |_|_| _|_|_| However, some of the LEDs are broken, and it's possible that only these are left: _ _ _|_| |_|_| Now, you're required to output all integers possibly expressed on this screen. An integer, something matching RegEx /^0$|^-?...
[]
Given an array of integers. Find out its longest sub-array (contiguous subsequence) whose sum is 0. The sub-array for output may be an empty array. Input Input an array of integers. Output Output the longest zero sum sub-array. If there are multiple such arrays, output any one of them. Output Format You may output in o...
[]
Background A Jordan matrix is a block-diagonal matrix where each block on the diagonal has the structure of $$ \begin{bmatrix} \lambda & 1 & 0 & \cdots & 0 \\ 0 & \lambda & 1 & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \lambda & 1 \\ 0 ...
[]
Consider the following binary matrix: $$\begin{matrix} 1 & 0 & 1 \\ 1 & 0 & 0 \\ 0 & 1 & 1 \end{matrix}$$ The (1-indexed) co-ordinates of the \$1\$s here are \$(1,1), (1,3), (2,1), (3, 2), (3, 3)\$. We can also notice that there are three "shapes" of \$1\$s in the matrix, made of orthogonally connected \$1\$s: $$\begin...
[]
This is similar in concept to this challenge, but that is pretty restrictive on input and output and I think opening up these restrictions would lead to a completely different set of solutions that would be interesting in their own right. Background Set is a card game in which players compete to construct sets of thre...
[]
Background A338268 is a sequence related to a challenge by Peter Kagey. It defines a two-parameter function \$T(n,k)\$, which counts the number of integer sequences \$b_1, \cdots, b_t\$ where \$b_1 + \cdots + b_t = n\$ and \$\sqrt{b_1 + \sqrt{b_2 + \cdots + \sqrt{b_t}}} = k\$. Since \$k\$ cannot be larger than \$\sqrt{...
[]
Related A room, in the context of this challenge, is a multidimensional array where the elements on the "outside" are 1, to represent the walls, and all the other elements are 0 (empty space inside the room) Here's a 1D room with size 5: [1,0,0,0,1] And here's a 2D room with size 6x4: [[1,1,1,1], [1,0,0,1], [1,0,0,1...
[]
05AB1E has the £ builtin which, given a list of integers b and a string s, splits s into sublists of lengths equal to the elements in b. For example, [1,2,3,4,1] "hello world"£ produces ["h", "el", "lo ", "worl", "d"]. Your task is to imitate this behaviour. Given a list \$L\$ containing \$n\$ elements, and a list \$B\...
[]
Related: Boustrophedonise, Output the Euler Numbers (Maybe a new golfing opportunity?) Background Boustrophedon transform (OEIS Wiki) is a kind of transformation on integer sequences. Given a sequence \$a_n\$, a triangular grid of numbers \$T_{n,k}\$ is formed through the following procedure, generating each row of num...
[]
Background -rot transform (read as "minus-rot transform") is a sequence transformation I just invented. This transform is done by viewing the sequence as a stack in Forth or Factor (first term on the top) and repeatedly applying -rot +. -rot is a command that moves the top of the stack to two places down, and + adds tw...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
Write a function that takes in a string and for each character, returns the distance to the nearest vowel in the string. If the character is a vowel itself, return 0. Vowels are : aeiouAEIOU For the purposes of this challenge, y is not a vowel. The input will be a string consisting of uppercase and lowercase letters. E...
[]
Consider the integer set \$S = \{3, 5, 6, 7\}\$. If we list all \$2^n\$ subsets of \$S\$ (its powerset) and calculate their sums, we get $$ \mathcal{P}(S) = \{\emptyset, \{3\}, \{5\}, \{6\}, \{7\}, \{3, 5\}, \{3, 6\}, \{3, 7\}, \{5, 6\}, \{5, 7\}, \{6, 7\}, \{3, 5, 6\}, \{3, 5, 7\}, \{3, 6, 7\}, \{5, 6, 7\}, \{3, 5, 6,...
[]
Content You count numbers every day (I think), and most of you know how to count properly, the one next to 1 is 2, and the next is 3, so go on, no matter what number you receive, you can easily know what next number is. Anyway, the program doesn't know, they are incredibly stupid, if I make a program shaped like 1, it ...
[]
Euler's numerus idoneus, or idoneal numbers, are a finite set of numbers whose exact number is unknown, as it depends on whether or not the Generalized Riemann hypothesis holds or not. If it does, there are exactly 65 idoneal numbers. If not, there are either 66 or 67. For the purposes of this challenge, we'll revoluti...
[ [ 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 ] ]
There are 31 positive integers that cannot be expressed as the sum of 1 or more distinct positive squares: 2, 3, 6, 7, 8, 11, 12, 15, 18, 19, 22, 23, 24, 27, 28, 31, 32, 33, 43, 44, 47, 48, 60, 67, 72, 76, 92, 96, 108, 112, 128 There are 2788 positive integers that cannot be expressed as the sum of 1 or more distinct ...
[]
The fill bucket is a tool available in many drawing tools which replaces a contiguous chunk of one color with a another color. We are going to define a fill bucket which operates on lists of non-negative integers. When used this replaces a contiguous sub-list of one integer with another selected integer. For example [...
[]
Background A Young diagram is a diagram that represents a nonincreasing sequence of positive integers using left-justified rows of squares. As an example, 5, 4, 1 is drawn as OOOOO OOOO O A Young diagram is said to be symmetric if it is identical to its transpose (reflection along the NW-SE diagonal). The above diagra...
[]
Background The 4-8-8 tiling looks like this: For the purpose of this challenge, we take the orientation of the tiling as exactly shown above. In plain English words, we take the tiling so that it can be seen as a rectangular grid of alternating octagons and squares, the upper left corner being an octagon. In order to ...
[]
Consider the following 9 "row patterns", using 0s to represent empty cells and 1s to represent a full cell. Each pattern is associated with an integer \$n\$, such that \$0 \le n \le 8\$ (multiple [1,1,1,1,1,1]s exist as there's some difference that we don't care about): \$n\$ Pattern 0 [0,0,0,0,0,0] 1 [1,1,1,...
[]
This was inspired by this question. Given an \$m\times n\$ matrix of \$0\$'s and \$1\$'s, apply "gravity" to it. This means to drop down all the \$1\$'s as if they were affected by gravity. For example [[1,0,1,1,0,1,0] [0,0,0,1,0,0,0] [1,0,1,1,1,1,1] [0,1,1,0,1,1,0] [1,1,0,1,0,0,1]] Should result in [[0,0,0,0,0,0,...
[]
Let's start with the natural numbers [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,...
[]
I have a small pill box of \$n\$ slots. (Think of it as a linear one like the image below, but not necessarily having 7 slots.) Each slot has at most one pill. Every day, I take one of two actions: take one pill from the pill box, or refill the pill box. The order of taking a pill alternates between left-to-right and ...
[]
Challenge Given input as a list/array of natural numbers that each represent the floor of a class a student has to go to, sort the numbers in a way such that the MAD (mean average deviation) number of flights between classes is minimized, thus saving energy and preventing the chance of being late to a class. When sorte...
[]
Inspired by How to write down numbers having an infinity of decimals? Link Background From Wikipedia: for almost all real numbers \$x\$, coefficients \$a_i\$ of the continued fraction expansion of \$x\$ have a finite geometric mean that is independent of the value of \$x\$ and is known as Khinchin's Constant. Khinchin...
[]
There is a "sorting" algorithm often called Stalin Sort, where instead of sorting an array, you just remove any items that are out of order. In this challenge, you'll implement part of a sorting algorithm which recursively sorts the removed items, then merges the arrays to form one (properly sorted) array. Algorithm Ta...
[]
Background A fractal sequence (Wikipedia; MathWorld) is an infinite sequence of positive integers meeting the following conditions: Each positive integer appears infinitely many times in the sequence. Before the first occurrence of a number \$i > 1\$, every number smaller than \$i\$ appears at least once. Between co...
[ [ 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...