instruction_seed stringlengths 292 48.7k | found_ngrams listlengths 0 21 |
|---|---|
<< Prev Next >>
Challenge
Now that Santa has finally figured out how to get into his present vault, he realises that somehow the elves got in there before him and stole some of his presents! They haven't figured out how to leave the vault yet though, so Santa has to try and catch them all. Santa and the elves both have... | [] |
<< Prev Next >>
Unfortunately, Santa was not able to catch the elves in time! He has to go back to manufacturing presents now. Since the elves are definitely not Santa's slaves, he has to figure out the expenses for how much to pay them.
Challenge
Given some information for the presents, determine the cost of manufactu... | [] |
A traditional Western die is a cube, on which the integers 1 to 6 are marked on the faces. Pairs that add to 7 are placed on opposite faces.
As it is cube, we can only see between 1 and 3 faces (inclusive)1 at any given time. Opposite faces can never be seen at the same time.
Your task is to write a program or function... | [
[
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
]
] |
<< Prev Next >>
Thanks to the PPCG community, Santa has managed to remanufacture all of his presents and after the assembly line, the presents are now ready to be moved into the transport docks!
Each of Santa's transport docks only holds a range of present sizes because the transport sleighs are specialized for a speci... | [
[
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 half-exponential function is one which when composed with itself gives an exponential function. For instance, if f(f(x)) = 2^x, then f would be a half-exponential function. In this challenge, you will compute a specific half-exponential function.
Specifically, you will compute the function from the non-negative integ... | [] |
<< Prev Next >>
After some careful analysis, Santa was able to determine the dock size ranges and get the presents into the correct transportation dock.
Now, he needs you to help him balance out the transportation carts and place the presents in them in the most balanced fashion.
Challenge
You will be given the size of... | [] |
A follow-up to this challenge
Given a set of mixed dice, output the frequency distribution of rolling all of them and summing the rolled numbers on each die.
For example, consider 1d12 + 1d8 (rolling 1 12-sided die and 1 8-sided die). The maximum and minimum rolls are 20 and 2, respectively, which is similar to rolling... | [
[
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
]
] |
<< Prev
Thanks to the PPCG community, Santa now has balanced his storage carts. Now, he needs to move them into the transport docks so that they can be sent to the loading bays. Unfortunately, the tracks to move the carts around are a mess, and he needs to figure out how to get them all around without them crashing tog... | [
[
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
]
] |
For another challenge I am writing, I need to verify that test cases are solveable with bounded integers. Specifically, I need to verify the following, for a non-empty array of integers A and an integer bit width n:
All integers a in A satisfy -2**(n-1) <= a < 2**(n-1) (representable with n-bit two's complement intege... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
This challenge posed an algorithm for encoding an integer n as another integer r. What follows is a succinct explanation of that algorithm, using n=60 as an example.
The original algorithm
First, we encode the number as a string of brackets.
If n = 1, return an empty string.
Otherwise, we take n's prime decomposition... | [] |
The characteristic polynomial of a square matrix \$A\$ is defined as the polynomial \$p_A(x) = \det(Ix-A)\$ where \$I\$ is the identity matrix and \$\det\$ the determinant. Note that this definition always gives us a monic polynomial such that the solution is unique.
Your task for this challenge is to compute the coeff... | [] |
Unary numbers typically only represent nonnegative integers, but we can extend them to represent all integers as follows:
A positive integer N is represented as N 1's: 5 -> 11111
A negative integer -N is represented as a 0 followed by N 1's: -5 -> 011111
Zero is represented as 0
We can then represent a list of these ... | [] |
To check whether a list of non-negative integers is balanced, one can imagine putting respective weights on a board and then try to balance the board on a pivot such that the summarized relative weights left and right of the pivot are the same. The relative weight is given by multiplying the weight with its distance to... | [
[
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
]
] |
Definition
An arrowhead matrix is a matrix that has all entries equal to 0, except the ones on the main diagonal, top row and leftmost column. In other words, the matrix should look like this:
* * * * * *
* * 0 0 0 0
* 0 * 0 0 0
* 0 0 * 0 0
* 0 0 0 * 0
* 0 0 0 0 *
Where each * is any non-zero entry.
Task
Given a squa... | [] |
This has no practical purpose but it could be fun to golf.
Challenge
Given a number n,
Count the amount of each digit in n and add 1 to each count
Take the prime factorization of n
Count the amount of each digit in the prime factorization of n, without including duplicate primes
Create a new list by multiplying togeth... | [] |
Introduction
You have a friend that keeps asking you for loans and you are getting tired of it. Today, he came for a loan again. Instead of turning down his offer, you get a great idea: troll your friend by giving him as many coins/bills as possible.
Challenge
You will take as input: the amount of money your friend wa... | [] |
A doubly linked list is a data structure in which each node has a value as well as "links" to both the previous and next nodes in the list. For example, consider the following nodes with values 12, 99, and 37:
Here, the nodes with values 12 and 99 point to their respective next nodes, with values 99 and 37. The node w... | [
[
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... |
Challenge
Given a non-negative integer, output whether it is possible for two dates (of the Gregorian calendar) differing by exactly that many years to share a day of the week. A year is assumed to be a leap year either if it is divisible by 4 but not by 100, or if it is divisible by 400.
Output may be:
falsey/truthy ... | [] |
It is well known that odd primes will appear in Pascal's triangle exactly twice. However, not all numbers that appear exactly twice in Pascal's triangle are prime. We'll call these numbers Pascal primes.
Pascal primes are composite numbers that appear exactly twice in Pascal's triangle. The first few Pascal primes are... | [
[
11,
220,
16,
17,
11,
220,
16,
19,
11,
220,
16,
21,
11
],
[
220,
16,
17,
11,
220,
16,
19,
11,
220,
16,
21,
11,
220
]
] |
Inspired by Taken from a question at Stack Overflow.
The challenge
Given an integer n>1, output all arrays that can be obtained by swapping exactly two entries in the array [1, 2, ..., n].
The arrays can be produced in any order.
You can consistently use [0, 1, ..., n-1] (0-based) instead of [1, 2, ..., n] (1-based).
A... | [] |
Challenge
Given a grid like this,
1 2 3 4 5 6 7 8
1 . . . . . . . .
2 . # . . . # . .
3 . . . . . . . .
4 . . . . . . . .
5 . . . . . . . .
6 . . # . . . . .
7 . . . . . . . .
8 . . . . . . . .
write a piece of code that can determine the size of the largest square that does not include a '#'. (The answer to this in... | [] |
The Task
Given an input positive integer n (from 1 to your language's limit, inclusively), return or output the maximum number of distinct positive integers that sum to n.
Test Cases
Let f define a valid function according to the task:
The sequence for f, starting at 1:
1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5... | [] |
Introduction:
At home we have a clock that strikes the stated amount at each hour, but also strikes once at every half-hour. So from 0:01 to and including 12:00 it strikes in this order:
1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12
Challenge:
Given an integer n, output a list of time-frame... | [] |
The Collatz conjecture postulates that if you take any positive integer, then repeat the following algorithm enough times:
if number is odd, then multiply by three and add one
if number is even, then divide by two
you'll eventually end up at 1. It seems to always work, but it's never been proven that it always does.
Y... | [] |
Ethereum is a blockchain platform. It has its own native cryptocurrency, ether, but in this challenge, we'll be focusing on its ability to run smart contracts.
The ERC-20 standard describes an implementation of fungible tokens within a smart contract. Some examples of this implementation are EOS, OmiseGo, and the Golem... | [] |
Given two positive integers A and B, return the position p that minimises the number of prime factors (counting multiplicities) of the resulting integer, when B is inserted in A at p.
For example, given A = 1234 and B = 32, these are the possible insertions (with p being 0-indexed) and the corresponding information abo... | [] |
Note: The title of this question should be "Loop It", but because title needs to be at least 15 characters, there are some invisible spaces. This note is such that the challenge can be searched for.
Challenge
Given a finite list of unique integral points in the plane, find a polygon whose vertices are exactly those... | [] |
A positive integer x is a square triangle number iff there are two different positive integers, y and z, which are smaller than x such that all of the sums
x + y
x + z
y + z
are perfect squares.
For example 30 is a square triangle number because
30 + 6 = 62
30 + 19 = 72
6 + 19 = 52
Your task is to write some code that... | [] |
Challenge
Write a program that takes an 11x11 array of integers, and constructs a 3D ASCII block building, where each value in the array represents the height of a column of blocks at the coordinates matching the array position. A negative height is a "floating" column - only the top block is visible.
Example
... | [] |
When multiplying monomials in the Milnor basis for the Steenrod algebra, part of the algorithm involves enumerating certain "allowable matrices".
Given two lists of nonnegative integers r1, ... ,rm and s1, ... ,sn, a matrix of nonnegative integers X
is allowable if
The sum of the jth column is less than or equal to... | [] |
Inspired by this Math.SE question.
Background
The Fibonacci Sequence (called F) is the sequence, starting 0, 1 such that each number (F(n)) (after the first two) is the sum of the two before it (F(n) = F(n-1) + F(n-2)).
A Fibonacci Sequence mod K (called M) is the sequence of the Fibonacci numbers mod K (M(n) = F(n) % ... | [
[
16,
11,
220,
16,
17,
11,
220,
16,
19,
11,
220,
16,
21
],
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
16,
17,
11,
220,
16,
19,
11,
220,
... |
Given a list of hole yardages, green sizes, a slice angle and a max distance, compute a golf score.
Assumptions
Earth is flat
All greens are circular
Slice angle will be between -45 and 45 degrees and will be given in degrees
All distances in the same metric (yards or meters, doesn't matter)
No out of bounds, obstruct... | [] |
Inspiration.
Given (by any means):
A two-argument (or single argument consisting of a two-element list) black box function, f: ℤ+ × ℤ+ → ℤ+ (input and output are 1, 2, 3,…)
A strictly positive integer matrix with at least two rows and two columns
return the matrix's function trace.
What is a function trace?
A normal ... | [] |
Challenge:
Input: Three integers: bottom-edge length; starting amount of grains of sand; index
Output: Output the state of the bottom part of an hourglass at the given index, based on the given bottom-edge length and amount of grains of sand.
Challenge rules:
We simulate the grains of sand with digits 1-9
We put the c... | [] |
Introduction
Output all the numbers in specific base that would appear in an adapted version of the game of seven.
Challenge
Your task is to output all the numbers in a given base in a given range, skipping the ones matching certain conditions.
You will be given four inputs: base elim start and end. The roles of the f... | [] |
Input is an r by c matrix of non-negative integers (you may input r and c as other parameters if this helps with golf). This may be inputted as a 2D array or, if you prefer, a 1D array (though taking in r this time is necessary). Strings separated by spaces to distinguish rows and newlines to distinguish columns are al... | [] |
Input:
A matrix containing integers in the range [0 - 9].
Challenge:
Determine if all non-zero elements are connected to each other vertically and/or horizontally.
Output:
A truthy value if all are connected, and a falsy value if there are non-zero elements/groups that aren't connected to other elements/groups.
Test ca... | [] |
This challenge is from an admission test to a closed number cyber security course. Anyway it doesn't have to do with cyber security, it's just to test the students logical and coding skills.
Task
Write a program that removes entries from an array so that the remaining values are sorted in a strictly decreasing order an... | [] |
Apparently yes! In three easy steps.
Step 1
Let f(n) denote the prime-counting function (number of primes less than or equal to n).
Define the integer sequence s(n) as follows. For each positive integer n,
Initiallize t to n.
As long as t is neither prime nor 1, replace t by f(t) and iterate.
The number of iterations ... | [] |
As computer scientists, you're probably all familiar with the basic list operations of pop and push. These are simple operations that modify a list of elements. However, have you ever heard of the operation flop? (as in flip-flop)? It's pretty simple. Given a number n, reverse the first n elements of the list. Here's a... | [
[
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 task is to model the effects of batter on pieces of food. Please add three layers of crust.
[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0], // in
[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0],
[0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,1,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0],
[0,0,0,0,0,0,0,0... | [] |
Task
Given a list of integers L and another integer s, the goal is to compute the column-wise sums of all s-length (potentially overlapping) slices of L, while pertaining their positions relative to L (see below).
Definitions
The s-length (overlapping) slices of the list L are all the contiguous subsequences (without w... | [
[
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 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.