instruction_seed stringlengths 292 48.7k | found_ngrams listlengths 0 21 |
|---|---|
Challenge
Given some JSON data, calculate the maximum depth reached. (Both arrays and dictionaries increase the depth)
Input/Output
The program is expected to read a JSON string from stdin and as soon as the program receives a \n start calculating the max depth, printing it to stdout and terminating the program when do... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
Inspired by this SO answer about peak detection.
Background
Persistent homology is a fancy term for a fancy math concept, but in this case all we care about is how it can be used for peak detection. In the case of a 1-dimensional array we can describe the algorithm as follows:
We are given an array as input. We begin b... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220... |
Background
You have been given the task of calculating the number of landmines in a field.
You must calculate the landmine score given a list/string of numbers and the landmine number.
The landmine number tells you where landmines are.
For each digit:
if the left digit plus the right digit is equal to the landmine num... | [] |
There is a challenge for multiplying two numbers so I guess this counts too
Given as input a positive real number n compute its natural logarithm.
Your answer should be within \$10^{-6}\$ for \$1 \leq n \leq 10\$ and within \$10^{-3}\$ for \$0.1 \leq n \leq 100\$. You don't need to handle numbers outside this range.
Se... | [] |
Background
You have again x3 been given the task of calculating the number of landmines in a field. But this time, we have no landmine number, and some landmines have exploded.
You must calculate the landmine score given a string of numbers. This is the landscape.
You have no landmine number to start with. Instead, the... | [] |
Conway's Game of Life is a cellular automaton "played" on an infinite grid, filled with cells that are either alive or dead. Once given an initial state, the board evolves indefinitely according to the following rules:
Any live cell with 2 or 3 living neighbours lives to the next state
Any dead cell with exactly 3 liv... | [] |
Diagonalize a vector into a matrix.
Input
A vector, list, array, etc. of integers \$\mathbf{v}\$ of length \$n\$.
Output
A \$n \times n\$ matrix, 2D array, etc. \$A\$ such that for each element \$a_i \in \mathbf{v}\$,
$$
A =
\left( \begin{array}{ccc}
a_1 & 0 & \cdots & 0 \\
0 & a_2 & \cdots & 0 \\
\vdots & \vdots & ... | [] |
Your task is it to output a number as a unary string. You get the number of a non-negative integer input in the range of 0 - 2'000'000'000.
Rules
You can choose any character for the digit you like. But it has to be the same everywhere and for every input.
Output a unary string by outputting this character N times. N... | [] |
Write a function (or a whole program) that outputs (or prints) the following ASCII art:
Output:
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 5 6 5 4 3 2 1
1 2 3 4... | [] |
On the Mathematica Stack Exchange, 100xln2 asks:
I need a list of integers […] The list contains integers and is characterized by [three] parameters, lets call them k and j [and listmax], which should be variable.
If k=1 and j=1 then the list would look like this: {1,3,5,7,9,11,....until listmax}
If k=2 and j=3 then t... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
The unique-disjointness matrix ( UDISJ(n) ) is a matrix on all pairs of subsets of {1...,n} with entries $$ U_{(A,B)}=\begin{cases}
0, ~ if ~ |A\cap B|=1\\
1, ~ otherwise
\end{cases} $$
Or a bit less mathematical, it is the 2n times 2n matrix with a 0 in all entries where both indices have exactly one common 1 bit in t... | [] |
A powerful number is a positive integer \$n\$ such that for every prime \$p\$ that divides \$n\$, \$p^2\$ also divides \$n\$. Or equivalently, \$n\$ is powerful if and only if it can be written in the form \$n = a^2b^3\$, where \$a\$ and \$b\$ are positive integers.
For example, \$972 = 2^2 \times 3^5\$ is powerful, be... | [] |
This challenge was originally posted on codidact.
At my job we have to sometimes lay out materials. Materials come in large long rolls and are cut into smaller pieces when being laid out.
When we order the rolls we draw up a layout document which describes how we are going to cut them and layout the pieces. This tells... | [] |
Most people would cut circular pizzas into circular sectors to divide them up evenly, but it's also possible to divide them evenly by cutting them vertically like so, where each piece has the same area (assume the pizza has no crust):
Challenge
Your task is to make a program or function that takes a positive integer \... | [] |
Given a sequence of integers with length \$L\$ and an integer \$1 \le N \le L\$, an "\$N\$-rich" permutation is one whose the longest strictly increasing contiguous subsequence has length exactly \$N\$.
For example, let our sequence be [0, 1, 2, 3]. There is exactly one \$1\$-rich permutation, given by [3, 2, 1, 0]. By... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
How to play the duck game
This is a 2-player game.
First, we start with a line of blue rubber ducks (represented here as circles):
Now, in each turn, the current player can turn either one blue duck or two adjacent blue ducks red.
So, a valid move would be indexes 2 and 3 (0-indexed):
Then, the other player cou... | [] |
Given a positive integer n, output a number meter formatted like this:
0 1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 1 1 1 1 1 1 1 1 1 1 2
The input number is 20 in this example.
More formally, the decimal representations of the numbers are arranged vertically, from most significant digits on the last row ... | [] |
Problem
You are tasked with creating a program that performs emoji encryption on a given string of emojis. In this encryption scheme, each emoji is replaced by a unique character (from a to z). Your program should take an emoji string as input and output the corresponding encrypted string.
The mapping of emojis to char... | [] |
Your task is to find out how often you need to "shuffle" a given list with the following operation until you get back the original list.
start with a list:
(1 2 3 4 5 6 7 8 9)
split it into the elements at odd and even indices
(1 3 5 7 9) (2 4 6 8)
concatenate these two list
(1 3 5 7 9 2 4 6 8)
Input: A list
Output: ... | [] |
Brief description of the game
In the game Otteretto Classic (which you can test directly in your browser; try it!) the player has to form palindromic sequences using adjacent cells on a square grid. Each cell has one of five possible colours, which we will denote by the letters \$\mathrm A, \ldots, \mathrm E\$.
The use... | [] |
Background
Fibonacci numbers are defined as follows:
$$
F_0 = 0, F_1 = 1, F_n = F_{n-1} + F_{n-2}
$$
The Zeckendorf representation is a representation of positive integers as a sum of one or more non-adjacent Fibonacci numbers, using indices 2 and higher. It is known that such a representation is unique for every posit... | [] |
Background
Given an elementary cellular automaton rule number like, for example, 28 = 00011100…
We can swap \$\color{red}{\text{the 2nd bit with the 5th bit}}\$ and \$\color{orange}{\text{the 4th bit with the 7th bit}}\$ to get a rule that acts the same way but mirrored horizontally. This gets us 01000110 = 70.
We ca... | [] |
Alternatively, guess who's doing a course on operating systems
Round Robin scheduling is a way to schedule ready processes in an operating system. Each process in the queue is run for a certain amount of time (quantum), interrupted after that time (if not yet finished), and then added back to the ready queue for anothe... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220... |
Description
Given a list of positive integers, write the shortest code to find the number count of the longest consecutive sequence of numbers within the list.
Input
A list of positive integers. You can assume the list is not empty and may contain duplicates.
Output
The length of the longest consecutive sequence of num... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
American odds (aka moneyline odds) are numbers like \$+150\$ or \$-400\$ used to express how much a winning bet would pay out. Convert odds to a fair win probability like this:
Positive odds \$+n\$ with \$n \geq 100\$ correspond to $$p=\frac{100}{100+n},$$ producing a probability with \$0 < p \leq 1/2\$.
Negative odds... | [] |
Write a program or function that outputs all positive integers with distinct decimal digits (OEIS: A010784)
Examples:
1 2 3 4 5 6 7 8 9 10 12 13 ...
96 97 98 102 103 ...
123456789 123456798 ... 9876543120 9876543201 9876543210
Rules
You can output the list of numbers in any convenient format (string with separators, ... | [] |
Inspired by this (off topic) post
Given an array of numbers, find the largest sum over a subarray not containing two adjacent elements
[1,2,3,4] -> 6 // [_,2,_,4]
[1,2,3,4,5] -> 9 // [1,_,3,_,5]
[2,2,1,1,2,1,1,2] -> 7 // [2,_,1,_,2,_,_,2]
[3,1,4,1,5,9,2] -> 16 // [3,_,4,_,_,9,_]
[9,8,7,9,9,8] ... | [] |
Background
Numeric Mahjong is a hypothetical variation of Japanese Mahjong, played with nonnegative integers instead of Mahjong tiles. Given a list of nonnegative integers, it is a winning hand if it satisfies the following:
its length is \$3n+2\$ for some nonnegative integer \$n\$, and
it can be partitioned into \$n\... | [] |
Your challenge is to print any 100 consecutive digits of π. You must give the index at which that subsequence appears. The 3 is not included.
For example, you could print any of the following:
1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679 (index 0)
821480865132823... | [] |
In this challenge, we define a range similarly to Python's range function: A list of positive integers with equal differences between them. For example, [1, 2, 3] is a range from 1 to 3 with a skip count of 1, because there is a difference of 1 between each item, and [4, 7, 10, 13] is a range from 4 to 13 with a skip c... | [] |
In this challenge, we define the complement of a list of positive integers as all positive integers not included in that list. For example, the complement of the even numbers [2, 4, 6, 8...] is the odd numbers [1, 3, 5, 7...]. Your challenge is to, given a monotonically increasing, infinite list of positive integers, ... | [] |
This challenge is to list out all possible words which are built from a pattern of syllables. Words are composed by joining syllables together. Syllables are composed of a number of vowels with some number of consonants optionally to the left and/or right. Your code should take in:
a list of consonants
a list of vowel... | [] |
In this challenge you will take a non-empty (finite) list of (possibly infinite) lists of positive integers, and your task is to output the longest one. An infinite list is longer than a finite list of any length, and any two infinite lists are equally long.
You're guaranteed that there won't be any ties for longest be... | [] |
Given a number \$n\$, you are to compute the sequence of positive numbers where for each number \$a\$, the \$n\$-times multiple \$n\cdot a\$ is missing.
Example
We always start with the sequence of all positive numbers: $$1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, \dots$$
For \$n=2\$, going left-to-right, we first encounter ... | [] |
Not sure if it's correct to ask such a question on this site, but let's try.
Let a(n) be a sequence of positive integer such that a(1) = 1. To reproduce the sequence a(n) through itself, use the following rule: if binary 1xyz is a term then so are 110xyz and 1XYZ where the last one is the same as 1xyz with rewrite 1 ->... | [] |
You work at a beach. In the afternoon, the sun gets quite hot and beachgoers want to be shaded. So you put out umbrellas. When you put out umbrellas you want to shade the entire beach, with as few umbrellas as possible.
Umbrellas come in many sizes. However, larger umbrellas are susceptible to being pulled away by the ... | [] |
Task
Here is an interesting math problem:
Let's say that there are \$n\$ indistinguishable unlabeled objects in a bin. For every "round", pull \$k\$ objects randomly out of the bin with equal probability, and apply a label on each object (Nothing happens to objects already having a label). Then put these \$k\$ objects... | [] |
We already have a challenge for polynomial interpolation: given a list of points, output the coefficients of the polynomial that passes through them.
Hermite interpolation is a generalization of polynomial interpolation. Instead of just specifying the points that the polynomial passes through, we also specify the highe... | [] |
We will think of a partition as a sequence of non-increasing integers.
For a given partition into \$n_1, n_2, \dots, n_k\$ with \$n_1 \geq n_2 \dots n_{k-1} \geq n_k = n\$ we write it out with \$n_i\$ dots on row \$i\$. So for \$6, 1, 1\$ we would write six dots on the first row, one on the second and one on the third... | [] |
Task
Your boss is on another crusade for 'efficiency.' He wants to encourage the use of numbers with fewer syllables, so that they're easier to discuss in meetings. If you want to take some time off work, you're boss would prefer you take 9 days instead of 7. You're boss would prefer a credit card expense of $99,502 ov... | [] |
Imagine there are \$n\$ people \$\{a_1, a_2, \ldots, a_n\}\$ who enter a room in order and sit down in \$n\$ seats, arranged in a row. Each of these people belong to some gang, indicated by an integer \$\{1, 2, \ldots, k\}\$. These gangs hate the members of the other gangs, so they want to sit as far away from those pe... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
The well-known Urinal Protocol states that each person that takes a urinal will take the one furthest from any other taken urinal. But this fails to account for short urinals; in many cases, a person would prioritize taking a taller urinal in addition to distance.
In the real world, you might struggle to find a restroo... | [] |
The Rudin-Shapiro sequence is a sequence of \$1\$s and \$-1\$s defined as follows: \$r_n = (-1)^{u_n}\$, where \$u_n\$ is the number of occurrences of (possibly overlapping) \$11\$ in the binary representation of \$n\$.
For example, \$r_{461} = -1\$, because \$461\$ in binary is \$111001101\$, which contains \$3\$ occu... | [] |
We need to produce a block cipher round function with a 1 bit round key size and a 7 bit message size with the highest level of cryptographic security according to our measure of security.
Introduction
We are going to need new symmetric encryption functions. We are at the point where we cannot improve the performance o... | [] |
One lane is closed, the vehicles have to thread their way in according to the zip-lock system: One car from one lane, the next car from the other lane, always taking turns.
Input: Two vehicle queues, represented e.g. as strings, in which short cars are represented by individual symbols, lorries by several identical sym... | [] |
It is a well-known fact that you can colour a two-dimensional map with four colours in such a way that two countries with a common border always have different colours. There have already been enough challenges on this topic.
However, the prerequisite for this is that there must be no enclaves, i.e. non-contiguous area... | [] |
Objective
Given two non-negative integers encoded in unbounded-length Gray code, add them and output the result, where the result is also encoded in Gray code.
Gray code
There are many equivalent formulations of Gray code, but here's an intuitive one.
The Gray code encodes each non-negative integer as an infinite bit-s... | [] |
Challenge
This challenge is based on the domino effect:
Initially, each domino is located on one straight line and is in a vertical state. It can be dropped either to the left along the same straight line, or to the right. Then this domino will knock down the next one, and that one, perhaps, the other.
The dominoes are... | [] |
Given a string of ASCII text as input, encode it in BPSK31 using Varicode. You may either output an audio file in any common format, or play the audio over the device speakers. You may output at any sample rate and with any carrier frequency between 500 Hz and 2500 Hz. The sample rate and carrier frequency must be cons... | [] |
You know what a monotonic sequence is: each element is bigger than its predecessor (monotonically rising) or as its successor (monotonically falling).
Bitonic means you have two arms of the sequence, one monotonically rising, the other falling.
For example, 1,3,5,7,6,4,2 is bitonic (rising until 7, then falling until t... | [] |
In this challenge, an infinitely proportional sequence is defined as a infinite sequence of positive integers such that:
All positive integers are contained infinitely many times within the sequence.
As more and more terms are added to the sequence, for all positive integers \$n\$, the ratio of the number of \$n\$s to... | [] |
OEIS sequence A003242 comprises the numbers of Carlitz compositions for any given positive integer. This is the number of integer partitions of the integer for which no two adjacent parts are equal.
For example, for 4:
Generate the possible integer partitions (and their permutations): [1,1,1,1], [1,1,2], [1,2,1], [2,1... | [] |
Given an n non-negative integers, how many numbers must be changed so that each number x appears x times? You cannot add or remove elements, only replace them with other numbers.
For example:
1 6 23 6 9 23 1 1 6
can be turned into:
1 6 2 6 6 2 6 6 6
with 5 changes, which is optimal.
Test cases
0 => 1
1 2 3 => 1
5 5 5... | [] |
Every Brazilian citizen has a national identification number associated with them, named CPF.
This number has 11 digits (formatted as XXX.XXX.XXX-XX) and it's validated by the following (real) algorithm1:
Take the 9 most significant digits of the number. Call it c.
Multiply the n-th least significant digit of c by n+1... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
I define mousetail's sequence as follows:
If the nth element of the sequence is q, then n+1 must appear q times in the sequence
The sequence is weakly monotonically increasing (i.e. no lower number may follow a higher number)
f(1)=1
I'll show an example of how this works:
the first element is 1
after the 1, come 1 2... | [] |
Historic Tetris Achievement
Blue Scuti became the first ever human to beat the classic game of Tetris on NES.
Here's the Tetris Kill Screen
Challenge
Output the following Tetris Kill Screen board (10x20 blocks)
EEEEEEEEEE
EEEEEEEEEE
EEEEEEEEEE
EEEEEEEEEE
EEEEEEEEEE
EEEEEEEEEE
EEEEEEEEEE
EEEEEEEEEE
EEEEEEEEEE
EEEEGGEEE... | [] |
Earlier I asked about this problem on stackoverflow (link), but now I also want to see the golfiest solutions
Problem:
Given an array of arbitrary numbers, what is the longest subarray that is repeated (appears more than once)? In case there are multiple distinct repeated subarrays that all have the longest length, the... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
Consider a function \$r\$ where
$$
r(i,k)= \begin{cases}
L_{i+1}-L_i, & \text{if}\ k =0\ \text{ (1st reduction)} \\
r(i,0)-r(\lfloor \log_2{k} \rfloor,k-2^{\lfloor \log_2{k} \rfloor}) & \text{if}\ k \geq 1\ \text{ (2nd reduction)}
\end{cases}
$$
where \$k<2^i\$ and \$L\$ is a finite sequence of integers.
For example,... | [
[
220,
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220
],
[
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
20
]
] |
Definitions
The common methods to generate consecutive composites are
$$\overbrace{(n+1)! + 2, \ (n+1)! + 3, \ \ldots, \ (n+1)! + (n+1)}^{\text{n composites}}$$
$$\overbrace{n!+2,n!+3,...,n!+n}^{\text{n-1 composites}}$$
$$\overbrace{n\#+2,n\#+3,…n\#+n}^{\text{n-1 composites (Primorials)}}$$
A less common method involv... | [] |
Exposition
In this challenge, I am talking about ARM assembly language. ARM is a 32-bit RISC processor; I'll use instruction set up to architecture v6.
To load a constant ("immediate") value into a register, use
the MOV instruction:
MOV r8, #42
To load negative values, use the MVN instruction, with a bit-complement of... | [] |
Even though the concept of phat-fingered-lights-out number should be pretty self-explanatory here is a definition:
Given a nonnegative integer in binary representation a phat-fingered double-bit-flip or phatflip for short replaces a pair of adjacent, equal bits with their complement.
For example given the number 0b1110... | [] |
Input: You are given two numbers n and m.
Create the snail: Given an n >= 3, fill an n * n grid with the numbers from 1 to n * n, starting at the top left, going clockwise to the middle like this (for n = 5):
1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
Calculate the sum of the neightbour... | [] |
Background
As noted in this question, for all positive integers \$n>2\$ there exists at least one Egyptian fraction representation (EFR) of \$n\$ distinct positive integers \$a_{1} < a_{2} < \dots < a_{n}\$ such that $$ \sum_{k=1}^{n} \frac{1}{a_{k}} = 1. \tag{1} \label{1} $$
When \$n=3\$, for instance, we have $$ \fra... | [] |
A list \$[a_1,a_2,a_3 \cdots a_n]\$ can be uniquely represented as an unordered list of its prefixes - \$ [[a_1],[a_1, a_2], [a_1,a_2,a_3] \cdots [a_1,a_2,a_3 \cdots a_n]] \$. This can be in any order - for example, \$[1, 2, 3]\$ could be represented by any of \$[[1],[1,2],[1,2,3]]\$, \$[[3,2,1],[2,1],[1]]\$, or \$[[2,... | [] |
Challenge
Given ASCII-encoded text input of any size, detect numbers between -1,000,000,000,000,000,000 and 1,000,000,000,000,000,000 exclusive and rewrite them with thousands separators. Use commas only and ignore leading zeroes. Leave the rest of the input unchanged.
Test cases
Input
Output
Description
123
123... | [] |
Given a collection of coloured laces, what would be the probability, \$P\$, that Alice won't create any loops if, until impossible, they tie two uniformly chosen, free lace ends of differing colours together?
For the avoidance of doubt:
Each lace will be of only one colour and will have precisely two ends.
Alice does ... | [] |
I recently found this game and have been enjoying it. Basically, there is a grid of colored tiles and you act by clicking on empty spaces. When you click an empty space, the first tile (if any) in each of the four axis-aligned directions is selected. If any color appears more than once, all tiles of that color are dest... | [] |
Have you heard about trees?
When performing DFS on a binary tree, you can traverse it in 3 possible orders.
Root, left node, right node (Pre-order)
Left node, Root, right node (In-order)
Left node, right node, root (Post-order)
Check wikipedia to know more.
For this challenge, you have to provide a program that, giv... | [] |
Objective
Write a program in any language that reads a matrix from stdin in which all columns are space delimited and all rows are newline delimited. The program must output a sub matrix so as that there is no other sub matrix with greater average, this sub matrix' average value, as well as the starting and ending coor... | [] |
You have a number of polynomials who are lonely, so make them some companions (who won’t threaten to stab)!
For a polynomial of degree n, there is an n by n companion cube matrix for it. You need to make a function that accepts a list of coefficients for a polynomial in either ascending (a + bx +cx^2 + …) or descendin... | [] |
Given a string consisting of printable ASCII chars, produce an output consisting of its unique chars in the original order. In other words, the output is the same as the input except that a char is removed if it has appeared previously.
No built-ins for finding unique elements in an array can be used (for example, MATL... | [] |
In public-key cryptography, a public key fingerprint is a short sequence of bytes used to identify a longer public key.
In SSH in particular they can be used to verify that a server is in fact the server I'm expecting to communicate with and I'm not targeted by a man-in-the-middle attack.
They are usually represente... | [] |
Well, the librarian caught you cheating at your job by using your sorting algorithm, so now you're being punished. You've been ordered to create some code so the librarian can impress the object of their unrequited affection, the math teacher. So that's what "Other duties as assigned" means ...
Everyone is familiar wit... | [
[
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... |
Challenge
Given a positive integer N that is 28 or above, output a list of numbers summing to N that uses each digit 1 through 7 exactly once. You can give as a program or function.
The digits can appear by themselves or concatenated, as long as you use each of them once without repeats. For example,[12, 34, 56, 7] is ... | [
[
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 Alternating Harmonic Series is a well known convergent series.
"Clearly", it is obvious that it converges to the natural log of 2. Or does it?
Since the series is not absolutely convergent, by simply rearranging the terms, I can make it approach anything I want. Suppose I want the series to converge to e. All I'd ... | [] |
Introduction
In this challenge, your task is to simulate a certain type of elimination game.
In the game, the participants stand in a circle, and everyone is holding an integer.
On each round of the game, every participant points at the person n steps away, if n is the number they are holding. If n is positive, they co... | [] |
Output coordinates of the vertices of a cube. Then, output a list of twelve triangles that will cover the cube, each triangle being a list of three vertex-indexes, consistently oriented. Output must be an ASCII string of distinct decimal numbers. This golf has no input. Winner is the fewest characters, where the charac... | [] |
The Challenge
I always write my math assignments down in the same way. For example:
pg. 420: #25, 50-56, 90
pg. 26: #50-60 evens, 70-80 odds, 90-99 3s
pg. 69: #12, 16, 18, 37
But I need you to tell me the individual problem numbers. For example:
input:
pg. 420: #25, 50-56, 90
output:
25, 50, 51, 52, 53, 54, 55, 56, ... | [
[
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 Mission
You are Jim, a CIA agent in charge of super secret spies around the world. However, your enemies, the Naissurs, are highly trained in computer intelligence, and they can hack into your super secret communication systems. To contact your super secret spies, you must encrypt each message with a 16-c... | [] |
Objective
Given a grid of numbers, fill in the inequalities.
Assumptions
The number of columns and rows in the grid are equal.
The maximum size of the grid is 12x12.
The grid only consists of integers 0-9.
The output may contain a trailing newline.
The input is exactly as written below, including spaces and newlines.
E... | [] |
Robbers' challenge thread is here.
Cops' challenge: Design a programming language that appears to be unusable for programming, but admits computation (or at least completion of the task) through some non-obvious mechanism.
You should design a simple programming language that reads code from an input file and then does ... | [] |
Input
A list of between 1 and 255 positive integers (inclusive), each in the range 1 to 232 - 1 (inclusive).
Your input format does not need to be identical to the test cases.
Input without leading zeroes is required to be accepted.
Input with leading zeroes is not required to be accepted.
You may use whatever delimit... | [] |
Christmas is fast approaching and along with it, arranging the annual family Secret Santa. I'd like to try and get a head start on this, but making sure couples don't buy for each other keeps causing problems and despite doing this for years there's still the problem that Bob is pretty rubbish at buying gifts for most ... | [] |
When you round a number, if the next digit is >= 5 you add 1. For example:
3.1415926535 rounded to 1dp is 3.1
3.1415926535 rounded to 4dp is 3.1416 <-- Note the 5 changed to 6
3.1415926535 rounded to 5dp is 3.14159
3.1415926535 rounded to 9dp is 3.141592654 <-- Note the 3 changed to 4
You challenge is to receive ... | [] |
You saved the day with your prime sequence code, and the math teacher loved it. So much so that a new challenge was posed to the librarian (a/k/a, your boss). Congratulations, you get to code the solution so the librarian can once again impress the math teacher.
Start with the sequence of natural numbers in base-10, \$... | [
[
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... |
In a steam-punk multidimensional world, our boss wants to affix printed index labels to each drawer in our conglomerate's multidimensional file cabinet.
The boss wants to typeset the entire label sheet as a single form, using a font bought only for this purpose, so we have to order the sorts (metal symbol pieces). Sinc... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220... |
Introduction
In this challenge, your task is to write a program that decides whether two given trees are isomorphic.
A tree means a directed acyclic graph where every node has exactly one outgoing edge, except the root, which has none.
Two trees are isomorphic if one can be transformed into the other by renaming the no... | [] |
First post here! I recently participated in a small friendly competition and this was one of the questions:
A positive integer whose only prime factors are 2, 3, 5 or 7 is called a humble number.
The first 20 humble numbers are:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27
Write a program of... | [
[
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 you express some positive integer in binary with no leading zeros and replace every 1 with a ( and every 0 with a ), then will all the parentheses match?
In most cases they won't. For example, 9 is 1001 in binary, which becomes ())(, where only the first two parentheses match.
But sometimes they will match. For exam... | [] |
Write a program or function that takes in an odd positive integer N and a string of decimal digits (0123456789). The string represents a ten-state one-dimensional cellular automaton. Each digit occupies one cell and the update rule from one generation to the next is that every cell becomes the digit resulting from the ... | [] |
Inspired by this question:
Make a function (or a full program) that receives a list of numbers and outputs the list rearranged, so that even-indexed numbers appear first, and odd-indexed numbers follow. The values of the numbers themselves don't affect ordering - only their indices do. All indices are zero-based.
For e... | [] |
Background
Today (or Yesterday) is (or was) 11/23 or Fibonacci day! What better way to celebrate than to make a Fibonacci cake?
Examples
3
ii
i_i_ii_i_i
</>
8
ii
ii
ii
ii
ii ... | [
[
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... |
Goal:
Your goal is to print out numbers within a given range (Also including given values).
Input Format:
The input will look like:
(int-int, int-int, ...)
... meaning the user can add as many int-int as they'd like.
Other Info:
You will only have to handle non-negative integer numbers.
The first integer in int-int wi... | [] |
Given a non-negative number n, output the number of ways to express n as the sum of two squares of integers n == a^2 + b^2 (OEIS A004018). Note that a and b can be positive, negative, or zero, and their order matters. Fewest bytes wins.
For example, n=25 gives 12 because 25 can be expressed as
(5)^2 + (0)^2
(4)^2 + (... | [] |
Pretty simple challenge today:
Write a program or function that takes in a positive integer N and prints or returns a sorted list of the unique numbers that appear in the multiplication table whose row and column multiplicands both range from 1 to N inclusive.
The list may be sorted in ascending order (smallest to larg... | [
[
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... |
Time for another maze challenge, but not as you know it.
The rules for this challenge are a little different than most maze challenges. The tile types are defined as follows:
S: The location on the maze you start at
E: The location you are trying to get to
0: Wall that you can't cross
+: Floor that you can cross
You ... | [] |
There's quite a few challenges on this site that ask you to print out a sequence, and this is no exception.
(The following explanation of the sequence for this challenge assumes the symbols in the sequence are 0 and 1.)
The recursive definition of the Thue-Morse sequence is that
T_0 = 0
T_2n = T_n
T_2n+1 = 1 - T_n
A ... | [] |
Write a program or function that takes an array of non-negative integers as input and outputs a set of vectors/arrays with the elements of the input array in order, split so that each vector sums up to 15. If the sum of the first N elements doesn't "hit 15", then the number that made it pass 15 must be cut off, and the... | [] |
Inspired by https://puzzling.stackexchange.com/questions/24334/to-catch-a-thief
You are given an n by n (n itself is optional input) grid filled with 0s and 1s (or any other character of your choice). You aim is to make every cell the same (either 0 or 1). You can make a series of moves as defined below (note dissimila... | [] |
Inspired by this SO question
As input you will be given a non-empty list of integers, where the first value is guaranteed to be non-zero. To construct the output, walk from the start of the list, outputting each non-zero value along the way. When you encounter a zero, instead repeat the value you most recently added to... | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.