instruction_seed stringlengths 292 48.7k | found_ngrams listlengths 0 21 |
|---|---|
King of the Hill: Greed Control
What is Greed Control
Greed control is a multiplayer round-based game
in which in every round, a player bet a number inside
a specific range, say 1~100. Say 2 people betted 100,
then they'd both get 100/2 which is 50 points in
the game. Basically, the players that choose the same
numb... | [] |
Given a set of positive integers \$ S \$, output the set of all positive integers \$ n \$ such that \$ n \$ can be made by summing a subset of \$ S \$ in more than one different way, i.e., that are the sums of more than one subset of \$ S \$.
To be clear, a subset of \$ S \$ means that you can't use numbers from \$ S \... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
The Zany Car Game is a tile matching game. You are given a number of tiles, with coloured cars split into a top and bottom half. To win the game, you need to find a square arrangement of the tiles so that only whole, correctly coloured cars are formed at each tile join , like the image below.
Challenge
Given a square ... | [] |
Inspired by the recent 3Blue1Brown video
Consider, for some positive integer \$n\$, the set \$\{1, 2, ..., n\}\$ and its subsets. For example, for \$n = 3\$, we have
$$\emptyset, \{1\}, \{2\}, \{3\}, \{1,2\}, \{1,3\}, \{2,3\}, \{1,2,3\}$$
If we take the sum of these subsets, we can then ask ourselves the following ques... | [] |
In this question I asked you to determine if a run ascending list could be made. It was code-golf so naturally most the answers are very slow. But what if we want it to be fast. In this challenge I ask you to solve the same task except your goal will be to minimize asymptotic time complexity.
Here's the challenge re... | [] |
The "standard" polyhedral game dice have 4, 6, 8, 10, 12 and 20 sides. (Yes, I know that there are two 10-sided dice which together make a d100, but we're ignoring that right now.)
If I want to generate a random number between 1 and \$n\$ where \$n\$ is not one of those sides, I have a couple of options.
One option is ... | [] |
aka. implement an easier version of 05ab1e's canvas element.
Description
The canvas element is used to draw ASCII lines on the screen.
The (easier version of the) canvas element takes a list of integers and returns a multi-line string (or a list of strings).
The integers map to the following directions:
7 0 1
↖ ↑... | [] |
Given a multi-dimensional rectangular array of non-negative integers, pad it with the minimal number of zeroes so that only zeroes are "touching the edges" of the array, in every dimension.
The output must remain rectangular, have the same number of dimensions as the input, and be no smaller than the input.
Example
For... | [] |
Say I have a ragged list, like:
[
[1, 2],
[3,
[4, 5]
]
]
And I want to iterate over each item and delete it one-by-one. However, I don't know the structure of the list.
So, I have to iterate over the list, with the following algorithm:
Look at the first item of the list.
If it's a list, concatenate it to t... | [] |
Given a multidimensional, rectangular array and a list of dimensions, such as:
[ [1, 2],
[3, 4] ]
[3, 4]
Your challenge is to extend the matrix to the dimensions given in the list.
To extend an array to a length in a single direction, simply repeat its elements; for example, if we want to extend [1, 2, 3] to length... | [] |
Background
In the online graphing calculator Desmos, there is a certain shape that appears in the lower left portion of the graph in many high detail graphs, which the Desmos community has dubbed "Bernard". You can see an example of it in this graph and an isolated version of it in this graph. This shape is a consequen... | [] |
This is a simpler variant of my previous challenge Don't touch the walls!, as suggested by Jonah.
Given a multi-dimensional rectangular array of integers between 0 and 9, output all the elements which are "touching the edges".
Output is very flexible: it can be in any order, and may be flattened or partially nested, bu... | [] |
For this challenge, we will define the "complement" of a list of integers A as being any list B such that the union of A and B is a list of consecutive integers with no repeats.
In other words, B is the complement of A if
B has all of the integers between the minimum and maximum of A which are missing from A, and
B ha... | [] |
Related.
Given a list of 3 or more positive integers, remove every number X for which there is another number Y in the list and the average of X and Y is also in the list. In other words, if X, Y, and the average of X and Y are all in the input, neither X nor Y should appear in the output.
Note: Pairs of numbers are no... | [] |
Say I have a grid with some obstacles:
----
| X |
| |
|XX |
| |
----
I can fill this with numbers, as distance from the top left corner. But, because there are obstacles in the way some cells will take further to reach than a straight line:
----
|01X5|
|1234|
|XX45|
|7656|
----
This can be done through f... | [] |
Given a list \$X\$ of 2 or more integers, output whether, for all \$n\$ such that \$0 \leq n < length(X)-2\$, there exists a pair of equal integers in \$X\$ separated by exactly \$n\$ elements.
In other words: output whether, for all overlapping slices/windows of the input, there exists at least one slice/window of eac... | [] |
Background
In programming, there is a recursive algorithm called binary exponentiation, which allows for large integer powers to be calculated in a faster way. Given a non-zero base \$x\$ and a non-negative exponent \$n\$, the algorithm goes something like this (based on the example code from Wikipedia):
Function exp_b... | [] |
Background
When searches return many pages of results, GitHub avoids cluttering their UI by eliding page links. Instead, their UI lets you select:
Pages at the beginning of the results.
Pages near the current page.
Pages at the end of the results.
In this way, no more than 11 page links are ever displayed at one tim... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
In this challenge you will be given a list of positive integers which represents some range of integers which has been truncated for display. Your job is to find the missing bits and insert ellipses to show that that part has been truncated.
The input will always be strictly ascending and if two consecutive values dif... | [] |
If you place the positive integers together and read each set of two adjacent digits at the same time, you get: (A136414)
12, 23, 34, 45, 56, 67, 78, 89, 91, 10, 1, 11, ...
However, if you squash that sequence again:
12, 22, 23, 33, 34, 44, 45, 55, 56, 66, 67, 77, 78, 88, 89, 99, 91, 11, 10, 1, 11, 11
and so on.
Your... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
Background
I was working on a system where for convenience (not security) people could use four digit codes to identify themselves. I figured this is something that may actually be useful in many real cases, yet is well enough defined that it could make a nice challenge!
Explanation of pin codes and typo resistant sets... | [] |
Related
We start with the string a, and forever append to the string a comma followed by the string quote-escaped, where quote-escaping means doubling all quotes in a string, and then surrounding it with an additional pair of quotes.
In the first few steps we will get:
a
a,'a'
a,'a','a,''a'''
a,'a','a,''a''','a,''a'',... | [] |
Special String
We call a binary string \$S\$ of length \$N\$ special if :
substring \$S[0:i+1]\$ is lexicographically strictly smaller than substring \$S[i+1:N]\$ for \$ 0\leq i\leq N-2\$,
Note: \$ S[a:b] \$ is substring \$S[a]S[a+1]...S[b-1]\$
Given a binary string \$T\$ of length \$N\$ we are interested in the fi... | [] |
The exponential generating function (e.g.f.) of a sequence \$a_n\$ is defined as the formal power series \$f(x) = \sum_{n=0}^{\infty} \frac{a_n}{n!} x^n\$.
When \$a_0 = 0\$, we can apply the exponential function \$\exp\$ on this formal power series:
\$\begin{align}
\exp(f(x)) &= \sum_{n=0}^{\infty} \frac{1}{n!} f(x)^n ... | [
[
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,... |
Suppose you have an array with some known set of values (e.g. a string of \$0\$ and \$1\$) and you want to get all the locations of \$1\$s. Instead of storing a list of all the indices, if the \$1\$s come in "clumps" you can sometimes save space by storing starting and ending indices of "runs" of values -- i.e. substri... | [] |
Background
Here on CGCC, a commonly seen subgenre is radiation-hardening – writing a program that works even if one character is deleted. A similar problem is studied in the field of coding theory: finding an encoding that can be decoded even if one symbol is deleted from the encoded string. In this challenge, we're lo... | [] |
Searching for rotatable numbers, like: 68089
If you consider numbers upside-down,
6 looks like 9,
8 looks like 8,
9 looks like 6 and
0 looks like 0.
The others digits (1, 2, 3, 4, 5 and 7 ) look like nothing...
I wonder how many number could be rotatable between 0 and 1000! The answer is definitively 11: 0, 8, 69, 8... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
Solve the Greek Computer Puzzle Toy
There is a small toy of a series of stacked dials -- loosely inspired by the Antikythera Device. The puzzle, made by Project Genius, has a series of dials that must be arranged in a particular configuration to win. In this challenge, you will write a function/program to find that sol... | [] |
Given a positive input \$n\$, output all permutations of either \$\{0,1,\ldots,n-1\}\$ or \$\{1,2,\ldots,n\}\$.
Examples
Outputting permutations of \$\{1,2,\ldots,n\}\$.
Input
Output
1
[(1)]
2
[(1, 2), (2, 1)]
4
[(1, 2, 3, 4), (1, 2, 4, 3), (1, 3, 2, 4), (1, 3, 4, 2), (1, 4, 2, 3), (1, 4, 3, 2), (2, 1, 3, 4... | [] |
Given an undirected graph, find out if it is a tree.
A tree is an undirected graph in which there is exactly one path between any two vertices. In other word, the graph is both acyclic and connected.
Input
You can take input in any reasonable format. Here are some example formats:
an adjacency matrix, e.g., [[0,1,1,0]... | [] |
A perfect number is a positive integer whose sum of divisors (except itself) is equal to itself. E.g. 6 (1 + 2 + 3 = 6) and 28 (1 + 2 + 4 + 7 + 14 = 28) are perfect.
A sublime number (OEIS A081357) is a positive integer whose count and sum of divisors (including itself) are both perfect. E.g. 12 is a sublime number bec... | [
[
16,
17,
525,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220
],
[
220,
16,
17,
525,
220,
16,
11,
220,
17,
11,
220,
18,
11
],
[
17,
525,
220,
16,
11,
220,
17,
11,
220,
... |
Given a list of positive integers \$\mathcal I=I_1,I_2,I_3,...,I_n\$ and a base \$b>1\$ return their "carry-less sum", i.e. represent \$\mathcal I\$ in base \$b\$ and sum digit-by-digit discarding carry.
Worked example:
I = 13, 2, 9; b = 3
In base 3:
111
+ 2
+ 100
-----
= 210
and back to base 10:
desired out... | [
[
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
]
] |
easy mode of my previous challenge
A perfect number is a positive integer whose sum of divisors (except itself) is equal to itself. E.g. 6 (1 + 2 + 3 = 6) and 28 (1 + 2 + 4 + 7 + 14 = 28) are perfect.
A sublime number (OEIS A081357) is a positive integer whose count and sum of divisors (including itself) are both perfe... | [
[
16,
17,
525,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220
],
[
220,
16,
17,
525,
220,
16,
11,
220,
17,
11,
220,
18,
11
],
[
17,
525,
220,
16,
11,
220,
17,
11,
220,
... |
Level-index is a system of representing numbers which has been proposed as an alternative to floating-point formats. It claims to virtually eliminate overflow (and underflow, in its symmetric form) from the vast majority of computations.
The usual floating-point format internally represents a number \$x\$ in terms of a... | [] |
Introduction:
I'm old-fashioned and still read a physical newspaper in the morning while eating my breakfast. Although I don't like Sudoku that much, I do solve the Light-complexity ones, which are extremely easy. With these, I always try to solve all the numbers using only the Hidden Single technique†, in increasing o... | [] |
In a given 2d grid of positive integers (representing different types of "bubbles"), there are one of two actions that you can do each "step". You can either:
Pop an island (a connected group of bubbles - two bubbles that are diagonally adjacent are not considered connected) of the same type of bubbles, given that th... | [] |
Given a relation, and a domain, output whether the relation is an equivalence relation.
Context
For this challenge, a relation is defined as being a set of ordered pairs that is a subset of the cartesian product of a domain with itself. That is, \$R \subset X \times X\$.
For a relation \$R\$ to be an equivalence relati... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
The persistence of a number \$x = d_1d_2d_3...d_n\$, with \$d_1 \ne 0\$, under some function \$f : \mathbb N_0 \times \mathbb N_0 \to \mathbb N_0\$ is defined as the number of applications of \$f\$ to the digits of \$x\$ before it reaches a single digit integer. That is, if we have the map
$$I_f: (x = d_1d_2d_3...d_n) ... | [] |
Note: most of the questions that are already in existence about this topic only deal with two numbers as inputs. This question deals with any number (>1) of inputs.
GCD
The GCD (greatest common divisor) of a list of integers is the largest integer which divides all of the numbers in the list.
For example:
\$gcd(9, 12,... | [] |
Given the diagonals of a matrix, reconstruct the original matrix.
The diagonals parallel to the major diagonal (the main diagonals) will be given.
Diagonals: [[5], [4, 10], [3, 9, 15], [2, 8, 14, 20], [1, 7, 13, 19, 25], [6, 12, 18, 24], [11, 17, 23], [16, 22], [21]]
Rules
The matrix will be non-empty and will consis... | [] |
Carryless multiplication is an operation similar to binary long multiplication, but with XOR instead of addition:
1011 11
× 101 5
-----
1011
0
1011
------
100111 39
In this challenge, you'll be given a positive integer >= 2, and must return a list of all positive integers which are carryless factor... | [] |
Description
All cubic equations can be solved, and every cubic has at least one solution. The goal of this challenge is to find the real solutions to a given cubic using inputs, and (obviously) the smallest program size.
Rules
The solution must find the real solutions of a cubic correctly, using any method. The cubic m... | [
[
61,
18,
488,
44241,
61,
17,
488,
20716,
488,
294,
284,
220,
15
],
[
706,
61,
18,
488,
44241,
61,
17,
488,
20716,
488,
294,
284,
220
]
] |
inspired by Longest Increasing Substring
Task
Given a list of non-negative integers, output the length of its longest alternating subsequence.
An alternating sequence is a sequence of numbers which alternates between strictly increasing and strictly decreasing. [], [999], [9, 1], and [0, 5, 0, 3, 2, 4] are examples of ... | [] |
Given an array of \$n\$ positive integers we will say its self-sum order is the number of ways to add elements from it to make \$n\$. We will count ways as distinct up to associativity. So \$1+(2+3)\$ and \$(1+2)+3\$ are not counted as separate ways to make 6, but \$2+4\$ and \$4+2\$ are counted as separate. Two sums... | [] |
Determine whether a given sequence could be a winning sequence for the game shut the box.
Background
There are a few variants to this game, so I'll clarify the rules here. Play begins with 12 tiles (1 through 12) face up. Each turn the player rolls two six sided dice, and must then flip over one or more tile(s) which s... | [
[
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
]
] |
Ruby has a strange operator, .., called flip-flop (not to be confused with the range operator, which looks the same). Used in a loop, flip-flop takes two conditions as operands and will return false until the first operand is truthy, then return true until the second operand is truthy, whereupon it returns true one mor... | [] |
From the infinite triangular array of positive integers, suppose we select every 2nd numbers on every 2nd row as shown below:
$$
\underline{1} \\
\;2\; \quad \;3\; \\
\;\underline{4}\; \quad \;5\; \quad \;\underline{6}\; \\
\;7\; \quad \;8\; \quad \;9\; \quad 10 \\
\underline{11} \quad 12 \quad \underline{13} \quad 14 ... | [] |
The look-say sequence is a sequence of lists of numbers where each element is the previous element with run length encoding. Run length encoding is the process of grouping together like elements and then giving the element and the size of the group for each group. So for example:
1 1 1 2 2 1
To run length encode thi... | [] |
A Young diagram is a rectangular binary mask whose every row and every column are sorted in descending order.
It is easy to check that every rectangular binary mask can be formed by xor-ing together a finite number of Young diagrams.
This decomposition is by no means unique, but there will be a minimum number of Young ... | [] |
There exists a bijection between the natural and rational numbers that works (approximately) like this:
You create a 1-indexed 2-dimensional grid.
In every field of this grid with position (x, y), put the number x / y.
You start at (1,1) and iterate over the field in the following way:
However, this task is not abou... | [] |
Background
HQ0-9+-INCOMPUTABLE?! is a half-joke programming language introduced in Internet Problem Solving Contest 2011, Problem H.
HQ9+ is an esoteric programming language specialized for certain
tasks. For example, printing “Hello, world!” or writing a quine (a
program that prints itself) couldn’t be any simpler. U... | [] |
Given a non negative integer number tell if it can be erased by repeatedly removing all occurrences of the length of that number from it including overlapping matches.
Erasing means cancel all its digits.
For example the number 4440 is not lengthy because after removing all 4's you obtain 0 which cannot be erased.
Nei... | [] |
Inspiration
There is a problem on the most recent AMC 12B test, the one held on November 16, 2022, which goes like this:
(AMC 12B 2022, Question 17)
How many \$4\times4\$ arrays whose entries are \$0\$s and \$1\$s are there such that the row sums (the sum of the entries in each row) are \$1\$, \$2\$, \$3\$, and \$4\$,... | [] |
I like to play (The Settlers of) Catan on Board Game Arena with totally random number tokens. These tokens determine the production rate of the terrain tiles beneath:
There are 18 number tokens, two each of 3, 4, 5, 6, 8, 9, 10, 11 and one each of 2 and 12. A valid arrangement of these tokens on the board (19 hexes in... | [] |
Description
Inspired by this question, write a program/function to encode a number and a program (possibly the same as the first) to decode a bitstream in variable-length encoding as follows (taken from that question's answer, slightly modified):
Represent the string x using the following encoding:
$$0, x_k, \dots, 0,... | [] |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
Fen is a magician Elf. He can cast spells on an array of numbers to produce another number or array of numbers.
One of his inventions is the Wick spell. He loves to use this spell because "once this spell is applied, a combination of p... | [
[
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
]
] |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
Fen is a magician Elf. He can cast spells on an array of numbers to produce another number or array of numbers.
One of his inventions is the Wick spell. He likes this magic so much that he's cast it on every single array in sight. Now ... | [
[
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
]
] |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
The Elves like playing number games. One day, Bin (a friend of Fen) suggests a new game: given a positive integer n, each Elf says a number which has exactly n runs of ones in binary. The first Elf must say the smallest number, and the... | [] |
Introduction
In the binary representation of a \$k-\$bit \$(k>1)\$ square number \$n^2, \$ not all bits can be \$1\$. The maximum number of \$1\$-bits (Hamming weight, \$B\$ for short) is given in A357658, but only up to \$k=95\$ bits.
An example of a \$99\$-bit square is \$B(796095014224053^2)=87\$. The records in A35... | [] |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
It's Hanukkah! Unfortunately, it appears some of the candles in your menorah have been blown out. You've got a lighter on hand, but it doesn't work quite right. Whenever you use your lighter at position k, the candles at positions k-1,... | [] |
Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
Santa and the Elves are secretly preparing for a new tourist train service, called "North Pole Railroads". The train will travel through various sightseeing spots near the North Pole.
As a part of this project, they want to know how ma... | [] |
Title is an homage to this classic challenge
In Pip, the Scalar data type encompasses strings and numbers. A Scalar value is truthy in most cases. It is falsey only if:
It is the empty string ""; or
It is some representation of the number zero.
A Scalar is considered to be a representation of zero if:
It consists of... | [] |
Given a list of lists of positive integers, output a subset of them so their union forms a continuous non-empty range with no numbers missing. For example, consider this input:
[
[1, 2, 3, 5],
[2, 4, 6],
[7, 9, 11]
]
The union of the first 2 forms a continuous sequence: [1, 2, 3, 4, 5, 6] with no numbers miss... | [
[
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 the title of the Toggle some bits and get a square challenge.
In that challenge you output how many bits should be toggled, in order for the base-10 representation of the binary to become a square number.
Challenge:
In this challenge, you'll be given a bit-matrix \$M\$ and an integer \$n\$ as inputs.
Output... | [] |
In this challenge you will be tasked with implementing a sequence of natural numbers such that:
Each number appears a natural number of times
No two numbers appear the same number of times
No two numbers appear in the sequence next to each other more than once.
For some examples, the sequence
1,2,3,1,4,5,1,6,7,1,8,9,... | [] |
Your function must accept 2 strings which are correct numbers. It needs to sum them up (without rounding and floating point errors) and return the result (which is also a correct number) without any leading zeros in the integer part, trailing zeros in the decimal part and without minus if the answer is 0 i.e. -0 is not... | [] |
Suppose we have a sequence \$P\$. Every element \$P_n\$ represents the distance between the \$n^{th}\$ prime number and the average of the next two prime numbers.
For example, \$P_1\$ would be the distance between the first prime number (2) and the average of the next two prime numbers (3 and 5), so
\$P_1 = \frac{3+5}{... | [] |
It can be proven that there's exactly one string of infinite length that remain same after base64 encoding Vm0wd2QyUXlVWGxWV0d4V1YwZ...
Given a position, output the character on that position.
Your program would be run on AMD Ryzen 5 5500U@4GHz given 4GB memory and 1 minute (may decrease if RAM turns out to be hard lim... | [] |
Given a base as input, output all pan-digital numbers. A number is pan-digital if it includes every digit in that base at least once, possibly multiple times. Every number is considered to contain an infinite number of leading 0s.
sequence rules apply. Given a base, you may either:
Given an index, output the n-th pan-... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220... |
You are given a matrix of size m x n where each cell can contain either 1 or 0. You need to find the largest square submatrix that contains only 1's. The output should be the area of the largest square submatrix.
For example, given the following matrix:
1 0 1 1 1
1 0 1 1 1
1 1 1 1 1
1 0 0 1 0
The largest square submat... | [] |
Your task is to create a program or function, that when given an input list of nonnegative integers of length \$l \ge 2\$ and a nonnegative integer \$c\$ where \$2 \le c \le l\$, group the list into \$c\$ "clusters." What this means is, the average (population) variance* of all the groups should be as low as possible.
... | [] |
Challenge
Given a non-negative integer, find the sum of its digits.
Rules
Your program must take a non-negative integer as input.
Your program should output the sum of the digits of the input integer.
Your program should be able to handle inputs up to 10^100.
Examples
If the input is 123, the output should be 6 (1... | [] |
Description
Given an unsorted array of integers, find the smallest positive integer that does not appear in the array. Your task is to write the shortest code possible to solve this problem.
Input
A non-empty or empty array of integers, where the integers may be negative, zero, or positive.
Output
The smallest positive... | [
[
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
20,
11
]
] |
Typically, when we want to represent a magnitude and direction in 2D space, we use a 2-axis vector. These axes are typically called X and Y:
This isn't always convenient, however. The game BattleTech is played on a hexagonal grid, and it's convenient for the axes to line up with the sides of the hexagons. To represent... | [
[
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 permutation, we can define its high-water marks as the indices in which its cumulative maximum increases, or, equivalently, indices with values bigger than all previous values.
For example, the permutation \$ 4, 2, 3, 7, 8, 5, 6, 1 \$, with a cumulative maximum of \$ 4, 4, 4, 7, 8, 8, 8, 8 \$ has \$1, 4, 5\$ as... | [] |
It's easier to put this into coding terminology, so here we go:
First find the average, median, mode, and range.
Then, put those values in another array, then find the new average, median, mode, and range.
Bonus -10 bytes (yeah, negative bytes, because there's already answers) for programs that can handle this many ti... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
Take the sequence of all natural numbers in binary, (1, 10, 11, ..) then write them vertically beside each-other like this (least significant bit on top; 0s have been replaced with spaces):
1 1 1 1 1 1 1 1 1
11 11 11 11
1111 1111
11111111
11
Notice there are areas of connected 1s in the... | [] |
Nerdle is a Wordle variant, in which instead of words, the answers are equations. Each equation entered in the game must be a valid one.
Examples: 13³-1=2196, (1/1)²*8=8, (((3)))²=9
The task is to generate and output to a .txt file, one equation per line, all possible 10 character equations that could be an answer for ... | [
[
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... |
Voronoi diagram is a partition of a plane (or part of plane) into regions close to each of a given set of objects ("seeds").
Here we’ll be dealing with discrete arrays or even rather with ASCII-art:
2 2 4 4 4 4 1 1 1 1 1 1 1 3 3 3 3
2 2 4 4 4 1 1 1 1 1 1 1 3 3 3 3 3
2 2 4 4 4 1 1 1 1 1 1 3 3 3 3 3 3
2 2 2 4 1 1 1 1 1 1... | [] |
This question is an extension of Who's that Polygon? to arbitrary numbers of sides.
A fundamental polygon for a surface is an polygon with a prescribed pairing for all its \$2n\$ sides, each marked with an arrow, such that identifying the sides according to this pairing and the arrow directions produces the surface (up... | [
[
220,
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220
]
] |
This challenge arises from a claim made in a MathOverflow answer and a paper linked in that answer which seems to back up the claim:
Searching for triangular embeddings is much quicker than enumerating over all embeddings… In fact, Jungerman was able to find a triangular embedding of \$K_{18}-K_3\$ in about half an ho... | [] |
This is a sequel to Ragged list pattern matching. In this challenge, the wildcard may match a sequence of items of any length instead of just a single item.
Given a pattern and a ragged list of integers, your task is to decide whether the pattern matches the ragged list.
The pattern is also represented by a ragged list... | [] |
Problem author: https://stats.ioinformatics.org/people/5815
You are given a system with a hidden permutation of the numbers \$1, 2, 3, \ldots, n\$. Your task is to guess this permutation by asking the system a series of questions.
Each question consists of providing the system with a permutation of the numbers \$1, 2, ... | [] |
(Inspired by this challenge.)
Given six real values in three pairs: \$(x_1, x_2), (y_1, y_2),\$ and \$(x_0, y_0)\$, where \$x_1 < x_0 < x_2\$ and \$y_1 < y_0 < y_2\$, create a function which maps between \$(x_1, x_2)\$ and \$(y_1, y_2)\$ which also passes through \$(x_0,y_0)\$. In other words, make some function
$$f: ... | [] |
Non-metals typically* have a fixed number of covalent bonds in every chemical they are part of. Given the number of bonds every element requires, output whether it's possible to construct a single molecule from the given chemicals, such that every atom has it's desired number of bonds.
In other words, output if it's po... | [] |
Given a string s consisting of characters a-z lowercase, generate 5 arrays a1, a2, a3, a4, and a5 of size n (length of s) where the i-th element of each array represents the index of the next occurrence of the i-th character in s, with the following conditions:
If no such occurrence exists, set the value to n (0-based... | [] |
Challenge:
A Frog List is defined by certain rules:
Each frog within a Frog List has an unique positive digit [1-9] as id (any 0 in a list is basically an empty spot, which can mostly be ignored).
A Frog List will always have exactly one Lazy Frog. A Lazy Frog will remain at its position.
Every other frog in a Frog Li... | [] |
You are the sonar captain aboard an underwater submarine. The way sonar works is that every submarine sends out a ping at regular intervals. Each interval is a whole number of seconds. Each submarine has an identifying amplitude, that is no two submarines send out pings at the same amplitude. The amplitude is always a... | [] |
The Greatest Common Divisor, or gcd, of two positive integers \$x\$ and \$y\$ is the largest positive integer that divides both \$x\$ and \$y\$.
The Least Common Multiple, or lcm, of two positive integers \$x\$ and \$y\$ is the smallest positive integer that is a multiple of \$x\$ and \$y\$.
We define the Least Uncommo... | [] |
In this challenge, you're given a list of overlapping waves. Each wave is a finite list with n truthy values, then n falsy values, then n truthy and so on, where n is the wavelength (or half the wavelength I guess, but it really doesn't matter in this challenge). The values of a wave may have an offset, so a wave of wa... | [] |
Related but noticeably different
You are the leader of the guard in the dungeon of an ancient castle.
There are N doors in the dungeon and N guards with keys.
Guard with index i may operates with doors
that have multiple indexes:
i, 2 * i, 3 * i, ...
The way he operates is very dumb: he just toggles state of the door:... | [
[
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 idea is based on this interactive game. Given a set of eight decimal digits which are not necessarily distinct, your task is to find a hyperjump trip with the specified length.
But what is a hyperjump? I ain't got time to click on HOW TO PLAY
Ok, you have a set of eight digits where none is 0 or 9. Let's say [1, 3,... | [] |
Part I
Previous part was considered encoding of non-empty nested lists with a positive integer.
Reminding the coding procedure \$G(x)\$:
If \$x\$ is a number, \$G(x) = 2^x\$
If \$x\$ is a list \$[n_0, n_1, n_2, n_3, …]\$, \$G(x) = 3^{G(n_0)} \cdot 5^{G(n_1)} \cdot 7^{G(n_2)} \cdot 11^{G(n_3)} \cdot...\$
Bases are cons... | [] |
The problem statement here is pretty simple, take two real numbers on the range [0,1) as input and output their sum, with probability 1.
The catch here is that there are a lot of real numbers. There are in fact so many real numbers that it is impossible to fit all of them into any finite data type. As such, any way to ... | [] |
A Hankel matrix is a square matrix in which each ascending skew-diagonal from left to right is constant, e.g.:
$$\begin{bmatrix} a & b & c & d \\ b & c & d & e \\ c & d & e & f \\ d & e & f & g \end{bmatrix}.$$
Given a sequence of integers \$\{a_n\}\$, we can construct a sequence of Hankel matrices \$\{H_n\}\$, where \... | [] |
Background
Being in a philosophical mood, I remembered one old idea. I think it is suitable for CG.
Duplicates are not found, but it's of course just a kind of totalistic cellular automaton or erosion.
Given an infinite board filled with empty (let 0) cells. We create a figure - a finite set of non-empty (let 1) cells.... | [] |
You may have seen something called a "perpetual dice calendar":
Two 6-sided dice can be rearranged and rotated. One die has the numbers 0, 1, 2, 3, 4, and 5. The second die has the numbers 0, 1, 2, 6, 7, and 8. With this, any day of the month—from 1 to 31—can be displayed on the front of the calendar. The 6 can be rot... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
This is my first codegolf post so let me know if I have missed anything. Thanks :)
Description
You are given a list of numbers with 2 < n <= 6 length i.e. [1, 10] or [75, 9, 9, 8, 2, 100]. Given the basic operators + - / * you must try and generate all possible equations. The list of numbers to pull from is: [1, 1, 2, ... | [] |
Euclidean distance between two lattice points \$(x_1, y_1)\$ and \$(x_2, y_2)\$ on a plane is: \$\sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2}\$.
Imagine now a lattice N x N replicated infinitely many times next to itself. The two points \$(x_1, y_1)\$ and \$(x_2, y_2)\$ also get replicated. Euclidean distance on a torus is t... | [
[
17,
29776,
17,
488,
320,
88,
62,
16,
481,
379,
62,
17,
29776
],
[
29776,
17,
488,
320,
88,
62,
16,
481,
379,
62,
17,
29776,
17
],
[
481,
856,
62,
17,
29776,
17,
488,
320,... |
Although it's done a few times as sub-challenge of a larger challenge, and we also have a challenge to remove the borders of a square matrix, I couldn't find a challenge to output the borders of a given matrix, so here it is.
Challenge:
Given a rectangular-shaped matrix containing integers as input, output its borders.... | [
[
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.