instruction_seed stringlengths 292 48.7k | found_ngrams listlengths 0 21 |
|---|---|
We are going to fold a list of integers. The procedure to do so is as follows, If the list is of even length, make a list of half of its length where the nth item of the new list is the sum of the nth item of the old list and the nth-to-last item of the old list. For example if we had the list
[1 2 3 4 5 6 7 8]
We ... | [] |
Given a positive integer n as input, output the reversed range sum of n.
A reversed range sum is created by making an inclusive range up to n, starting with 1 and including n, reversing each of the numbers inside, and summing it.
Example:
Here is what would happen for an input of 10:
Range: [1,2,3,4,5,6,7,8,9,10]
Rever... | [] |
Oh no, I am lost on the way to finding the great treasures of Marakov! And all I have are these useless instructions that look like S10R10D30... I have no idea what they mean! Can you help me?
Challenge
Given directions consisting of N E S W U D L R 1 2 3 4 5 6 7 8 9 0, output how far I will be from where I started whe... | [] |
Inspired by this, this and this.
So, now that the evil farmer has set your field on fire, you naturally want to put it out. You have a bunch of friends who all have buckets, and you want a program to figure out where to place everyone to save as much of your wheat as possible.
Your Task:
Write a program or functio... | [] |
Given an unsigned 16-bit integer N, your task is to determine whether its binary representation mapped inside a 4x4 matrix is matching a tetromino shape, and if so, which shape it is.
Matrix
Each bit of N is mapped inside a 4x4 matrix, from left to right and from top to bottom, starting with the most significant one.
E... | [] |
Lost is a 2-D programming language where the start position and direction of the ip are entirely random.
This makes it very difficult to make deterministic Lost programs. However today we are not writing a deterministic program, we are writing an RNG.
Write a Lost program that takes no input and outputs a single digit... | [] |
Challenge description
In taxicab metric, a distance between two points is defined as:
Consider a matrix with only zeros and ones:
0 0 0 1 0
1 0 0 0 0
0 0 0 0 0
1 0 0 1 0
1 0 0 0 0
Let's map each 1 to the distance to nearest different 1 in the matrix (of course, assuming that distance between two adjacent rows/column... | [] |
Challenge
Here at PPCG, we sure do like our sequences, so here's a fun another one.
Let's define a(n) as being the smallest non-negative integer X that is not equal to any a(k) (0 < k < n), and a(n-1) and X do not share any decimal digits. a(0) = 0
Given an input n > 0, output such a(n).
For example, for input n = 13, ... | [
[
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... |
Everybody knows pi the mathematical constant, the ratio of a circle's circumference to its diameter.
3.14159265358979323846264338327950288419716939937510...
You probably also know e the mathematical constant, the base of a natural logarithm.
2.71828182845904523536028747135266249775724709369996...
But... do you know p... | [] |
Given a string S and a list of indices X, modify S by removing the element at each index of S while using that result as the new value of S.
For example, given S = 'codegolf' and X = [1, 4, 4, 0, 2],
0 1 2 3 4 5 6 7 |
c o d e g o l f | Remove 1
c d e g o l f | Remove 4
c d e g l f | Remove 4
c d e g f ... | [] |
The coefficient of relationship refers to how much DNA two persons have in common. A parent has 50% common DNA with their child (unless the parents are related), so to calculate it we have to find all pairs of directed disjoint paths starting at same node (common ancestor) and ending at each of the two siblings, and su... | [] |
Given as input a positive integer n>=1, output the first n rows of the following triangle:
1
1 0 1
0 0 1 0 0
1 1 1 0 1 1 1
0 0 0 0 1 0 0 0 0
1 1 1 1 1 0 1 1 1 1 1
0 0 0 0 0 0 1 0 0 0 0 0 0
1 1 1 1 1 1 1 0 1 1 1 1 1 1 1
0 0 0 0 0 0... | [] |
Given positive integer n > 2. We convert it to an array as follows:
If it is equal to 2 return an empty array
Otherwise create array of all n's prime factors sorted ascending, then each element replace with its index in prime numbers sequence and finally convert each element to array
For example, lets convert number ... | [] |
The title is valid Jelly Code which has the same output as L€€ except printed twice.
Background
You can skip this section without losing ability to complete the challenge
Some operations in Jelly try to convert its argument to a list first before applying the operation. One example is €, the mapping quick. This some... | [] |
Warning : this is NOT a "hey, let's draw a cake in ASCII-art" challenge! Please keep reading ;)
Some time ago it was my birthday, I'm 33 now.
So there is this awkward social tradition consisting in inviting family and friends, putting number-like candles on a cake, sing songs and open gifts.
33
--------
Instead... | [] |
Let us say a substring is any continuous section of an original string. For example cat is a substring of concatenate. We will say that a proper substring is a substring that is not equal to the original string. For example concatenate is a substring of concatenate but not a proper substring. (single character strin... | [] |
We've had a few challenges for base conversion, but all of them seem to apply to integer values. Let's do it with real numbers!
The challenge
Inputs:
A real positive number x, expressed in base 10. This can be taken as a double-precision float or as a string. To avoid precision issues, the number can be assumed to be ... | [] |
Make a program/function which takes in an integer from 0 to 999999999999 (inclusive) as input and returns how many syllables it has when spoken in English. Make your code short.
Specification
A billion is a thousand million, a trillion is a million million, etc.
A million has three syllables -- it's mill-ee-on, as opp... | [] |
There is a game called Get Home that is played on the a chess board. In this game there is a single piece that is moved by both players in turns. There are some rules to how the piece can be moved. On a turn a player must make one of the following moves for positive n.
n spaces up
n spaces to the left
n spaces up a... | [] |
I ran into this problem while working on another challenge I'm making for this site. In that challenge I utilize "Mario Kart 8 Scoring". The amount of points the player in kth place gets is represented by this 1-indexed array: [15,12,10,9,8,7,6,5,4,3,2,1]. So 1st place gets 15 points, 2nd place gets 12 points, etc.
It... | [] |
Input:
We take two inputs:
An input b with two distinct values: Left and Right.†
And a positive integer n.
Output:
Based on the Left/Right input, we output either of the following two sequences in the range of 1-n (in the sequences below the first 125 items are displayed):
Left:
1, 6, 7, 56, 57, 62, 63, 960, 961, 96... | [
[
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 an array of non-negative integers, your task is to only keep certain elements of it, as described below.
Let's say the array is [1, 3, 2, 4, 11, 5, 2, 0, 13, 10, 1].
First get the first element of the array, n. Keep the first n elements and discard the next one (discard the n+1th). The new array is [1, 2, 4, 11... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
Let's count...
Count up to 2 and back to 1
Count up to 4 and back to 1
Count up to 6 and back to 1
... ok you got it...
put all these together and you'll get the following sequence
{1,2,1,2,3,4,3,2,1,2,3,4,5,6,5,4,3,2,1,2,3,4,5,6,7,8,7,6,5,4,3,2,1,2,3...}
Challenge
Given an integer n>0for 1-indexed (or n>=0 for 0-i... | [] |
This challenge is based on a drinking game. I advise against alcohol consumption while programming.
In this game, the players count up in turns: the first player says 1, the second says 2 and so on. Here's the twist however: each number that is divisible by 7 or has a 7 in its digits (in base 10) is replaced by another... | [] |
Primes are everywhere...
they hide inside Pi
3.1415926535897932384626433832795028841971693993751
Let's get those primes!
The Challenge
Given as input an integer n>0, find out how many primes are hidden inside the first n digits of Pi
Examples
For n=3 we should search for primes in [3,1,4]. There are 2 Primes (3,31), so... | [] |
Cut a boolean matrix in 4x2 blocks and render them as Braille characters U+2800...U+28FF.
[[0,1,0,0,1,0],
[1,0,0,0,0,0],
[1,0,0,0,1,0],
[1,1,1,1,0,0]]
⣎⣀⠅
Pad with 0-s if dimensions are not multiples of 4 and 2.
[[0,1,0],
[1,0,0],
[1,1,1]]
⠮⠄
Usual golfing rules apply, flexible on input format. Output should e... | [] |
Inspired by a question at Stack Overflow.
Given a non-empty array of integers x and a positive integer n, compute the sum of each sliding block of length n along the array x, circularly filling the missing values at the left with values from the right as follows:
the first block contains the first entry of x, preceded... | [] |
Earlier I defined the process of crushing an array
In a crush we read the array left to right. If at a point we encounter two of the same element in a row we remove the first one and double the second one.
For example here is the process of crushing the following array
[5,2,2,4]
^
[5,2,2,4]
^
[5,2,2,4]
^
[5... | [] |
Inspired (with the explanation stolen from) this
Background
Say you have two lists A = [a_1, a_2, ..., a_n] and B = [b_1, b_2, ..., b_n] of integers. We say A is potentially-divisible by B if there is a permutation of B that makes a_i divisible by b_i for all i. The problem is then: is it possible to reorder (i.e. perm... | [] |
Convert a binary number (of any size) into a hexadecimal number.
Input
A POSITIVE binary number with just the 0s and 1s. A valid input will always match the following regex: [0-1]+. If the input is not a valid binary number, that is, anything not matching this regex, the output should be 0 or the program should exit,... | [] |
Given the written, spelled-out representation of an integer from 1 to 10^15-1 inclusive, convert it to an actual integer in decimal.
Input Format
The input will always be a string of groups, where each group is composed only of letters and spaces(). The groups are separated by commas.
You may choose whether you want t... | [] |
Input:
A string
Output:
1) First we take remove character at the end of the input-string until we are left with a length that is a square (i.e. 1, 4, 9, 16, 25, 36, etc.)
So abcdefghijklmnopqrstuvwxyz (length 26) becomes abcdefghijklmnopqrstuvwxy (length 25).
2) Then we put this in a square, one line at a time, left t... | [] |
Given an array of positive integers, output a stable array of the distinct prime factors of these integers. In other words, for each integer in the input in order, get its prime factors, sort them, and append any primes not already in the output to the output.
Test Cases
[1,2,3,4,5,6,7,8,9,10] -> [2,3,5,7]
[10,9,8,7,6,... | [] |
Given a positive input number \$n\$, construct a spiral of numbers from \$1\$ to \$n^2\$, with \$1\$ in the top-left, spiraling inward clockwise. Take the sum of the diagonals (if \$n\$ is odd, the middle number \$n^2\$ is counted twice) and output that number.
Example for \$n = 1\$:
1
(1) + (1) = 2
Example for \$n =... | [] |
The partition number of a positive integer is defined as the number of ways it can be expressed as a sum of positive integers. In other words, the number of integer partitions it has. For example, the number 4 has the following partitons:
[[1, 1, 1, 1], [1, 1, 2], [1, 3], [2, 2], [4]]
Hence, it has 5 partitions.
This... | [] |
A game of 2048 goes like this:
Every move you get another piece - either 2 90% of the time, or 4 10% of the time
for each 2 equal pieces combined you get a piece of the sum of the two and the sum gets added to your score
Your task
given a board of a 4x4 game, give the average score of what A game like that would resu... | [] |
Haskell has tuples that can be written as
(a,b,c)
However this is just syntactic sugar for
(,,)a b c
In general an n tuple can be formed with n-1 ,s between (...) followed by its elements separated by spaces. For example the 7-tuple, (1,2,3,4,5,6,7) can be formed by
(,,,,,,)1 2 3 4 5 6 7
Since Haskell does not have... | [] |
When you edit a post on SE, any further edits within a 5-minute grace period are merged into it. Given a list of times you edit a post, count the edits not in a grace period.
Say you edit at minutes [0,3,4,7,9,10,11,12]. This results in 3 edits at times [0,7,12], with the rest happening in their grace periods.
0: [3,4... | [
[
11,
220,
16,
17,
11,
220,
16,
19,
11,
220,
16,
21,
11
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
],
[
220,
16,
17,
11,
220,
16,
19,
11,
220,
16,
... |
Introduction
This is a log of length 5:
#####
I want to pile a bunch of these logs on top of each other.
How I do this is that I slide a new log onto the topmost one from the right, and stop sliding when their left or right ends align (don't ask why).
If the new log is longer, it slides all the way to the left end of ... | [] |
Background
We all know the famous Fibonacci sequence, where each term is the sum of the previous two, with the first term being 0 and the second one being 1. The first few elements are:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765
What we are going to implement today is a si... | [
[
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... |
Specifications
For this challenge, you will be given a matrix of some sort in any reasonable format for a 2-D array. For each row except the last, in order from top (first) to bottom (last), rotate the row below it by x to either direction (you choose a consistent direction to use) where x is the first element in the c... | [] |
Based on this Math.SE question; number copied from this answer. Number originally from a Numberphile video, of course.
Your task is to output the following 1350-digit prime number:
8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888881111111111111111111111118888881111111111111111... | [] |
This is how the Kolakoski sequence (OEIS A000002) is defined:
The Kolakoski sequence is a sequence that contains 1 and 2, and the nth element of the sequence is the length of the nth group of equal elements (run) in the sequence itself. The first 20 terms of the sequence and the respective lengths are:
1 2 2 1 1 2 1 2... | [] |
Background
The deltas of an array of integers is the array formed by getting the differences of consecutive elements. For example, [1, 2, 4, 7, 3, 9, 6] has the following deltas: [1, 2, 3, -4, 6, -3].
We will now define the deltas of a matrix of integers as the deltas of each row and each column it contains.
As an exam... | [] |
Inspired by this
In the linked challenge, we are asked to apply addition to the elements of the original and the reverse of the input array. In this challenge, we are going to make it slightly more difficult, by introducing the other basic math operations.
Given an array of integers, cycle through +, *, -, //, %, ^, wh... | [
[
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 math, one way to figure out what the type of a given relation (linear, quadratic, etc) is to calculate the differences. To do so you take a list of y values for which the gap between the correspondent x values is the same, and subtract each one from the number above it, creating a list of numbers one shorter then t... | [] |
Specs
You have a cubic 3D space x,y,z of size S integer units, such as 0 <= x,y,z <= S.
You get from default input methods an array of points P represented as x,y,z integer coordinates, in any reasonable format as you like, for example: [x1,y1,z1],[x2,y2,z2],[x3,y3,z3] ... [xn,yn,zn].
All the P values will be in the ... | [] |
Given a rectangular matrix of elevations, draw its contours.
Task
Two elements x and y are on the same contour level if floor(x/10) == floor(y/10). For example, 52 and 58 are on the same contour level, but 58 and 64 are not.
The act of drawing contours is defined as follows:
For every element e, replace it with a two-c... | [] |
I have a stupid old alarm clock with two buttons: hour and minute. The hour button increments the hour of a set alarm, and minute increments the minute time of a set alarm. However, some smart designers realized that pressing both buttons at the same time should have a meaning, and decided that pressing hour and minute... | [] |
We have a floating point number r between 0 and 1, and an integer p.
Find the fraction of integers with the smallest denominator, which approximates r with at least p-digit precision.
Inputs: r (a floating point number) and p (integer).
Outputs: a and b integers, where
a/b (as float) approximates r until p digits.
b... | [] |
Your challenge today is to take an array, split it into chunks, and add those chunks.
Here's how this works: Your program or function will be given an array of integers a and a chunk size L. The array should be split into arrays of size L, if the array length is not divisible by L then the array should have 0's appende... | [] |
An insignificant array is an array of positive integers, where the absolute differences between consecutive elements are all smaller than or equal to 1.
For example, the following array is insignificant:
[1, 2, 3, 4, 3, 4, 5, 5, 5, 4]
Because the corresponding (absolute) differences are:
[1, 1, 1, 1, 1, 1, 0, 0, 1]
W... | [
[
220,
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220
],
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11... |
Let me introduce you to GAU numbers
GAU(1) = 1
GAU(2) = 1122
GAU(3) = 1122122333
GAU(4) = 11221223331223334444
GAU(6) = 11221223331223334444122333444455555122333444455555666666
...
GAU(10) = 112212233312233344441223334444555551223334444555556666661223334444555556666667777777122333444455555666666777777788888... | [] |
Introduction
You can skip this part if you already know what a cyclic group is.
A group is defined by a set and an associative binary operation \$\times\$ (that is, \$(a \times b) \times c = a \times (b \times c)\$. There exists exactly one element in the group \$e\$ where \$a \times e = a = e \times a\$ for all \$a\$ ... | [] |
Inspired by Generate Keyboard Friendly Numbers.
Background
Many number pads have the following layout:
789
456
123
0
We define a number's neighborhood as the set of cells orthogonally adjacent to it on the numpad shown, including itself. For example, 2's neighborhood is {1,5,3,0,2} and 0's neighborhood is {1,2,... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
Challenge
Given a binary matrix and a binary string, determine if that binary string can be found starting at any point in the matrix and moving in any direction at any subsequent point to form the binary string. That is, can the string be found folded up however inside the matrix?
The string can only be folded at 90 d... | [] |
While doodling around with numbers, I found an interesting permutation you can generate from a list of numbers. If you repeat this same permutation enough times, you will always end up back at the original array. Let's use the following list:
[1, 2, 3, 4, 5]
as an example
Reverse the array. Now our array is
[5, 4, 3,... | [
[
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
]
] |
Take two inputs, a non-empty vector/list containing digits 1 and 2 and a string (no, you may not take 0/1 instead). The string will be one of the following (in lowercase, exactly as written below:
increasing
decreasing
ones
twos
all
none
If the string is ____ then you shall return the indices ___:
increasing ... wher... | [
[
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... |
Given two positive integers a and b, output the frequency distribution of rolling a b-sided die a times and summing the results.
A frequency distribution lists the frequency of each possible sum if each possible sequence of dice rolls occurs once. Thus, the frequencies are integers whose sum equals b**a.
Rules
The fre... | [
[
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
]
] |
You deal cards labeled 0 to 9 from a deck one a time, forming stacks that start at 0 and count up by 1.
When you deal a 0, you place it on the table to start a new stack.
When you deal any other card, you stack it atop a card that's exactly
one lower in value, covering it. If there's no such card, the deck isn't stac... | [
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
I guess I'm not the only one who have seen this kind of image on Facebook (and other sites).
The picture above was posted 16 days ago, and has accumulated 51 k comments. Some answers: 0, 4, 8, 48, 88, 120, 124 and so on.
Challenge:
The mathematics in the question doesn't make sense1, so we can't find the correct answ... | [] |
Introduction:
We all know these three basic arithmetic math tables I assume.
ADDITION:
+ | 1 2 3 4 5 6 7 8 9 10
----------------------------------
1 | 2 3 4 5 6 7 8 9 10 11
2 | 3 4 5 6 7 8 9 10 11 12
3 | 4 5 6 7 8 9 10 11 12 13
4 | 5 6 7 8 9 10 11 12 13 14
5 | 6 7 8 9 10 11 ... | [] |
Given a positive integer n output the n-th number of the euro-iginal sequence.
Calculating the Sequence
This sequence is equal to OEIS A242491.
A number is part of said sequence if the number can be made up by using as many different euro coins or notes, but only one of each. Note that you don't have to consider cents.... | [
[
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
20,
11
]
] |
Let's imagine we have a matrix of bits (which contains at least one 1):
0 1 0 1 1 0 1 0 0 1 0
0 1 0 1 0 0 1 0 1 1 0
0 0 1 0 1 1 0 1 0 1 0
1 1 0 0 1 0 0 1 1 0 1
0 0 0 1 0 1 1 0 0 1 0
We want to set some of the bits in this matrix such that it forms a contiguous blob of 1s, in which every 1 is directly or indirectly con... | [] |
Take an input list L containing positive integers, and insert the least amount of integers into the sequence, so that you make it a continuous one.
Example:
L = 4 2 6 1
Out: 4 3 2 3 4 5 6 5 4 3 2 1
The input and output formats are optional.
Test cases:
L = 1
Out: 1
L = 10 4
Out: 10 9 8 7 6 5 4
L = 13 13
Out: 13 13
... | [] |
Take two positive integers N and M and create the concatenated cumulative sums of [N], with M iterations. Output the result of the last iteration.
Definition of the concatenated cumulative sum:
Start with a number N and define a sequence X = [N]
Append to X the cumulative sums of X
Repeat step 2 M times.
The cumulati... | [
[
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
20,
11
]
] |
For the purpose of this challenge, a Prime Power of a Prime (PPP) is defined as a number that can be defined as a prime number to the power of a prime number. For example, 9 is a PPP because it can be represented as 3^2. 81 on the other hand is not a PPP because it can only be represented as 3^4, and 4 is not prime. ... | [] |
If Abe goes, then Beth and Diana go. If Beth goes, then Catherine goes. If Catherine goes, then Diana goes. If Diana goes, then Ezra goes. Only three people go. Who goes?
Challenge
Given a list of several pairings of people, such that in each pairing the second person goes if the first person goes, and a positive integ... | [] |
There have been a lot of prime-/prime factorization-related challenges recently, so I thought it might be interesting to go the other way.
Given:
a positive integer n, and
a non-empty list of positive integers f
write a full program or a function to find the smallest integer i such that i >= n and i is a product of n... | [
[
20,
11,
22,
11,
16,
16,
11,
16,
18,
11,
16,
22,
11
],
[
18,
11,
20,
11,
22,
11,
16,
16,
11,
16,
18,
11,
16
],
[
11,
20,
11,
22,
11,
16,
16,
11,
16,
18,
11,
... |
Consider a bridge of length B formed by tiles labeled with the digits of the positive integers concatenated. For example, if B was 41, then it would look like this:
-----------------------------------------
12345678910111213141516171819202122232425
Now imagine a train of length T crossing the bridge. The leftmost poi... | [
[
220,
20,
488,
220,
21,
488,
220,
22,
488,
220,
23,
488,
220
],
[
488,
220,
20,
488,
220,
21,
488,
220,
22,
488,
220,
23,
488
],
[
20,
488,
220,
21,
488,
220,
22,
488,
... |
For the purpose of this challenge, a multi-base prime is a prime which, when written in base 10, is prime in one or more bases smaller than 10 and larger than 1 as well. All single-digit primes are trivially multi-base primes. 11 is also a multi-base prime, as 11 in binary is 3, which is prime (it is also prime in ba... | [
[
11,
18,
11,
20,
11,
22,
11,
16,
16,
11,
16,
18,
11
]
] |
The binary-square-diagonal-sequence is constructed as follows:
Take the sequence of positive natural numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, ...
Convert each number to binary: 1, 10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, 10000, 10001, ...
Concatenate them: ... | [
[
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... |
This is Hole-1 from The Autumn Tournament of APL CodeGolf. I am the original author of the problem there, and thus allowed to re-post it here.
Given a list of numbers, produce a horizontal bar chart of # characters for how many numbers fit into each of ten equal-sized groups. For example, if the data ranges from 0-100... | [] |
A000330 - OEIS
Task
Your task is simple, generate a sequence that, given index i, the value on that position is the sum of squares from 0 upto i where i >= 0.
Example:
Input: 0
Output: 0 (0^2)
Input: 4
Output: 30 (0^2 + 1^2 + 2^2 + 3^2 + 4^2)
Input: 5
Output: 55 (0^2 + 1^2 + 2^2 + 3^2 + 4^... | [] |
Definition and Rules
A golfy array is an array of integers, where each element is higher than or equal to the arithmetic mean of all the previous elements. Your task is to determine whether an array of positive integers given as input is golfy or not.
You do not need to handle the empty list.
Default loopholes apply.... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
This is Hole-9 from The Autumn Tournament of APL CodeGolf. I am the original author of the problem there, and thus allowed to re-post it here.
Given a simple (rectangular, non-jagged) Boolean array (of one or more dimensions) return a list of thusly shaped arrays where the first array is identical to the input and the... | [] |
Life-like cellular automaton are cellular automaton that are similar to Conway's Game of Life, in that they operate on a (theoretically) infinitely large square grid, where each cell has exactly 8 neighbours, and is one of 2 states, namely alive and dead.
However, these Like-like versions are different in a crucial way... | [] |
We are searching for a sequence
Take the natural numbers
1,2,3,4,5,6,7,8,9,10,11,12,13,14...
Convert to base-2
1,10,11,100,101,110,111,1000,1001,1010,1011,1100,1101,1110...
Concatenate the above numbers
110111001011101111000100110101011110011011110...
Partition this number in Prime-Chunks
(chunks containing a prime num... | [
[
11,
18,
11,
20,
11,
22,
11,
16,
16,
11,
16,
18,
11
],
[
18,
11,
20,
11,
22,
11,
16,
16,
11,
16,
18,
11,
16
],
[
11,
20,
11,
22,
11,
16,
16,
11,
16,
18,
11,
... |
Consider the array of positive integers:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ...
Then, concatenate them:
1234567891011121314151617181920212223242526...
And then split them into chunks of variable length, each length being equal to the Nth positive integer:
[1][23][456][7891][01112][131415][1617181][92021222][3... | [
[
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
]
] |
Task
Your task is to output a single integer, with one restriction: its digits must be a permutation of [1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6].
For example, you could output 653443653152432, 413265345463352, or any of the other 15-digit integers whose digits are a permutation of the list.
Rules
Your code must t... | [] |
This is the PPCG Prime
624 digits long
77777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777711111111111111111111111111111111111111111111111111111111111111111111111111111118888888811888888881118888881118888881118811111... | [] |
Non-math explanation
This is an explanation that is meant to be approachable regardless of your background. It does unfortunately involve some math, but should be understandable to most people with a middle school level of understanding
A pointer sequence is any sequence such that \$a(n+1) = a(n-a(n))\$.
Lets pick apar... | [] |
iOS 11 has a bug that makes the result of 1+2+3 to be 24. This is related to the animation speed, but anyway:
The task is to make 1 + 2 + 3 == 24. But only that. So you should provide a function that correctly sums most sequences but returns 24 when the arguments are 1, 2 and 3 in any order.
Example inputs:
1 2 => 3
3 ... | [] |
Challenge
Given a list, determine if grouping the list into runs of increasing and decreasing elements will result in a list of equal-sized lists.
In other words, "turning points" of the list are spaced out evenly.
Example
Here's an example: 0, 3, 7, 5, 2, 3, 6
0, 3, 7 increases, 7, 5, 2 decreases, and 2, 3, 6 increase... | [] |
Note: This is #3 in a series of array-manipulation challenges. For the previous challenge, click here.
Moving Average of a List
The moving average of a list is a calculation resulting in a new, smoothed out list, created by averaging small overlapping sublists of the original.
When creating a moving average, we first... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
If we define a Fibonacci-like sequence as fk(n) = (fk(n-1) + fk(n-2)) % k, for some integer k (where % is the modulo operator), the sequence will necessarily be cyclic, because there are only k2 different values for (fk(n-1), fk(n-2)). However, this cycle doesn't usually include all possible pairs of values, so dependi... | [
[
220,
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220
]
] |
Consider the process of "picking" a nested list. Picking is defined as follows:
If the argument is a list, take an element from the list at random (uniformly), and pick from that.
If the argument is not a list, simply return it.
An example implementation in Python:
import random
def pick(obj):
if isinstance(obj, ... | [] |
Challenge:
Output all distinct permutations of a, potentially long, list of positive integers. You may assume that the vector has less than 1,000 numbers when testing, but the process should in theory work for any vector with more than one number regardless of size.
Restrictions:
You must restrict the memory usage to ... | [
[
220,
16,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220
],
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11... |
Title is made up, from 'Sequence Index Digit Not'.
Challenge:
Given an integer n which is >= 0, output the n'th number of the following sequence.
Here are the first 50 items, with it's (0-indexed) index above it:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 ... | [] |
Final Result
The competition is over. Congratulations to hard_coded!
Some interesting facts:
In 31600 out of 40920 auctions (77.2%), the winner of the first round won the most rounds in that auction.
If example bots are included in the competition, the top nine places won't change except that AverageMine and heurist ... | [] |
Consider the following sequence:
1, 0, 1, 2, 4, 1, 6, 8, 0, 1, 2, 4, 6, 8, 1, 0, 2, 4, 6, 8, 1, 0, 2, 4, 6, 8, 0, 1, ...
The even digits start from 0 and are grouped into runs of increasing length. They are arranged cyclically, meaning that they are sorted in ascending order until 8 is reached, and then cycled back fr... | [] |
Rectangle covers
Suppose you have a matrix of bits, for example the following.
1 1 0 0 0 1 1 0
1 1 1 1 0 1 1 1
0 1 1 1 0 1 1 1
1 1 0 1 1 1 1 0
1 1 0 1 1 1 0 1
We would like to find a rectangle cover for this matrix.
It is a set of rectangular subsets of the matrix that don't contain any 0s, but together contain all th... | [] |
Introduction
Every rational number between 0 and 1 can be represented as an eventually periodic sequence of bits.
For example, the binary representation of 11/40 is
0.010 0011 0011 0011 ...
where the 0011 part repeats indefinitely.
One way of finding this representation is the following.
Start with r = 11/40, then rep... | [] |
BCD difference
Given an integer n, convert it to BCD (binary-coded decimal) by replacing each decimal digit with its 4-digit binary representation
234 -> 0 0 1 0 0 0 1 1 0 1 0 0
Then rotate the list of binary digits in order to find the largest and smallest numbers, representable by this list without other rearrange... | [] |
A deck of cards is the Cartesian product of S suits and R ranks.
Many, though not all, card games use S=4 and R∊{6,8,13}.
A hand of H cards is dealt from the deck.
Its distribution, a.k.a. "hand pattern", is an array that describes
how many cards you got from each suit, ignoring suit order (so, it's like a multi-set).
... | [] |
Given a finite arithmetic sequence of positive integers with some terms removed from the middle, reconstruct the whole sequence.
The task
Consider an arithmetic sequence: a list of positive integers in which the difference between any two successive elements is the same.
2 5 8 11 14 17
Now suppose one or more integers... | [] |
One of my favorite definitions of the prime numbers goes as follows:
2 is the smallest prime.
Numbers larger than 2 are prime if they are not divisible by a smaller prime.
However this definition seems arbitrary, why 2? Why not some other number?
Well lets try some other numbers will define n-prime such that
n is t... | [
[
20,
11,
22,
11,
16,
16,
11,
16,
18,
11,
16,
22,
11
],
[
18,
11,
20,
11,
22,
11,
16,
16,
11,
16,
18,
11,
16
],
[
11,
20,
11,
22,
11,
16,
16,
11,
16,
18,
11,
... |
The Challenge
There are N cities aligned in a straight line. The i-th city is located A[i] kilometers to the right of the origin. No two cities will be in the same place.
You are going to build an electrical grid with some power plants. Power plants must be built inside a city. However, you are only allowed to build K ... | [] |
Introduction
Mathematicians often work with number sets. These are groups of numbers that share common properties. These are number sets are, in order from most specific to most broad:
Natural numbers (symbol N): These are the counting numbers: 1, 2, 3, ...
Integers (symbol Z): These are all the numbers with... | [] |
Next >>
Descriptive Keywords (for searching): Make Two Matrices Equivalent, Overlap, Array, Find
Challenge
Santa has had a history of elves stealing presents from his vault in the past, so this year he designed a lock that is very hard to crack, and it seems to have kept the elves out this year. Unfortunately, he has l... | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.