instruction_seed
stringlengths
292
48.7k
found_ngrams
listlengths
0
21
Find the longest run of true in a list of booleans. Return the same list, with all other trues falsified. Input, output A list; any usual format (e.g., a delimited list as a string). Details True and false can be anything your language typically uses for those values, or the integers 1 and 0. If you use single characte...
[]
RFC 2550 is a satirical proposal (published on April 1, 1999) for a space-efficient ASCII representation of timestamps that can support any date (even those prior to the beginning of the universe and those past the predicted end of the universe). The algorithm for computing a RFC 2550-compliant timestamp is as follows ...
[]
Consider binary block diagonal matrices which have square blocks of 1s on the main diagonal, and are 0 everywhere else. Let's call such matrices "valid" matrices. For example, here are some valid 4x4 matrices: 1 0 0 0 1 1 0 0 1 0 0 0 1 0 0 0 1 1 0 0 1 1 1 1 0 1 0 0 1 1 0 0 0 1 1 0 0 1 1 1...
[]
Don't you find that reading simple text isn't appealing enough? Try our ##### ### ### ##### ##### ##### ##### # # ##### # # # # # # # # # # # # # # ##### ### # # # # #### # # # # # # # # # # # # # # ...
[]
Problem Say you have N stacks named S1 through SN, where each Sk (k = 1 to N) contains N copies of the number k. For example, when N = 3 the stacks looks like this: 1 2 3 <- top of stack 1 2 3 1 2 3 <- bottom of stack ======= 1 2 3 <- stack index Here there are 3 stacks indexed as 1, 2, and 3, and each one ...
[]
What's the Binary Time? Everybody knows what the normal time is. It's up there in the top-right (or wherever you put it) of your screen. But a question people rarely seem to ask themselves is this: What's the binary time? Binary Time Binary Time (True Binary Time) works by first reading the most significant bit (MSB) o...
[]
Remember that a set is unordered without duplicates. Definition An N-uniquely additive set S whose length is K is a set such that all N-length subsets in S sum to different numbers. In other words, the sums of all the N-length subsets of S are all distinct. Objective Given an array/set as input and a number N to a func...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
Write a program or function that takes in a nonempty list of positive integers. You may assume it is input in a reasonable convenient format such as "1 2 3 4" or [1, 2, 3, 4]. The numbers in the input list represent the slices of a full pie chart where each slice size is proportional to its corresponding number and all...
[]
A Faro shuffle is a technique frequently used by magicians to "shuffle" a deck. To perform a Faro shuffle you first cut the deck into 2 equal halves then you interleave the two halves. For example [1 2 3 4 5 6 7 8] Faro shuffled is [1 5 2 6 3 7 4 8] This can be repeated any number of times. Interestingly enough, if y...
[ [ 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 a list of integers L, and an integer N, output L splitted in N sublists of equal lenghts. Non-divisible lengths If N does not divide the length of L, then it is not possible that all sublists have equal length. In any case, the last sublist of the output is the one that adapts its length to contain the remainder ...
[ [ 20, 11, 22, 11, 16, 16, 11, 16, 18, 11, 16, 22, 11 ], [ 18, 11, 20, 11, 22, 11, 16, 16, 11, 16, 18, 11, 16 ], [ 11, 20, 11, 22, 11, 16, 16, 11, 16, 18, 11, ...
The 3BV of a Minesweeper board represents the minimum number of left clicks required to solve the board if you already know the solution. It stands for "Bechtel's Board Benchmark Value". Here's his site explaining it. Below is a solved Minesweeper board. The flags indicate mines; tiles without mines indicate the count ...
[]
Background: Here's a little simple challenge. You want to be able to find out whether the arrays inside an array have the same length. Input: Your input should consist of exactly one array (this is the value passed to the function, not a user input). Your function takes exactly 1 parameter. It could contain arrays or ...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
In a project I am working on, I am checking to see if certain DNA sequences appear in certain genes in E. coli. I have written a program in Java that performs the below features. However, since I wrote my program in Java, the universe needs to be corrected and rid of verbosity by having you write your code in as few by...
[]
Well, sum it down really. Write a program or function that takes in a nonempty list of decimal integers (0-9) and outputs a downward pointing "triangle" of digits with the input list at the top where every digit after the first line is the sum of the two digits above it modulo 10. For example, the input [7, 5, 0, 9] ha...
[]
Implement the Discrete Fourier Transform (DFT) for a sequence of any length. This may implemented as either a function or a program and the sequence can be given as either an argument or using standard input. The algorithm will compute a result based on standard DFT in the forward direction. The input sequence has leng...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
I think most people around here know what a 7-segment display for digits is: _ _ _ _ _ _ _ _ | | | _| _| |_| |_ |_ | |_| |_| |_| | |_ _| | _| |_| | |_| _| We can define the 7-segment difference (7SD) between two digits to be the number of segments that ...
[]
Given an integer N, output the Nth positive number K with the following property in decimal base: For each digit I at position P of K, the number formed from K by removing the Pth digit (i.e. I) is divisible by I. Example and remarks 324 is such a number: 3 divides 24 2 divides 34 4 divides 32 Note 1: we assume that ...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ], [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220...
In special relativity, the velocity of a moving object relative to another object that is moving in the opposite direction is given by the formula: \begin{align}s = \frac{v+u}{1+vu/c^2}.\end{align} s = ( v + u ) / ( 1 + v * u / c ^ 2) In this formula, \$v\$ and \$u\$ are the magnitudes of the velocities of the objects...
[]
Almost every function can be expressed as a polynomial with infinite terms. For example, e^x = 1 + x + x^2/2! + x^3/3! + x^4/4! + ... For example, sin(x) = x - x^3/3! + x^5/5! - x^7/7! + ... The coefficients of the n-th terms form a sequence, and the corresponding function is called the Generating Function of the seque...
[]
The Microsoft FAT file system has a directory table to represent which "files" are in which "folders" on the disk. For the time, these entries crammed a lot of information into a small amount of bits. There are a bunch of technical specifications over on Wiki for the curious, but the challenge here is going to focus on...
[]
Your goal is to create a function or a program to reverse the bits in a range of integers given an integer \$n\$. In other words, you want to find the bit-reversal permutation of a range of \$2^n\$ items, zero-indexed. This is also the OEIS sequence A030109. This process is often used in computing Fast Fourier Transfor...
[ [ 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...
Definition Define the nth term of the CRAU sequence as follows. Begin with the singleton array A = [n]. Do the following n times: For each integer k in A, replace the entry k with k natural numbers, counting from 1 to k. Compute the sum of all integers in A. For example, if n = 3, we start with the list [3]. We repla...
[]
Definition Define the nth array of the CURR sequence as follows. Begin with the singleton array A = [n]. For each integer k in A, replace the entry k with k natural numbers, counting up from 1 to k. Repeat the previous step n - 1 more times. For example, if n = 3, we start with the array [3]. We replace 3 with 1, 2, ...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ], [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220...
An alternating sign matrix is an n by n matrix consisting of the numbers -1, 0, 1, such that: The sum of each row and column is 1 The nonzero entries in each row and column alternate in sign These matrices generalise permutation matrices, and the number of such matrices for a given n was of interest for some time. Th...
[]
Update: There are 6 mazes. They are included in the controller. There is a tar.gz of the mazes and their .bmp files here (dropbox). There is also a utility for making more mazes at that link (the maze_4.txt file is incorrect in archive). At this point, please feel free to run your own entry and update your score. Detai...
[]
GOAL : To Implement a character counting program This is how this counting system works : input of the program is a set of printable ASCII characters . the program counts each type of character , and outputs the number of each character , starting from first mentioned character to last mentioned character . Example :...
[]
Ninja Assassins - which ninja stays alive some basic information given an int N as the number of ninjas, return the number of the winning ninja. At the end only 1 ninja survives,the question is which one? what was his number?. Each ninja kills the ninja who stands after him. Afterwards, he passes the sword to the firs...
[]
In the game Stratego, the main game mechanic is when you attack an opponent's piece with yours. In this challenge, you job is to simulate one of these battles and say who survives. Specs You will get as input a pair of string representing Stratego pieces. The pieces are one of "S 1 2 3 4 5 6 7 8 9 10 B" (S is the Spy, ...
[]
The esoteric programming language evil has an interesting operation on byte values which it calls "weaving". It is essentially a permutation of the eight bits of the byte (it doesn't matter which end we start counting from, as the pattern is symmetric): Bit 0 is moved to bit 2 Bit 1 is moved to bit 0 Bit 2 is moved to...
[]
In scientific computing, it is often desirable to decompose some large domain into smaller "subdomains", then parallelize the computation by performing the work on each subdomain in parallel and the interaction of a subdomain with its neighboring subdomains. Since these interactions are typically data sync points, mini...
[]
Everybody loves nested lists! However, sometimes it's hard to make a nested list. You have to decide if you want to nest it deeper, or if you need to nest it shallower. So for your challenge, you must "Autonest" a list. To autonest a list, compare every pair of items in the list. If the second item is smaller, separat...
[ [ 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 ] ]
Your challenge is simple: GIven an integer N, ouput every list of positive integers that sums to N. For example, if the input was 5, you should output [1, 1, 1, 1, 1] [1, 1, 1, 2] [1, 1, 3] [1, 2, 2] [1, 4] [2, 3] [5] These lists do not have to be output in any particular order, nor do the numbers inside each list. Fo...
[ [ 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 ], [ 16, 11, 220, 16, 11, 220, 17, 11, 220, 18...
Given a list of integers, create a boolean mask such that the true indices can be used to filter the distinct values from the list. Which index is selected as the true one does not matter as long as only one of them is selected for each set of indices corresponding to identical values. The input will be a non-empty lis...
[]
Challenge description Given a list / array of items, display all groups of consecutive repeating items. Input / output description Your input is a list / array of items (you can assume all of them are of the same type). You don't need to support every type your language has, but is has to support at least one (preferab...
[]
Task: Make a program that leaves a comment on this question. The content should be 1234567890123456. Edits: You may leave your usernames and passwords as U and P if you are using username and password. (if applicable) No URL Shorteners (if applicable) You may not use the browser console.
[]
Consider the following table for the function d(n), which calculates the number of factors that n is divisible by without a remainder: n | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | ... d(n) | 1 | 2 | 2 | 3 | 2 | 4 | 2 | 4 | 3 | 4 | 2 | 6 | ... Going from left to right, it is possible to determine the "c...
[ [ 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 ] ]
Inspired by this challenge Given a number m, output a program that prints out the string Do not repeat yourself. Now for the challenging part: Each program the original code prints out has to have the byte at place m*n be the same as m*n + 1 and the same as m*n + 2 .... all the way down to m*n + m - 1. (In case you can...
[]
A heap, also known as a priority-queue, is an abstract data type. Conceptually, it's a binary tree where the children of every node are smaller than or equal to the node itself. (Assuming it's a max-heap.) When an element is pushed or popped, the heap rearranges itself so the the biggest element is the next to be poppe...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
Your task is to create a program or function that generates a zipper with a length of 10 lines. Each line of the zipper is represented by two dashes --: -- -- -- -- -- -- -- -- -- -- The program/function will take a percentage (divisible by 10) as input, and the output will be the zipper "unzipped" (dashes separated) ...
[]
Task Define a mod-fold as a function of the form f(x) = x % a1 % a2 % … % ak, where the ai are positive integers and k ≥ 0. (Here, % is the left-associative modulo operator.) Given a list of n integers y0, …, yn−1, determine if there exists a mod-fold f so that each yi = f(i). You may choose and fix any two outputs Y ...
[]
I'm new here. I tried seeing if this challenge was introduced before. Found a close call one counting the number of cycles, but didn;t find one for listing them. So I'm writing this one. Sorry if I'm repeating... Anyway, I'm looking for the shortest function to return all close cycles in a shuffled list of indices. For...
[ [ 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...
A difference pyramid is a pyramid where each new diagonal is the absolute value of the differences between the elements of the last diagonal. For example, if we start with the array 2 5 4 9 3 4 Now, we arrange these in a diagonal column: 2 5 4 9 3 4 Now, we fill in the nex...
[ [ 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 ] ]
Summary Given a list of integers, return the index each integer would end up at when sorted. For example, if the list was [0,8,-1,5,8], you should return [1,3,0,2,4]. Note that the two 8s maintain their order relative to each other (the sort is stable). Put another way: For each element in the list, return the number...
[]
Introduction Let's observe this array: [3, 2, 4, 1, 1, 5, 1, 2]. Each element displays the length of the substring which must be summed up. Let's take a look at the first element of the above array: [3, 2, 4, 1, 1, 5, 1, 2] ^ The element at the first index is 3, so we now take a substring of length three with the sam...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
Task Given (by any means) a sorted floating point dataset, return (by any means and within 1‰ of the correct value) the interquartile mean. One possible algorithm Discard the lowest and highest quarters of the data points. Calculate the average (sum divided by count) of the remaining data points. Note: If the dataset...
[]
The goal of this challenge is to collect selected items in a list and move them to a certain location in the list. As a visual example, take the input values (represented by black boxed integers) and a corresponding list of truthy values where true denotes the item is selected (represented by blue boxes, where T is tru...
[]
Given an input of an integer \$n ≥ 2\$, output a list of its divisors sorted by the exponents in their prime factorizations, in ascending order, ordering first by the largest prime, then by the second largest, and so on. As an example, take the integer \$72\$, which is \$2^3\cdot3^2\$. It has the divisors 1 3^0 · 2...
[]
An algebraic curve is a certain "1D subset" of the "2D-plane" that can be described as set of zeros {(x,y) in R^2 : f(x,y)=0 }of a polynomial f. Here we consider the 2D-plane as the real plane R^2 such that we can easily imagine what such a curve could look like, basically a thing you can draw with a pencil. Examples: ...
[]
Definition Fibonacci sequence F(n), on the positive integers, are defined as such: 1. F(1) = 1 2. F(2) = 1 3. F(n) = F(n-1) + F(n-2), where n is an integer and n > 2 The Fibonacci-orial of a positive integer is the product of [F(1), F(2), ..., F(n)]. Task Given positive integer n, find the Fibonacci-orial of n. Specs ...
[]
"The Nobel Prize in mathematics was awarded to a California professor who has discovered a new number! The number is bleen, which he claims belongs between 6 and 7." --George Carlin In this challenge, you will print all Integers, inclusive, within the given input range. Print numbers ascending or descending according...
[]
Given six unique non-negative integers, print the two 3-digit integers comprised of those numbers that sum to the smallest amount. Additionally, If there is more than one set of numbers that meets the smallest-sum requirement, print the two that have the greatest difference. For example, 269 + 157 = 267 + 159 = 426; ...
[]
The Collatz conjecture is a very well-known conjecture. Take a positive integer; if it's even, divide by 2, else, multiply by 3 and add 1. Repeat until you reach 1 or something else happens. The conjecture is that this process always reaches 1. You can also reverse the process. Start at 1, multiply by 2, and to branch ...
[]
Previously, we computed the Bit-Reversal Permutation where we found how the order of indices would be permuted. In that case, we received an input n which was the order of the permutation of the indices where the length was 2n. However, this time, we are given a string of length m = 2k for some k. Now we want to apply ...
[]
Given an input number n from 1 to 26 (or 0 to 25), output the alphabet reading left-to-right up to and including that corresponding letter, with a=1, b=2, c=3, .... The twist is the letters must also be repeated vertically corresponding to their position in the alphabet. Odd numbers (when 1-indexed) should be balanced ...
[]
Challenge description Multiplification (totally not a made-up word) is a process in which you take two positive integers: a and b, and produce another integer which is equal to a repeated ("glued together") b times. For example, multiplifying 3 by 7 gives 3333333. Similarly, 103 multiplified by 5 is 103103103103103. In...
[]
Every year, Dyalog Ltd. holds a student competition. The challenge there is to write good APL code. However, this is a multiple-holes (common theme is manipulation of data of any type and structure, especially special handling of empty data) code-golf version of the Phase I problems – open to any language. Enjoy! Objec...
[]
Executive summary: test whether an input sequence of integers is "admissible", meaning that it doesn't cover all residue classes for any modulus. What is an "admissible" sequence? Given an integer m ≥ 2, the residue classes modulo m are just the m possible arithmetic progressions of common difference m. For example, wh...
[]
A ballot number, which we'll label B, is the number of ways of arranging the numbers from 1 through B(B+1)/2 into a triangle, such that each row and column is in any increasing order. The first four ballot numbers are: a(0) = 1 a(1) = 1 a(2) = 1 a(3) = 2 a(3) is 2, which means that there are 2 ways of arranging the nu...
[]
In arithmetic, an n-smooth number, where n is a given prime number, is mathematically defined as a positive integer that has no prime factors greater than n. For example, 42 is 7-smooth because all its prime factors are less than or equal to 7, but 44 is not 7-smooth because it also has 11 as a prime factor. Define a p...
[]
OEIS: A167171 A dense number is a number that has exactly as many prime divisors as non-prime divisors (including 1 and itself as divisors). Equivalently, it is either a prime or a product of two distinct primes. The first 100 dense numbers are: 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 31, 33, 34,...
[]
"Fit Numbers" Sam has a "brilliant" idea for compression! Can you help? Here is a rundown of Sam's compression scheme. First take in a base 10 representation of any natural number strictly smaller than 2^16, and write it as a binary string without any leading zeros. 1 -> 1 9 -> 1001 15 ->1111 13 ->1101 16 -> 10000 17...
[]
Some people say curiosity killed the cat. Other say it was the box and poison. The RSPCA say Erwin Schrödinger needs to lose the right to own pets. With animal rights activists outside his house. The cat murderer scientist Schrödinger has finally come up with his greatest invention. A special, radioactive mix of unobta...
[]
Frank has been working IT his whole life. Each day he responds to tickets, organizes equipment, and reports to his boss. One day, near the closing time on friday, Frank is doing his final inventory and sorting come cables in the supply closet. Suddenly, the door closes and locks from the outside! Such audacity! Frank s...
[]
Extended Train Swapping Problem Part 1: Normal Train Swapping Problem In the 1996 CCC (Canadian Computing Competition), the first Stage 2 problem was a Train Swapping Problem. You can visit the link here. Essentially, you have a bunch of numbered trains, and you want to find out how many train swaps you need to get the...
[]
Since this SE community is about golfing, I thought a golf-related challenge would be appropriate. Explanation Normally, the objective of golf is to finish a hole (and consequently, the entire round) with the least amount of strokes. This is a simple version of golf: Play until you hole the ball and sum up your score. ...
[]
Introduction Dice 10,000 is a dice game which can be played with 6 dice and something to write. Players roll the dice multiple times a turn and gain a score at the end of it. The player who reaches 10,000 point first wins the game. Calculating the score of one roll is your job in this challenge. Look here for the full ...
[ [ 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 ], [ 16, 11, 220, 16, 11, 220, 17, 11, 220, 18...
Working with old files from DOS, I found an ancient text animation format, that specify how much time each frame must be shown in the screen. It's very simple: F1W5F2W3 This example above indicates that Frame 1 must be shown for 5 units of time, and frame 2 for 3 units more. Now I want to convert it to: 1, 1, 1, 1, ...
[]
In cryptography, PKCS#7 padding is a padding scheme which adds a number of bytes N ≥ 1, where the value of each added byte is equal to N. For example, Hello, World!, which has 13 bytes, is the following in hex: 48 65 6C 6C 6F 2C 20 57 6F 72 6C 64 21 If we choose to PKCS#7 pad to length 16, then the result is: 48 65 6C...
[]
It is time to embark on a perilous quest to defeat the British Intelligence. The aim of this challenge is to write the shortest code that will solve a Nonogram. What is a Nonogram? The rules are simple. You have a grid of squares, which must be either filled in black or left blank. Beside each row of the grid are...
[]
The sequence of segmented numbers or prime numbers of measurement (OEIS A002048) is the sequence of numbers such that each member is the smallest positive (greater than zero) number that can't be made of a sum of earlier consecutive numbers, with a(0) = 1. Example To calculate a(7) we first calculate a(0->6) = [1, 2, 4...
[]
Introduction The game of xiangqi, also known as Chinese chess, is a chess-like game popular in China, Vietnam, Taiwan, and other East Asian countries. The colours of the two sides in xiangqi are red and black. There are seven pieces in xiangqi: the general (G), advisor (A), elephant (E), horse (H), chariot (R), cannon ...
[]
Decipher Neurotic Frogs Now that Puzzling.SE has finally cracked my amphibian-obsessed cipher, let's write a program or function to decrypt it! (If you want to look at the puzzle before having it spoiled for you, click the above link now.) How the cipher works In Neurotic Frogs Ought To Relax In Mud Baths ("Neurotic F...
[]
Continued fractions are expressions that describe fractions iteratively. They can be represented graphically: $$ a_0 +\cfrac 1 {a_1 + \cfrac 1 {a_2 + \cfrac 1 {\ddots + \cfrac 1 {a_n} } } } $$ Or they can be represented as a list of values: \$[a_0 ; a_1, a_2, \dots, a_n]\$ The challenge: take a base nu...
[ [ 64, 62, 16, 11, 264, 62, 17, 11, 1124, 67816, 11, 264, 1089 ] ]
Write a program or function which will provably print all integers exactly once given infinite time and memory. Possible outputs could be: 0, 1, -1, 2, -2, 3, -3, 4, -4, … 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -2, -3, -4, -5, -6, -7, -8, -9, 10, 11, … This is not a valid output, as this would never enumerate negative num...
[ [ 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 number x and a number n, round number x to n significant figures and output the result. Significant figures The significant figures of a number are digits that carry meaning contributing to its measurement resolution. This includes all numbers except leading zeroes. Bear in mind that leading zeroes af...
[]
This challenge is the first in a two-challenge series about Repetition. The second will be up soon. In a language called Repetition (something I just made up), there consists an infinite string of 12345678901234567890..., with 1234567890 repeating forever. The following syntax is available to output numbers: +-*/: Thi...
[]
Background In 1870 Émile Baudot invented Baudot Code, a fixed-length character encoding for telegraphy. He designed the code to be entered from a manual keyboard with just five keys; two operated with the left hand and three with the right: The right index, middle and ring fingers operate the I, II, and III keys, res...
[]
The challenge is to list all ordered partitions (composition (combinatorics)) of a given positive integer n. These are the lists of numbers from 1 to n whose sum is n. For example, given input n = 4, the result should be: 4 1, 3 3, 1 2, 2 2, 1, 1 1, 2, 1 1, 1, 2 1, 1, 1, 1 The result can be in any order...
[]
Input: A list/array of integers for which each item is in the range of 2-36. Output: The sum of the integers (as base 10), where each next integer is in the base of the previous value (starting with a regular base 10). Example: Let's say we have an input like this: [4, 12, 34, 20, 14, 6, 25, 13, 33] Then we have a sum ...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ], [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220...
This is sequel to this challenge by Adnan. If you like this challenge, chances are you'll like the other one too. Check it out! A multiple choice test with 8 questions each with 4 choices might have the answers: BCADBADA. Converted to four different arrays, with true and false if the current letter is the answer, it w...
[]
Task Given the pre-order and post-order traversals of a full binary tree, return its in-order traversal. The traversals will be represented as two lists, both containing n distinct positive integers, each uniquely identifying a node. Your program may take these lists, and output the resulting in-order traversal, using ...
[]
Credit My thanks to Rand Al'Thor's letter-based question for the inspiration for this code-golf challenge. Background The nature of this challenge is based off the algorithm mentioned by Rand in his "A Triangle Formed of Three Letters": Start with a sequence of 10 letters each of which is X, Y, or Z. Under each row, ...
[]
A guitar fretboard diagram looks like this: 0 1 2 3 4 5 6 7 8 9 10 11 12 <- Fret number (0 means it's open) |-E--F--F#-G--G#-A--A#-B--C--C#-D--D#-E |-B--C--C#-D--D#-E--F--F#-G--G#-A--A#-B |-G--G#-A--A#-B--C--C#-D--D#-E--F--F#-G |-D--D#-E--F--F#-G--G#-A--A#-B--C--C#-D |-A--A#-B--C--C#-D--D#-E--F--F#-G--G#-...
[]
Things to know: First, lucky numbers. Lucky numbers are generated like so: Take all the natural numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20... Then, remove each second number. 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39... Now, 3 is safe. Remove every 3...
[ [ 11, 220, 16, 17, 11, 220, 16, 19, 11, 220, 16, 21, 11 ], [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, ...
XKCD #99, with the title "Binary Heart" shows a simple image of ones and zeros, with some digits colored red. The red heart is visible to the naked eye, but the message hidden in the binary sequence is not. If you remove all the spaces and newlines and interpret the binary sequence as 8 bit ASCII-code, you'll end up ...
[]
Crash Course on DST Dempster–Shafer theory (DST) provides a method to combine various sources of evidence to form a belief. Given a list of possible statement (one of which is the true answer), each possible combination of statements is assigned a "mass" indicating the degree of supporting evidence. The total mass of...
[]
Given a list of indices and zero or more lists of integers, output the lists of integers, sorted in ascending order, with the key priority from the first input. Example Let the keys input be [1, 0, 2], and the lists input be [[5, 3, 4], [6, 2, 1], [5, 2, 1]]. Those lists need to be sorted by their second element, then ...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
Write a program or function that outputs this exact text, case-insensitive: A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z. (Based on the alphabet song that many American kids learn to help memorize the alphabet, though edited for more compressibility.) The output must look exactly the sa...
[ [ 32, 11, 425, 11, 356, 11, 422, 11, 468, 11, 434, 11, 479 ] ]
Challenge I've recently gotten into 8-bit computers and are fascinated with the workings of them and others alike; thus the objective of this code golf, is to replicate a portion of the Woz Monitor, designed by Steve Wozniak for the Apple I. You are to store an array of 22 hexadecimal values with a width of two bytes...
[]
Introduction A Gray Code is an alternative to binary representation in which a number is incremented by toggling only one bit, rather than a variable amount of bits. Here are some gray codes along with their decimal and binary equivalents: decimal | binary | gray ------------------------- 0 | 0 | 0 ----...
[]
Introduction The Atari ST was a rather popular personal computer from the mid 80's to early 90's era, powered by a Motorola 68000 microprocessor. On this machine, the default behavior of the operating system for uncaught CPU exceptions was to display a row of bombs on the screen, as shown in the following picture: Sou...
[]
Given a Sudoku puzzle, find all possible marks that can be filled into each empty cell. Test case Input: [ [ // Top left: [ 0, 0, 0, 3, 4, 0, 0, 0, 2 ], // Top middle: [ 7, 4, 0, 0, 0, 0, 0, 0, 3 ...
[]
Given a number determine if it is a folding number. A folding number is a number such that if you take it binary representation and "fold" it in half, That is take the result of XNOR multiplication of the first half of the number and the second half with it digits in reverse, you will get zero. If the number has a odd...
[]
Challenge Ever seen those movie trailer titles (namely Martian, Interstellar, etc) where they have huge gaps in between letters slowly spreading out? The challenge is to recreate this effect given a string, gap multiplier and direction, by inserting appropriate amount of spaces in between the letters. Example Input: '...
[]
We have already defined a folding number here. But now we are going to define a Super Folding Number. A Super Folding number is a number that if folded enough times it will eventually reach one less than a power of two. The method of folding is slightly different than in the folding number question. The folding algor...
[]
The Wythoff matrix is an infinite matrix consisting of the Grundy numbers of each square on a chessboard in Wythoff's game. Each entry in this matrix is equal to the smallest nonnegative number that does not appear anywhere above, to the left, or diagonally northwest of the position of the entry. The top-left 20-by-20 ...
[]
String Similarity String similarity is basically a ratio of how similar one string is to another. This can be calculated in many ways, and there are various algorithms out there for implementing a ratio calculation for string similarity, some being more accurate than others. It's actually very useful to use these metho...
[]
Introduction A decimal is terminating if it has a finite number of decimal digits. For example, 0.4 (2/5) is terminating because it has one decimal digit. A decimal is purely periodic if it has an infinite number of decimal digits and has no decimal digits before its repetent (the part of the decimal that repeats.) For...
[]
Write a program or function that takes in positive integers a, b and c, and prints or returns a/b to c decimal places, using the operations +-*/% [add, subtract, multiply, divide, modulate] on the positive integers: you can use all that your language allows, but not on floating point numbers. The range of a,b,c would b...
[]
Backstory Disclaimer: May contain made up information about kangaroos. Kangaroos traverse several stages of development. As they grow older and stronger, they can jump higher and longer, and they can jump more times before they get hungry. In stage 1, the kangaroo is very little and cannot jump at all. Despite this, is...
[]