instruction_seed
stringlengths
292
48.7k
found_ngrams
listlengths
0
21
Introduction By definition, unique identifiers should be unique. Having multiple identifiers that are the same causes one to retrieve unexpected data. But with data arriving concurrently from multiple sources, it can be difficult to ensure uniqueness. Write a function the uniquifies a list of identifiers. This is po...
[]
Task Given a non-empty array of 0 and 1, halve the lengths of the runs of 0. Input An array of 0 and 1. Acceptable format: Real array in your language Linefeed-separated string of 0 and 1 Contiguous string of 0 and 1 Any other reasonable format For example, the following three inputs are all acceptable: [1, 0, 0, 1]...
[]
Given a list of (key, value) pairs, determine whether it represents a function, meaning that each key maps to a consistent value. In other words, whenever two entries have equal keys, they must also have equal values. Repeated entries are OK. For example: # Not a function: 3 maps to both 1 and 6 [(3,1), (2,5), (3,6)] ...
[]
I used to play a game while I was in the car, it consisted in taking the n-1 first numbers of another car plate and use operators and roots on them to get the nth number of the plate. I could use the following operators and roots : addition (ex: 1 + 1 = 2) subtraction (ex: 2 - 4 = -2) division (ex: 10 / 2 = 5) (Note ...
[]
The goal of this challenge is to use Euler's method to approximate the solution of a differential equation of the form f(n)(x) = c.† The input will be a list of integers in which the nth value represents the value of f(n)(0). The first integer is f(0), the second is f'(0), and so on. The last integer in this list is 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 ] ]
Write a program which calculates if an inputted monetary value, as an integer, can be represented by a unique combination of coins and/or notes, that meaning the same coin/note cannot be used more than once. Your program should take a value as input, and can take a list of coin/note values either via input or via your ...
[]
In the standard loopholes, the following is forbidden: Claiming that your answer is written in "MyOwnLanguage", where the command x means "read a sequence of numbers, split them into groups of three, and print the last numbers of those groups where the second number is less than the first" Here, we are going to do th...
[]
K-Means Clustering (Wikipedia) The task here is rather simple, perform a single iteration of a k-means clustering algorithm on a binary matrix. This is essentially the setup task for the main k-means algorithm, I felt the setup might be easier and entice golfing languages to give it a shot as well. The matrix passed to...
[]
Challenge Given a list of integers, show how gravity sort would be done. Gravity Sort In gravity sort, imagine the numbers as rows of asterisks. Then, everything falls, and the new rows will be obviously sorted. Let's look at an example: [2, 7, 4, 6]: ** ******* **** ****** ------- ** **** ******* ****** ------- ** ...
[]
Given an array of numbers, find out how many iterations of averaging* it takes for the average of every element to be no more than 1 higher or lower than the first element (absolute difference between the array's average and the first element is less than or equal to 1). *Array averaging To "average" a number in our ar...
[]
Suppose we start with the infinite list of prime numbers: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, ... Then, we take the absolute differences between each pair of numbers, repeatedly: [1, 2, 2, 4, 2, 4, 2, 4, 6, 2, 6, 4, 2, 4, 6, 6, 2, 6, 4, ... [1, 0, 2, 2, 2, 2, 2, 2, 4, 4, 2, 2, ...
[]
I saw this recent Puzzling question: Add parentheses to make this true And saw that one answer used a Python script to try all possibilities. Your challenge is, given an expression (as a string) and an integer, is to make a program that can tell whether you can add parens to make the expression equal the integer. For ...
[]
You will be given a number x, where 0 <= x <= 2^32 - 1. You should output a list of numbers in decimal, after recursive splitting in binary format. Examples: Example 1: 255 -> 255 15 15 3 3 3 3 1 1 1 1 1 1 1 1 The current list is just 255. The binary representation of 255 is 1111 1111. Splitting it, we get 1111 and 1...
[]
Sometimes, I have lists of constant matrices in my code: [ [[1, 0], [0, 1]], [[1, 0], [0,-1]], [[0, 1], [1, 0]], [[0,-1], [1, 0]] ] That's a terrible use of screen real estate. I'd much rather write them next to each other: [ [[1, 0], [[1, 0], [[0, 1], [[0,-1], [0, 1]], [0,-1...
[]
Challenge Find the oxidation states of each of the atoms in a given molecule. These can be output as a list or otherwise. Rules The total oxidation state of a molecule will always be zero. The total oxidation state is the sum of the oxidation states of each of the individual atoms in the molecule. The following atoms h...
[]
A mad scientist has just created a new species of bacterium! He has decided to name it Noblus Gentlemanus, after observing its behaviour. However, his bacteria have ran out of food, and have declared war, as they are able to harvest other bacterium's corpses for enough food to create copies of themselves. There are ...
[]
In Rocket League, there are controls assigned to quick chat. For PC, they are 1, 2, 3, and 4. To use a quick chat, you must press two controls. For example, the first option would be 1, 1. You will be simulating the Rocket League client. You will be given a non-empty list composed only of four characters of your choosi...
[ [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220 ] ]
Given 2 non-negative integers as input, output a non-negative integer that cannot be created through any mathematical operators on the 2 inputs. For example, given inputs 2 and 3, 6, 0, 5, 1, 9, 8, 23, 2 are all invalid outputs. Operations that must be taken into account are: Addition (a + b) Subtraction (a ...
[ [ 11, 220, 16, 11, 220, 17, 11, 220, 18, 11, 220, 20, 11 ] ]
Task Write a program or function that, given a string and a list of strings, replaces each occurrence of an element of the string list contained in the string with the next element of the string list. Example The string is The cat wore a hat on my doormat so I gave it a pat and the list is ["at","or","oo"], we observe ...
[]
An addition chain is a sequence of integers starting with 1, where every integer other than the initial 1 is a sum of two previous integers. For instance, here's an addition chain: [1, 2, 3, 4, 7, 8, 16, 32, 39, 71] Here are the sums that make it an addition chain: 1 + 1 = 2 1 + 2 = 3 1 + 3 = 4 3 + 4 = 7 1 + 7 = 8 8 +...
[]
Given a stream of bits, output the shortest possible Hamming code that encodes it. The steps to generate the Hamming code are as follows, although your submission does not necessarily have to conform to them as long as it produces identical output. The input 110100101 will be used as an example. Pad the input with tra...
[]
Also known as the [analog root] (Opposite of the digital root!) ;) The digital root of a number is the continuous summation of its digits until it is a single digit, for example, the digital root of 89456 is calculated like this: 8 + 9 + 4 + 5 + 6 = 32 3 + 2 = 5 The digital root of 89456 is 5. Given a digit as input vi...
[]
Kids who are learning how to count often know runs of numbers, but can't seem to put those runs together properly. For example, they might say: 1,2,3,4,7,8,9,10 Sometimes kids will realize that they skipped some numbers, and go back: 1,2,3,4,7,8,5,6,7,8,9,10 This is clearly the superior pattern. We need to identify ...
[]
The challenge You're given: a non-empty, unsorted list h of positive integers (the haystack) a positive integer n (the needle) Your task is to return the list of all unique decimal concatenations of permutations of h whose binary representation contains the binary representation of n. Examples h = [ 1, 2, 3 ] n = 65...
[ [ 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 ] ]
Before I begin, this challenge was not mine originally Credits to The University of Waterloo. This came from the Canadian Computing Competition 2016, Senior Problem 5. Here is a clickable link to the contest PDF: http://cemc.uwaterloo.ca/contests/computing/2016/stage%201/seniorEn.pdf Here is a link to the site: http://...
[]
This is a challenge about the the tricks and optimizations that can be used when golfing in CJam. CJam golfers may recognize many of the tricks involved. However, unfamiliar approaches and constructs may be involved, so take a look at the CJam tips as well as the CJam instruction reference if you get stuck. Solutions m...
[]
The Straddling Checkerboard is a method for converting letters to numbers and was part of a pencil an paper cipher known as VIC To convert letters to numbers first you have to make a checkboard like this: 0 1 2 3 4 5 6 7 8 9 --------------------------------------- E T A O N ...
[]
Overview Given a 2 dimensional array of values with a filled in rectangle, find the position and size of the rectangle. Do it in the fewest array accesses as possible. Requirements The x and y values in the output must be 0-indexed. The top left corner is (0, 0). The output should be the 4-tuple (x, y, width, height)....
[]
DONT EVALUATE YET, ALMOST FINISHED, NEED A CLEAR WINNING CRITERION Make me rich in minecraft Minecraft is a 3D game made of blocks that you can destroy and place. There are some interesting farms you can build to provide you with game resources. In this problem, we will only have a look at pumpkin and melons farms. Her...
[]
The Challenge Generate 1 sec of an 8 bit tone sampled at 256 samples per second. The tone will be made up of a number of sine waves. The frequency of each sine wave will be determined from the input data. These are deep tones, too low for a human to perceive, but I've chosen 8 bit numbers here since it's code-golf. The...
[ [ 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, ...
When writing code-golf programs, I usually end up using some numeric constants. I always put them in decimal because that's how I think, but I just realized that my language supports other number formats that might let me shorten my code slightly. Challenge Given a non-negative integer less than 2^53-1, decide whether ...
[]
Your task is to take an encrypted string as input, and output the string decrypted, to reveal its hidden message. The strings, both the input and output, will contain characters from this list of 64 ASCII-characters (note the leading space): !"#$%&'()*+,-./0123456789:;=?@[\]^_abcdefghijklmnopqrstuvwxyz|~ These charac...
[]
Introduction Given a String containing an arithmetic expression, your task is to output a truthy or falsey value based on whether it contains unmatched parentheses. Input Your program should take in a String containing an arithmetic expression. It may take input in any way except assuming it to be present in a pre-def...
[ [ 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...
Consider a binary string S of length n. Indexing from 1, we can compute the Hamming distances between S[1..i+1] and S[n-i..n] for all i in order from 0 to n-1. The Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. For example, S = 01010...
[]
The xorspace of a set of integers is the set of all integers that can be obtained by combining the starting integers with the usual bitwise xor operator (^). For example, the xorspace of (8, 4) is (0, 4, 8, 12): 0 is 4^4, 12 is 4^8, and no other numbers can be reached. Note that the starting numbers are always included...
[]
Consider the string 160615051. It can be "triangulated" as such: 1 606 15051 Then, each row is a palindrome. Also note that each side on the perimeter is also a palindrome: 1 | 1 | 6 | 6 | 1 | 1 | 15051 Therefore, this string can be considered to be a fully-palindromic triangle. Don'...
[]
I recently listed to the song I'm a Textpert about texting while driving and one particular line in the song inspired this challenge. I never stoop so low as to text photos / Instead I text the correct combo of ones and zeros Now obviously, this would be an almost impossible thing to do in ones head and so you should...
[]
This is not an invitation for you to downvote everything I've posted. Just sayin' ;) Challenge Figure out how I can get myself back down to 1 reputation. Details will follow input format, then followed by output. Input Input will consist of the my current reputation, the number of questions I have posted with an accept...
[]
Your Task: Write a program or function to check if a number that is inputted is a Fibonacci number. A Fibonacci number is a number contained in the Fibonacci sequence. The Fibonacci Sequence is defined as: F(n) = F(n - 1) + F(n - 2) With the seeds being F(0) = 0 and F(1) = 1. Input: A non-negative integer between 0 a...
[]
Challenge You must write a program that takes a positive integer n as input, and outputs the nth Fibonacci number (shortened as Fib# throughout) that contains the nth Fib# as a subtring. For the purposes of this challenge, the Fibonacci sequence begins with a 1. Here are some examples that you can use as test cases, or...
[ [ 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...
– of crisis and martyrdom (that's the subtitle because subtitles are cool) In this king-of-the-hill challenge in python (yup; you need go no farther to know you may not submit in java), you need to create a bot that plays a game very similar to welcome to the dungeon Game Rules (note that this is not the original game)...
[]
From the sandbox! I2c or TWI, is a 2 way stream that uses 2 signal lines: SDA and SCK. This is used in sensors to communicate between a master and a slave. So, how does this work? Well, here's the boilerplate: Input: 1 I2c command represented by 2 strings where - is a high signal, and _ is low. SDA is always the fi...
[]
Take a positive integer n as input, and output a n-by-n checkerboard matrix consisting of 1 and 0. The top left digit should always be 1. Test cases: n = 1 1 n = 2 1 0 0 1 n = 3 1 0 1 0 1 0 1 0 1 n = 4 1 0 1 0 0 1 0 1 1 0 1 0 0 1 0 1 Input and output formats are optional. Outputting the matrix as a list of lists i...
[]
I'm supposed to sort a list of numbers, but I'm super lazy. It's really hard to figure how to swap all the numbers around until all of them are in increasing order, so I came up with my own algorithm that will guarantee that the new list is sorted¹. Here's how it works: For a list of size N, we'll need N-1 iterations. ...
[]
Overview In the US, the common denominations are the penny ($0.01), the nickel ($0.05), the dime ($0.10), the quarter ($0.25), one dollar, two dollars (less common but lets pretend it's common), five dollars, ten dollars, twenty dollars, fifty dollars, and one hundred dollars. ($1 to $100 respectively). Your goal is ...
[]
The task is to compute OEIS A005434 as quickly as possible. Consider a binary string S of length n. Indexing from 1, we can determine if S[1..i+1] matches S[n-i..n] exactly for all i in order from 0 to n-1. For example, S = 01010 gives [Y, N, Y, N, Y]. This is because 0 matches 0, 01 does not match 10, 010 mat...
[]
This is code golf. For this challenge, I will accept a method (you don't need a full program), but the method signature does count towards the byte count and I want to see the full signature (not a lamdba). The input for the method is an integer array with 81 elements. The output/return value from the method is a strin...
[]
As is well known, Chuck Norris counted to infinity. Twice Besides, Chuck Norris can count to infinity backwards. Also, although perhaps less known, Chuck Norris can speak a little Spanish in addition to English. The challenge Write a program (or function) that can be run in two different languages. In one language ...
[]
Consider three sets A, B and C each containing n integers. From this we can make the set S_n = {a * b + c | a in A, b in B, c in C}. Given an n, there are one or more minimal sized S_n which depend on which sets A,B and C have been chosen. The sets can contain any n distinct integers (positive, zero or negative). ...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ], [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220...
Given a string, return a table where the first column has the unique letters of the string in order of occurrence and subsequent columns list the indices of that letter in the string, using zero or one-based indexing. Horizontal whitespace does not matter, as long as the left-most column is vertically aligned. Indices ...
[]
Challenge Given a square matrix of characters (single-byte printable ASCII characters), rotate each "ring" of the matrix in opposite directions. Let's take an example: 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Then, the outermost ring is rotated clockwise 90 degrees, like so: 1 2 3 4 5 L G B 6 1 6 A ...
[]
Help! My math exam is coming up soon and I didn't study! 1 Part of the exam is to classify a quadrilateral given its vertex coordinates, which I, unfortunately, do not know how to do. 2 So, your challenge is to write a program to do this for me so I don't fail! Challenge Given four vertices such that no three of them a...
[]
Given a positive integer n, output the N-dimensional identity "matrix", which is the N^N array with 1 where all the components of the indices are equal and 0 otherwise. N^N means N-by-N-by-N-by-... 1 -> [1] 2 -> [[1,0],[0,1]] 3 -> [[[1,0,0],[0,0,0],[0,0,0]],[[0,0,0],[0,1,0],[0,0,0]],[[0,0,0],[0,0,0],[0,0,1]]] 4 -> [...
[]
Divinacci (OEIS) Perform the Fibonacci sequence but instead of using: f(n) = f(n-1)+f(n-2) Use: f(n) = sum(divisors(f(n-1))) + sum(divisors(f(n-2))) For an input of n, output the nth term, your program should only have 1 input. First 14 terms (0-indexed, you may 1-index; state which you used): 0 | 0 # Initial ...
[]
A proper divisor is a divisor of a number n, which is not n itself. For example, the proper divisors of 12 are 1, 2, 3, 4 and 6. You will be given an integer x, x ≥ 2, x ≤ 1000. Your task is to sum all the highest proper divisors of the integers from 2 to x (inclusive) (OEIS A280050). Example (with x = 6): Find all th...
[ [ 16, 17, 525, 220, 16, 11, 220, 17, 11, 220, 18, 11, 220 ], [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 323, 220, 21 ], [ 17, 525, 220, 16, 11, 220, 17, 11, 220, ...
Take a matrix of positive integers as input, and make it explode! The way you explode a matrix is by simply adding zeros around every element, including the outside borders. Input/output formats are optional as always! Test cases: 1 ----- 0 0 0 0 1 0 0 0 0 -------------- 1 4 5 2 ----- 0 0 0 0 0 0 1 0 4 0 0 0 0 0 0 0 ...
[]
Consider the following 3x3 blocks which the marching squares algorithm would identify for every cell (with 0-based labeled ID): 0: ... ... ... 1: ... ... \.. 2: ... ... ../ 3: ... --- ... 4: ..\ ... ... 5: /.. ... ../ 6: .|. .|. .|. 7: /.. ... ... 8: /.. ... ... 9: .|. .|. .|. 10: ..\ ... \.. 11: ..\ ... ......
[]
The Zachtronics game TIS-100 contains a graphics display called the visualization module. I could try and explain the specs of this module, but the game's manual will do a better job: (As you may have guessed, the motivation of this problem is to create a code golf challenge in which TIS-100 is the optimal language.) ...
[]
You will be given a String that only contains letters of the English Alphabet, both lowercase and uppercase (ASCII 65-90 and 97-122). Your task is to output the Fizz-Buzzified version of the String. How to Fizz-Buzzify a String? Each letter that has an even index in the English alphabet (the alphabet must be 1-indexed...
[]
The dragon curve sequence (or the regular paper folding sequence) is a binary sequence. a(n) is given by negation of the bit left of the least significant 1 of n. For example to calculate a(2136) we first convert to binary: 100001011000 We find our least significant bit 100001011000 ^ Take the bit to its le...
[]
Here is an example of an input of monoliths. There are 4 in this example. _ | | _ | | _ | | | | | | | | _ _| |_| |___| |____| |_ The first monolith is 4 units high, the second is 2, the third is 3, and the last is 1. The task Your program should output the heights of the monoliths in order from l...
[]
For this challenge, you should write a program or function which outputs the diagonals of a given square matrix. However, if you transpose the rows and columns of your solution's source code, it should instead become a program or function which returns the matrix's antidiagonals. Read on for specifics... Rules The sou...
[]
The treewidth of an undirected graph is a very important concept in Graph Theory. Tons of graph algorithms have been invented which run fast if you have a decomposition of the graph with small treewidth. The treewidth is often defined in terms of tree decompositions. Here's a graph and a tree decomposition of that grap...
[]
What you need to do is create a function/program that takes a decimal as input, and outputs the result of repeatedly taking the reciprocal of the fractional part of the number, until the number becomes an integer. More specifically, the process is as follows: Let x be the input If x is an integer, output it. Otherwise...
[]
This is a very very simple algorithm, that I am sure can be solved in many many different languages. In Spain ID cards (known as DNI) consist of 8 numbers and a control character. The control character is calculated with the following algorithm: divide the number by 23, take the remainder of the operation and replace i...
[]
Inspired by the bugged output in @Carcigenicate's Clojure answer for the Print this diamond challenge. Print this exact text: 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 ...
[]
Compress a sparse matrix using Compressed sparse row (CSR, CRS or Yale format). These are all the same form of compression (ignore new Yale). Input may be any 2d data structure (list of lists, etc): e.g [[0 0 0 0], [5 8 0 0], [0 0 3 0], [0 6 0 0]] And the output should be three 1d data structures (list etc), that d...
[]
Continuing my It was just a bug challenge: Input: A string consisting of printable ASCII characters without white-spaces nor new-lines. Output: First turn the input into a palindrome by reverting the input, and adding it before itself, excluding the middle character (i.e. with an input 1234567890, it will becomes 09876...
[]
Given a positive integer n ≤ 500: Find the smallest positive integer k such that all digits in the decimal representation of n*k are either 0 or d, with 1 ≤ d ≤ 9. Print or return d in less than 30 seconds (read more about that in the Clarifications and rules section). Easy examples Here are the first 30 values of d....
[]
If we write a sequence of numbers as the coefficients of a power series, then that power series is called the (ordinary) generating function (or G.f.) of that sequence. That is, if for some function F(x) and series of integers a(n) we have: a(0) + a(1)x + a(2)x^2 + a(3)x^3 + a(4)x^4 + ... = F(x) Then F(x) is the gener...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 16, 11, 220, 16, 11, 220, 17, 11, 220, 18, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11,...
The task is to find a non-trivial factor of a composite number. Write code that finds a non-trivial factor of a composite number as quickly as possible subject to your code being no more than 140 bytes long. The output should just be the factor you have found. Your code can take input and give output in any way that i...
[]
You are going to participate in a gameshow. One of the challenges works as follows: The first room contains a large number of identical balls. The second room contains a series of chutes, each of which has a sensor which counts how many balls have been placed in it. A ball which is placed in a chute cannot then be rec...
[]
Task Write a program that will take (as input) a positive integer. It will then count up from 0, appending each integer to a String, only continuing if the length of the String is less than the value of the input. A serialized integer is defined as the fully-formed integer with the maximum value belonging to the Strin...
[]
An integer is binary-heavy if its binary representation contains more 1s than 0s while ignoring leading zeroes. For example 1 is binary-heavy, as its binary representation is simply 1, however 4 is not binary heavy, as its binary representation is 100. In the event of a tie (for example 2, with a binary representation ...
[]
The first two MU-numbers are 2 and 3. Every other MU-number is the smallest number not yet appeared that can be expressed as the product of two earlier distinct MU-numbers in exactly one way. Here are the first 10 2, 3, 6, 12, 18, 24, 48, 54, 96, 162 Task Given a positive number calculate and output the nth MU-number...
[]
There are lots of challenges that just pick a sequence from oeis and ask you to print n-th number or first n numbers or whatever. It's time to stop automate! Task Your task is to parse a sequence page from oeis.org and print its index, description and example values. The page's index should be chosen and random, sele...
[ [ 220, 15, 11, 220, 16, 11, 220, 16, 11, 220, 18, 11, 220 ] ]
Imagine a histogram. Pour an infinite amount of water on to it. Then stop. How much water does the histogram hold? Let's say we have a histogram with columns of these heights: 1 3 2 1 4 1 3 That would look like this: # # # # ## # # ####### 1321413 If we pour an infinite amount of water on this histogram, some ...
[]
Background I play D&D on a regular basis with some friends. While talking about the complexity of some systems/versions when it comes to rolling dice and applying bonuses and penalties, we jokingly came up with some additional complexity for dice rolling expressions. Some of them were too outrageous (like extending sim...
[ [ 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 ] ]
Seahorses, of course, need shoes. However, a seahorse, having just one tail, needs just one shoe. Unfortunately, the shoes only come in pairs. Money is tight for the seahorse government, so they need to buy as few pairs as possible. Each seahorse has a shoe size x where x is a positive integer. However, a seahorse can ...
[]
Lets take a set of integers greater than 1 and call it X. We will define S(i) to be the set of all members of X divisible by i where i > 1. Would like to choose from these subsets a group of sets such that Their union is the set X No element of X is in two of the sets. For example we can regroup {3..11} as ...
[]
Many of us are familiar with the game Tron. You control a "lightcycle" placed on a grid. The lightcycle always moves forward (though you control the direction) and leaves a permanent trail behind it. If you run into a trail, you crash! The goal here is to determine if a given path is a valid loop, that is, it returns t...
[]
Introduction Classically, booleans are one bit; true or false, 1 or 0. Leading zeros would just be redundant. For example, 001 means the same as 00001 or just 1. The 32-bit boolean Given a truthy/falsey value, output the equivalent 32-bit boolean as a string. (Or as a number if for some reason your language supports l...
[]
We are all familiar with the famous Fibonacci sequence, that starts with 0 and 1, and each element is the sum of the previous two. Here are the first few terms (OEIS A000045): 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584 Given a positive integer, return the closest number of the Fibona...
[ [ 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...
Description: A non-integer representation of a number uses non-integer numbers as the bases of a positional numbering system. e.g. Using the golden ratio (the irrational number 1 + √5/2 ≈ 1.61803399 symbolized by the Greek letter φ) as its base, the numbers 1 to 10 can be written: Decimal Powers of φ Base φ...
[]
According to me, a tornado looks like this: ######## ####### ###### ##### #### ### ## # This tornado starts out with width n, and on each next line, a character is removed from either the left or the right, depending on the input. Input The input will be a list of some sort of any two unique values (...
[]
There have been a billion iterations of Fibonacci challenges on this website, so lets spice things up with a Fibonacci challenge of a billion iterations! Your challenge is to output the first 1000 decimal digits of the 1,000,000,000th Fibonacci number with as short a program as possible. This may then optionally be fol...
[]
Imagine a straight river and a road that goes across the river n times through bridges. The road does not loop on itself and is infinitely long. This road would be considered an open meander. An open meander is an open curve, that does not intersect itself and extends infinitely at both ends, which intersects a line n ...
[ [ 220, 16, 11, 220, 16, 11, 220, 17, 11, 220, 18, 11, 220 ] ]
Given an integer n ≥ 1, output a 2D representation† of a percent sign of width n. The construction goes as follows: Create an n by n matrix (or list of lists) filled with zeroes. Insert ones in the top-left and bottom-right corners. Place ones on the diagonal from the bottom-left to the top-right. For input n = 4, th...
[]
Challenge Given a list of integers, return the list of these integers after repeatedly removing all pairs of adjacent equal items. Note that if you have an odd-length run of equal numbers, one of them will remain, not being part of a pair. Example: [0, 0, 0, 1, 2, 4, 4, 2, 1, 1, 0] First, you should remove 0, 0, 4, 4,...
[]
A curve is a set of points on a square grid such that each point has exactly two neighbors in the four-neighbor neighborhood and the points form a single connected component. That is, the graph induced by the points on a grid graph is isomorphic to a single cycle. "Induced" means that two points cannot touch in the inp...
[]
Your task today is to apply a wave to an array of numbers. A wave looks like this: [1, 0, -1, 0, 1, 0, -1, 0, 1...] Applying it to a given array means adding together the first elements, the second elements, etc. More precisely: Your program or function will receive an array of integers. It must print or return an equa...
[]
Challenge Given a set T of subsets of a finite set S={1,2,3,...,n}, determine whether T is a topology or not. Explanation The powerset P(S) of some set S is the set of all subsets of S. Some examples: S = {}, P(S) = {{}} S = {1}, P(S) = {{}, {1}} S = {1,2}, P(S) = {{}, {1}, {2}, {1,2}} S = {1,2,3}, P(S) = {{}, {1}, {2}...
[]
(inspired by Helka's response to my random pairing of "chess" and "Fibonacci" tags in chat) Fibonacci The Fibonacci numbers are one of the more well-known sequences in mathematics, where each number is composed by adding the two previous numbers together. Below is a definition of the zero-indexed sequence: f(0) = 0 f(...
[ [ 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...
Your challenge is to generate this string: 0110101101011010011010110101101011010110101101001101011010110100110101101011010110101101011010011010110101101001101011010110101101011010110100110101101011010000110101101011010011010110101101011010110101101001101011010110100110101101011010110101101011010011010110101101001101011...
[]
Related: Tell me how many math problems I have to do! Challenge Given a strictly positive strictly ascending integer list L and an integer 3 ≤ N ≤ length of L, replace the middle integers of L's consecutive integer runs of length ≥ N with a single dash -. Rules Horizontal whitespace is irrelevant. You may optionally p...
[]
Challenge Given a matrix M with r rows and c columns, and two Boolean lists V of length r and H of length c, calculate the partitioned cumulative vertical and horizontal sums. Rules r and c are greater than or equal to one H and V begin with a true value The values in M are within your language's reasonable numeric do...
[]
Given two lists of dice rolls for a battle in Risk, your program or function must output how many troops each player loses. Background You do not have to read this, for it is merely background. Skip to "Task" subheading to continue unabated. In the game of Risk, one player can attack another player (in fact, this is ...
[]
You will be given as input an integer k in the range from -4503599627370496 (−252) to 4503599627370496 (252). As is well known, integers in this range can be represented exactly as double-precision floating-point values. You should output the Hamming weight (number of ones) of the encoding of k in binary64 format. Thi...
[]
Given a list of non-negative integers in any reasonable format, iterate over it, skipping as many elements as every integer you step on says. Here is a worked example: [0, 1, 0, 2, 5, 1, 3, 1, 6, 2] | [] ^ First element, always include it [0, 1, 0, 2, 5, 1, 3, 1, 6, 2] | [0] ^ Skip 0 elements [0, 1, 0, 2, 5, 1, 3...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 220, 15, 11, 220, 16, 11, 220, 16, 11, 220, 18, 11, 220 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11...
Fermat numbers are positive integers that can be expressed as 22x+1 with an integer x. Let us now define an attribute of a number called "Fermat-ness": The Fermat-ness of the number is one less than the length of the chain of powers of two, starting from the base, with powers of two expanded so as to maximize the ferm...
[]