instruction_seed stringlengths 292 48.7k | found_ngrams listlengths 0 21 |
|---|---|
You are given a non-empty list of positive integers. Your task is to figure out how many distinct numbers can be obtained by applying the following algorithm:
Remove either the first or the last item from the list and initialize N to the corresponding value.
Remove either the first or the last item from the list. Let'... | [] |
Background
Adám and I were once discussing a way to properly extend some features in Dyalog APL. I came up with the following extension to Take, a function that takes some front or back elements (and an analogous extension to Drop). We agreed that it was a good idea, but it was incredibly hard to come up with a piece o... | [
[
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... |
Because I forgot to celebrate Pi Day (14.3), let's celebrate with \$\pi\$, \$e\$ (Euler's number) and music!
Challenge
No, we don't have time to eat a pi-pizza, let's make a program.
What you need is \$500\$ digits of \$\pi\$, and \$10\$ digits of \$e\$.
The input is an integer \$n\$ between \$0\$ and \$499\$ inclusiv... | [] |
Sandbox
Many of us have seen math problems where a shape made of unit cubes is dipped in paint, and the answer is the number of painted sides. We'll generalize that problem in this challenge.
Input
A 3-dimensional matrix of 0s and 1s.
Output
A non-negative integer
Challenge
Given a n by m by k matrix of 0s and 1s, we c... | [] |
Background
In Minesweeper, you will often encounter a horizontal or vertical wall of one's and two's (not yet revealed cells are marked as ?):
... 1 1 1 1 2 2 2 1 2 1 1 ...
... ? ? ? ? ? ? ? ? ? ? ? ...
... A B C D E F G H ...
It is equivalent to a problem of recovering zeros and ones in a boolean array when only wind... | [] |
Background
Sometimes in calculus you're expected to calculate the sum of an infinite series. Sometimes these series are very friendly, like a geometric series, but add anything else onto it and it can quickly get complicated to solve by hand.
Sometimes I like to be lazy - a lot of sums can be found simply by adding the... | [] |
Background
Milking the deck is the name given to the following card shuffling method:
'Pinch' the deck to remove the top and bottom cards simultaneously. (With lots of imagination, this action resembles milking a cow.) This pair of cards forms the base of a new pile.
Repeat, adding each pair of cards to the top of the... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
A ripoff of this challenge. Go upvote it!
Objective
Given a rational number amongst \$[0,1]\$, apply the Cantor function to it and output the rational number that's produced.
The Cantor function
The Cantor function is continuous everywhere and constant almost everywhere, but has an average slope of 1:
The Cantor funct... | [] |
In this question at Code Review they tried to find the fastest way to return the unique element in an array where all the elements are the same except one. But what is the shortest code that accomplish the same thing?
Goal
Find the unique element in an array and return it.
Rules
The input array will contain only integ... | [] |
Summary
Videos which are sped up every time a particular word is said exist for everything from the Bee Movie to the classic Rick Roll. The goal for this challenge is to figure out how much you'd have to slow down the sped-up video in order to match the duration of the original video.
For example, the original Bee Movi... | [] |
Paper Folding for the win
"How many times can you fold a paper?" - This well known question led to many arguments, competition, myths and theories.
Well, the answer to that question depends on many properties of the paper (length, strength, thickness, etc...).
In this challenge we will try to fold a piece of paper as ... | [] |
A matrix is antisymmetric, or skew-symmetric, if its transpose equals its negative.
The transpose of a matrix can be obtained by reflecting its elements across the main diagonal. Examples of transpositions can be seen here:
\$\begin{pmatrix}11&12&13\\21&22&23\end{pmatrix}\rightarrow\begin{pmatrix}11&21\\12&22\\13&23\en... | [] |
Thin Paper Folding
This is a "lighter" version of the challenge Paper Folding for the win. This challenge is being posted as a different challenge with many modifications in order to try and get wider range of interesting answers.
For anyone who is answering the first challenge, I marked the changes with bold (also no... | [] |
Given a directed network, with a single source and a single sink, it is possible to find the maximum flow through this network, from source to sink. For example, take the below network, \$G\$:
Here, the source is node 0 and the sink 5. We can see, from the minimum cut-maximum flow theorem, that the maximum flow throu... | [
[
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
]
] |
Source Code Byte Frequency
Write a program that get a single byte character as an input and prints the frequency of that byte in the program's source code as an output.
Examples:
Assuming my program is: ab#cd%b then the output of the program should be (each line is a separate execution):
input output
----- ... | [] |
In the body of this challenge, \$\begin{pmatrix}n\\k\end{pmatrix}\$ is used to represent the number of combinations of \$k\$ elements of \$n\$, also written as \$\frac{n!}{k!(n-k)!}\$ or \$n\mathrm{C}r\$.
Any nonnegative integer \$m\$, for arbitrary natural (positive) \$r\$, can be written as a unique series of \$r\$ c... | [] |
Challenge
Given an integer radius \$r \geq 0\$, write a program that prints each set of cartesian coordinates in a counter-clockwise spiral originating at \$(0, 0)\$ as shown here (for \$r = 3\$), with indices:
Input
The program should take \$r\$, a non-negative integer, as an input. The input is assumed to be valid a... | [] |
Design a language and golf its interpreter so that it solves the following programming challenges in as few bytes as possible:
Hello World
cat
Fizz Buzz
List the first \$n\$ primes
Fibonacci Sequence
Sort a numerical list
Balanced parentheses/brackets/braces test
Rule 110 (as a proof of Turing completeness)
Challenge... | [
[
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
20
],
[
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
20,
11
]
] |
I just realized that Python allows more than names as for loop iteration variables:
for a[i] in sequence:
pass
The real fun begins when a and i change during the loop. The following function inverts a list a in place while printing the intermediate steps. All assignments occur implicitly in the iteration variables... | [
[
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 Polygamma function of order \$m\$, \$\psi^{(m)}(z)\$, is the \$(m + 1)\$th derivative of the logarithm of the gamma function, which is also the \$m\$th derivative of the digamma function. Your task is to take an integer \$m\$ and a positive real number \$z\$ and output \$\psi^{(m)}(z)\$
Definitions
For those unfami... | [] |
Challenge
Given a number x and a precision e, find the lowest positive integer q such that x can be approximated as a fraction p / q within precision e.
In other words, find the lowest positive integer q such that there exists an integer p such that abs(x - p/q) < e.
Input
The pair (x, e) where x is a floating-point n... | [] |
Input a String and surround it with a rounded rectangle of alternating "friendliness pellets".(0)
Sandbox
Idea originally from Lyxal.
Challenge
Given a single line non-empty String of length \$<100\$, print the string with a rounded rectangle of alternating pellets(0) around it.
The rectangle must be 11 lines in heigh... | [] |
Banknotes in many countries come in denominations of 1,2,5,10,20,50,100,200,500,1000, etc. That is, one of \$ \{ 1,2,5\} \$ times a power of \$10\$. This is OEIS A051109, except we'll extend the sequence to bigger values.
Given a positive integer as the input, the program should output the largest bank note that is les... | [] |
Given a rectangle, a start point, and an end point, find any path from start to finish that avoids the rectangle.
Example
Suppose you were at \$(1.5, -1.5)\$ and you needed to get to \$(2, 4)\$. However, there is a rectangle with upper left corner \$(1, 3)\$ and bottom right corner \$(4, 1)\$ in your way. It would look... | [] |
You are a medieval overlord tasked with designing a road network between three kingdoms placed on a \$9 \times 9\$ grid. A sample placement of kingdoms might look like this:
Non-commercial use of tileset by douteigami. Thanks!
The kingdoms make the following three demands:
The road network must be connected: for any ... | [] |
Who's up for a second attempt?
If you've ever listened to the radio program "I'm sorry, I haven't a clue", then you've probably heard of the game called "Mornington Crescent". For those who haven't, it's a game where players name random stations on the London Underground network. The first person to name "Mornington Cr... | [] |
Let's start by defining a Two Bit Number™:
It is a positive integer
When expressed as a binary string it has exactly 2 true bits OR
When expressed as a decimal number, it has exactly 2 of the numeral one, and all other numerals are zero.
Or as a sentence
A Two Bit Number™ is a number which contains exactly 2 of the n... | [] |
Introduction:
You're a key maker, and want to access something from a safe that has a lock. Unfortunately, the key to that lock is lost, so you'll have to make a new one. You have access to a bunch of blank keys, to which you can add notches to turn it into actual keys. You also have loads of keys with notches already ... | [] |
Executive summary:
Print NxN matrices \$A\$ and \$B\$ where \$ AB = 10A + B \$. Largest N wins!
Details:
Entrants in this challenge should choose an N. Submit a program that takes an input integer 'seed', and produces two full rank NxN matrices \$A\$ and \$B\$, where each element of \$A\$ and \$B\$ is an integer from ... | [
[
15,
609,
220,
15,
609,
481,
16,
59,
408,
90,
1653,
11035,
1291
]
] |
Leonhard Euler wants to visit a few friends who live in houses 2, 3, ..., N (he lives in house 1). However, because of how his city is laid out, none of the paths between any houses form a loop (so, the houses exist on a graph which is a tree).
He gets bored easily but if he visits his friends in a different order, he ... | [
[
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
Mastermind is a game of code-breaking for two players. One of the players is codemaker (Alice) and the other is codebreaker (Bob).
4x4 means that the player should guess the length-4 sequence made of four alphabets (say RGBY). The hidden sequence may have duplicate letters, so there are \$4^4 = 256\$ possibi... | [] |
Background
Sometimes when I'm golfing a program, I'm presented with the following situation: I have an integer value \$x\$ on some fixed interval \$[a, b]\$, and I'd like to test whether it's in some fixed subset \$S \subset [a, b]\$ with as few bytes as possible.
One trick that sometimes works in a language where nonz... | [] |
Given three distinct numbers from \$1\$ to \$7\$, output three other distinct numbers from \$1\$ to \$7\$, that is having no numbers in common with the original numbers. Your code must produce a different output set for each possible input set. That is, no two inputs can produce the same output, treating both as unorde... | [] |
The task
In this challenge, you are given a number and a list.
Your task is to remove from the list all occurrences of the given number except the first (leftmost) one, and output the resulting list.
The other elements of the list should be left intact.
The number will be a positive integer below 1000, and the list wi... | [] |
Context
Consider the following sequence of integers:
$$2, 10, 12, 16, 17, 18, 19, ...$$
Can you guess the next term? Well, it is \$200\$. What about the next? It is \$201\$... In case it hasn't become obvious to you, this is the sequence of positive integers whose name starts with a letter D in Portuguese.
Task
Given a... | [] |
We can read 13576870234289 digit-by-digit in English, and it makes a haiku:
one three five seven
six eight seven zero two
three four two eight nine
We say it's a "digit haiku", because when read out like this, it's 5+7+5 syllables long, and no word is broken across a line.
For example, 111171111101111 is not a digit ... | [] |
This problem is based on non-terminating, repeating decimal points.
Let \$n\$ be any positive integer \$(n > 1 \text{ and } n < 10000)\$, say \$7\$. Then, \$1/n = 1/7 = 0.142857142857142857...\$
We see a pattern like, 0. 142857 142857 142857 ...
In this, the 142857 part is always repeating, which has length of \$6\$. ... | [] |
Because the coronavirus is still at large, I thought it would be fitting to have a epidemic-themed challenge.
Challenge
You are given a 2D array of people, where 1 represents someone with the virus, and 0 represents someone without the virus. Every day, the people with the virus infect their neighbours. You must calcul... | [] |
It is possible (Wikipedia reference) to compute the square root of any number in a digit by digit fashion using a simple (I had learned it in primary school) algorithm.
Challenge:
read a positive integer from the user, in base 10, no error check;
compute the square root of that integer using a digit-by-digit algorithm... | [] |
Let's consider the sequence \$S\$ consisting of one \$1\$ and one \$0\$, followed by two \$1\$'s and two \$0\$'s, and so on:
$$1,0,1,1,0,0,1,1,1,0,0,0,1,1,1,1,0,0,0,0,...$$
(This is A118175: Binary representation of n-th iteration of the Rule 220 elementary cellular automaton starting with a single black cell.)
Given \... | [] |
I have a problem, which I haven't found a solution for. Solutions to the first part are well documented, but I have yet to find anyone who has solved the second part. I call this the "Dobble" challenge...
Challenge 1
Using the numbers 1 - 57, populate 57 arrays. Each array must have 8 numbers in it, with no duplicates.... | [] |
TLDR: Sort your input according to a new English alphabet somewhat based on Chinese stroke count methods.
Background: In a Chinese glossary/index, finding terms that are contained within the book is different from English because Chinese doesn't have an alphabet like English, instead they are sorted by stroke count. (一... | [] |
A centered polygonal number is a positive integer given by the number of vertices when a point is surrounded by (increasingly larger) polygons with the same number of sides, as shown below. For example, \$p_5(3) = 1 + 5 + 10 + 15 = 31\$ is a centered pentagonal number formed by taking a vertex and adding three layers o... | [] |
When studying numerology, you can say two words (strings consisting entirely of letters) are compatible if they produce the same number under the following operation (let's use the string hello as an example):
Map each letter to a number according to the following, ignoring case:
1 2 3 4 5 6 7 8 9
a b c d e f g h i
j ... | [] |
Here's an easy one, with just enough complexity to make golfing non-trivial.
Input
A list of non-negative numbers representing people waiting in line for Thanksgiving dessert. The first (leftmost) number is first in line, and the list can contain repeats (think of each number as a person's first name):
Note: Pie not... | [] |
Background:
A sequence of infinite naturals is a sequence that contains every natural number infinitely many times.
To clarify, every number must be printed multiple times!
The Challenge:
Output a sequence of infinite naturals with the shortest code.
Rules:
Each number must be separated by a (finite) amount of visible... | [] |
The Problem:
You receive a (section of) a Conway's Game of Life grid. Your task is to output whether it represents a still-life (subsequent generations are identical to the current grid), a oscillator of period up to 4 (every nth generation is identical to the current grid), or something else.
The remainder of the inf... | [] |
This challenge is inspired by the AoC 2020, Day 14 - Part II, created by Eric Wastl and his team, which asks to output the possible binary values from a bitmask.
Let's say we've a bitmask like "10X0X0", then we've to find the possible binary values that can be generated by replacing an X with either 0 or 1. Here I've 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
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220... |
I will preface this by saying that I made this for fun; I have absolutely no formal knowledge on cryptography or error correction. Do not use this algorithm in anything remotely important.
I was kind of bored a few days ago, so I decided to write a simple function to take some data and return an easily memorable (but 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... |
Create the shortest function, program, or expression that calculates a sequence of squarefree palindromic numbers.
A squarefree number is one which is not evenly divisible by a square number (i.e. does not contain a repeated prime factor). For example, \$44 = 2^2 \times 11\$ is not squarefree, whereas \$66 = 2\times3\t... | [] |
A newspaper is made of several sheets; for the purposes of this question, each sheet of newsprint holds four pages of the final newspaper. Here is an example of three sheets of newsprint making up a newspaper with twelve pages:
___________
|2 | 11|
| ___|_____|_
| |4 | 9|
|_| ___|_____|_
| |6 | 7|... | [
[
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 palindromic number, as a refresher, is any number which reads the same forward as backwards. However, what about palindromes in other bases?
Input
Any integer b where b > 1.
Output
All integer base 10 numbers from 0 to 1000 inclusive that are palindromes in base b. The output can either be a list of integers, or inte... | [] |
Your goal is to make a function that takes the coordinates of a cell in 2D space and a distance \$r\$ and returns the coordinates of all cells in the input coordinate's von Neumann neighborhood of radius \$r\$. That is, all cells at most \$r\$ away in Manhattan distance.
For example, given the following cell coordinat... | [] |
Given a binary sequence of finite length, find the starting position where this sequence first appears in the binary digits of π (after the decimal). You can assume that an answer exists for any input sequence.
The binary digits of π start with
11.001001000011111101101010100010001000010110100011...
and digits will be ... | [] |
Interval notation is a way to write complicated range bounds more conveniently and concisely than writing an inequality. The challenge, should you choose to accept it, is to write a program or function that interprets a subset of interval notation. In this subset, intervals are a comma-separated pair of integers delimi... | [] |
Inspired by a recent challenge involving Fibonacci numbers in which OEIS was mentioned, I would like to present a challenge of creating a function that generates a wide array of different linear integer sequences, depending on user input.
Specifically, the user should provide three inputs:
the kernel (a representation... | [
[
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,
17,
11,
220,
18,
11,
220,
19,
11... |
Your program should take two lists, where each entry (a positive integer) represents the number of members of some group, as input. These lists will have the same sum but may have different lengths.
Your mission, should you choose to accept it, will be to pair up members of the first list with members of the second, ou... | [] |
Do you know the game Battleship? Well, I want to play with my little brother, but before we can begin we need to set up our ships on the board. This is your input.
Now, we need to check that the ships that we set up are valid. This is where you come in to help. Your task is to write a program or function which checks w... | [] |
This problem will have you analyzing circles drawn on the grid, with the gridlines drawn at integer values of \$x\$ and \$y\$.
Let \$\varepsilon\$ be a very small number (think, \$\varepsilon = 0.0001\$). If we paint a filled-in circle of radius \$\varepsilon\$ centered at the origin, it will require paint to be in \$4... | [] |
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... | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.