instruction_seed stringlengths 292 48.7k | found_ngrams listlengths 0 21 |
|---|---|
X Marks the spot
Your goal is to add a cross-hair around the capital X:
Example Input / Output
Input:
mdhyyyyyyyhhhddmmm
mdyyssoo oooosyyyhhhdmm
hsso oossoooooyyhhdhhdmmm
yoooooo oo ssysssyhhdyyyhmmmm
myso oso... | [] |
Challenge
In the shortest amount of code:
Compute the length of the permutation cycle of a perfect shuffle on a deck of cards of any size n (where n ≥ 2 and n is even).
Output a table of all cycle lengths for 2 ≤ n ≤ 1000 (n even).
Note that there are two basic ways of defining a perfect shuffle. There is the out-shu... | [] |
Prindeal (pronounced prin-dee-al) is a new esoteric programming language that only has four commands: print, increment, decrement, and alias. Despite its minimalism, complex mathematical operations can be done in Prindeal by cleverly combining the four commands.
Your task in this code golf challenge is to write the sho... | [] |
Just about every store nowadays uses Universal Product Code (UPC) barcodes to simplify the checking out process. If the name doesn't mean anything to you, you will surely recognize what they look like:
Format
The most common system is UPC-A, which uses 12 digits to represent each specific product. Each digit is encode... | [] |
This challenge is loosely inspired by the unimplemented esolang Pada.
Consider an array of 8 bits, all initialised to zero. We'll introduce a very minimalistic instruction set to print arbitrary strings. There are two instructions, both of which take a parameter N which is the index of a bit:
t N for toggle: This chan... | [] |
Consider a rectangular two-dimensional grid where each cell can either be empty (.) or full (0).
e.g.
..00....
0000....
.00000..
000...00
..000000
000.00..
The grid is considered infinite, all cells outside the depicted region are empty.
The goal is to cover the filled spaces and leave the empty spaces open using a se... | [] |
There are quite a large number of prime generating functions. Pretty much all of them are constructed and are based on the sieve of Eratosthenes, the Möbius function or the Wilson's theorem and are generally infeasible to compute in practice. But there are also generators, that have a very easy structure and were found... | [] |
Write a program (or function) that takes in a non-empty string of any printable ASCII characters.
Print (or return) a zigzagging chain of the characters in the string with every neighboring pair of characters linked by:
/ if the first character occurs before the second character in normal ASCII order. e.g.
B
/
A
\... | [] |
A tree is a connected, undirected graph with no cycles. Your task is to count how many distinct trees there are with a given number of vertices.
Two trees are considered distinct if they are not isomorphic. Two graphs are isomorphic if their respective vertices can be paired up in such a way that there is an edge betwe... | [
[
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... |
Note: all array references in this post are zero-indexed.
When playing the piano, two notes on the same key must be pressed with two different fingers. You could use the same finger, but it doesn't sound as good. At least, according to my piano teacher. I can't hear any difference.
The challenge is to take a space-sepa... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
Consider three number sequences, \$A\$, \$B\$ and \$C\$:
\$A\$: A sequence based on recurrence relations, \$f(n) = f(n-1)+f(n-2)\$, starting with \$f(1) = 3, f(2) = 4\$. So, the sequence begins like this: \$3, 4, 7, 11, 18, 29, 47, 76, ...\$
\$B\$: The composite numbers, that is all integers that aren't primes (or 1):... | [] |
Inspired by this question
Given a positive integer \$n\$, your code must output the first \$n\$ composite numbers.
Input / Output
You may write a program or a function. Input is through STDIN or function argument and output is to STDOUT, or function return value.
Output can be a List, Array, or String.
Examples
0 ->
... | [] |
You work for a company that wants to make a user-friendly calculator, and thus you have been tasked with adding the ability for users to use "numerical shorthands," that is, letters that represent numerical values, such as k for 1000. Because your company wants to save money on storage in said calculators, you must min... | [] |
This challenge is a tribute to our Legendary Challenge Writer™,
Calvin's Hobbies — now renamed to Helka Homba —, in the same spirit as
Generate Dennis Numbers.
Calvin is a pretty impressive contributor to PPCG, with the 6th most reputation
overall and probably indisputibly the best challenge writing skills out of all
o... | [] |
Write a program that goes through a string of non-whitespace characters (you may assume that they are digits 0 to 9, but nothing in the way they are to be processed depends on this) and adds spaces according to the following rules.
Let the current token be the empty string, and the previously emitted tokens be an empt... | [] |
This is my first challenge!
Background
Perfect number is a positive integer, that is equal to the sum of all its divisors, except itself.
So 6 is perfect number, since 1 + 2 + 3 = 6.
On the other hand 12 is not, because 1 + 2 + 3 + 4 + 6 = 16 != 12.
Task
Your task is simple, write a program, which will, for given n, pr... | [
[
220,
16,
488,
220,
17,
488,
220,
18,
488,
220,
19,
488,
220
]
] |
Computers live by binary. All programmers know binary.
But the 2**x bases are often neglected as non-practical, while they have beautiful relations to binary.
To show you one example of such a beatiful relation, 19 will be my testimonial.
19 10011 103 23 13 j
19 is decimal, included for clarity.
10011 is 19 in binary... | [] |
I am a teacher who was given a problem a few years ago. Every year since I have given it to my advanced students as a bonus assignment, but in ~10 years only 8 solved it, each with a slightly different approach. The problem is as follows:
You have some input (from stdin), in the following format (the //comments are not... | [] |
Monday Mini-Golf: A series of short code-golf challenges, posted (hopefully!) every Monday.
A Fibonacci-like sequence is obtained using the same method as the famous Fibonacci sequence; that is, each number F(n) is found by adding the previous two numbers in the sequence (F(n) = F(n-1) + F(n-2)), or by subtracting the ... | [
[
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
]
] |
Challenge:
Create a program that compresses a semi-random string, and another program that decompresses it. The question is indeed quite similar to this one from 2012, but the answers will most likely be very different, and I would therefore claim that this is not a duplicate.
The functions should be tested on 3 cont... | [] |
Your company is just getting started on a project, and for the first time you decided to go use a functional programming code-style. However your boss is really diffident and doesn't want to use built-in functions, and requires you to implement yourself the main functions. In particular you need to write the functions:... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220
]
] |
Have you heard about trees?
When performing DFS on a binary tree, you can traverse it in 3 possible orders.
Root, left node, right node (Pre-order)
Left node, Root, right node (In-order)
Left node, right node, root (Post-order)
Check wikipedia to know more.
For this challenge, you have to provide a program that, giv... | [] |
Objective
Write a program in any language that reads a matrix from stdin in which all columns are space delimited and all rows are newline delimited. The program must output a sub matrix so as that there is no other sub matrix with greater average, this sub matrix' average value, as well as the starting and ending coor... | [] |
You have a number of polynomials who are lonely, so make them some companions (who won’t threaten to stab)!
For a polynomial of degree n, there is an n by n companion cube matrix for it. You need to make a function that accepts a list of coefficients for a polynomial in either ascending (a + bx +cx^2 + …) or descendin... | [] |
Given a string consisting of printable ASCII chars, produce an output consisting of its unique chars in the original order. In other words, the output is the same as the input except that a char is removed if it has appeared previously.
No built-ins for finding unique elements in an array can be used (for example, MATL... | [] |
In public-key cryptography, a public key fingerprint is a short sequence of bytes used to identify a longer public key.
In SSH in particular they can be used to verify that a server is in fact the server I'm expecting to communicate with and I'm not targeted by a man-in-the-middle attack.
They are usually represente... | [] |
Well, the librarian caught you cheating at your job by using your sorting algorithm, so now you're being punished. You've been ordered to create some code so the librarian can impress the object of their unrequited affection, the math teacher. So that's what "Other duties as assigned" means ...
Everyone is familiar wit... | [
[
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... |
Challenge
Given a positive integer N that is 28 or above, output a list of numbers summing to N that uses each digit 1 through 7 exactly once. You can give as a program or function.
The digits can appear by themselves or concatenated, as long as you use each of them once without repeats. For example,[12, 34, 56, 7] is ... | [
[
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 Alternating Harmonic Series is a well known convergent series.
"Clearly", it is obvious that it converges to the natural log of 2. Or does it?
Since the series is not absolutely convergent, by simply rearranging the terms, I can make it approach anything I want. Suppose I want the series to converge to e. All I'd ... | [] |
Introduction
In this challenge, your task is to simulate a certain type of elimination game.
In the game, the participants stand in a circle, and everyone is holding an integer.
On each round of the game, every participant points at the person n steps away, if n is the number they are holding. If n is positive, they co... | [] |
Output coordinates of the vertices of a cube. Then, output a list of twelve triangles that will cover the cube, each triangle being a list of three vertex-indexes, consistently oriented. Output must be an ASCII string of distinct decimal numbers. This golf has no input. Winner is the fewest characters, where the charac... | [] |
The Challenge
I always write my math assignments down in the same way. For example:
pg. 420: #25, 50-56, 90
pg. 26: #50-60 evens, 70-80 odds, 90-99 3s
pg. 69: #12, 16, 18, 37
But I need you to tell me the individual problem numbers. For example:
input:
pg. 420: #25, 50-56, 90
output:
25, 50, 51, 52, 53, 54, 55, 56, ... | [
[
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 Mission
You are Jim, a CIA agent in charge of super secret spies around the world. However, your enemies, the Naissurs, are highly trained in computer intelligence, and they can hack into your super secret communication systems. To contact your super secret spies, you must encrypt each message with a 16-c... | [] |
Objective
Given a grid of numbers, fill in the inequalities.
Assumptions
The number of columns and rows in the grid are equal.
The maximum size of the grid is 12x12.
The grid only consists of integers 0-9.
The output may contain a trailing newline.
The input is exactly as written below, including spaces and newlines.
E... | [] |
Robbers' challenge thread is here.
Cops' challenge: Design a programming language that appears to be unusable for programming, but admits computation (or at least completion of the task) through some non-obvious mechanism.
You should design a simple programming language that reads code from an input file and then does ... | [] |
Input
A list of between 1 and 255 positive integers (inclusive), each in the range 1 to 232 - 1 (inclusive).
Your input format does not need to be identical to the test cases.
Input without leading zeroes is required to be accepted.
Input with leading zeroes is not required to be accepted.
You may use whatever delimit... | [] |
Christmas is fast approaching and along with it, arranging the annual family Secret Santa. I'd like to try and get a head start on this, but making sure couples don't buy for each other keeps causing problems and despite doing this for years there's still the problem that Bob is pretty rubbish at buying gifts for most ... | [] |
When you round a number, if the next digit is >= 5 you add 1. For example:
3.1415926535 rounded to 1dp is 3.1
3.1415926535 rounded to 4dp is 3.1416 <-- Note the 5 changed to 6
3.1415926535 rounded to 5dp is 3.14159
3.1415926535 rounded to 9dp is 3.141592654 <-- Note the 3 changed to 4
You challenge is to receive ... | [] |
You saved the day with your prime sequence code, and the math teacher loved it. So much so that a new challenge was posed to the librarian (a/k/a, your boss). Congratulations, you get to code the solution so the librarian can once again impress the math teacher.
Start with the sequence of natural numbers in base-10, \$... | [
[
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... |
In a steam-punk multidimensional world, our boss wants to affix printed index labels to each drawer in our conglomerate's multidimensional file cabinet.
The boss wants to typeset the entire label sheet as a single form, using a font bought only for this purpose, so we have to order the sorts (metal symbol pieces). Sinc... | [
[
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... |
Introduction
In this challenge, your task is to write a program that decides whether two given trees are isomorphic.
A tree means a directed acyclic graph where every node has exactly one outgoing edge, except the root, which has none.
Two trees are isomorphic if one can be transformed into the other by renaming the no... | [] |
First post here! I recently participated in a small friendly competition and this was one of the questions:
A positive integer whose only prime factors are 2, 3, 5 or 7 is called a humble number.
The first 20 humble numbers are:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27
Write a program of... | [
[
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 you express some positive integer in binary with no leading zeros and replace every 1 with a ( and every 0 with a ), then will all the parentheses match?
In most cases they won't. For example, 9 is 1001 in binary, which becomes ())(, where only the first two parentheses match.
But sometimes they will match. For exam... | [] |
Write a program or function that takes in an odd positive integer N and a string of decimal digits (0123456789). The string represents a ten-state one-dimensional cellular automaton. Each digit occupies one cell and the update rule from one generation to the next is that every cell becomes the digit resulting from the ... | [] |
Inspired by this question:
Make a function (or a full program) that receives a list of numbers and outputs the list rearranged, so that even-indexed numbers appear first, and odd-indexed numbers follow. The values of the numbers themselves don't affect ordering - only their indices do. All indices are zero-based.
For e... | [] |
Background
Today (or Yesterday) is (or was) 11/23 or Fibonacci day! What better way to celebrate than to make a Fibonacci cake?
Examples
3
ii
i_i_ii_i_i
</>
8
ii
ii
ii
ii
ii ... | [
[
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... |
Goal:
Your goal is to print out numbers within a given range (Also including given values).
Input Format:
The input will look like:
(int-int, int-int, ...)
... meaning the user can add as many int-int as they'd like.
Other Info:
You will only have to handle non-negative integer numbers.
The first integer in int-int wi... | [] |
Given a non-negative number n, output the number of ways to express n as the sum of two squares of integers n == a^2 + b^2 (OEIS A004018). Note that a and b can be positive, negative, or zero, and their order matters. Fewest bytes wins.
For example, n=25 gives 12 because 25 can be expressed as
(5)^2 + (0)^2
(4)^2 + (... | [] |
Pretty simple challenge today:
Write a program or function that takes in a positive integer N and prints or returns a sorted list of the unique numbers that appear in the multiplication table whose row and column multiplicands both range from 1 to N inclusive.
The list may be sorted in ascending order (smallest to larg... | [
[
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... |
Time for another maze challenge, but not as you know it.
The rules for this challenge are a little different than most maze challenges. The tile types are defined as follows:
S: The location on the maze you start at
E: The location you are trying to get to
0: Wall that you can't cross
+: Floor that you can cross
You ... | [] |
There's quite a few challenges on this site that ask you to print out a sequence, and this is no exception.
(The following explanation of the sequence for this challenge assumes the symbols in the sequence are 0 and 1.)
The recursive definition of the Thue-Morse sequence is that
T_0 = 0
T_2n = T_n
T_2n+1 = 1 - T_n
A ... | [] |
Write a program or function that takes an array of non-negative integers as input and outputs a set of vectors/arrays with the elements of the input array in order, split so that each vector sums up to 15. If the sum of the first N elements doesn't "hit 15", then the number that made it pass 15 must be cut off, and the... | [] |
Inspired by https://puzzling.stackexchange.com/questions/24334/to-catch-a-thief
You are given an n by n (n itself is optional input) grid filled with 0s and 1s (or any other character of your choice). You aim is to make every cell the same (either 0 or 1). You can make a series of moves as defined below (note dissimila... | [] |
Inspired by this SO question
As input you will be given a non-empty list of integers, where the first value is guaranteed to be non-zero. To construct the output, walk from the start of the list, outputting each non-zero value along the way. When you encounter a zero, instead repeat the value you most recently added to... | [] |
This challenge is based off a riddle I read in some book a while ago, which I found again here. It is about bullets fired from a gun once per second at varying speeds that travel in a straight line forever. When one bullet hits another, both are destroyed completely. (Feel free to replace all instances of "bullet" with... | [] |
Background
A fractal sequence is an integer sequences where you can remove the first occurrence of every integer and end up with the same sequence as before.
A very simple such sequence is called Kimberling's paraphrases. You start with the positive natural numbers:
1, 2, 3, 4, 5, 6, 7, 8, 9, ...
Then you riffle in so... | [
[
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
]
] |
About the Series
First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You can find the leaderboard along with some more information about the series in the first post.
Although I have a bunch of i... | [
[
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... |
Don't you hate it when you want to copy-paste a list of numbers (vector, array ...), from one program to another, but the format you have the numbers on doesn't match the format you need it on?
For instance, in MATLAB you may have a space separated list like this:
[1 2 3 4 5] (you can also have it comma separated, ... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
]
] |
Disclaimer: while I have been on this site for entertainment purposes for a little while now, this is my first question, so please forgive any minor errors.
Background
When assigning us homework, my teacher is really annoying and writes out all the problems we have to do individually. As such, it takes me forever to co... | [
[
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220
]
] |
Given a string input, write a program that prints a truthy value to STDOUT or equivalent if the input is a valid UUID, without using regexes.
A valid UUID is
32 hexadecimal digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters (32 alphanumeric characters and four h... | [] |
The Background
Folks were talking prime factorization in chat and we found ourselves talking about repunits. Repunits are a subset of the numbers known as repdigits, which are numbers consisting of only repeating digits, like 222 or 4444444444444444, but repunits consist only of 1.
The first couple repunits are therefo... | [] |
Introduction
In base 10, the Champernowne constant is defined by concatenating representations of successive integers. In base 10: 0.1234567891011121314151617... and so on.
You can see that the first appearence of 15 starts at the 20th decimal:
Position
00000000011111111112222222222333333333344444444445555555555666... | [] |
In his xkcd about the ISO 8601 standard date format Randall snuck in a rather curious alternative notation:
The large numbers are all the digits that appear in the current date in their usual order, and the small numbers are 1-based indices of the occurrences of that digit. So the above example represents 2013-02-27.
... | [] |
In his xkcd about the ISO 8601 standard date format Randall snuck in a rather curious alternative notation:
The large numbers are all the digits that appear in the current date in their usual order, and the small numbers are 1-based indices of the occurrences of that digit. So the above example represents 2013-02-27.
... | [] |
Task
Given input N, generate and output an NxN grid where each row, column and the two diagonals contain the numbers 1 to N (or 0 to N−1 if that's easier).
Input
The input is a positive integer N. It represents the number of columns and rows in the grid. For this problem, you can assume N will be a reasonable size, 4 ≤... | [] |
A double precision representation of a decimal can only guarantee an accuracy of 15 decimal places, thus pi is approximated as:
3.141592653589793
You can see that the digit 3 is in positions 1, 10, 16, the digit 1 is in positions 2, 4 etc.
Challenge
Your task is to create a program or function that creates a random d... | [] |
Colonies of bacteria labelled 1 through 9 live on a segment of equally-spaced cells, with empty cells indicated by 0
0 0 2 0 0 0 1 2 0 0 3 3 0 0
Every second, each colony spreads to adjacent empty cells. If two colonies reach an empty cell at the same time, the larger-labeled colony takes it.
t=0: 0 0 2 0 0 0 1 2 0 0... | [] |
The goal of this challenge is to compute one kind of numerology digit from strings containing characters and numbers.
The input may be through any convenient method (standard input, arguments, separated file).
The input may contain any printable ASCII chars, but only alphanumerical (A-Z, a-z, and 0-9) have to be consi... | [] |
A fountain is arrangement of coins in rows so that each coin touches two coins in the row below it, or is in the bottom row, and the bottom row is connected. Here's a 21 coin fountain:
Your challenge is to count how many different fountains can be made with a given number of coins.
You will be given as input a positi... | [
[
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
]
] |
Introduction
Number theory is full of wonders, in the form of unexpected connections. Here's one of them.
Two integers are co-prime if they have no factors in common other than 1. Given a number \$N\$, consider all integers from 1 to \$N\$. Draw two such integers at random (all integers have the same probability of bei... | [] |
Introduction
XOR is a digital logic gate that implements an exclusive or. Most of the times, this is shown as ^. The four possible outcomes in binary:
0 ^ 0 = 0
0 ^ 1 = 1
1 ^ 0 = 1
1 ^ 1 = 0
This can also be seen as addition modulo 2 in binary. In decimal, we need to convert the decimal to binary, 35 = 100011 and 25 =... | [] |
Some background
In math, a group is a tuple \$(G, *)\$ where \$G\$ is a set and \$*\$ is an operation on \$G\$ such that for any two elements \$x, y \in G, x * y \in G\$.
For some \$x,y,z\in G\$, basic group axioms are as follows:
\$G\$ is closed under \$*\$, i.e. \$x * y \in G\$
The operation \$*\$ is associative, i.... | [
[
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
]
] |
Time for another Pyth practice. I present here 8 problem statements with a Pyth solution each. These solutions are written by a Pyth beginner. He is quite happy about these solutions, since they are a lot shorter than his Python answers. Your task however is to show him better. Create equivalent but shorter programs.
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
]
] |
Conceptually, this challenge is really simple. You're given a list of non-negative integers ai. If possible, find a non-negative integer N, such that the list consisting of bi = ai XOR N is sorted. If no such N exists, output should be anything that can't be mistaken for a valid N, e.g. a negative number, nothing at al... | [
[
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
The Enigma was one of the first electro-mechanical rotor cipher machines used in World War II. That means that after a single letter is coded, it would change the key for the next letter. This was considered unbreakable by the Germans, due to the enormous key space. Even brute-forcing was almost impossible... | [] |
If you have ever travelled with kids more than about 20 minutes, you will have no doubt heard cries of "Are we there yet?" and "How much further?"
So we play games like "I Spy" to help pass the time as the miles go by.
There is a variation on "I Spy" whereby instead of spotting arbitrary named things, you must spot int... | [] |
Yes, this is old and probably very simple, but I really want to be mindblown by things that I thought were obvious, so here's the challenge:
You're given a positive integer as the input and you need to output the exponents of all of the prime factors up to the highest factor in base 36 ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 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
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220... |
Introduction
For the ones wondering what Befunge exactly is, it is a two-dimensional stack based language made in 1993 by Chris Pressy. I made 7 brain teasers that need to be solved in Befunge-93. This is quite an experimental challenge, but I thought it's worth a shot :). A full list of all commands used in Befunge-93... | [] |
Consider a sequence based on recurrence relations, f(n) = f(n-1)+f(n-2), starting with f(1) = x1, f(2) = x2. For x1 = 2, x2 = 1, the sequence begins like this:
2 1 3 4 7 11 18 29 47 76 123 199 322 521 843
Concatenating this into a string will give:
213471118294776123199322521843
Now, divide this list i... | [] |
There exists a brain game called Enumerate (which I made, based on Takuzu). Your challenge is to play this game.
Task
Solve a game of 4x4 Enumerate/Takuzu.
Receive a starting grid via STDIN or command line.
Output the solved grid via STDOUT or writing to file.
Rules
A game is characterized by a 4x4 board, made up o... | [] |
As a spin-off to my challenge over at Puzzling, your goal is to output 2016.
Rules:
You must include the numbers 10 9 8 7 6 5 4 3 2 1 in that order. They can be used as individual integers or concatenated together (like 1098), but the 10 may not be separated into 1 and 0 - no character(s) may be present between the di... | [] |
The Champernowne constant is a number that is constructed by concatenating the first n numbers, with n tending to infinity. It looks something like this:
0.123456789101112131415161718192021222324252627282930...
Now, I will describe to you the Rien number. It can be thought of as a minimization of the Champernowne cons... | [] |
The purpose of this challenge is to find the general term of a given arithmetic or geometric sequence.
Explanation
The formula for an arithmetic sequence is as follows
an = a1 + (n-1)d
where a1 is the first term of the sequence, n is the index of the term, and d is the common difference between the terms. For a geomet... | [] |
A list of positive integers can be visualized as a quantized mountain range where each list entry represents the height of one vertical section of the mountains.
For example, the list
1, 2, 2, 3, 4, 3, 5, 3, 2, 1, 2, 3, 3, 3, 2, 2, 1, 3
can become the range
x
x x
xxxxx xxx x
xxxxxxxx xxxxxx x
x... | [] |
Given an input of an integer n and a list of positive integers m1,
m2, ..., output a list of integers m1',
m2', ... where mx' is defined as the average of
mx-n through mx+n.
When calculating these averages, ignore indices that are out of bounds (and
adjust what you are dividing the sum by accordingly). n will always be... | [] |
Countries own a series of territories on a 1D world. Each country is uniquely identified by a number. Ownership of the territories can be represented by a list as follows:
1 1 2 2 1 3 3 2 4
We define a country's edgemost territories as the two territories closest to either edge. If the above list was zero indexed, cou... | [] |
Introduction
We've have a few base conversion challenges here in the past, but not many designed to tackle arbitrary length numbers (that is to say, numbers that are long enough that they overflow the integer datatype), and of those, most felt a little complicated. I'm curious how golfed down a change of base code like... | [] |
Introduction
A229037 has a quite intriguing plot (at least for the first few terms):
There is the conjecture, that it might indeed have some kind of fractal property.
How is this sequence constructed?
Define a(1) = 1, a(2) = 1 then for each n>2 find a minimal positive integer a(n) such that for every arithmetic 3 term... | [] |
There's a really important problem in cellular automata called the Majority problem:
The majority problem, or density classification task is the problem of finding one-dimensional cellular automaton rules that accurately perform majority voting.
...
Given a configuration of a two-state cellular automata with i + j cel... | [] |
Time for another easy challenge in which all can participate!
The multinomial theorem states:
$$(x_1 + x_2 + \cdots + x_m)^n = \sum_{k_1 + k_2 + \cdots + k_m = n} \binom n {k_1, k_2, \dots, k_m} \prod_{1 \le t \le m} x_t^{k_t}.$$
The expression in parentheses is the multinomial coefficient, defined as:
$$\binom n {k_1,... | [] |
Given an input of a string consisting entirely of qs representing quarter
notes and es representing eighth notes, output the indices of the quarter
notes that are syncopated.
Syncopation is complex, but for
the purposes of this challenge, our definition of "syncopated" will be very
simple: a quarter note that starts on... | [] |
The Sylvester-Gallai theorem says: Suppose you have a finite list of points in the plane. Suppose further that not all of those points are collinear (lie in a single line). Then there is some line containing precisely two of the points. (That is, there's some line on which two of the points lie, but not more than two.)... | [
[
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
11
],
[
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220
]
] |
Your goal is to output all the "sides" (corners, edges, faces, etc.) of an N-dimensional unit hypercube, where N is non-negative. A "side" is defined as any (N-M)-dimension surface embedded in N-dimensional space, where 1 <= M <= N.
The hypercube spans the space [0, 1] in each dimension. For example, for N=2 the square... | [] |
We all already crossed the look and say sequence, and where asked to guess the next element. As its name tells it very well, you just have to say what you see :
1
1 1
2 1
1 2 1 1
1 1 1 2 2 1
3 1 2 2 1 1
...
But, what if we had to use a different base to describe it? You could count it in base 3 as this OEIS squence do... | [] |
Generate the sequence number of bases in which n is a palindrome (OEIS A126071).
Specifically, the sequence is defined as follows: given a number n, express it in base a for a = 1,2, ..., n, and count how many of those expressions are palindromic. "Palindromic" is understood in terms of reversing the base-a digits of t... | [] |
Quick musical refresher:
The piano keyboard consists of 88 notes. On each octave, there are 12 notes, C, C♯/D♭, D, D♯/E♭, E, F, F♯/G♭, G, G♯/A♭, A, A♯/B♭ and B. Each time you hit a 'C', the pattern repeats an octave higher.
A note is uniquely identified by 1) the letter, including any sharps or flats, and 2) the octav... | [] |
Introduction
While studying, I tried to come up with several ways to cheat a multiple choice test. It basically is a compressed version of the multiple choice answers. The method goes as following:
The answers to the test:
BCAABABA
These can be converted to 3 different arrays, which indicates true or false if the curr... | [] |
Introduction
Arrays can also be seen as a field for a bouncing ball. This of course sounds very vague, so here is an example of an input:
[1, 2, 3, 4, 5, 6, 7, 8, 9]
[9, 8, 7, 6, 5, 4, 3, 2, 1]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
The challenge is to output the bounced arrays. These are made from diagonal patterns which bounce... | [
[
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 goal of this challenge is to compute the set of equivalence classes over the transitive closure of a symmetric, reflexive relation. For those who don't know what that means, here is a brief introduction into the relevant terms:
A relation ◊ is symmetric if a ◊ b ↔ b ◊ a. It is reflexive if each object is related to... | [
[
11,
425,
11,
356,
11,
422,
11,
468,
11,
434,
11,
479,
11
],
[
425,
11,
356,
11,
422,
11,
468,
11,
434,
11,
479,
11,
472
],
[
32,
11,
425,
11,
356,
11,
422,
11,
468,
... |
A helicopter starting at the top left corner is descending (in a 2D space, for the purpose of this question) towards the ground. It has an autopilot mode and a manual mode.
The autopilot mode behaves as follows:
If the space directly below is free, descend to it.
Otherwise move a step left or right, totally at random.... | [] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.