instruction
stringlengths
34
53.1k
Don't you find that reading simple text isn't appealing enough? Try our ##### ### ### ##### ##### ##### ##### # # ##### # # # # # # # # # # # # # # ##### ### # # # # #### # # # # # # # # # # # # # # ...
We don't have enough (semi-)easy challenges for beginners. More and more of the easy ones are already taken. So I tried to come up with something that might be achievable by beginners, but that isn't a duplicate. Input: A single string separated with your OS new-line (i.e. \r\n), or an array with multiple strings. Outp...
Your challenge is to convert a string to an ASCII art version of it. Input Your input is a single string, wich you should convert into the ASCII art version of it. Output Your output should be formatted in the following ASCII art type: _/_/_/_/ _/_/_/_/ _/_/_/_/ _/_/_/ _/_/_/_/ _/_/_/_/ _/_/_/_/ _/ _/ ...
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 ...
Write a program or function with no input that prints or returns this string of 24-hour and 12-hour times: 00:00 12:00am 01:00 1:00am 02:00 2:00am 03:00 3:00am 04:00 4:00am 05:00 5:00am 06:00 6:00am 07:00 7:00am 08:00 8:00am 09:00 9:00am 10:00 10:00am 11:00 11:00am 12:00 12:00pm 13:00 1:00pm 14:00 2:00pm 15:...
Who needs to compare things case insensitively when you're able to generate every permutation of uppercase and lowercase? No one! That's the answer. No one does. Your task is to achieve this feat; generate all possible permutations of uppercase/lowercase for a given input. Input A string of printable standard ascii cha...
Background I have a bunch of old and grainy black-and-white images. Some of them depict vines climbing on a wall, others don't – your task is to classify them for me. Input and output Your input is a rectangular 2D array of bits A, given in any convenient format. It will not be empty, but it's not guaranteed to contain...
Statement Given an input like this 35 15 0 0 10 that matches the following constrains: Width in characters of the grid (5-50) Height in characters of the grid (5-25) Initial X position of the ball (0-(Width-1) Initial Y position of the ball (0-(Height-1) Number of movements to simulate Generate a grid that shows the ...
For every given degree \$n\$ it is possible to construct (at least one) an integral polynomial \$p \in \mathbb Z[X]\$ such that \$p(k)\$ (\$p\$ evaluated in \$k\$) is the coefficient of the term \$x^k\$ in the polynomial for all \$0 \leqslant k \leqslant n\$. To make them unique, we require the leading coefficient (the...
"Digital sum" refers to the sum of all the digits in a number. For example, the digital sum of 1324 is 10, because 1+3+2+4 = 10. The challenge is to write a program/function to calculate the smallest number bigger than the input whose digital sum is the input. Example with walkthrough As an example, take the number 9 a...
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...
Cosmic rays are bad for computers. They corrupt RAM, and that causes problems. Computer chips are shrinking, and that makes them more vulnerable to the cosmic rays. We will not give in to these high-energy particles. Turing-completeness shall live on! Task Your task is to write a Turing machine. But not just any Turing...
Task Given an input list of integers x1…xn, compute a list of ranks r1…rn (a permutation of {1…n}) so that xr1 ≤ xr2 ≤ … ≤ xrn. Then, for each xi, replace its rank by the arithmetic mean of the ranks of all values in x that are equal to xi. (That is, whenever there is a tie between equal values in x, fairly redistribut...
This is my first codegolf question, so I apologize in advance if it's not appropriate, and I welcome any feedback. I have a file with this format: a | rest of first line b | rest of second line b | rest of third line c | rest of fourth line d | rest of fifth line d | rest of sixth line The actual contents vary, as do...
Background Jelly's arithmetic atoms vectorize automatically. In fact, x + y is well-defined whenever x and y are numbers or ragged arrays of numbers. Jelly's source code implements this behavior using a generic vectorizer, but for this challenge, we'll only consider addition of integers and nested integer arrays. Defin...
(Inspired by this question) Objective Your task is to write a program or function to print an ASCII version of the Stack Overflow logo to STDOUT \|/ (-) (-) (-) (-) Your program should take two inputs, referred to here as H and N. The height of the stack "container" (the parentheses) is determined by H. The number of...
Let's build a simulation for an aspect in the card game, which I personally know by the Dutch name 'Oorlog' (translates to 'War'). How does 'Oorlog' work? Two decks of cards (each including two Jokers) are equally divided between the amount of players playing. Each player shuffles their own stock, put it upside down in...
Given a sequence of bytes, output the SHA-256 hash value of the sequence. The SHA-256 Algorithm The following pseudocode is taken from the Wikipedia page for SHA-2. Note 1: All variables are 32 bit unsigned integers and addition is calculated modulo 2^32 Note 2: For each round, there is one round constant k[i] and one ...
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...
Task description Given an integer, swap its (2k–1)-th and 2k-th least significant bits for all integers k > 0. This is sequence A057300 in the OEIS. (The number is assumed to have “infinitely many” leading zeroes. In practice, this simply means prepending a single 0 bit to odd-length numbers.) This is code-golf, so th...
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...
(Follow-up to my question about swapping bits with their neighbours.) Task Given a positive integer x = (2a · 3b) · (5c · 7d) · (11e · 13f) · …, print the integer obtained by swapping the exponents in this factorization for each successive pair of primes, y = (2b · 3a) · (5d · 7c) · (11f · 13e) · … A061898 in the OEIS....
This one is simple to describe and I could hardly believe that this was not golfed before: For a given image (whatever format is supported by your language), find the unique colors and output a list of the colors. Print the color code in hex RGB, that is a hash sign # followed by 2 digits for R, 2 digits for G and 2 ...
Background / Description Note: as @HelkaHomba points out, the actual GitHub identicons are not actually random but based on the hash of a username The default GitHub avatar is a 5x5-pixel image. A color is picked randomly, and then random pixels are filled in on one side (right or left, 2x5 size) using that color. Then...
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...
The card game War is interesting in that the final outcome is entirely determined by the initial arrangement of the deck, so long as certain rules are followed for the order in which cards are picked up from the playing field and moved to decks. In this challenge, there will only be 2 players, simplifying things greatl...
(via chat) The OEIS entry A123321 lists the sequence of numbers that are the product of seven distinct primes. For brevity, we'll call this a 7DP number. The first few numbers and their corresponding divisors are below: 510510 = 2 * 3 * 5 * 7 * 11 * 13 * 17 570570 = 2 * 3 * 5 * 7 * 11 * 13 * 19 690690 = 2 * 3 * 5 * 7 *...
Geobitsian language is a new perversion of English where a word is broken into segments that each must start with a different letter. Then every time one of those starting letters appears in another string, it is replaced with its entire corresponding segment, maintaining capitalization. This process is called Geobitsi...
Cribbage is an interesting game, because you need a specific board to score your game. A cribbage board looks like this: Notice how the first column is on the left as it goes up, then on the right as it goes down, then back on the left as it goes up again. And here is what a poorly drawn rendered ASCII art of a cribba...
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 ...
Task Define a simple regex as a non-empty regular expression consisting only of characters 0 and 1, grouping parentheses ( and ), one-or-more repetition quantifier +. Given a non-empty string of 0s and 1s, your program should find the shortest simple regex matching the full input string. (That is, when matching a sim...
The happy ending problem (actually a theorem) states that Any set of five points in the plane in general position has a subset of four points that form the vertices of a convex quadrilateral. The problem was so named by Paul Erdős when two mathematicians who first worked on the problem, Ester Klein and George Szekere...
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 ...
Write a program using only printable ASCII characters that takes no input. For reference, here are the 95 printable ASCII characters in order: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ When your program is run it should print 0 (plus an optional trailing newline) t...
There is a rather curious number which shows up sometimes in math problems or riddles. The pseudofactorial(N) is the least (i.e. lowest) common multiple of the numbers 1 through N; in other words, it's the lowest number which has all numbers from 1 through N as factors. For instance pseudofactorial(7) = 3 * 4 * 5 * 7, ...
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 ...
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...
This is similar to simplifying fractions, but with Dates! The input of your program must be of the form mm/dd For example 3/4 //March 4 12/15 //December 15 1/1 // January 1 We assume that the input will be valid such that the months have these numbers of days in them: January 31 February 28 March 31 April 30 May 31 Ju...
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...
Tonight, my fiancée took me out to dinner to celebrate my birthday. While we were out, I heard Happy Birthday sung to 5 different guests (including myself), in a restaurant full of 50 people. This got me wondering - the original birthday problem (finding the probability that 2 people in a room of N people share the sam...
Introduction and Credit We all know and love our awesome rules to test whether a number is divisble by 11 or 3, which is just some clever sum over the digits of the number. Now this challenge takes this to a new level, by requiring you to compute the sum of the digits and then checking whether the result is a perfect i...
We all know that the Euler's number, denoted by \$e\$, to the power of some variable \$x\$, can be approximated by using the Maclaurin Series expansion: $$e^x=\sum_{k=0}^{\infty}{\frac{x^k}{k!}}=1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\frac{x^4}{4!}+\dots$$ By letting \$x\$ equal \$1\$, we obtain $$\sum_{k=0}^{\infty}{\frac{...
Write a program/function that returns the vote count of its own Stack Exchange answer at the time of its execution. Your program/function may access this page (codegolf.stackexchange.com/questions/82609) off the internet, however: Your program/function may not accept any user input and The use of URL shorteners is not...
This challenge is very simple. You are given as input a square matrix, represented in any sane way, and you have to output the dot product of the diagonals of the matrix. The diagonals in specific are the diagonal running from top-left to bottom-right and from top-right to bottom-left. Test Cases [[-1, 1], [-2, 1]] ->...
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...
In a single file, write a program that requires no input and produces no output. When run it should reverse the name of the file it is contained in, regardless of what the name is, without altering the code or producing other lasting side effects. Any way of achieving this is fine. It only matters that once the program...
Note: reference to Nothing up my sleeve number. Your task is to take no input and generate this exact output: d76aa478 e8c7b756 242070db c1bdceee f57c0faf 4787c62a a8304613 fd469501 698098d8 8b44f7af ffff5bb1 895cd7be 6b901122 fd987193 a679438e 49b40821 f61e2562 c040b340 265e5a51 e9b6c7aa d62f105d 02441453 d8a1e681 e7...
This is my pet emoji, Billy: -_- Emojis don't like to be in the rain, so Billy is sad... Let's draw him an umbrella to make him feel better! /\ / \ / \ -_- This is good, he is entirely covered by his umbrella! Here is an example where only part of him is covered: /\ / \ / \ -_- In this case, s...
Your dumb teacher is always wrong, so flip his answer. Change these responses True -> False Yes -> No 0 -> 1 Yeah -> Nope and vice versa. Keeping punctuation and the first letter's capitalization counts. Only one condition will be passed to the program. You only need to accept the following test cases: True <-> Fals...
Given a nonempty list of nonnegative integers, consider rewriting it as an arithmetic problem where: A plus sign (+) is inserted between pairs of numbers that increase from left to right (a.k.a. from the start of the list to the end). A minus sign (-) is inserted between pairs of numbers that decrease from left to rig...
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 ...
Introduction Eisenstein integers are complex numbers of the form a+bω Where a,b are integers, and ω = e^(2πi/3) The Eisenstein integers form a triangular lattice in the complex plane: We say that an Eisenstein integer z=a+bω is prime if it cannot be written as the product of two non-unit (not 1,-1,ω,-ω,ω^2, or -ω^2) ...
Last time when I tried to come up with something easy that wasn't a duplicate, it ended up being way too hard.. So hopefully this time it's indeed something newcomers can try as well. Input: An array/list with integers/decimals. (Or a string representing an array with integers/decimals.) Output: Loop through the number...
The cosmic call is a message sent into space in 1999 and 2003. It's made of 23 127*127px monochrome bitmap images, as detailed here. Your mission is to write a program that displays the entire 127*2921px message, either as a text (made of zeros, ones and line breaks) or as an image (drawn on screen or saved on disk). T...
Earlier, we did the pseudofactorial of a number, which is the LCM of the numbers from 1 to n. It would be useful in adding fractions together. However, we find that the denominator of 1/1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6 is 20 instead of the pseudofactorial of 6, which is 60. Your task is to find the denominator of 1/1 + ...
Turn the characters abcdefghijklmnopqrstuvwxyz!?., upside down and don't modify the other characters. Then, reverse the text to achieve the upside down affect. If text is already upside down, turn it right side up. Don't modify capitals. Use this as a reference: abcdefghijklmnopqrstuvwxyz!?., ɐqɔpǝɟƃɥıɾʞןɯuodbɹsʇnʌʍxʎz...
Back to basics... As a teacher at the local primary (grade?) school, you need a way to teach your class their times tables. At your disposal, you have hundred squares and a load of red pens. You need to also be able to show your class the correct answers quickly. Now, you're clever enough to write a program that can do...
Introduction We define twin primes as two natural numbers p,p+2 which both are prime. Example: 5 and 7 are twin primes. Let's define the twin number of some set of numbers as the number of twin prime numbers in that set Example: {6,7,11,13,18,29,31} has a twin number 4, since there are four twin primes; 11,13 and 29,3...
Write a program or function that takes in a positive integer N and outputs the first N numbers of this amplifying zigzag pattern, using only the lines needed: 26 25 27 . 10 ...
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 ...
A field in mathematics is a set of numbers, with addition and multiplication operations defined on it, such that they satisfy certain axioms (described in Wikipedia; see also below). A finite field can have pn elements, where p is a prime number, and n is a natural number. In this challenge, let's take p = 2 and n = 8,...
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...
So task is simple, given array of numbers and result, you need to find what operations you need to use on numbers from array , to obtain requested result. Let's make it simple for start, and allow only basic operations such as: addition, subtraction, multiplication and division. Example: Input : [5,5,5,5,5] 100 Outpu...
The handshake problem is the classic problem that for n people in a room, if they all shake hands, what's the total number of handshakes that occur. You code should take an input of any number and output the number of handshakes, both in base ten. Also the code should not let non-integers through. You should output a ...
{}is the empty set. You may use () or [] if you choose. We aren't going to rigorously define "set", but sets all satisfy the following properties: Sets follow the usual mathematical structure. Here are some important points: Sets are not ordered. No set contains itself. Elements are either in a set or not, this is bo...
For example, the gate A and B is a logic gate with 2 inputs and 1 output. There are exactly 16 of them, because: each logic gate takes two inputs, which can be truthy or falsey, giving us 4 possible inputs of the 4 possible inputs, each can have an output of truthy and falsey therefore, there are 2^4 possible logic ga...
Given a natural number \$n\$, return the \$n\$-th Leyland number. Leyland Number Leyland numbers are positive integers \$k\$ of the form $$k = x^y + y^x$$ Where \$x\$ and \$y\$ are integers strictly greater than 1. They are enumerated in ascending order. EDIT: @DigitalTrauma suggested I include following "definition": ...
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...
Earlier, we talked about exponential generating functions (e.g.f.). Task You will take a few terms of a sequence. Your task is to find another sequence with that many terms, whose e.g.f., when multiplied to the original e.g.f., would be exactly the constant function 1 accurate to that many terms. That is, given a0=1, a...
Task Using any type of parallelisation, wait multiple periods, for a total sleep time of at least a minute (but less than a minute and a half). The program/function must terminate within 10 seconds and return (by any means and in any format) two values: the total elapsed time, and the total executed sleep time. Both ti...
You will take two positive integers n and x as input, and output Euler's totient function (number of positive integers less than x co-prime to x) applied n times. Testcases n x result 1 10 4 2 10 2 3 10 1 1 100 40 2 100 16 3 100 8 4 100 4 5 100 2 6 100 1
Write a program that takes in an integer from 0 to 65535 (216-1) and generates a unique 500×500 pixel image that looks as similar as possible to these 6 real life images of cracked soil: These are thumbnails, click them to see the full-size 500×500 images. The goal here is to make your computer generated images a...
Did you know that a small number can borrow bits from a larger number? Here's an example. Let's say our two numbers 5 and 14. First, write them out in binary: 5 14 000101 001110 First we take the smallest on bit away from the larger number, and we give it to the smallest off bit on the other number. So This bit...
Challenge description On a Cartesian plane, a triangle can be described as a set of three points, each point being one of the triangle's vertices. For instance, coordinates (2, 1), (6, 8), (-7, 3) correspond to the following triangle: As you can see, it does not contain the origin of the plane, i.e. the point (0, 0), ...
My friend made a lisp translator the other day, that is to say it took a string and converted s=>th and S=>Th. It was quite long and I thought that it could be golfed. So the task is to make a program/function that takes an input string, translates it in to lisp and outputs the string Test case Sam and Sally like Sheep...
Introduction A hypercube/tesseract is the 4 dimensional equivalent of a normal cube. It's made by taking a cube net, extending it to the 3rd dimension, then – using the 4th dimension – folding it into a hypercube. It's basically a cube, where each side is a cube. To create a hypercube, you need 16 4d vectors (a vector ...
The program should take a string as input and reverse the consonants in it, while keeping the order of vowels. All the letters will be lowercase, so you don't have to worry about casing. Examples follow. Input: a test case. The consonants here are t,s,t,c,s. They should come in reversed order, i.e. s,c,t,s,t and inse...
If you look at the Fibonacci Numbers, you will notice a pattern in their parity: 0, 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 , 55 , 89 , 144. Every third number is even, and all the others are odd. This makes sense because an even plus an odd is odd, but an odd plus an odd is even and the sum for a term will always include...
Fibonacci Numbers Fibonacci Numbers start with f(1) = 1 and f(2) = 1 (some includes f(0) = 0 but this is irrelevant to this challenge. Then, for n > 2, f(n) = f(n-1) + f(n-2). The challenge Your task is to find and output the n-th positive number that can be expressed as products of Fibonacci numbers. You can choose to...
Sometimes it really is a struggle to convert Cartesian coordinates (x,y) to Polar coordinates (r,phi). While you can calculate r = sqrt(x^2+y^2) quite easily, you often need some distinction of cases when calculating the angle phi because arcsin,arccos and arctan and all other trigonometric functions have a co-domain t...
Your task is to create a polish notation calculator. For those who don't know what is polish notation, it's a mathematical notation where operators are before the operands. Eg: + 1 2 = 1 + 2 Your calculator should implement integer addition, substraction multiplication and division. Standard loopholes are forbidden but...
An Armstrong number (AKA Plus Perfect number, or narcissistic number) is a number which is equal to its sum of n-th power of the digits, where n is the number of digits of the number. For example, 153 has 3 digits, and 153 = 1^3 + 5^3 + 3^3, so 153 is an Armstrong number. For example, 8208 has 4 digits, and 8208 = 8^4 ...
You would simply take this image and make every color added one to every hexadecimal digit. For example, #49de5f would become #5aef60 (with the 9 looping to an a, and the f looping to a 0.) This would also mean that all white (#ffffff) would become black (#000000) because all f loops back to 0, but all black will beco...
This is Bub. Bub is a soccer player. However, he's not a very good one. He still can't kick the ball to the net! (If you haven't noticed, @ is the ball. _____ | \ O ...
Description Your task is to take a string as input, and convert the first letter of each word to uppercase, and the rest to lowercase. Test Cases Input => Output ISN'T THIS A REALLY COOL TEST CASE??? => Isn't This A Really Cool Test Case??? tHis iS A rEALLY WeiRd SeNTEncE => This Is A Really Weird Sentence I Like This ...
Find the difference between the square of the sums and sum of the squares. This is the mathematical representation: \$\left(\sum n\right)^2-\sum n^2\$ Your program/method should take two inputs, these are your lower and upper limits of the range, and are inclusive. Limits will be whole integers above 0. Your program/m...
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...
Nice verb there, in the title. Write a program that given an input string, will "elasticize" this string and output the result. Elasticizing a string is done as follows: The first character is shown once. The second character is shown twice. The third character is shown thrice, and so on. As you can see, the amount of...
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, ...
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...
Your task is to create a program that adds random numbers to previous sums in the ultimate number racing showdown. Each racer (column) starts at 0 and adds either 1 or 0 to the previous sum at each step of the race until all of the racers reach the score required to win. The 1 or 0 should be chosen at random (the stand...
Chess pieces (kings, queens, rooks, bishops, and knights) and pawns are on a board, but not on the a1 or h8 square. Your task is to travel from the empty a1 to the empty h8 squares, passing through only empty squares. The rules of movement are as follows: You can proceed from any empty square to any empty square next ...
Inspired by this answer (emphasis mine): We will play a game. Suppose you have some number x. You start with x and then you can add, subtract, multiply, or divide by any integer, except zero. You can also multiply by x. You can do these things as many times as you want. If the total becomes zero, you win. For example,...
Your task is to write a self referential program similar to a quine. The objective is to write a program that will generally print to stdout twice whatever the input is. But when it receives the input of "Tell me about your source" it should output its source (like a quine). Also if it receives the query "tell me about...
Given the input of the first number and the second number (both positive integers, zero exluded), determine in how many ways could you make the second out of the first, using following actions: +1,+2 and *3. Operations are simply applied from left to right. Examples: Input: 1 2. Output: 1. I.e, you could only get 2 b...
My preferred way to approximate a derivative is the central difference, its more accurate than forward difference or backward difference, and I'm too lazy to go higher-order. But the central difference requires a data point on either side of point you are evaluating. Normally this means you end up not having a derivati...
Background Euler's totient function φ(n) is defined as the number of whole numbers less than or equal to n that are relatively prime to n, that is, the number of possible values of x in 0 < x <= n for which gcd(n, x) == 1. We've had a few totient-related challenges before, but never one which is just calculating it. Th...
For this golf, you will need to use more than one language. The task A Rube Goldberg machine is a contraption that takes an enormous number of complicated steps in order to execute a very simple task. The goal of this golf is to output Rube Goldberg... but not directly. The machine Your "machine" is the source code tha...