instruction_seed
stringlengths
292
48.7k
found_ngrams
listlengths
0
21
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 ...
[]
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...
[]