instruction_seed stringlengths 292 48.7k | found_ngrams listlengths 0 21 |
|---|---|
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... | [] |
The brethren from the order of St Golfus the Concise have a tradition of reciting a short prayer whenever they see someone make the sign of the cross. Due to the high level of sin measured among tourists recently, they have installed CCTV in the monastery, and they've hired you to help them keep old tradition alive in ... | [] |
There are n places set around a circular table. Alice is sat on one of them. At each place, there's a cake. Alice eats her cake, but it doesn't taste very nice. Then the Mad Hatter comes in. He gives Alice a list of n-1 numbers, each between 1 and n-1. For each item i in the list, Alice has to move around i places and ... | [] |
You are given an array A of n strictly positive integers, with n ≥ 2.
Your task is to map each entry Ai to:
1 if Aj mod Ai is odd for each j such that 1 ≤ j ≤ n and j ≠ i
2 if Aj mod Ai is even for each j such that 1 ≤ j ≤ n and j ≠ i
0 otherwise (mixed parities)
Example
For A = [ 73, 50, 61 ], we have:
50 mod 73 = ... | [] |
Most everyone here is familiar with Pascal's Triangle. It's formed by successive rows, where each element is the sum of its two upper-left and upper-right neighbors. Here are the first 5 rows (borrowed from Generate Pascal's triangle):
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
. . .
Collapse these rows to the left
1
1... | [] |
You will be given a square matrix of integers M and another positive integer n, strictly smaller than the size of M. Your task is to generate all square sub-matrices of M of size n.
For the purposes of this challenge, a square sub-matrix is a group of adjacent rows and columns contained in M.
Input / Output Formats
Yo... | [] |
Local periods
Take a non-empty string s.
The local period of s at index i is the smallest positive integer n such that for each 0 ≤ k < n, we have s[i+k] = s[i-n+k] whenever both sides are defined.
Alternatively, it is the minimal length of a nonempty string w such that if the concatenation w w is placed next to s so t... | [] |
The Challenge
Given a number, find the sum of the non-composite numbers in the Fibonacci sequence up to that number, and find the prime factors of the sum.
For example, if you were given 8, the non-composite numbers would be 1, 1, 2, 3, and 5. Adding these up would get 12. The prime factors of 12 are 2, 2 and 3, so you... | [] |
Introduction
Your task is to generate the first 1000 terms in the continued fraction representation of digit-wise sum of square root of 2 and square root of 3.
In other words, produce exactly the following list (but the output format is flexible)
[2, 6, 1, 5, 7, 2, 4, 4, 1, 11, 68, 17, 1, 19, 5, 6, 1, 5, 3, 2, 1, 2, 3,... | [
[
220,
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220
],
[
11,
220,
16,
11,
220,
16,
11,
220,
18,
11,
220,
21,
11
],
[
220,
16,
11,
220,
16,
11,
220,
18,
11,
22... |
I was at a friend's house for dinner and they suggested the idea of a "Prime-factor vector space". In this space the positive integers are expressed as a vector such that the nth element in the vector is the number of times the nth prime divides the number. (Note that this means that our vectors have an infinite numb... | [] |
A Brainfuck derivative
Let's define a simple Brainfuck-like programming language.
It has a two-directional tape of cells, and each cell holds one bit.
All bits are initially 0.
There is a moving head on the tape, initially at position 0.
A program is a string over the characters <>01!, executed from left to right, with... | [] |
Grouping takes a list and splits it into new lists of equal adjacent elements. For example
[1,1,2,1,1] -> [[1,1],[2],[1,1]]
If you then take the length of these groups you get a new list of integers
[1,1,2,1,1] -> [2,1,2]
Your task is to write a program that takes a list of positive integers and find the number of t... | [] |
This challenge is inspired by this, now deleted question.
Take a positive integer N as input, and output a matrix with the numbers 1 .. N2 that follows the pattern below:
Fill in the first row with 1 .. N then fill the last row (row number N) with (N+1) .. 2N, then fill the second row with (2N+1) .. 3N and continue un... | [] |
Challenge:
Input:
An integer n (> 0)
An integer-array a of size > 0 (which contains positive and negative values, but no zeroes)
Output:
First output the first n items
Then take the last item you've outputted (let's call it e), and go e steps forward if e is positive, or abs(e) steps backwards if e is negative. And ... | [
[
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 is to write the fastest code possible for computing the Hafnian of a matrix.
The Hafnian of a symmetric 2n-by-2n matrix A is defined as:
$$\operatorname{haf}(A)=\frac{1}{n ! 2^n} \sum_{\sigma \in S_{2 n}} \prod_{j=1}^n A_{\sigma(2 j-1), \sigma(2 j)}$$
Here \$ S_{2 n} \$ represents the set of all permutati... | [] |
Block shuffle sort
The block shuffle sort is a (rather artificial) method of sorting a list.
It works as follows, illustrated by an example.
[6, 1, 0, 3, 2, 4, -2, -1]
Break list into contiguous blocks
[6][1, 0][3, 2, 4][-2, -1]
Sort each block
[6][0, 1][2, 3, 4][... | [
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220
]
] |
We have many challenges based on base 10, base 2, base 36, or even base -10, but what about all the other rational bases?
Task
Given an integer in base 10 and a rational base, return the integer in that base (as an array, string, etc.).
Process
It's difficult to imagine a rational base, so let's visualize it using Expl... | [] |
This is a repost of an old challenge, in order to adjust the I/O requirements to our recent standards. This is done in an effort to allow more languages to participate in a challenge about this popular sequence. See this meta post for a discussion of the repost.
The Kolakoski sequence is a fun self-referential sequen... | [] |
A maze is given as a matrix of 0s (walls) and 1s (walkable space) in any convenient format. Each cell is considered connected to its 4 (or fewer) orthogonal neighbours. A connected component is a set of walkable cells all transitively connected to each other. Your task is to identify the cutpoints - walkable cells whic... | [] |
Given a triangulation of the surface of a polyhedron p, calculate its Euler-Poincaré-Characteristic χ(p) = V-E+F, where V is the number of vertices, E the number of edges and F the number of faces.
Details
The vertices are enumerated as 1,2,...,V. The triangulation is given as a list, where each entry is a list of the ... | [] |
The Challenge
Your program should take 3 inputs:
A positive integer which is the number of variables,
A set of unordered pairs of nonnegative integers, where each pair represents an equality between variables, and
A positive integer which represents the starting variable,
It should return a set of nonnegative integer... | [
[
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... |
Four integer sequences
In this challenge, you will test four different properties of a positive integer, given by the following sequences.
A positive integer N is
perfect (OEIS A000396), if the sum of proper divisors of N equals N. The sequence begins with 6, 28, 496, 8128, 33550336, 8589869056, 137438691328, 23058430... | [] |
The input is an array (or space-separated string, as you wish), zero-indexed, consisting of one strictly increasing array and one strictly decreasing array (in this order, not other vice versa), each having a length of 2 at least. Example is:
-10 -2 4 18 38 46 28 19 10
The goal is to write the fastest algorithm to fin... | [] |
The rules are as follows:
Take in a string of integers separated by spaces. Add the first and last numbers, the second and second-last numbers, and so on.
The program must output the numbers separated by newlines.
The program must handle negative numbers, but may not handle decimals.
If an odd amount of integers are i... | [] |
Alice (A) and Bob (B) decided to have a battle.
Each combatant has 10 health.
They take turns to roll a 6 sided die for damage.
That damage is removed from their opponent's health.
In the end either Alice or Bob, will vanquish their foe.
Show me how the battle went. Outputting these codes for the actions which have ... | [
[
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... |
Self-limiting lists
Consider a nonempty list L containing nonnegative integers.
A run in L is a contiguous sublist of equal elements, which cannot be made longer.
For example, the runs of [0,0,1,1,3,3,3,2,1,1] are [0,0], [1,1], [3,3,3], [2], [1,1].
The list L is self-limiting if for each integer N ≥ 1, the number of oc... | [] |
This challenge already describes dropsort. However, I'm kinda lazy and I really only need my array to be a bit more sorted than before, it doesn't need to be sorted all the way.
In Drop Sort, we drop every element less than any element before it. In Lazy Drop Sort, we drop every element less than the one strictly prece... | [] |
Inspired by this.
Agatha Stephendale, a sophomore who is really into raster graphics, has taken a course in linear algebra. Now she imagines matrices as rectangles, but in her artistic mind, she attaches diagonal lines to those rectangles and tries to compute traces along them. In fact, she wants to compute traces of a... | [] |
Overview
Given the integer representation of three elements in GF(2^64), give the product of the first two elements over GF(2^64) with the reducing polynomial defined as the polynomial m such that m(x) = x^64 + n(x), where n is the polynomial representation of the third element.
You want me to what?
A finite field GF(... | [] |
Your task is to accept as input two gene sequences, and a sequence of "cross over points", and return the gene sequence that results from the indicated cross overs.
What I mean by this is, say you have the sequences [A, A, A, A, A, A, A] and [Z, Z, Z, Z, Z, Z, Z], and cross over points of 2 and 5. The resulting sequenc... | [] |
In this simple challenge you are given an input array L of non-negative integers and a number of bins b greater than 0 but no more than the length of L. Your code must return a new array M whose length is b and which has binned the array L. This is easiest explained with examples.
L = [1,0,5,1] and b = 2 returns M = [1... | [] |
Introduction
For as long as programmers have been programming and as long as English teachers have been teaching, there's a controversy over the datasets called Arrays and Lists (or hashes).
Arrays have almost always had their first index at 0. Which, for the programmer, is understandable because of math. But along 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
]
] |
Background
IEEE 754 Double-precision floating-point format is a way to represent real numbers with 64 bits. It looks like the following:
A real number n is converted to a double in the following manner:
The sign bit s is 0 if the number is positive, 1 otherwise.
The absolute value of n is represented in the form 2**y... | [] |
Input:
A 2D array containing two distinct (optional) values.
I'll use 0 and 1 when explaining the rules. The input format is of course flexible.
Challenge:
Zeros are water, and ones are islands. In order to ensure loneliness, your task is to surround all islands with water by inserting rows and columns of zeros. You d... | [] |
Description :
Given a string of space separated binary digits or space separated booleans or an array of binary digits or array of booleans . Your job is to find the xor of each until you end up with one answer either 0 or 1. The inputs will always be valid and will only be either 0 or 1.
Example :
1 0 0 1 0 --> 0
1 0 ... | [] |
You're given the map of a cinema theatre as a boolean matrix: 0 represents a free seat, 1 - occupied. Each Finn who walks in chooses the seat farthest away (Euclidean distance) from the nearest occupied one, or if several such exist - the first among them in row-major order. Output a matrix showing the order seats will... | [] |
For a computer language, a reserved word is a word that cannot be used as an identifier, such as the name of a variable, function, or label. For other computer languages, keywords can be considered as the set of the language instructions.
Challenge
Using your language of choice, write a code in the chosen language that... | [
[
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... |
Recursively define a "valid arithmetic expression":
Any natural number is a valid arithmetic expression.
If s is a valid arithmetic expression, then so is (-s).
If p and q are valid arithmetic expressions, then so is (p+q).
In the above, a "natural number" is recursively defined as follows:
0 1 2 3 4 5 6 7 8 9 are n... | [] |
Back in the day, telephone autodialers used punched cards with one column for each digit of the number to be dialed. Columns had seven rows. The first three rows represented the numbers (1,2,3), (4,5,6), and (7,8,9) respectively. The last three rows rotated this arrangement by 90°: (1,4,7), (2,5,8), and (3,6,9). The mi... | [] |
Interleaved sequences represent an arbitrary merging of some number of sequences.
An interleaved sequence can be made by appending elements to a list one by one from some number of lists, choosing the next element from some list each time. Therefore, an interleaved sequence will contain exactly the same elements of all... | [
[
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... |
Take the numbers 0, 1, 2, 3, 4, ... and arrange them in a clockwise spiral, starting downward, writing each digit in its own separate square.
Then, given one of four distinct and consistent ASCII characters (your choice) representing an axis, and an input integer n, output the first n terms of the sequence described by... | [
[
220,
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220
]
] |
Write the shortest program or function which generates these 1000 numbers or a sequence (0- or 1-indexed) which begins with them.
[0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0,
1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1,
0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1,... | [] |
I've been recently playing through 'The Weaver' and I think it presents an interesting challenge for code-golf.
Premise:
The Weaver is a game wherein you are given a number of ribbons coming from 2 directions 90 degrees apart and your goal is to swap them at certain intersections to achieve a desired output.
Like th... | [] |
Today was AP exam registration day at my school, and while I was meticulously bubbling in the pages and pages of information required, the idea for this challenge hit me. So, given a string of letters and numbers, output an appropriately filled out bubble chart.
Rules:
For each character in the input string, replace t... | [] |
The input consists of i rows with neighbors information. Each ith row contains 4 values, representing the neighbor of i to the North, East, South and West directions, respectively. So each value represents a neighbor at the given direction of the ith row, starting from row 1, and can go up to 65,535 rows. The 0 value i... | [] |
This question is similar to Biggest Square in a grid.
Challenge
Given a matrix of 1 and 0 in a string format "xxxx,xxxxx,xxxx,xx.." or array format ["xxxx","xxxx","xxxx",...], You will create a function that determines the area of the largest square submatrix that contains all 1.
A square submatrix is one of equal widt... | [] |
Find the area of a region of unit cells given its perimeter loop as a sequence of 90-degree turns.
For example, take the three-cell region
XX
X
whose perimeter loop we draw
L<S<L
v ^
S R>L
v ^
L>L
Each turn is marked as left (L), straight (S), or right (R). Starting from the R, the turns are RLLSLSLL. So, given in... | [] |
Let's say that this array is how many press-ups I've achieved each day in the last 28 days:
[
20,20,20,30,30,30,30,
35,35,40,40,40,45,45,
50,50,50,50,50,50,50,
60,70,80,90,100,110,120
]
As you can see, it's taken a steep upward trend in the last week, and that's the part of this data I'm most interested in. Th... | [] |
This was inspired by a math problem I saw somewhere on the internet but do not remember where (UPDATE: The original problem was found on the math riddles subreddit with a proof provided that it is possible, also see this Math SE post), asking for a proof if the following process is possible for any arbitrary pair of in... | [] |
Let an 8x8 chessboard be represented by any two distinct values, with one value being an empty square and the other being a queen. In the following examples, I use 0s as the empty squares and 1s as queens. For example:
is given by
1 0 1 1 1 0 0 0
1 0 1 0 1 0 1 1
1 0 1 0 1 1 0 1
0 1 0 1 0 1 0 0
0 1 1 0 0 1 0 1
1 0 0 0 ... | [] |
Mölkky
Mölkky is a Finnish throwing game. The players use a wooden pin (also called "mölkky") to try to knock over wooden pins of almost similar dimensions with the throwing pin, marked with numbers from 1 to 12. The initial position of the pins is as follows:
(07)(09)(08)
(05)(11)(12)(06)
(03)(10)(04)
(01)... | [] |
Challenge
Let's imagine an N-tuple of integers between 0 and M inclusive, and let's call it F.
There are (M + 1) ** N possible Fs in total.
How many such Fs satisfy all of the following inequalities (index is one-based)?
F[n] + F[n+1] <= M for 1 <= n < N
F[N] + F[1] <= M
Write a program or function that takes two pos... | [] |
Imagine an arsonist walking around the town and picking its victims according to a very specific pattern (Or, alternatively, Imagine a bee flying around the garden and picking its flowers to pollenize according to a very specific pattern). Let's say the town is an N × N matrix, where N is an integer higher than or equa... | [] |
The 21 Hairstyles of the Apocalypse
Given a a list of numbers between 1 and 21 (or 0 and 20) output a "stitched together" drawing of the following faces (see rules for stitching information):
___ ,,, ooo === +++ ### -*~*-
(o o) (o o) ... | [] |
Given a nonempty list of positive integers \$(x, y, z, \dots)\$, your job is to determine the number of unique values of \$\pm x \pm y \pm z \pm \dots\$
For example, consider the list \$(1, 2, 2)\$. There are eight possible ways to create sums:
\$+ 1 + 2 + 2 \to +5\$
\$+ 1 + 2 − 2 \to +1\$
\$+ 1 − 2 + 2 \to +1\$
\$+ 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
]
] |
Input: An array I of k positive integers. The integers will be no larger than 100 and k ≤ 100.
Output: Your code must output all possible arrays O of non-negative integers of length k with the restriction that 0 ≤ Oi ≤ Ii. To get from one array to the next you may add or subtract 1 to one value in the array. Your co... | [] |
Given this list of all the words in english and a string with s_me missi_g lett__s, find one way to fill in the letters. Do note that some words on the list contain special characters (! & ' , - . /) and numbers
Input:
This list and a string with missing letters.
The input sentence can contain or be missing any of thes... | [] |
Challenge
Given an integer n ≥ 4, output a permutation of the integers [0, n-1] with the property that no two consecutive integers are next to each other. The value of a permutation pi is the sum of abs(pi[i] - i) for all indices i.
Examples
(1, 3, 0, 2) has value 6
(0, 2, 4, 1, 3) has value 6
(0, 2, 4, 1, 3, 5) ha... | [] |
You are probably familiar with the Fibonacci sequence where the first two terms are 0, 1 (or sometimes 1, 1) and every term after that is the sum of the previous two. It starts like this:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
Sometimes, the sequence contains numbers that have a particular pattern that I find int... | [
[
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... |
Consider the infinite matrix:
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
0 0 2 3 0 0 2 3 0 0 2 3 0 0 2 3
0 0 0 4 5 6 0 0 0 4 5 6 0 0 0 4 ...
0 0 0 0 7 8 9 10 0 0 0 0 7 8 9 10
0 0 0 0 0 11 12 13 14 15 0 0 0 0 0 11
...
Each new row of the matrix is co... | [] |
Challenge
Given a matrix of positive integers, determine if there are any "rings" of mountains. The formal definition for this challenge is: given a matrix of positive integers, is there any positive integer n for which there is a closed ring of cells in the matrix that are strictly greater than n such that all cells e... | [] |
Consider a one-dimensional sequence of numbers within a fixed range, i.e.
[1, 2, 4, 6, 8, 0, 2, 7, 3] in range [0, 10⟩
The Ever-Increasing Graph* ** is a line that connects all the points in this sequence left to right, and always goes upwards or stays level. If necessary, the line wraps around from top to bottom and ... | [
[
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
20
],
[
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
20,
11
]
] |
Your task is to write a program or a function that outputs n random numbers from interval [0,1] with fixed sum s.
Input
n, n≥1, number of random numbers to generate
s, s>=0, s<=n, sum of numbers to be generated
Output
A random n-tuple of floating point numbers with all elements from the interval [0,1] and sum of all el... | [] |
Given an integer matrix a and a nonnegative integer i, output a mapping b that maps the distinct values in the ith column of a to rows of a who have that value in the ith column.
You may assume that i is in the half-open range [0, num_cols(a)) (or [1, num_cols(a)] if you choose to use 1-based indices), and that all int... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
We all know that a lot of exercises only affect one half of your body, so you have to do them twice, once for each side. Such exercises have two counterparts, one for the left side and one for the right. However, there's no need to execute the two counterparts consecutively, as long as the exercises for both sides are ... | [] |
The task is taken from an MIT lecture by Prof. Devadas called You can read minds. A detailed explanation of the trick can be found in the linked video, or in this document. I'll try to explain it in simpler terms.
It turns out this was invented in the 1930's, and is known as the "Five-Card Trick of Fitch Cheney".
The ... | [] |
There's a type of n×n matrix W called the basic Weyr canonical form. Such a matrix is described by its blocks and has the following properties, using the following reference diagram:
the main diagonal blocks Wii are ni×ni matrices of the form λIni where Ini is the ni×ni identity matrix.
n1 ≥ n2 ≥ ... ≥ nr
the first s... | [] |
Definitions
The kth ring of a square matrix of size N, where 1 ≤ k ≤ ceiling(N/2) is the list formed by the elements of the kth and (N-k+1)th rows and columns, but without the first and last k-1 elements.
Example:
Matrix:
1 2 3 4 5
6 7 8 9 1
8 7 6 5 4
3 2 1 9 8
7 6 5 4 3
Delimited in rings:
+-------------------+
| ... | [] |
Given an array of numbers with length >=3 and length % 3 == 0
[1, 2, 3, 4, ...]
You will split it in sub-arrays of length 3
[[1, 2, 3], [4, 5, ...], [...
And return an array with
[0] => The amount of cases in the sub-array where all numbers are equal
[1] => In case all numbers in sub-array are not equal, the amount ... | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.