instruction_seed stringlengths 292 48.7k | found_ngrams listlengths 0 21 |
|---|---|
You live in a rectangular neighborhood which is completely partitioned into N rectangular plots, i.e. there are no gaps or overlaps. Plots do not necessarily have the same width/height as other plots. All widths/heights are positive integers. Your goal is to output all shared edges between plots.
Inputs
The input may c... | [] |
The Möbius function is an important number theoretic function.
Your submission should accept a positive integer \$n\$ and return the value of the Möbius function evaluated at \$n\$.
Definition
The Möbius function \$μ(n)\$ is defined as follows:
$$\mu(n) = \begin{cases}
\hphantom{-}1, &n\text{ is squarefree and has an e... | [] |
Introduction
Prime numbers are simple, right? Well, now you get your chance to find out!
Challenge
You must write a program or function that takes an input n and outputs the first n prime numbers.
Example Input and Output
Input: 10
Output: 2,3,5,7,11,13,17,19,23,29
Rules
You must not include any of the following built... | [
[
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 task
In this challenge, your input is a non-empty list of positive integers, given in the native format of your language.
Your output is that same list, in the same format, with some elements removed.
You shall remove every occurrence of 1, every second occurrence of 2, every third occurrence 3, and so on.
In gener... | [] |
Given an input of a list of blocks to drop at certain points, output the height
of the resulting "tower."
The best way to explain this challenge is by example. The input will be a list
of 2n integers representing n blocks. The first integer is the block's x
position, 0-indexed, and the second is how wide the block is. ... | [] |
A Stack Exchange script determines which five comments on questions or answers are initially seen on the main page of sites through the number of upvotes on them; the five comments with the highest number of votes are displayed. Your task is to recreate this behavior.
Write a full program or function taking input throu... | [] |
The challenge is very simple. Given an integer input n, output the n x n identity matrix. The identity matrix is one that has 1s spanning from the top left down to the bottom right. You will write a program or a function that will return or output the identity matrix you constructed. Your output may be a 2D array, or n... | [] |
This isn't very widely known, but what we call the Fibonacci sequence, AKA
1, 1, 2, 3, 5, 8, 13, 21, 34...
is actually called the Duonacci sequence. This is because to get the next number, you sum the previous 2 numbers. There is also the Tribonacci sequence,
1, 1, 1, 3, 5, 9, 17, 31, 57, 105, 193, 355, 653, 1201...
... | [
[
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
]
] |
The Scenario
I am building a fancy oscilloscope but I need your help. The oscilloscope can display any number of individual waveforms at the same time (e.g. sine waves) but I don't know how to synchronise the display so it doesn't jump around too much.
The Challenge
Your program or function will take a series of floati... | [] |
Lets say we have this existing data:
Total - 10
Won - 7
Lost - 3
Longest Winning Streak - 5
Longest Losing Streak - 2
Now you need to write a function which generates an array of random boolean values (true representing a win and false representing a loss) which fulfills the above criteria.
So, in this case the o... | [] |
The task is simple: consolidate an array of ints. Consolidating this array consists of the following:
All instances of 0 need to be moved to the end of the array.
There should be no 0s between the non-zero integers.
All non-zero indices should retain their order.
Challenge
Consolidate an array in the least amount of ... | [] |
Introduction
Finally the movie company is financing your film. They have given you a maximum budget and they also set the running time of your movie.
Now you can start with the pre-production. You have a bunch of scenes already planned, but not all of them will fit into the budget and the film would get way too long as... | [] |
Your boss wants you to write code like this:
public static boolean isPowerOfTen(long input) {
return
input == 1L
|| input == 10L
|| input == 100L
|| input == 1000L
|| input == 10000L
|| input == 100000L
|| input == 1000000L
|| input == 10000000L
|| input == 100000000L
|| input == 1000000000L
|... | [] |
Introduction
Let's observe the following sequence (non-negative integers):
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, ...
For example, let's take the first three numbers. These are 0, 1, 2. The numbers used in this sequence can be ordered in six different ways:
012 120
021 201
102 210
So, let's say 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... |
This is a problem from NCPC 2005. Roy has
an apartment with only one single electrical outlet, but he has a bunch of power strips.
Compute the maximum number of outlets he can have using the power strips he
has. The number of outlets per power strip is given as input.
It turns out that if the number of outlets of the... | [] |
Background
I have a row of powerful magnets and a bunch of metal objects between them.
Where will the magnets pull them?
Input
Your input is an array of non-negative integers, which will contain at least one 1.
You can use any reasonable format.
The 0s of the array represent empty space, and the 1s represent fixed magn... | [] |
Write a program or function that takes in a positive integer N. Output a list of all the distinct decimal numbers that can be written in exactly N characters using digits (0123456789), decimal points (.), and negative signs (-).
For example, some numbers that would be in the N = 4 output list are 1337, 3.14, .999, -789... | [
[
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 Task
The task is very simple. Given an array containing only integers and strings, output the largest number and the smallest number.
Test Cases
Input: [1, 2, 3, 4, 5, 6, 7, 8]
Output: 1, 8
Input: [5, 4, 2, 9, 1, 10, 5]
Output: 1, 10
Input: [7, 8, 10, "Hello", 5, 5]
Output: 5, 10
Numbers in strings are not consi... | [
[
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 input of a single positive integer, output the "cross-alternate sum"
that corresponds to that integer.
Take the example of the input n=5. To find the cross-alternate sum, first
create a square grid of width and height n that, reading from left to right
and top to bottom, starts at 1 and increases by one each p... | [] |
Isn't it annoying when you're working with floating point numbers and your code doesn't work because two numbers are not equal by the least significant bit? Now you can fix that!
Write some code that takes two floating point numbers in any IEEE 754 binary format and returns TRUE if:
the two numbers are exactly equal
f... | [] |
The other day my chemistry teacher was explaining to us about scientific notation (using a small number and multiplying it by powers of ten to express large numbers more easily), which brought me back a few years to when I first learnt it. After learning the basics, we had done a bunch of typical maths questions, some ... | [] |
In trigonometry, there are certain angles known as "special angles". This is because when you take sin, cos or tan of one of these angles, you get a result that is easy to remember because it is a square root of a rational number. These special angles are always multiples of either pi/6, or pi/4. Here is a visualizatio... | [
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220
]
] |
Background
Most everyone is familiar with the Fibonacci numbers \$F(n)\$:
\$0, 1, 1, 2, 3, 5, 8, 13, 21, ...\$
These are formed by the recursion function \$F(n) = F(n-1) + F(n-2)\$ with \$F(0)=0\$ and \$F(1)=1\$. A000045
A closely related sequence is the Lucas numbers \$L(m)\$:
\$2, 1, 3, 4, 7, 11, 18, 29, ...\$
Th... | [
[
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
Your submission should consist of 2 or more programs each written in distinct languages. They can be arbitrarily numbered from 1 to k.
Each program p, given a natural number n should print the next n prime numbers (initially, the next prime is the 0-th prime, 2) on a single line, followed by a single blank 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,
... |
The determinant of a 2 by 2 matrix
a b
c d
is given by ad - bc.
Given a matrix of digits with dimensions 2n by 2n, n ≥ 1, output the result obtained by recursively computing the determinant of each 2 by 2 sub-block until we reach a single number.
For example, given the input
3 1 4 1
5 9 2 6
5 3 5 8
9 7 9 3
After one ... | [] |
Introduction
Note: this is not some kind of method to encourage cheating. As Cᴏɴᴏʀ O'Bʀɪᴇɴ already said, studying is the best solution for passing a test :3.
Consider the following answers to the multiple choice test:
ABCBCAAB
Here is a table which indicates whether the answers match:
A B C B C A A B
A 1 0 0 0 ... | [] |
We will be implementing division for arbitrarily large integers.
This is code-golf.
The task is to write a program or function that implements arbitrary precision integers and Division on them.
Note that many things that might make this very easy are disallowed, please make sure to read through the spec.
Input
You will... | [] |
Given an input of a list of numbers in the format of a shorthand increasing
integer sequence, output the sequence in full.
Shorthand increasing integer sequence format works by finding every number n
with fewer digits than the number preceding it, m. With d as the number of
digits in n, the last d digits of m are repla... | [] |
Given a non-empty list/array containing only non-negative integers like this:
[0, 0, 0, 8, 1, 4, 3, 5, 6, 4, 1, 2, 0, 0, 0, 0]
Output the list with trailing and leading zeroes removed.
The output for this would be:
[8, 1, 4, 3, 5, 6, 4, 1, 2]
Some other test cases:
[0, 4, 1, 2, 0, 1, 2, 4, 0] > [4, 1, 2, 0, 1, 2, 4]... | [] |
In the vein of large number challenges I thought this one might be interesting.
In this challenge, we will be using the Residue Number System (RNS) to perform addition, subtraction, and multiplication on large integers.
What is the RNS
The RNS is one of many ways that people have developed to identify integers. In th... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
Background
Imagine for a moment that you have a mind-numbingly boring job.
Every morning, you are given a collection of tasks that you should work on that day.
Each task has a certain duration, and once started, it must be completed in one go.
Your boss will not tolerate idling, so if there are tasks that you could sti... | [] |
Given an input of a list of positive integers with some replaced with 0,
output the list with the missing numbers that were changed to 0 replaced.
Characteristics of the input list:
The list will always have a length of at least 2.
Let us define the input list as a and the "original list" (that is, the
list before num... | [] |
Write a program or function that takes in a non-negative integer N from stdin or as a function argument. It must print or return a string of a hollow ASCII-art square whose sides are each made with N copies of the number N.
Specifically:
If N is 0, no copies of N are used, so there should be no output (or only a single... | [] |
Inspired by Draw a timeline.
Given a timeline of events, output the date for each event.
A timeline will be given in the form
2000
--AF-C-------E--D---B--
Where the first line shows a known point in time. The known year is always the character below the first digit of the known year
You may assume:
On the timelin... | [] |
Given a number > 0, output the sum with all digits (1 .. n) concatenated and reversed and add them up. For example, with n = 6:
The numbers 1 to 6 concatenated:
123456
Reversed:
654321
Adding them up together will result in: 777777. Another example is n = 11:
1 2 3 4 5 6 7 8 9 10 11 > 1234567891011
and
11 10 9 8 7 6... | [] |
Write a function or program which, given a number of lines and columns, generates a corresponding tabular environment for LaTeX with no data in it.
Table format and tabular Environment
Here is an example of a table with 2 rows and 4 columns:
As you can see, we do not count the first row nor do we count the first colum... | [
[
90,
6192,
1276,
15170,
91,
66,
91,
66,
91,
66,
91,
66,
91
],
[
7265,
90,
6192,
1276,
15170,
91,
66,
91,
66,
91,
66,
91,
66
],
[
6192,
1276,
15170,
91,
66,
91,
66,
91,
... |
Context
Straw Poll is a website that is meant for the creation of simple/informal polls. Provided with a list of options, the user can select their choice(s), and the votes are tallied up. There's two very important features of a Straw Poll:
It is possible to view the current results before voting
It is often possib... | [] |
In almost every row nowadays, the people tends to order themselves as militaries would do.
Challenge
Suppose 4 people where:
person 1 has priority against person 2, 3 and 4,
person 2 has priority against person 3 and 4,
person 3 has priority against person 4,
person 4 has the lowest priority.
Then, when ordering thos... | [] |
A standard domino set has 28 unique pieces:
Given a list of 28 or fewer unique dominoes, output the list required to make a complete set.
Input and output dominoes are specified by two digits - the number of pips on each side of the domino, e.g. 00, 34, 40, 66.
The digits may be given in any order, so 34 is the same d... | [] |
Challenge description
For every positive integer n there exists a number having the form of 111...10...000 that is divisible by n i.e. a decimal number that starts with all 1's and ends with all 0's. This is very easy to prove: if we take a set of n+1 different numbers in the form of 111...111 (all 1's), then at least ... | [] |
For mostly historical reasons, bash is quite a hodge-podge of syntax and programming paradigms - this can make it awkward and sometimes frustrating to golf in. However it does have a few tricks up its sleeve that can often make it competitive with other mainstream script languages. One of these is brace expansion.
Th... | [] |
You have a deck of cards, consisting of cards with non-negative numbers on them, and you haven't shuffled it yet, and no player trusts the other players to be fair at shuffling. You devise a way to shuffle the deck that is completely deterministic, but chaotic enough that the other players are okay with using it. Here'... | [] |
Introduction
There are often times that we have challenges which require communication of some sort (such as in team KOTH), where density of information may be more important than density of code. There are a number of compression techniques that can allow us to convey more information in less space, but for simple dat... | [] |
Consider some binary sequence, using 1 and 2, e.g.:
1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1 ...
Let's write down the run lengths of that:
1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 1 ...
_ _ ____ ____ _ _ _ ____
1, 1, 2, 2, 1, 1, 1, 2, ...
In this case we happen to get another binary sequence. Of course, that's not g... | [] |
Given a vector of \$n\$ values \$(x_1,x_2,x_3,\ldots,x_n)\$ return the determinant of the corresponding Vandermonde matrix
\$V(x_1, x_2, \ldots, x_n) = \begin{bmatrix}1 & x_1 & x_1^2 & x_1^3 & \ldots &x_1^{n-1} \\1 & x_2 & x_2^2 & x_2^3 & \ldots &x_2^{n-1} \\ \vdots & & & \vdots & & \vdots \\ 1 & x_n & x_n^2 & x_n^3 & ... | [] |
Given a list with number, output the ranges like this:
Input: [0, 5, 0] would become [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0].
This is mapping a range through the array, so we first have to create the range [0, 5], which is [0, 1, 2, 3, 4, 5]. After that, we use the 5 to create the range [5, 0]. Appended at our previous range... | [
[
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... |
Here is a quick Monday morning challenge...
Write a function or program in the least number of bytes that:
Takes as input a list of [x,y] coordinates
Takes as input a list of the [x,y] coordinates' respective masses
Outputs the calculated center of mass in the form of [xBar,yBar].
Note:
Input can be taken in any for... | [] |
In the game Yahtzee, players roll five six-sided dice, and attempt to create certain hands to score points. One such hand is a small straight: four consecutive numbers, not necessarily in order. The three possible small straights are 1, 2, 3, 4, 2, 3, 4, 5, and 3, 4, 5, 6.
For example, [3, 5, 6, 1, 4] contains the smal... | [
[
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11,
323,
220
],
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11... |
Input
A integer n ( ≥ 1) and a digit d (an integer such that 0 ≤ d ≤ 9).
In either order; from stdin or parameters or whatever; to a program or function; etc.
Output
The integers from 1 to n inclusive (in order) whose decimal representations contain an even number of ds. (That is, the integers in the list are the integ... | [] |
The Challenge
Given a n x m matrix with n > 1 and m > 1 filled with integers
1 2 3
4 5 6
and a list of integers with exactly as many values as 2x2 blocks in the matrix ((n-1)*(m-1) if you need the exact number)
[1, 2]
Output the matrix with every 2x2 block rotated by the current value in the list in the given orde... | [] |
This is the 2-dimensional generalisation of this challenge.
For our purposes, one matrix (or 2D array) A is considered a submatrix of another matrix B, if A can be obtained by completely removing a number of rows and columns from B. (Note: some sources have different/more restrictive definitions.)
Here's an example:
A ... | [] |
Resistors and other electronic components are typically manufactured with values that conform to one of the E-series of preferred numbers. IEC 60063 defines the following E-series:
E6:
10 15 22 33 47 68
E12:
10 12 15 18 22 27 33 39 47 56 68 82
E24:
10 11 12 13 15 16 18 20 22 24 27 30 33 36 39 43 47 51 56 62 68 75 82 ... | [] |
Inspired by an old manual...
The challenge
I define the ath suffix vector of b as the boolean list of length a with b trailing truthy values.
Write a program or function that, given a and b by any means, returns the ath suffix vector of b by any means.
Now this may seem trivial, but here is the catch: Your score is the... | [] |
Introduction
I found this question that was closed because it was unclear, yet it was a nice idea. I'll do my best to make this into a clear challenge.
The Riemann Zeta function is a special function that is defined as the analytical continuation of
to the complex plane. There are many equivalent formulas for it which... | [] |
This was inspired by Problem 13 - Non-Repeating Binary of HP CodeWars' recent competition.
Let's take a random decimal number, say
727429805944311
and look at its binary representation:
10100101011001011111110011001011101010110111110111
Now split that binary representation into subsequences where the digits 0 and 1 a... | [] |
The Scenario
You are given a matrix of size m x n (width x height) with m*n spots where there are a few obstacles. Spots with obstacles are marked as 1, and those without are marked as 0. You can move vertically or horizontally, but can visit each spot only once. The goal is to cover as much area/spots as possible, avo... | [] |
If we have a list, say the list [9, 2, 4, 4, 5, 5, 7], we can do a moving average across it.
Taking a window of say, 3 elements, each element is replaced by a window like such: [[9], [9, 2], [9, 2, 4], [2, 4, 4], [4, 4, 5], [4, 5, 5], [5, 5, 7]], and then taking averages, we get [9.0, 5.5, 5.0, 3.3333333333333335,... | [] |
Inspired by this question
Another way to unroll a 2D image into a 1D string is to use an Hilbert Curve.
There are many version of this curve, depending on the number of iterations used while computing it. Below follow example of Hilbert Curves from first order to fifth order.
The way of computing this curve is the fol... | [] |
Write a program or function that accepts an integer in the range 1..3999 as input and returns the number of line segments required to express that integer in standard Roman numerals (so you would use XL but not VM). Examples:
1 -> 1
4 -> 3
5 -> 2
9 -> 3
10 -> 2
40 -> 4
50 -> 2
90 -> 3
100 -> 1
400... | [] |
There is a virus inside a recipient of 5x5. As we know how it propagates its contamination, your mission is to output the last stage of the contamination.
The recipient
It will be representend as a two dimensional array of 5x5:
0 0 0 0 1
0 0 0 0 1
0 0 0 1 1
0 0 1 1 1
0 1 1 1 1
Where 1 means a position where the virus ... | [] |
Background
The parity of a permutation, as defined by wikipedia, is as follows:
The sign or signature of a permutation σ is denoted sgn(σ) and defined as +1 if σ is even and −1 if σ is odd.
The sign of a permutation can be explicitly expressed as
sgn(σ) = (−1)^N(σ)
where N(σ) is the number of inversions in σ.
Alternat... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
Introduction
Maximum-length sequences, usually known as m-sequences, are binary sequences with some interesting properties (pseudo-noise appeareance, optimal periodic autocorrelation) which make them suitable for many applications in telecommunications, such as spread-spectrum transmission, measurement of impulse respo... | [] |
Write a function that when given a buffer b (1 - 104857600 bytes long) and a number of bits n (1 <= n <= 64), splits the buffer into chunks of n bits. Right-pad the last chunk with 0s up to n bits.
e.g.
Given the buffer b = "f0oBaR" or equivalently [102,48,111,66,97,82] and n = 5, return
[12, 24, 24, 6, 30, 16, 19, 1, ... | [] |
This is a code-golf question.
Input
A list of non-negative integers in whatever format is the most convenient.
Output
The same list in sorted order in whatever format is the most convenient.
Restriction
Your code must run in O(n log n) time in the worst case where nis the number of integers in the input. This means t... | [
[
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... |
Gaussian integers are complex numbers of the form a+bi where a and b are both integers. In base -1+i, all Gaussian integers can be uniquely represented using the digits 0 and 1, without the need for a symbol to denote sign.
For instance, 1100 in base -1+i represents the decimal number 2, since
1*(-1+i)^3 + 1*(-1+i)^2 +... | [] |
The Challenge
Given 3 numbers X, Y and Z in base B, find a Base in which the addition of X and Y yields Z. The inputs x = 20, Y = 12 and Z = 32 could yield 5 because 20 + 12 = 32 in base 5.
You may assume that there will always be a base in which the addition is correct (there are cases where no base exists, thanks t... | [] |
This used to be an old Computer Olympiad Question, not sure what the actual source was.
Assume function f:
f(1) = 1
This f(1), f(2), f(3), f(4), ... sequence of numbers are in ascending order.
Number n has been repeated f(n) times
Here is the sequence up to the fifteenth number:
n : 1 2 3 4 5 6 7 8 9 10 11 12 13 ... | [] |
Two distinct vertices in a directed graph are strongly connected if there is path in the graph from each to the other. A strongly connected component of the graph is a subset of the graph such that each pair of distinct vertices in the subset are strongly connected, and adding any more vertices to the subset would brea... | [] |
In this challenge, you need to partition a list, where partitions have a max size, a min size, and a preferred size. I'll be using the notation (min,pref,max) to indicate the sizes in this challenge.
For those unfamiliar with partitioning, the following list has been partitioned into parts of 3:
[0..9] -> [[0,1,2],[3... | [] |
Background
Consider a round-robin tournament, in which each contestant plays one game against every other contestant.
There are no draws, so every game has a winner and a loser.
A contestant A is a king of the tournament, if for every other contestant B, either A beat B, or A beat another contestant C who in turn beat ... | [] |
The challenge is simple: Determine the type of an input, and output an identifier telling what type it is.
"UI", Unsigned integer: 0, 1,34, 111111111111111111111111111111111111111111
"SI", Signed integer: +0, +1, +42, -1, -3, -111111111111111111111111111111111111111111
"UD", Unsigned decimal: 0.0, 1.23, 1234.1234
"SD... | [] |
Introduction
Let a field be a rectangle filled with only the characters - and [0-9]. An example of a field is:
11-011123
111-010--
0010---01
111-01234
You see that this field has been separated into three smaller areas:
To calculate the score of a smaller area, we just add all numbers up. For example:
11
111
0010
111... | [] |
Write a program or function that takes in a multiline string of 0's and 1's. No other characters will be in the string and the string will always be rectangular (all lines will have same number of characters), with dimensions as small as 1×1, but otherwise the 0's and 1's may be arranged arbitrarily.
You may assume the... | [] |
In this game two players compete to eat the most points worth of tokens, but there's a twist! Eating multiple tokens in a row of the same color gives an ever-growing bonus, but watch out, or your opponent will thwart your plans by eating the tokens you want before you can!
Rules:
1 versus 1
n by n board (random size b... | [] |
Introduction
A pointer array is an array L of nonzero integers where 0 ≤ L[i]+i < len(L) holds for all indices i (assuming 0-based indexing).
We say that the index i points to the index L[i]+i.
A pointer array is a loop if the indices form a single cycle of length len(L).
Here are some examples:
[1,2,-1,3] is not a po... | [] |
Most languages come with a built-in to search a string for all occurrences of a given substring and replace those with another. I don't know of any language that generalises this concept to (not necessarily contiguous) subsequences. So that's your task in this challenge.
The input will consist of three strings A, B and... | [] |
Given 5 distinct points on a two-dimensional plane, determine the type of conic section formed by the points. The output shall be one of circle, hyperbola, ellipse, or parabola.
Rules
The points will be in general linear position, meaning that no three points are collinear, and thus the conic passing through them will... | [] |
I recently got a really weird irregular chess board. It's squares are all over the place and not even all connected. At least they're still laid out on a regular grid. I want to adapt the chess rules to be able to play on the board, but to start with, I need a piece that can actually go anywhere on the board, and it se... | [] |
For the non-zero digits on a standard numpad
789
456
123
consider placing a chess knight at any digit and moving it around with any number of normal L-shaped jumps, tracing out a positive decimal integer. What positive integers can be expressed in such a way?
One of them is 38, since the knight could start on the 3 an... | [
[
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
]
] |
Driftsort is a simple way to "sort" an array. It works by "sliding" or "rotating" the elements over in the array until the array is sorted, or until the array fails to be sorted.
Let's walk through two examples. First, consider the array [10, 2, 3, 4, 7]. Since the array is not sorted, we rotate it once. (This can happ... | [] |
Introduction
It may sound strange, but we haven't got ONE challenge for counting from 1 to n, inclusive.
This is not the same thing. That one is a (closed) not well-explained challenge.
This is not the same thing. That one is about counting up indefinitely.
Challenge
Write a program or function that prints every intege... | [
[
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
]
] |
Introduction
Gijswijt's sequence (A090822) is famously really, REALLY slow. To illustrate:
The first 3 appears in the 9th term (alright).
The first 4 appears in the 220th term (a long way away, but feasible).
The first 5 appears at (approximately) the 10^(10^23)th term (just no).
No one really even knows where the fir... | [] |
In this challenge 2 years ago, we found the period of a unit fraction (1/n where n is a natural number).
Now, your task is to write a program/function to find the repetend of a unit fraction.
The repetend is the part of the decimal expansion which repeats infinitely, like:
The decimal representation of 1/6 is 0.16666.... | [] |
Credits
This challenge originated from @miles.
Create a function that computes the CRC32 hash of an input string. The input will be an ASCII string of any length. The output will be the CRC32 hash of that input string.
Explanation
The algorithm of CRC32 and other CRC are essentially the same, so only CRC3 will be demo... | [] |
Introduction
Let's observe the following array:
[1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1]
A group consists of the same digits next to each other. In the above array, there are 5 different groups:
[1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1]
1, 1, 1
2, 2
1, 1, 1, 1
... | [] |
Note: This challenge is not the same.
Challenge
Believe it or not, we haven't got ONE challenge for reversing one-dimensional arrays (although we've got one for n-dimensional ones)! This should operate only on the 1st dimension, not on all dimensions of an array.
Rules
Standard loopholes are denied
[[1, 2], [3, 4]] be... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
]
] |
This was inspired by a Minecraft mini-game. The rules are pretty simple: you run and jump around, and every block you step on disappears once you've stepped on it. The goal is to be the last one left.
Your bot should be a complete program. It should accept input as a command line argument. The input will be a map of th... | [] |
Introduction
The two most common trigonometric functions, sine and cosine (or sin and cos for short), can be extended to be matrix-valued functions. One way to compute the matrix-valued analogs is as follows:
Consider these two important trigonometric identities:
$$
e^{i x} = \cos(x) + i \sin(x) \\
\sin^2(x) + \cos^2(x... | [] |
You have to write a function/program that will draw an ASCII art of a square made with numbers.
Challenge
This program will take one input n as a positive integer and draw a hollow square using this number. The inside must be filled with spaces. The borders also must have the same width. The width and height of the squ... | [] |
Important note: Because this challenge only applies to square matrices, any time I use the term "matrix", it is assumed that I am referring to a square matrix. I am leaving off the "square" description for brevity's sake.
Background
Many matrix-related operations, such as computing the determinant, solving a linear sys... | [] |
Lower level languages, such as C and C++ actually have no concept of multidimensional arrays. (Other than vectors and dynamic arrays) When you create a multidimensional array with
int foo[5][10];
This is actually just syntactic sugar. What C really does is create a single contiguous array of 5 * 10 elements. This
foo[... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
Introduction
Turns out, aliens love memes just as much as we do. Every alien race we've encountered so far has their own version of 2spooky4me (see the following question) and equivalent, though, with some variation. The inhabitants of planet CUTE1f can't handle a lot of spook, so their preferred spook is 1spooky2me, w... | [] |
My local ACM chapter gives out door prizes to people who come to the meetings. You get an increased chance of winning if you solve the programming puzzle, however (but I always solve that puzzle). Thus, some people have 1 entry, while others have 2. But wait! The way the raffle program works is not by adding in another... | [] |
Given three dice rolls (integer values from 1-6) in sorted order (so as to be indistinguishable), convert them to the sum of two fair dice with an identical distribution.
The answer for three to one is summing them all, modulo 6. The end-result is a perfectly flat distribution, where each of the six numbers are equall... | [
[
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
]
] |
Steiner Chains are a set of N circles where each circle is tangent to 2 other non-intersecting circles as well as the the previous and next circles of the chain, as seen in the below images:
In this challenge, you will write a program/function that draws Steiner chains recursively, that is, circles of a given chain ... | [] |
related and inspired by -- Finding sum-free partitions
A set A is defined here as being distinctly sum-free if
1) it consists of at least three elements, |A| ≥ 3, and
2) its distinct self-sum A + A = { x + y | x, y in A} (with x,y distinct, i.e., x≠y) has no elements in common with A.
(Obsolete - do not use this goi... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
As a kid, I used to play the card game "golf" a lot. Your challenge, should you choose to accept it, is to calculate the score of a golf hand. Since there are over 9000 variations on this card game1, we will go with the rules I remember playing.
Rules (of the game)
You end a round with 6 cards, and you want as few poi... | [
[
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 integer N >= 1, output the mean number of bits in an integer from 0 to N - 1
Specification
The output can be calculated as the sum of the number of bits in the binary representation of each integer from 0 to N-1, divided by N.
The binary representation of an integer has no leading zeroes in this context, with... | [] |
This question is probably harder than all of those "generate a sequence of numbers" tasks, because this requires TWO sequences working in unison.
Really looking forward to the answers!
In his book "Gödel, Escher, Bach: An Eternal Golden Braid", Douglas Hofstadter has a quite few sequences of numbers inside, all of them... | [] |
Inspired by this question which was further inspired by this one, write a program which takes two integers and adds them in a unique way, by performing an OR operation on the segments used to display them in a 7-segment display. For reference, the digits are represented in the following way:
_ _ _ _ ... | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.