instruction_seed
stringlengths
292
48.7k
found_ngrams
listlengths
0
21
Challenge This challenge is based on the domino effect: Initially, each domino is located on one straight line and is in a vertical state. It can be dropped either to the left along the same straight line, or to the right. Then this domino will knock down the next one, and that one, perhaps, the other. The dominoes are...
[]
Given a string of ASCII text as input, encode it in BPSK31 using Varicode. You may either output an audio file in any common format, or play the audio over the device speakers. You may output at any sample rate and with any carrier frequency between 500 Hz and 2500 Hz. The sample rate and carrier frequency must be cons...
[]
You know what a monotonic sequence is: each element is bigger than its predecessor (monotonically rising) or as its successor (monotonically falling). Bitonic means you have two arms of the sequence, one monotonically rising, the other falling. For example, 1,3,5,7,6,4,2 is bitonic (rising until 7, then falling until t...
[]
In this challenge, an infinitely proportional sequence is defined as a infinite sequence of positive integers such that: All positive integers are contained infinitely many times within the sequence. As more and more terms are added to the sequence, for all positive integers \$n\$, the ratio of the number of \$n\$s to...
[]
OEIS sequence A003242 comprises the numbers of Carlitz compositions for any given positive integer. This is the number of integer partitions of the integer for which no two adjacent parts are equal. For example, for 4: Generate the possible integer partitions (and their permutations): [1,1,1,1], [1,1,2], [1,2,1], [2,1...
[]
Given an n non-negative integers, how many numbers must be changed so that each number x appears x times? You cannot add or remove elements, only replace them with other numbers. For example: 1 6 23 6 9 23 1 1 6 can be turned into: 1 6 2 6 6 2 6 6 6 with 5 changes, which is optimal. Test cases 0 => 1 1 2 3 => 1 5 5 5...
[]
Every Brazilian citizen has a national identification number associated with them, named CPF. This number has 11 digits (formatted as XXX.XXX.XXX-XX) and it's validated by the following (real) algorithm1: Take the 9 most significant digits of the number. Call it c. Multiply the n-th least significant digit of c by n+1...
[ [ 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 ] ]
I define mousetail's sequence as follows: If the nth element of the sequence is q, then n+1 must appear q times in the sequence The sequence is weakly monotonically increasing (i.e. no lower number may follow a higher number) f(1)=1 I'll show an example of how this works: the first element is 1 after the 1, come 1 2...
[]
Historic Tetris Achievement Blue Scuti became the first ever human to beat the classic game of Tetris on NES. Here's the Tetris Kill Screen Challenge Output the following Tetris Kill Screen board (10x20 blocks) EEEEEEEEEE EEEEEEEEEE EEEEEEEEEE EEEEEEEEEE EEEEEEEEEE EEEEEEEEEE EEEEEEEEEE EEEEEEEEEE EEEEEEEEEE EEEEGGEEE...
[]
Earlier I asked about this problem on stackoverflow (link), but now I also want to see the golfiest solutions Problem: Given an array of arbitrary numbers, what is the longest subarray that is repeated (appears more than once)? In case there are multiple distinct repeated subarrays that all have the longest length, the...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
Consider a function \$r\$ where $$ r(i,k)= \begin{cases} L_{i+1}-L_i, & \text{if}\ k =0\ \text{ (1st reduction)} \\ r(i,0)-r(\lfloor \log_2{k} \rfloor,k-2^{\lfloor \log_2{k} \rfloor}) & \text{if}\ k \geq 1\ \text{ (2nd reduction)} \end{cases} $$ where \$k<2^i\$ and \$L\$ is a finite sequence of integers. For example,...
[ [ 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 ] ]
Definitions The common methods to generate consecutive composites are $$\overbrace{(n+1)! + 2, \ (n+1)! + 3, \ \ldots, \ (n+1)! + (n+1)}^{\text{n composites}}$$ $$\overbrace{n!+2,n!+3,...,n!+n}^{\text{n-1 composites}}$$ $$\overbrace{n\#+2,n\#+3,…n\#+n}^{\text{n-1 composites (Primorials)}}$$ A less common method involv...
[]
Exposition In this challenge, I am talking about ARM assembly language. ARM is a 32-bit RISC processor; I'll use instruction set up to architecture v6. To load a constant ("immediate") value into a register, use the MOV instruction: MOV r8, #42 To load negative values, use the MVN instruction, with a bit-complement of...
[]
Even though the concept of phat-fingered-lights-out number should be pretty self-explanatory here is a definition: Given a nonnegative integer in binary representation a phat-fingered double-bit-flip or phatflip for short replaces a pair of adjacent, equal bits with their complement. For example given the number 0b1110...
[]
Input: You are given two numbers n and m. Create the snail: Given an n >= 3, fill an n * n grid with the numbers from 1 to n * n, starting at the top left, going clockwise to the middle like this (for n = 5): 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9 Calculate the sum of the neightbour...
[]
Background As noted in this question, for all positive integers \$n>2\$ there exists at least one Egyptian fraction representation (EFR) of \$n\$ distinct positive integers \$a_{1} < a_{2} < \dots < a_{n}\$ such that $$ \sum_{k=1}^{n} \frac{1}{a_{k}} = 1. \tag{1} \label{1} $$ When \$n=3\$, for instance, we have $$ \fra...
[]
A list \$[a_1,a_2,a_3 \cdots a_n]\$ can be uniquely represented as an unordered list of its prefixes - \$ [[a_1],[a_1, a_2], [a_1,a_2,a_3] \cdots [a_1,a_2,a_3 \cdots a_n]] \$. This can be in any order - for example, \$[1, 2, 3]\$ could be represented by any of \$[[1],[1,2],[1,2,3]]\$, \$[[3,2,1],[2,1],[1]]\$, or \$[[2,...
[]
Challenge Given ASCII-encoded text input of any size, detect numbers between -1,000,000,000,000,000,000 and 1,000,000,000,000,000,000 exclusive and rewrite them with thousands separators. Use commas only and ignore leading zeroes. Leave the rest of the input unchanged. Test cases Input Output Description 123 123...
[]
Given a collection of coloured laces, what would be the probability, \$P\$, that Alice won't create any loops if, until impossible, they tie two uniformly chosen, free lace ends of differing colours together? For the avoidance of doubt: Each lace will be of only one colour and will have precisely two ends. Alice does ...
[]
I recently found this game and have been enjoying it. Basically, there is a grid of colored tiles and you act by clicking on empty spaces. When you click an empty space, the first tile (if any) in each of the four axis-aligned directions is selected. If any color appears more than once, all tiles of that color are dest...
[]
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...
[]
Given two integers, A and B, output A if A-B (A minus B) is in A-B (A to B), otherwise output B. "A minus B" is standard subtraction. "A to B" is the range of integers starting at A and ending at B, including both A and B. For example: 1 to 4: 1, 2, 3, 4 -2 to 5: -2, -1, 0, 1, 2, 3, 4, 5 3 to -1: 3, 2, 1, 0, -1 7 to 7:...
[ [ 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 ] ]
For a story I'm writing, I needed to convert 101⅐ (101 + 1/7 if that doesn’t show up for you) into base 47. Expressing an integer in some base brings back memories of first learning how to program back in the days of 8-bit systems; it’s a fairly easy exercise. Doing so using a floating-point format is a bit harder, tho...
[]
Input: Two integers: one negative, one positive. Output: On the first line output lowest to highest. On the second line we've removed the highest and lowest numbers and sign-changed all individual numbers. On the third line we've removed the highest and lowest numbers again and sign-changed all individual numbers again...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20, 11 ], [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220...
The Challenge Given the number of items, n, in a non-empty, sorted list output the index, i(n), at which its "Back-To-Front Permutation" would reside in a list of all permutations if said permutations were sorted lexicographically. Results may be 0 or 1-based, just say which (that is i, not n). The Back-To-Front Permut...
[]
Writing out numbers is among the Hello worlds of programming, often the numbers 1-10. I want to write out many numbers! Many, Many numbers. But how many numbers do I have to write? Task Given an integer input, give a number as output that would give me the number of digits that would be in a string containing all integ...
[]
The challenge here is to extend an implementation of palindrome given the following as inputs: n > 1 and a list l. Your program must palindrome the list both vertically and horizontally, that is to say it must first palindrome the list itself, then each element in the list after; or the other way around. Before pali...
[]
Write a program that will determine if a given matrix represents a quandle. A quandle is a set equipped with a single (non-commutative, non-associative) operation \$◃\$ which obeys the following axioms: The operation is closed, meaning that \$a◃b = c\$ is always an element of the set if \$a\$ and \$b\$ are elements o...
[]
The Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. Let P be a binary string of length n and T be a binary string of length 2n-1. We can compute the n Hamming distances between P and every n-length substring of T in order from left to ri...
[]
This challenge is adapted from the British Informatics Olympiad. Dice game Two players are playing a dice game where they each roll a pair of dice, and the highest sum wins. The pairs of dice have the same number of sides, but do not have to have the same values on each side. Therefore, the game is fair if for both pa...
[]
Problem: Your task is to decide if in a sequence of numbers, every number contains at least one of the digits of the number that preceded it. For example, the following should return truthy: [1, 12, 203, 0, 30] ^ ^ Contains a 0 ^ Contains a 2 ^ Contains a 1 The following should return ...
[ [ 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 ] ]
Sometimes, when I'm really bored I like to take the sum of an array of non-negative integers. I only take the sum of arrays of lengths that are powers of two. Unfortunately I often make mistakes. Fortunately I keep track of my work as I go along in the following way: I add pairs of adjacent numbers until there's only o...
[]
A list of numbers is called monotonically increasing (or nondecreasing) is every element is greater than or equal to the element before it. For example, 1, 1, 2, 4, 5, 5, 5, 8, 10, 11, 14, 14 is monotonically increasing. Given a monotonically increasing list of positive integers that has an arbitrary number of empty sp...
[ [ 220, 16, 11, 220, 16, 11, 220, 17, 11, 220, 18, 11, 220 ], [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 11, 220, 17, 11, 220, 18, 11, 220, 19, 11...
Some decimal numbers cannot be precisely represented as binary floats due to the internal representation of the binary floats. For example: rounding 14.225 to two decimal digits does not result in 14.23 as one might expect but in 14.22. Python: In: round(14.225, 2) Out: 14.22 Assume, however, that we have a string rep...
[ [ 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 N, output the Nth term of this infinite sequence: -1 2 -2 1 -3 4 -4 3 -5 6 -6 5 -7 8 -8 7 -9 10 -10 9 -11 12 -12 11 ... etc. N may be 0-indexed or 1-indexed as you desire. For example, if 0-indexed then inputs 0, 1, 2, 3, 4 should produce respective outputs -1, 2, -2, 1, -3. If 1-indexed then inputs 1, 2, 3, 4, ...
[ [ 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 ] ]
Today, we'll be computing the most efficient binary function. More specifically, we'll be computing the function which, when an expression is created from applying the function to the constant input 0 or its own output, can represent all positive integers with the shortest possible expressions, placing higher priority ...
[]
Write a program to determine if a periodic sequence of positive integers has the property that, for every integer n occurring in the sequence, there are never more than n other integers between two consecutive occurrences of n. For example, 2, 3, 5, 2, 3, 6, 2, 3, 5, 2, 3, 6, ... does have this property: every pair of ...
[]
Background By expanding and cancelling terms, it is easy to show the following identity: However, it is an open problem whether all 1/n-by-1/(n+1) rectangles can tile the unit square. The Task Your program should take a positive integer N as input in any convenient manner, and pack all 1/n-by-1/(n+1) open rectangles w...
[]
We define a binarray as an array satisfying the following properties: it's non-empty the first value is a 1 the last value is a 1 all other values are either 0 or 1 For instance, the array [ 1, 1, 0, 1 ] is a valid binarray. The task Given a non-empty array A of non-negative integers and a positive integer N, your jo...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ], [ 220, 16, 11, 220, 18, 11, 220, 21, 11, 220, 24, 11, 220 ], [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 22...
(There are related questions about infinite sandpiles, and finding identity elements of sandpiles.) Given a matrix of non-negative integers, return a matrix of the same dimensions, but toppled: If the matrix doesn't contain any values larger than 4, return it. Every "cell" that is larger than 3 gets reduced by 4, and ...
[ [ 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 fun game to play if you are bored is the Diffy Game. It is a one player game that is pretty simple and can consume a good deal of your time. The Diffy game works like as follows: You start with a list of non-negative integers, in this example we will use 3 4 5 8 Then you take the absolute difference between adjacen...
[]
Today, as I'm writing this, is March 31st. In the US, this is 3/31. I was playing around with 331 as a number to come up with a challenge, and found that its residues (modulo small numbers) is palindromic. 331%2=1, 331%3=1, 331%4=3, 331%5=1, 331%6=1 (11311). Your challenge here is, when given an integer n > 2, output t...
[]
In this challenge, you'll get four different but somewhat related tasks that must be solved in a specific manner. First, I'll explain the tasks, then follows an explanation of how you must solve it. Your code should for all four tasks take two positive integers as input: n,m, where n<m. All tasks must be solved in the ...
[]
Challenge: Output the 'integer-digits' of one of the following six arithmetic-tables based on the input: - addition (+); - subtraction (-); - multiplication (*); - division (/); - exponentiation (^); - modulo operation (%). Rules: What do I define as 'integer-digits': Every result of the arithmetic operand which is ex...
[]
Am I under Budget? Every 2 weeks when I get my cheque, I allocate a certain amount to last me until my next cheque, and bank the rest. To figure out how much I can spend per day and still remain under/on budget, I just need to divide the allocated amount by the number of days it needs to last me. On Day 1 if the budget...
[]
Given two permutations in disjoint cycle form, output their product/composition in disjoint cycle form. To find the composition, convert the disjoint cycles to permutations in two-line notation. Each number in a disjoint part of a cycle is mapped to the number following it in the same part. It wraps around. So 1 -> 5,...
[]
Backstory I've always found it quite annoying how some numbers in English don't have the same number of syllables even though they have the same number of digits. Example: seven has 2 syllables whereas all of the other digits have one (other than zero). So, when I'm counting in time to something (like a drill cadence i...
[]
Title misspelled on purpose. Read more to find out why. Your task: given a delimited string or list including the characters A,B,C,D, output the indexes of all the adjacent equal characters. Output can be multiple strings/integers on multiple lines, a list/array, or a delimited string. All output should be in a list or...
[]
Convert a hexadecimal number (of any size) into a binary number. Input A POSITIVE hexadecimal number with a 0x in the beginning. A valid input will always match the following regex: 0x[0-9a-fA-F]+. If the input is not a valid hexadecimal number, that is, anything not matching this regex, the output should be 0. Output ...
[]
Recently I posted a question about Diffy games which has gone unanswered. Thats fine, the question is really hard, but I would like to make an easier question about Diffy games so that we can get the ball rolling. How Diffy works Copied from Find Diffy Games The Diffy game works like as follows: You start with a lis...
[]
First, a few definitions: Given n and k, consider the sorted list of multisets, where for each multiset we choose k numbers from {0, 1, ..., n-1} with repetitions. For example, for n=5 and k=3, we have: [(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 0, 3), (0, 0, 4), (0, 1, 1), (0, 1, 2), (0, 1, 3), (0, 1, 4), (0, 2, 2), (0,...
[]
Your challenge is to make a program or function that outputs the GCD of its inputs in one language and the LCM of its inputs in another. Builtins for GCD or LCM (I'm looking at you, Mathematica) are allowed but not encouraged. There will be 2 inputs, which will always be positive integers, never greater than 1000. Test...
[]
If you're going to invent some fake news, you'll want to fabricate some data to back it up. You must already have some preconceived conclusions and you want some statistics to strengthen the argument of your faulty logic. This challenge should help you! Given three input numbers: N - number of data points μ - mean o...
[ [ 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220, 20 ] ]
This challenge was inspired by @HelkaHomba's excellent challenge Red vs. Blue - Pixel Team Battlebots. That challenge was probably the best one I've seen on this site. Ever. My challenge is still a lot different, but @HelkaHomba deserves credit for the inspiration. Overview This is a team king-of-the-hill where your t...
[]
Definitions You can skip this part if you already know the definitions of groups, finite groups, and subgroups. Groups In abstract algebra, a group is a tuple (G, ∗), where G is a set and ∗ is a function G × G → G such that the following holds: Closure: for all x, y in G, x ∗ y is also in G (implied by the fact that ∗...
[ [ 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 ] ]
Your task is to find the nth Fibonacci number, but n is not necessarily an integer. The Fibonacci sequence, 0-indexed, goes as follows: 0, 1, 2, 3, 4, 5, 6, 7, ... 1, 1, 2, 3, 5, 8, 13, 21, ... However, what happens if we want the 2.4th number? The 2.4th number is 0.4 times the difference between the 3rd and 2nd F...
[ [ 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,...
Definitions Euler Phi Function (AKA totient function): a function which takes in a positive number and returns the number of positive numbers less than the given number which are co-prime with given number. It is denoted as φ(n). Reachable number: if there exists a positive integer x such that φ(x) == n, then n is rea...
[]
Definitions A subsequence may not be contiguous, e.g. [1, 1, 1] is a subsequence of [1, 2, 1, 2, 1]. An equal subsequence is a subsequence in which every element is equal. The longest equal subsequence may not be unique, e.g. [1, 1] and [2, 2] are both longest equal subsequences of [2, 1, 1, 2]. Input A non-empty lis...
[ [ 220, 16, 11, 220, 17, 11, 220, 18, 11, 220, 19, 11, 220 ] ]
You must take two lists of positive integers as input, let's call these n and m. You may assume that: All integers in n are part of m All integers in m are unique The lists are non-empty Challenge: Return the indices of where you find the values in n, in m. That might be confusing, but I think the test cases will ma...
[]
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 ...
[]