instruction_seed stringlengths 292 48.7k | found_ngrams listlengths 0 21 |
|---|---|
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... |
Introduction:
Although we have a lot of challenges where swapping two items in a list is a subtask, like Single swaps of an array; Swap to Sort an Array; \$n\$ swaps into a nop; etc., we don't have the simple challenge of just swapping two items given a list and two indices.
Input:
A list with some positive integers \$... | [] |
Prefix normal words arise in the context of binary jumbled pattern matching. A binary word \$w\$ consisting of \$0\$s and \$1\$s is said to be prefix normal * if, among all of its substrings, none contains more \$1\$s than the prefix of \$w\$ of the same length does. In other words, if \$w\$ contains \$n\$ \$1\$s then ... | [] |
Background
One kind of river-crossing problems involves two kinds of animals. One such problem reads like this: (all wordings, including animal species, are arbitrary)
A farmer has to cross a river with three chickens and three dogs. There's a boat which can only fit the farmer and at most two animals. On either side ... | [] |
Output the flattened version of the sequence A297359, which starts like the following:
1, 1, 1, 1, 2, 1, 1, 3, 3, 1, 2, 4, 6, 4, 2, 1, 6, 10, 10, 6, 1,
1, 7, 16, 20, 16, 7, 1, 3, 8, 23, 36, 36, 23, 8, 3, 3, 11, 31, 59,
72, 59, 31, 11, 3, 1, 14, 42, 90, 131, 131, 90, 42, 14, 1,...
----------------
1,
... | [] |
Challenge
Given two integer values \$a \ge 2\$ and \$0 \le b < a\$, generate a \$(2a-1) \times (2a-1)\$ matrix consisting of the integers 0, 1, and 2 as follows:
Create a checkerboard of 0s and 1s of the given size, corners being 0.
If \$b > 0\$, overwrite the checkerboard with 2s in the X shape at the center, each le... | [] |
Challenge
Generate the 2D sequence of bits of A141727. (Allowed I/O methods explained at the bottom.)
1
1 0 1
1 0 0 1 0
1 0 1 0 1 0 0
1 0 0 1 1 0 1 1 1
1 0 1 0 0 0 0 0 1 1 0
1 0 0 1 0 0 0 0 1 1 1 0 0
1 0 1 0 1 0 0 0 1 1 0 0 1 1 1
... | [] |
There is a division-free algorithm for computing determinants published by R.S.Bird in 2011 that uses only matrix multiplications. Given a \$n×n\$ matrix \$X\$, the matrix \$Y=μ(X)\$ is another \$n×n\$ matrix which entries are given by
$$Y_{i,j} = \begin{cases}
0 & \text{ if } j < i \\
X_{i,j} & \text{ if } j > i \\
-(... | [] |
A triplet of real tensors \$(A,B,C)\$ of size \$\gamma \times \gamma \times \sigma\$ represents a matrix multiplication algorithm with \$\sigma\$ elementary multiplications iff the following function evaluates to zero:
$$ \text{error}(A,B,C) \equiv \sum_{i,j,k,l,m,n=1}^\gamma\left(\sum_{r=1}^{\sigma}{A_{ij}^r B_{kl}^r ... | [] |
Similar to this.
Input a list and rotate N numbers in it given their indices. The following example uses 1-indexing, but feel free to use either.
In other words, take a list of indices and a list of numbers:
[1,2,3,4,5,6,7]
[1,3,6]
Separate out the elements at those indices:
[ 2 4 5 7]
1 3 6
Rotate those... | [
[
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 objective is to make the smallest SB3 file that can simply be imported into Scratch 3.0 without a "The project file that was selected failed to load" error. Any means can be used, like editing the JSON or better compression. Here's where I am with project.json, the only file inside mine:
{"targets":[{"isStage":true... | [] |
Background
A bijective base \$b\$ numeration, where \$b\$ is a positive integer, is a bijective positional notation that makes use of \$b\$ symbols with associated values of \$1,2,\cdots,b\$.
Bijective base 2 representations of positive integers look like this:
1 -> 1
2 -> 2
3 -> 11
4 -> 12
5 -> 21
6 -> 22
7 -> 111
8 -... | [] |
Background
J has trains similar to APL's. Given a sequence of verbs (functions), three rightmost verbs are grouped to form a derived verb (a fork) recursively, until one or two verbs remain. If the sequence has odd length, the entire train is a chain of forks. Otherwise, two verbs remain at the end, forming a hook.
... | [] |
Given a sorted array of unique positive integers \$A\$ \$(A_0<A_1<\cdots<A_{n-1})\$, and an integer \$t\$, where \$A_0\le t\le A_{n-1}\$. Output the value \$i\$ such that:
If \$t \in A\$, \$A_i=t\$.
If \$t \notin A\$, \$ \left(i-\left\lfloor i\right\rfloor\right)\cdot A_{\left\lceil i\right\rceil} +\left(\left\lceil i... | [] |
Consider all arrays of \$\ell\$ non-negative integers in the range \$0,\dots,m\$. Consider all such arrays whose sum is exactly \$s\$. We can list those in lexicographic order and assign an integer to each one which is simply its rank in the list.
For example, take \$\ell=7, s=5, m=4\$, the list could look like:
(0... | [] |
Consider a linear system of equations, in \$n\$ unknowns, expressed as
$$A \textbf x = \textbf b$$
where \$A \in M_{n,n}(\mathbb Z)\$ is an \$n \times n\$ matrix of integers, \$\textbf x\$ is a column vector of unknowns \$(x_1, x_2, \dots, x_n)\$ and \$\textbf b = (b_1, b_2, \dots, b_n)\$ is a column vector of integers... | [
[
15,
609,
220,
15,
24984,
220,
15,
609,
220,
16,
609,
220,
15
],
[
609,
220,
15,
24984,
220,
15,
609,
220,
16,
609,
220,
15,
24984
],
[
220,
15,
609,
220,
16,
609,
220,
15... |
Your task is to write a short program that represents a large (infinite) ordinal, using a well-ordering of the set of positive integers. Your program will take two different positive integers and indicate which one is greater in your chosen well-ordering. The order type of the well-order is the represented ordinal. 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 digit small number is a positive integer \$n\$ such for any two numbers that multiply to \$n\$, their total number of digits is more than the digits in \$n\$.
In otherwords: there are no two positive integers \$a\$ and \$b\$ such that:
\$
ab = n
\$
and
\$
\left\lfloor\log_{10}(a)\right\rfloor+\left\lfloor\log_{10}(b)... | [] |
Consider the \$4\$ divisors of \$6\$: \$1, 2, 3, 6\$. We can calculate the harmonic mean of these numbers as
$$\frac 4 {\frac 1 1 + \frac 1 2 + \frac 1 3 + \frac 1 6} = \frac 4 {\frac {12} 6} = \frac 4 2 = 2$$
However, if we take the \$6\$ divisors of \$12\$ (\$1, 2, 3, 4, 6, 12\$) and calculate their harmonic mean, we... | [] |
Task :
Wonky numbers are 3-or-more digit numbers that meet one or more of the following criteria:
Any digit followed by all zeros: 100, 70000
Same digit throughout the entirety of the number : 1111, 777777777
The digits are in consecutive ascending order : 1234, 1234567890 (for 0 see below)
The digits are in consecuti... | [] |
Introduction
In computer science, a literal is a notation for representing a fixed value in source code. Almost all programming languages have notations for atomic values, some also have notations for elements of enumerated types and compound values. Wikipedia
For example 1 usually represent an integer value, "Hello"... | [] |
Inspired by this Puzzling SE question: All distances different on a chess board.
Introduction
Lets define a sequence \$a(n), n\geqslant 1\$ as how many pawns can you put on a \$n \times n\$ chessboard in such a way that all the distances between two pawns are different.
Pawns are placed always in the centre of the squ... | [] |
A basis of a vector space \$V\$ is a set of vectors \$B\$ such that every vector \$\vec v \in V\$ can be uniquely written as a linear combination of the vectors in \$B\$. In other words, let \$B = \{\vec b_1, \dots, \vec b_n\}\$ be a basis of some vector space \$V\$. For every possible \$\vec v \in V\$, we can say tha... | [
[
7265,
90,
5187,
2555,
92,
856,
24984,
379,
1124,
408,
90,
5187,
2555
],
[
90,
5187,
2555,
92,
856,
24984,
379,
1124,
408,
90,
5187,
2555,
92
],
[
2555,
92,
856,
24984,
379,
1124,... |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
Related to AoC2015 Day 10.
Here's why I'm posting and not Bubbler
The Elves are playing a variation of the game called look-and-say. In plain look-and-say, they take turns making sequences by reading aloud the previous sequence and using tha... | [] |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
Related to AoC2015 Day 20, Part 1.
Here's why I'm posting instead of Bubbler and why not emanresuA
To keep the Elves busy, Santa has them deliver some presents by hand, door-to-door. He sends them down a street with infinite houses numbered ... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11,
323
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11... |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
The story continues from AoC2015 Day 24, Part 2.
Here's why I'm posting instead of Bubbler
To recap: Santa gives you the list of gift packages' weights. The packages must be split into multiple groups so that each group has the same weight, ... | [
[
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
]
] |
We all know how binary conversion works: the sequence of bits
$$ b_1, b_2, ..., b_{n-1}, b_n $$
encodes the number
$$ b_1 \times 2^{n-1} + b_2 \times 2^{n-2} + ... + b_{n-1} \times 2^1 + b_n \times 2^0 $$
This gives an unambiguous representation when we limit all bits \$ b_i \$ to be only 0 or 1.
...but what if we allo... | [] |
Following the theme of strange kitchen appliances, let's talk about my microwave.
Introduction
My microwave has a keypad that is laid out like this:
30 > 15
1 2 3
4 5 6
7 8 9
+/- 0 S/M
I can press the +/- and S/M keys to switch between adding and subtracting minutes or seconds.
The microwave starts in a... | [] |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
Related to AoC2017 Day 6.
A debugger program here is having an issue: it is trying to repair a memory reallocation routine, but it keeps getting stuck in an infinite loop.
In this area, there are n memory banks; each memory bank can hold any... | [] |
Your task is to input a sequence of integers and chunk sort it. You may assume the input list can always be chunked into groups of 1, 2, and 3.
Definition
Chunk sorting (a term I made up for the purpose of this challenge) is the action of first chunking a sequence into groups of 1, 2, and 3 in a cycle and then sorting ... | [
[
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
]
] |
Your challenge is to, given a positive integer n, count up to each digit of it, giving the effect of converging on it.
Basically, count up to the first digit of n by its place value (\$⌊\log_{10}\left(x\right)⌋\$). Then do the same for each subsequent digit, but with the values of the previous digits added.
Example imp... | [] |
The story continues from AoC2017 Day 22, Part 2.
The damn virus that was infecting a grid computing cluster now has jumped to a hexagonal computing cluster! In this cluster, the computers are connected in the honeycomb-like shape, and each computer has three neighbors.
.. .. ..
. .. .. .
.. .. ..
. .. .. ... | [
[
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 two binary vectors (containing two consistent values of your choice) of length \$n\$ and \$m\$, output a corresponding ascii-art hitomezashi stitching pattern.
You are to fill the following pattern, where \$n\$ is the number of A-columns and \$m\$ is the number of B-rows:
A A A A A
B+B+B+B+B+B
A A A A... | [] |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
The story continues from AoC2018 Day 7, Part 2.
Why I'm pxeger, not Bubbler
As soon as you and a few Elves successfully assemble the Sleigh kit, you spot another set of the same kit not so far away. But you noticed that the last Elf is slack... | [] |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
Related to AoC2018 Day 8.
The license file for an imaginary software system is defined as follows:
The entire file is a sequence of non-negative integers.
The entire file defines a tree of nodes.
Each node in the tree has the following fiel... | [] |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
The story continues from AoC2017 Day 11.
Crossing the bridge, you've barely reached the other side of the stream when you are overcome with a sense of deja-vu. "Haven't I done this already?" But before you can finish that thought, someone r... | [] |
Consider the array [5, 6, 8, 3, 9, 4, 2, 1, 7]. If we list how far each number has moved from it's (1-indexed*) index, we have (considering absolute distance):
Array: [5, 6, 8, 3, 9, 4, 2, 1, 7]
Index: [1, 2, 3, 4, 5, 6, 7, 8, 9]
Dists: 4 4 5 1 4 2 5 7 2
We can then group the elements of the array based on th... | [
[
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
]
] |
Consider a length-\$n\$ array of positive integers.
The complement of the element with index \$i\$ is the element with index \$n - i - 1\$.
The twin of an element \$a\$ is its complement after removing all elements not equal to \$a\$.
For example, in the array [1, 2, 3, 4, 2, 1, 3, 2], the complement of the first 2 i... | [] |
Part of Advent of Code Golf 2021 event. See the linked meta post for details.
Related to AoC2020 Day 13, Part 2.
Why Bubbler isn't posting this; Why Riker isn't posting this
A shuttle bus service runs between the sea port (where you are) to the airport (where you need to go). Each bus has an ID number that also indica... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
Consider some arbitrary polynomial with integer coefficients,
$$a_n x^n + a_{n-1}x^{n-1} + \cdots + a_1x + a_0 = 0$$
We'll assume that \$a_n \ne 0\$ and \$a_0 \ne 0\$. The solutions to this polynomial are algebraic numbers. For example, take the polynomial $$x^4 - 10x^2 + 1 = 0$$
We have that \$x = \sqrt 2 + \sqrt 3\$ ... | [
[
488,
264,
15159,
77,
12,
16,
92,
87,
47822,
77,
12,
16,
92
],
[
77,
12,
16,
92,
87,
47822,
77,
12,
16,
92,
488,
1124,
4385
],
[
16,
92,
87,
47822,
77,
12,
16,
92,
488... |
Let's say I have a non-empty list (array):
l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
I want to incrementally slice the list into incremented amount of elements per chunk.
For this array, my desired output is:
[[1], [2, 3], [4, 5, 6], [7, 8, 9, 10]]
What would be the best way to slice the array in multiple chunks.
This is c... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
This challenge is one of the two challenges which were planned for Advent of Code Golf 2021, but didn't fit into the 25-day schedule.
Related to AoC2020 Day 24, Part 2.
Given a binary configuration on a hexagonal grid, output the next generation of Hexagonal Game of Life using AoC rules:
A living cell survives if it ... | [] |
Let's say I've got a list (or array) of:
l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
I want to get the third Cartesian power of the above list, where we take every possible triple of elements from l.
Then I want to filter and only keep the sublists where the sum of that sublist equal to the maximum value of the list.
Then I 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
]
] |
Inspired by this StackOverflow post
Given a list where each element appears a maximum of 2 times, we can define it's "sortedness" as the sum of the distances between equal elements. For example, consider
[1,1,2,3,3] (array)
0 1 2 3 4 (indices)
The sortedness of this array is \$2\$. The distance between the 1s is \$1... | [] |
Inspired by this Stack Overflow post.
Given an ascending-sorted array of possibly duplicated integers, your goal is to increment each number by a counter, starting at 0, that resets for each group.
Spec:
Any numbers may be negative (but if so, they'll be at the beginning, because the array is sorted),
The array will h... | [] |
Add++, the Language of the Month, has the "collect" builtin as BC. Your task is to implement this builtin.
Consider a non-empty array, where each element is either:
A positive digit between 1 and 9 inclusive, or
A non-empty list of positive digits between 1 and 9
For example, all the following such arrays meet this ... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
Input a non-empty array of positive (greater than 0) integers. Output another non-empty array of positive integers which encode the input array. Output array does not use any numbers used in the input array.
Rules
Output array should not contain any numbers used in the input array.
Both input and output array may con... | [] |
This challenge is inspired by the High throughput Fizz Buzz challenge.
The goal
Generate a list of prime numbers up to 10,000,000,000,000,000. The output of primes should be in decimal digits followed by a newline character '\n' in ascending order starting from the lowest prime 2. You may not skip a prime number or out... | [] |
Given an integer n, find the next number that follows the following requirements:
The next greater number is a number where each digit, from left to right, is greater than or equal to the previous one. For example, 1455:
1<4
4<5
5<=5
The next greater number has to be bigger than n
Testcases
10 -> 11
19 -> 22
99 -> ... | [] |
Let's define a simple function \$f\$ which takes an integer and produces a list:
\$
f(n) = [g(1),g(2),\dots,g(n)] \\
g(n) = [f(0),f(1),\dots,f(n-1)]
\$
We can then calculate the first couple of values for \$f(n)\$:
0 ->
[]
1 ->
[[[]]]
2 ->
[[[]],[[],[[[]]]]]
3 ->
[[[]],[[],[[[]]]],[[],[[[]]],[[[]],[[],[[[]]]]]]]
4 ... | [] |
Inspired by this Mathematica.SE post
Given two positive integers \$n, k\$ with \$n > k \ge 1\$, output a binary \$n\times n\$ matrix such that every row and column contains exactly \$k\$ 1s, and the leading diagonal is all zero. This is the adjacency matrix of a regular graph.
You may output any valid matrix, and it do... | [] |
Let's build a sequence of positive integers. The rule will be that the next number will be the smallest number which:
It hasn't already appeared in the sequence
Its absolute difference from the number preceding it wouldn't be equal to any previous absolute difference between consecutive elements.
Task
Your task is t... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.