instruction_seed
stringlengths
292
48.7k
found_ngrams
listlengths
0
21
Connect Four is a game where two players take turns to drop disks into columns of a vertically mounted grid, and attempt to connect four disks orthogonally or diagonally. When a column is chosen, the disk falls to the lowest empty position in that column, so any game may be completely specified by the size of the grid ...
[]
Given a number N, draw a left aligned NxN board of numbers, leaving 1 blank (as a space) (I will show diagrams with N=5) 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Your job is to construct the Sieve of Eratosthenes, step by step. First, start with 2. It's prime, so leave it there, and re...
[]
Consider the natural sequence up-to 6 (disregard 1): 2,3,4,5,6 We start scanning from the left (in this case from 2), search for a number divisible by 2 (here 4) and then remove both the numbers from the list (here 2 & 4), such that the list reduces to: 3,5,6 We continue the same process, here leftmost is 3, so we...
[]
The Goldbach conjecture states that every even number greater than two can be expressed as the sum of two primes. For example, 4 = 2 + 2 6 = 3 + 3 8 = 5 + 3 However, once we get to 10 something interesting happens. Not only can 10 be written as 5 + 5 but it can also be written as 7 + 3 Since 10 can be expressed as t...
[]
The challenge is to write the fastest code possible for computing the permanent of a matrix. The permanent of an n-by-n matrix A = (ai,j) is defined as Here S_n represents the set of all permutations of [1, n]. As an example (from the wiki): In this question matrices are all square and will only have the values -1 a...
[]
This challenge was inspired by this Wendy's commercial from 1984. Illustration by T S Rogers Your task is to find a hexadecimal 0xBEEF on a binary bun. The 'beef' consists of the following pattern: 1 0 1 1 (0xB) 1 1 1 0 (0xE) 1 1 1 0 (0xE) 1 1 1 1 (0xF) And the 'bun' consists of a 12x12 binary matrix, such as: 1 ...
[]
Introduction Suppose you have a ruler with numbers from 0 to r-1. You place an ant between any two of the numbers, and it starts to crawl erratically on the ruler. The ruler is so narrow that the ant cannot walk from one position to another without walking on all the numbers in between. As the ant walks on a number for...
[]
This is different from My Word can beat up your Word as it is less complex and only requires you to calculate it, and not compare them. To find the digital root, take all of the digits of a number, add them, and repeat until you get a one-digit number. For example, if the number was 12345, you would add 1, 2, 3, 4, and...
[]
Bailey–Borwein–Plouffe Iterations We've seen a few pi challenges on PPCG, but none that specifically dictate the algorithm you should be using. I'd like to see implementations of the Bailey–Borwein–Plouffe algorithm in any language up to iteration n. The formula is as follows: Your algorithm should output each iterati...
[]
I am interested in seeing programs which don't ask for any input, print a googol copies of some nonempty string, no less, no more, and then stop. A googol is defined as \$10^{100}\$, i.e., 1 followed by a hundred 0's in decimal. Example output: 111111111111111111111111111111111111111111111111111111111111111111111111......
[]
Your challenge is to write a program or function that, when given two strings of equal length, swaps every other character and outputs/returns the resulting strings in either order. Examples "Hello," "world!" --> "Hollo!" "werld," "code" "golf" --> "codf" "gole" "happy" "angry" --> "hnpry" "aagpy" "qwerty" "dvorak" -->...
[]
Background Back in the late 90's / first 00's when Flash Web Design was so much cool that noone could live without having a full Flash website, or at least an animated widget, I was hired to develop a "horse races viewer" in Flash/Actionscript, in the shape of an 80's videogame style animation, so the site's visitors c...
[]
The program should take input the number, the start of the range and the end of the range, and output how many integers the number appears between the start and end of the range, inclusive. Both programs and functions are allowed. Example Inputs For example: //Input example 1 3,1,100 //Input example 2 3 1 100 //Input e...
[]
This is my first code golf exercise for you: Your input is two integers n and k. You can assume n >= 1 and k >= 1 You have to output all numbers from 1 to n (inclusively) and replace every element that is a multiple of k or that contains k with "Shaggy". you can take the input in any convenient form and output it in a ...
[]
A Primenary (binary-prime) string is one which, when written as a binary grid, every row and column has a prime total. That's quite a vague explanation, so let's break it down with a worked example... For this example we'll use the string bunny: First, find the ASCII code point of each character and its binary repre...
[]
Inspired by, and in memory of, my dear friend and colleague, Dan Baronet, 1956 – 2016. R.I.P. He found the shortest possible APL solution to this task: Task Given a Boolean list, count the number of trailing truth values. Example cases {} → 0 {0} → 0 {1} → 1 {0, 1, 1, 0, 0} → 0 {1, 1, 1, 0, 1} → 1 {1, 1, 0, 1, 1} → 2 ...
[]
Introduction In mathematics, a polygonal number is a number represented as dots or pebbles arranged in the shape of a regular polygon. The dots are thought of as alphas (units). These are one type of 2-dimensional figurate numbers. The number 10, for example, can be arranged as a triangle: * ** *** **** But 10 cannot...
[]
Hearts is a trick-taking card game for 4 players. Each trick is taken by the player who played the highest card of the leading suit. At the end of each hand, the players incur a penalty score depending on the penalty cards they have taken; the task is to determine the scores under Microsoft Hearts rules. Input Input 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 ] ]
A monotonic subsequence is a sequence of numbers \$a_1, a_2, ..., a_n\$ such that $$a_1 \le a_2 \le ... \le a_n \\ \text{or} \\ a_1 \ge a_2 \ge ... \ge a_n$$ [1, 3, 3, 7, 9, 13, 13, 100] is a monotonic (non-decreasing) subsequence, as well as [9, 4, 4, 3, 0, -10, -12] (this one is non-increasing), but [1, 3, 6, 9, 8] 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 ] ]
Problem The goal is as the title says to find the \$n\$th prime such that \$\text{the prime}-1\$ is divisible by \$n\$. Explanation Here is an example so you understand the question, this is not necessarily the way it ought to be solved. It merely as a way to explain the question given \$3\$ as an input we would first ...
[]
Let's take a look on a typical loop, which usually performs 8 iterations: for (int x=0; x<8; ++x); You have to make it infinite! It's a popularity-contest for all languages that support such form of for loop. So solution with highest score (upvotes minus downvotes) wins. If your language has the other form of for loo...
[]
I love /usr/share/dict/words; it's so handy! I use it for all my programs, whenever I can! You're going to take advantage of this ever so useful file to use, by testing a word's individuality. Input A word; defined in this challenge as any string of characters /usr/share/dict/words in some format; you may hard code i...
[]
EDITS: Added link to the plain-text (multiple strings) test data Added BLANK,EDGE and TIE2 test cases (see Test Data section) (11/25) Updated the JSON test cases (some lines were ill-formatted) (11/24) Renju match gone bad ! (well, technically these guys are playing Go, but who cares) Wikisource TL;DR Take a 15x15 ...
[]
Take a non-nested array as input. Turn it into a matrix by using the following method: Let's say my array is [1, 2, 3, 4, 5] First, I repeat that array 5 times: (the length) [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]] Then, I read it along the diagonals: [[1], [2, 1], [3...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
Task Given a Boolean matrix, find one (or optionally more) subset(s) of rows which have exactly one True in each column. You may use any algorithm, but must support very large matrices, like the last example. One possible algorithm (Knuth's Algorithm X) While there is no requirement to use this algorithm, it may be you...
[ [ 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 An unlabelled tree may look like this: o / | \ o o o | / \ o o o To linearize this tree, we first label each node o with it's number of child nodes: 3 / | \ 1 0 2 | / \ 0 0 0 and then write the numbers in a list in a breath-first manner, meaning line by line and left to right: [3...
[]
You will write a simple program that prints exactly 1 2 3 4 5 6 7 8 9 10 to STDOUT, Console, or your language's closest output method. No other visible output should be seen. Any other code executed must be back-end only. This is answer-chaining, so the catch is that you must include the previous answer's source code i...
[]
Let's use the four basic operations, addition +, multiplication *, subtraction - and division / (float, not integer). Stewie's sequence is defined as follows: x = [x(1), x(2)] // Two initial numbers (one indexed) x(3) = x(1) + x(2) x(4) = x(2) * x(3) x(5) = x(3) - x(4) x(6) = x(4) / x(5) x(7) = x(5) + x(6) ... and s...
[]
Introduction A xenodrome in base n is an integer where all of its digits in base n are different. Here are some OEIS sequences of xenodromes. For example, in base 16, FACE, 42 and FEDCBA9876543210 are some xenodromes (Which are 64206, 66 and 18364758544493064720 in base 10), but 11 and DEFACED are not. Challenge Given ...
[ [ 11, 220, 16, 11, 220, 17, 11, 220, 18, 11, 220, 20, 11 ], [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220 ] ]
An unspeakable number is a number which is divisible by seven or has seven as one of its digits. A children game is to count skipping unspeakable numbers 1 2 3 4 5 6 ( ) 8 9 10 11 12 13 ( ) 15 16 ( ) 18 ... Cantor's version of the game is the sequence defined by recursively filling in the sequence "1 2 3 4 5 6 ( ) 8.....
[]
Given three sidelengths of a triangle, evaluate its aspect ratio AR given the following formula: where The closer to equilaterality a triangle is, the closer to 1 its aspect ratio is. The aspect ratio is bigger or equal to 1 for valid triangles. Inputs The input is three real positive numbers which can be encapsulate...
[]
There’s a famous tricky algorithm for counting the number of set bits in a 32-bit unsigned integer: int popcount(unsigned x) { x = (x & 0x55555555) + ((x >> 1) & 0x55555555); x = (x & 0x33333333) + ((x >> 2) & 0x33333333); x = (x & 0x0F0F0F0F) + ((x >> 4) & 0x0F0F0F0F); x = (x & 0x00FF00FF) + ((x >> 8) & 0x...
[]
Alphabetize Integers For a given set of numbers, put them in alphabetical order when they are spelled out (i.e. 1: one, 2: two, 90: ninety, 19: nineteen). Your code should work for the range [-999999, 999999]. Output must have a delimiter between numbers. A space will work, as will a space and a comma as shown in the e...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
Introduction Consider a sequence of integers and one of its subsequences, say A = [4 2 2 4 4 6 5] and B = [2 4 5]. We want to remove the elements of B from A in order, and there are several ways of doing that: A = 4 2 2 4 4 6 5 B = 2 4 5 -> 4 2 4 6 A = 4 2 2 4 4 6 5 B = 2 4 5 -> 4 2 4 6 A = ...
[]
Binary to decimal converter As far as I can see, we don't have a simple binary to decimal conversion challenge. Write a program or function that takes a positive binary integer and outputs its decimal value. You are not allowed to use any builtin base conversion functions. Integer-to-decimal functions (e.g., a functio...
[]
Introduction and Credit Imagine you're Amazon. Imagine you have a large number of products for which a lot of people have written reviews scoring 1-5 stars. Now you need to give your customers a summary for each product based on the simple product-scoring association. Because you're Amazon, time is money and as such yo...
[]
We are putting balls into a fixed number a bins. These bins begin empty. Empty bin (a=4): 0 0 0 0 And one by one we add balls to the bins. 0 0 0 1 or 0 0 1 0 or 0 1 0 0 or 1 0 0 0 We need a quick way to loop over all the possible states the bins take, without duplicates and without missing any and we don't want t...
[]
Generate me a QFP chip! From the sandbox! QFP is a type of form factor for an electrical component where pins come out the sides of a chip. Here are is a picture of a typical QFP component: you can see that the general formula is to have 4 sides of equal numbers of pins. Your challenge is to create a program that tak...
[]
You're given a non-empty list of positive integers, e.g. [6 2 9 7 2 6 5 3 3 4] You should rank these numbers by their value, but as is usual in leaderboards, if there is a tie then all the tied numbers get the same rank, and an appropriate number of ranks is skipped. The expected output for the above list would theref...
[]
Make a code that takes a list and a number as input, and generates all possible combinations with the length of the number. For example, with the list {0,1} and the number 2: 00 01 10 11 Your program doesn't have to expect characters twice or more often in the list, such as {0,0,0,0,0,1,1,5,5} Make sure you print the ...
[]
A secondary number is a positive integer whose prime factors (without multiplicity) are all less than or equal to its square root. 4 is a secondary number, because its only prime factor is 2, which equals its square root. However, 15 is not a secondary number, because it has 5 as a prime factor, which is larger than it...
[ [ 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 the decimal representation of every rational number p/q, you have a periodic tail, a non-periodic head, and a section before the decimal point in the following format: (before decimal point).(non-periodic)(periodic) Some examples include: 1/70 = 0.0142857... = (0).(0)(142857) 10/7 = 1.428571... = (1).()(428571) ...
[]
Scenario One of your friends is struggling on a homework assignment. He needs a simple program which prints the first 404 natural numbers: 1 2 3 4 5 6 7 8 9 10 11 ... 401 402 403 404 Your challenge is simple: write this program for him. However, your connection is terrible, so 1 random character is lost every time you...
[]
Introduction Consider two non-empty integer arrays, say A = [0 3 2 2 8 4] and B = [7 8 7 2]. To perform alignment addition on them, we do the following: Repeat each array enough times to have total length \$\text{lcm(length(A), length(B))}\$. Here \$\text{lcm}\$ stands for lowest common multiple. A -> [0 3 2 2 8 4][...
[]
Help PPCG Claus Deliver his Presents Overview PPCG Claus is running hella late delivering his gifts because nowadays we have so many odd little kiddos out there. This makes it much harder for PPCG Claus to get all the presents to the correct place. Your challenge is to help him delvier his presents correctly. The Compl...
[]
Prelude: I wanted to train making test cases, so I'm gonna try them on something easy. Challenge: Take any given (string) input (within visible ASCII range) and deduce if it's a number and output something that could be used to evaluate. Rules: A number will only contain the characters -0123456789,. Answers are only r...
[]
Input: A non-empty sequence of integers greater than zero, the length of which is greater than 1. Output: The largest product of all elements of the longest subsequence between the minimum and maximum elements of sequence including themselves. Note: Because the minimum and maximum elements can be repeated, then to a de...
[]
Positional Awareness Your task is to generate a program that, for every permutation of its characters (which includes the original program), outputs the positions of every character relative to the original program. If your program is Derp you must output [0, 1, 2, 3] (or some equivalent). This is because D is in the...
[]
The nutty maths professor wants to encode all of their research using a system sure to fox even the wiliest of their competitors! To this end the professor has decided to change the base of not just the number that they're writing but every single digit in that number, according to which place the digit finds itself in...
[]
Challenge Given a non-empty array of integers, e.g.: [5, 2, 7, 6, 4, 1, 3] First sever it into arrays where no item is larger than the previous (i.e. non-ascending arrays): [5, 2] [7, 6, 4, 1] [3] Next, reverse each array: [2, 5] [1, 4, 6, 7] [3] Finally, concatenate them all together: [2, 5, 1, 4, 6, 7, 3] This sh...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
Create a program that prints all whole numbers inclusively between an interval (a, b), and replaces multiples of 8 in the sequence with random (uniformly distributed, independent of other characters), non-numeric, non-whitespace, printable ASCII characters. Assume 0 < a < b in all cases. If the number has more than 1 ...
[]
We had a prime factorization challenge a while ago, but that challenge is nearly six years old and barely meets our current requirements, so I believe it's time for a new one. Challenge Write a program or function that takes as input an integer greater than 1 and outputs or returns a list of its prime factors. Rules I...
[]
Given a number n >= 2, output all the positive integers less than n where gcd(n, k) == 1 (with k being any one of the output numbers).  Numbers of this sort are coprime to each other. Example: 10 gives the output [1, 3, 7, 9] (in any form you like, as long as the numbers are unambiguously separated and in some sort of ...
[]
For any positive 32-bit integer (1 ≤ n ≤ 0xFFFFFFFF) output the number of bits needed to represent that integer. Test cases | n | n in binary | bits needed | |----------------------------------| | 1 | 1 | 1 | | 2 | 10 | 2 | | 3 | 11 | 2 | | 4 | 10...
[]
Goal: Given a hand of 5 cards, determine its value in the game Cribbage. Input a string through any reasonable means. You can assume the string will always be in this format: [Card Value][Card Face],[Card Value][Card Face],[Card Value][Card Face],[Card Value][Card Face],[Card Value][Card Face] Valid Card Values: A,2,...
[]
The presents have been opened. The mince-pies have been eaten. The Star Wars have been watched. The Christmas Season is beginning to wind down. By now you may well have pulled a few Christmas Crackers. If you're lucky, instead of the usual useless plastic toys, you may have won a Mystery Calculator with which you ...
[]
Introduction Similar to the Fibonacci Sequence, the Padovan Sequence (OEIS A000931) is a sequence of numbers that is produced by adding previous terms in the sequence. The initial values are defined as: P(0) = P(1) = P(2) = 1 The 0th, 1st, and 2nd terms are all 1. The recurrence relation is stated below: P(n) = P(n - ...
[ [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
This is the ASCII version of this challenge. The initial post was separated per request by Martin Ender Introduction Similar to the Fibonacci Sequence, the Padovan Sequence (OEIS A000931) is a sequence of numbers that is produced by adding previous terms in the sequence. The initial values are defined as: P(0) = P(1) =...
[ [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
About a year ago on Dec 31, 2015, I had the idea that: We should make a time capsule string. Everybody gets to add one character and next new years we'll see who can make the best program out of all the characters with the esolangs that exist then. Doorknob graciously collected characters from the PPCG community and ...
[ [ 11, 220, 16, 17, 11, 220, 16, 19, 11, 220, 16, 21, 11 ], [ 220, 16, 17, 11, 220, 16, 19, 11, 220, 16, 21, 11, 220 ], [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220,...
This challenge is simple enough that it's basically all in the title: you're given a positive integer N and you should return the smallest positive integer which is not a divisor of N. An example: the divisors of N = 24 are 1, 2, 3, 4, 6, 8, 12, 24. The smallest positive integer which is not in that list is 5, so that'...
[ [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220 ] ]
In this challenge, you need to solve 4 different tasks using the same set of characters. You can rearrange the characters, but you can't add or remove characters. The winner will be the submission that solves all tasks using the smallest number of characters. All tasks must be solved in the same language. Note that i...
[]
Challenge Given a nonempty list of real numbers, compute its median. Definitions The median is computed as follows: First sort the list, if the number of entries is odd, the median is the value in the center of the sorted list, otherwise the median is the arithmetic mean of the two values closest to the center of the ...
[]
Given a list of 1s and -1s, determine whether or not it is a valid OVSF code (by outputting a truthy or falsey value). OVSF codes are defined as follows: [1] is an OVSF code. If X is an OVSF code, then X ++ X and X ++ -X are both OVSF codes. Here ++ is list concatenation, and - negates every element in the list. No ...
[]
Balanced bases: Balanced bases are essentially the same as normal bases, except that digits can be positive or negative, while in normal bases digits can only be positive. From here on, balanced bases of base b may be represented as balb - so balanced base 4 = bal4. In this challenge's definition, the range of digits i...
[ [ 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 ] ]
This was inspired by part of the 2016 ARML competition Team Problem #6. Here's the challenge: You're given a "wildcard sequence", which is a sequence of digits and another character. A string matches this wildcard sequence by the following pseudocode: w = wildcard s = string # s matches w iff for all 0 >= i > wildcard....
[ [ 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 3 input items, a list of coordinate pairs, a 2D string, and a single-character string, output whether the character at each coordinate of the 2D string is equal to the single character. You can take the input in any order and the coordinates may be 1-indexed. You may take the 2D string as a 2D list, a list of li...
[]
I think it's easiest to explain this challenge in a sequential manner. Start with an input number \$N\$ and: Find its highest prime factor Check numbers above and below \$N\$ and see if the highest prime factor is higher (i.e. the highest prime factor of \$N-1\$ and/or \$N+1\$ is higher than the factor of \$N\$. Conti...
[]
I found about Code Golf after writing this program and decided to post the rules here so you can try it out too. I saw this, which is a less restrictive version of my question. I've got a bit more rules which (in my opinion) make the task quite a lot more tougher. Title says it all. If the input is 8, we should get: 8 ...
[]
Task Given a ASCII diagram of a loop e.g. .................... ......@@@@@......... ......@...@......... .....@@...@@@@@..... ....@@........@..... ....@........@@..... ....@@@@@@@@@@...... .................... .................... And a location on the loop e.g. (7,1) You must find the inside and outside of the loop ...
[]
Background Programmers these days can't seem to keep their buffers straight! A common source of error is trying to use an array index that is too large for the buffer. Your task is to implement a buffer where large indices are reduced to a size that the buffer can handle. Because I decide exactly what's best for everyo...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
Yup, you read the title right. play the sound of pi. More specifically, for every digit of pi in the first 1000, map it to a musical note and output the resulting melody to a file. Basically, each digit turns to a note on the C Major scale (basically the normal scale). so 1 turns to Middle C, 2 turns to D4, 3 turns to ...
[ [ 16, 11, 220, 16, 17, 11, 220, 16, 19, 11, 220, 16, 21 ] ]
Challenge Write a function or program that accepts a line of input, performs a very specific and oddly familiar shuffle on its characters, and outputs the result. The required shuffling can be described using the following algorithm: Label each character in the input with a 1 based index. Write character number 1 as o...
[]
Given a directed graph, output the longest cycle. Rules Any reasonable input format is allowed (e.g. list of edges, connectivity matrix). The labels are not important, so you may impose any restrictions on the labels that you need and/or desire, so long as they do not contain additional information not given in the in...
[]
Question : You will be given the starting and ending integers of a sequence and should return the number of integers within it which do not contain the digit 5. The start and end numbers should be included! Examples: 1,9 → 1,2,3,4,6,7,8,9 → Result 8 4,17 → 4,6,7,8,9,10,11,12,13,14,16,17 → Result 12 50,60 → 60 → Result...
[]
Brun's constant is the value to which the sum of the reciprocals of twin prime pairs (1/p and 1/(p+2) where p and p+2 are both prime) converges. It is approximately 1.902160583104. Given a positive integer N, approximate Brun's constant by summing the reciprocals of the twin prime pairs where both primes in the pair ar...
[]
(Challenge taken from a multiplayer game (clash of code) at codingame.com) The challenge Find the n-th term of the following sequence: 1, 1, 2, 1, 2, 3, 1, 2, 3, 4... or, to make it more obvious, {1}, {1,2}, {1,2,3}, {1,2,3,4}... The sequence is made up from concatenated ranges from 1 to x, starting from 1, all the way...
[]
Introduction There is a small village with nothing but a few houses and empty fields. The local bureaucrats want to divide the village into lots so that each lot contains exactly one house, and the borders of the lots form a nice straight-line grid. Your task is to determine whether this is possible. The task Your inpu...
[]
Introduction There is a tax collector that has some trouble managing the taxes of his kingdom: the historical records have burnt down in a great fire. He wants to find out how many possible pasts there could be in terms of where the current money was inherited from. Luckily, his kingdom is very simple. The kingdom can ...
[]
The problem: Write a function which, given a cycle length n and a number of cycles m, where 'm' is within [2, n-2], generates m random cycles, each of length n, and all of which are derangements of each other. Then n=7, for example, m could be 2, 3, 4, or 5. All possible sets of m cycles of length n that fit the criter...
[]
Introduction Some of you may have heard of Hilbert's Grand Hotel. The manager there has lost his list of where the guests are staying but he still has the order in which they checked in. Each guest can not stay in a room with a room number less than their value and if a guest is added to a lower room, all guests in hig...
[]
CodeGolf Challenge PWSSHHHH! You wake up in a cryogenics lab in the year 3000. Upon being escorted to the assignment office to receive your career chip, presumably that of a delivery boy, a probe detects that you are from the year 2000. Because of this, and a few stereotypes, you are assumed stupid compared to today's ...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
A graphic sequence is a sequence of positive integers each denoting the number of edges for a node in a simple graph. For example the sequence 2 1 1 denotes a graph with 3 nodes one with 2 edges and 2 with one connection. Not all sequences are graphic sequences. For example 2 1 is not a graphic sequence because there ...
[]
Your friend invited you to a high-stakes poker game at the last minute and, as a computer scientist, you've decided to use your skills to gain an edge on the game. Your task will be, given 2 cards (your hand) and 0, 3, 4 or 5 cards (the dealt cards), you must decide what the best possible hand you can get will be. If a...
[]
We are all familiar with the Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765 However, instead of, f(n) = f(n-1) + f(n-2) we'll be taking digital sum of the previous 2 entries. The sequence should still start with 0, 1, after that the differences are rapid...
[ [ 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...
OEIS has a variation (A111439) on Golomb's sequence. As in Golomb's sequence, A(n) describes how often n appears in the sequence. But in addition, no two consecutive numbers may be identical. While building up the sequence, A(n) is always chosen as the smallest positive integer that doesn't violate these two properties...
[]
Create a function (preferably) or a program that takes an ordered collection and outputs the smallest possible palindrome that starts with the input. For example: >>> completePalindrome( [1, 2, 3] ) [1, 2, 3, 2, 1] >>> completePalindrome( [1, 2, 3, 4, 5, 4, 3, 2] ) [1, 2, 3, 4, 5, 4, 3, 2, 1] >>> completePalindrome( ...
[ [ 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 The 1-2-3-Tribonacci Sequence Imagine for a second that you could make a fibonacci sequence by replacing the standard iteration formula with the following: Basically, instead of summing the last two to get the next, you sum the last three. This is the basis for the 1-2-3-Tribonacci sequence. Brown's Criteri...
[]
Background I was inspired by 3Blue1Brown's recent video about the necklace splitting problem (or as he calls it, the stolen necklace problem) and its relationship to the Borsuk-Ulam theorem. In this problem, two thieves have stolen a valuable necklace consisting of several different types of jewels. There are an even n...
[]
Objective Given an input list of 6 distinct digits, find 3 numbers a, b and c such that a × b = c, with a having 2 digits, b having 1 digit and c having 3 digits. In a more visual way, your program must arrange those 6 digits in the boxes of this image: If more than one solution exists, you may output any of them. Inp...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ] ]
A Graceful Graph is a type of Simple Graph. Graceful graphs are special because there is a way to label all their nodes with positive integers so that when the edges are also labeled with the differences of the nodes they connect, no two edges have the same label and every label up to the number of edges is used. Work...
[]
Objective Generate the original scrambled list, from the movements that an Insertion Sort would do to sort it. The original list will have all numbers from 0 to N-1(inclusive) where N is the size of the input. Input A list containing the necessary moves to sort the list. Each value represents the amount of slots displa...
[]
An Abundant number is any number where the sum of its proper divisors is greater than the original number. For example, the proper divisors of 12 are: 1, 2, 3, 4, 6 And summing these results in 16. Since 16 is larger than 12, 12 is abundant. Note that this does not include "Perfect numbers", e.g. numbers that are equa...
[]
Your task is to calculate the expected chance of winning for 2 players in some game, each with their own ELO Rating. Player A has ELO Ra and player B has ELO Rb The expected score for Player A (Ea) is: 1 / (1 + 10(Rb - Ra) / 400). There is a similar equation for Player B (Eb): 1 / (1 + 10(Ra - Rb) / 400). If you want a...
[]
Task is to output this text: ABCDEFGHIJKLMNOPQRSTUVWXYZA A 00000000000000000000000 Z B Y C 101010101010101010101 X D W E V F 2101210121012101210 U G T H S I R J 123210...
[]
You're in charge of distributing T-Shirts to everyone. Simple enough, right? But remember, there are different sizes of T-Shirts, and you have to keep that in mind... Challenge Specifications There are N T-Shirt sizes. There are K people. Each person may wear any T-Shirt that is larger than them, but they can only wear...
[]
Inspired by Silicon Valley's "three-comma club" scenes, like this one, in this challenge you'll be telling ten people the "comma club" to which they each belong. If you're unfamiliar with the term "comma club," let me explain: you're in the one-comma club if the money you have is in the inclusive range $1,000.00 to $99...
[]
Note: Minor spoilers for The Martian are in this challenge. Read ahead with caution The Martian is a Science Fiction novel about astronaut and botanist extraordinaire, Mark Watney, who has been accidentally stranded on Mars. At one point in the book, Mark tries communicating with NASA, but the only means of communicat...
[]
You've probably heard of the Fibonacci numbers; they're pretty famous. Each number in the Fibonacci sequence is the sum of the last two in the sequence with the first and second numbers being 1. The sequence looks like this: 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75...
[]
You should have heard about the Fibonacci Numbers, often called the Fibonacci Sequence. In this sequence the first two terms are 0 and 1, and every number after the first two is the sum of the two preceding ones. In other words, F(n) = F(n-1) + F(n-2). Here are the first 20 Fibonacci numbers: 0 1 1 2 3 5 8 13 21 34 55 ...
[]
Definition of Additive Primes: Numbers which have exactly 2 divisors are called Prime numbers. Numbers which are prime and their sum of digits is also a prime number are called Additive Primes Task: Given an integer x, compute all the additive primes amongst the first x prime numbers, with 2 being considered both t...
[]