text
stringlengths
180
608k
[Question] [ # Challenge Create a function takes in two 2-dimensional arrays of characters (or strings if the programming language does not have characters as a datatype) as inputs: a and b. If your language does not support these inputs, you may use any other standard one-byte variable. Your task is to determine i...
[Question] [ # Rotonyms 1 [ROT13](https://en.wikipedia.org/wiki/ROT13 "The ROT13 wikipedia page") ("rotate by 13 places") is a simple letter substitution cipher that replaces a letter with the 13th letter after it, in the alphabet. So, `A` becomes `N`, `N` becomes `A`, `B` <-> `O`, and so on to `M` <-> `Z`. `ROT13...
[Question] [ # Introduction On the 26th of August, 2017, [Floyd Mayweather, Jr.](https://en.wikipedia.org/wiki/Floyd_Mayweather,_Jr.) will face up to [Conor McGregor](https://en.wikipedia.org/wiki/Conor_McGregor) in a boxing match. Both participants will receive the phenomenal amount of 100 million dollars! Unfortu...
[Question] [ # The House of Santa Claus **Note:** This is the first challenge that I have attempted to set. It has been through the Sandbox however if you find something wrong with it please do not just downvote but leave a comment so that I can improve it. **Background** There is a old childrens puzzle where the c...
[Question] [ Every player has a number. Can yours be the farthest from them all? ## Requirements Write a Java, Python 2, or Ruby function named `choose()` that accepts three arguments: * an integer - the number of rounds already completed * an integer - the number of players * an array of strings - the results of e...
[Question] [ Here is a list of the 118 (current) elements of the periodic table (in a collapsed Stack Snippet for your convenience): ``` Hydrogen Helium Lithium Beryllium Boron Carbon Nitrogen Oxygen Fluorine Neon Sodium Magnesium Aluminium Silicon Phosphorus Sulfur Chlorine Argon Potassium Calcium Scandium Titaniu...
[Question] [ A [square-free word](https://en.wikipedia.org/wiki/Square-free_word) is a word consisting of arbitrary symbols where the pattern \$XX\$ (for an arbitrary non-empty word \$X\$) does not appear. This pattern is termed a "square". For example, `squarefree` is not square-free (using the lowercase letters a...
[Question] [ Consider a triangle where the **N**th row (1-indexed) is the array of the first **N** positive integer powers of **N**. Here are the first few rows: ``` N | Triangle 1 | 1 2 | 2 4 3 | 3 9 27 4 | 4 16 64 256 5 | 5 25 125 625 3125 ... ``` Now if we concatenate those powers into a single sequence, we get ...
[Question] [ ### Introduction Let's observe the following square, consisting only of the digits `0 - 9`: ``` 1034 4167 8414 3542 ``` The outer shell of this square is: ``` 1034 4 7 8 4 3542 ``` It contains zeros, so we need to *peel* off the outer shell, leaving: ``` 16 41 ``` The outer shell of this square is: `...
[Question] [ A [centered polygonal number](https://en.wikipedia.org/wiki/Centered_polygonal_number) is a positive integer given by the number of vertices when a point is surrounded by (increasingly larger) polygons with the same number of sides, as shown below. For example, \$p\_5(3) = 1 + 5 + 10 + 15 = 31\$ is a c...
[Question] [ A [Pythagorean Triple](https://en.wikipedia.org/wiki/Pythagorean_triple) is a positive integer solution to the equation: [![Pythagorean triple](https://i.stack.imgur.com/7aloH.png)](https://i.stack.imgur.com/7aloH.png) A Trithagorean triple is a positive integer solution to the equation: [![Trithagorea...
[Question] [ You're driving a car in an infinite city whose blocks are pentagons arranged in [the order-4 pentagonal tiling](https://en.wikipedia.org/wiki/Order-4_pentagonal_tiling). At each step, you proceed to the next intersection and choose whether to continue left, right, or straight. A sequence of choices tha...
[Question] [ *2fuck* is a simple 2D variation on brainfuck. Like traditional brainfuck, there is an 1D memory tape that extends 30000 bytes to the right from its beginning, consisting of values between 0 and 255. Arithmetic should wrap around, adding 1 to 255 sets the cell to 0, and moving right from memory cell 29...
[Question] [ ### The Challenge Given a multiline string, return the longest substring of leading whitespace present in every line, ignoring empty lines or lines composed only of whitespace. If input is empty or whitespace, return nullish or the empty string--up to you. Update: Per [Meta consensus](https://codegolf....
[Question] [ **Description** You have a list of integers and start counting from the first term to the next and continue from that to the next and so on.. How many times have you counted? For example given [ 2, 5, 3, 8 ] you start at 2 and count to 5 -> *3 4 5* (3 times) then from 5.. *4 3* (2 times) and fi...
[Question] [ A rhyme scheme is the pattern of rhymes at the end of the lines in a poem. They are typically represented using letters, like `ABAB`. We consider two rhyme schemes identical if they are [isomorphs](https://codegolf.stackexchange.com/q/50472), and therefore only report the lexicographically earliest. Eq...
[Question] [ Thanks to [rak1507](https://codegolf.stackexchange.com/users/95516/rak1507) for the [suggestion](https://chat.stackexchange.com/transcript/message/58238593#58238593) > > "Random" in this challenge always refers to "uniformly random" - of all possible choices, each has an equal chance of being chosen. ...
[Question] [ ### Background The summary of a non-negative integer \$n\$ is the concatenation of all digits that appear in \$n\$ in increasing order, with each digit being preceded by the number of times it appears in \$n\$. Some Examples: ``` n -> summary(n) 1221 -> 2122 (2 ones, 2 twos) 1212 ...
[Question] [ This is based off [this](https://codegolf.stackexchange.com/questions/203893/bl-lu-ur-rr-ry-yv-vi-is-si-io-on-blur-the-text/) challenge. Given an input string, check whether the string is blurry. ## What's a blurry string? A blurry string is a string that's contained in the set of all blurrified pure-A...
[Question] [ Create a program that generates a drum fill. Your program will output a pattern of `L` (left hand hits), 'R' (right hand hits), and `K` for kick drum hits. ## Rules * The pattern must never have more than 2 of the same hits consecutively. * The pattern must be loopable, so it mustn't have more than 2 ...
[Question] [ Given guaranteed strictly positive **integers \$w\$ and \$n\$**, output * An **equilateral triangle array** with **side length \$w\$**, filled with two distinct, consistent values. I'll call these `0` and `1` but they do not have to be equal to `0` and `1`. * The **number of `1`s** inside this array **...
[Question] [ Given 2 inputs (m=*minimum starting id*, n=*number of ids*), generate a sequential list of ids, starting at >=m, made up of the digits 0-9 where no 2 contiguous numbers are the same, e.g. 1232 is ok, 1233 is not (contains 2 '3's next to each other). **Example** for m=985, n=6, below shows what ids woul...
[Question] [ I was playing around with some numbers and found a sequence that, of course, is on OEIS. It is [A005823](https://oeis.org/A005823): ***Numbers whose ternary expansion contains no 1's***. It goes: > > a(2n) = 3\*a(n)+2 > > > a(2n+1) = 3\*a(n+1) > > > a(1) = 0 > > > a = 0,2,6,8,18,20,24,26,54.......
[Question] [ ## Challenge Code an ASCII cookie of a kind according to the input. ## Input * The cookie kind. This is one of the three strings: "Plain", "Chocolate", or "Nuts". May be function arguments, stdin (or closest equivalent), or file arguments. ## Output * An ASCII cookie. See below. Must be ``` ___ ...
[Question] [ Shorten (or not) text using run length encoding **Input:** ``` heeeello woooorld ``` **Output:** ``` 1h4e2l1o 1w4o1r1l1d ``` * Read lines from stdin. * Print to stdout. * Stderr is of course discarded. * Assume there are hidden testcases (no embedding of the output) * Input/Output as ASCII * Any lang...
[Question] [ A Shift matrix is a binary matrix with one superdiagonal or subdiagonal formed by only ones, everything else is a zero. A superdiagonal/subdiagonal is a diagonal parallel to the main diagonal, which is not the main diagonal, i.e. all entries \$a\_{ij}\$ where \$i=j+k\$ and \$k \neq 0\$. The main di...
[Question] [ Consider the \$4\$ divisors of \$6\$: \$1, 2, 3, 6\$. We can calculate the harmonic mean of these numbers as $$\frac 4 {\frac 1 1 + \frac 1 2 + \frac 1 3 + \frac 1 6} = \frac 4 {\frac {12} 6} = \frac 4 2 = 2$$ However, if we take the \$6\$ divisors of \$12\$ (\$1, 2, 3, 4, 6, 12\$) and calculate their ...
[Question] [ You are probably familiar with the [Fibonacci sequence](http://oeis.org/A000045) where the first two terms are `0, 1` (or sometimes `1, 1`) and every term after that is the sum of the previous two. It starts like this: `0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...` Sometimes, the sequence contains numb...
[Question] [ I enjoy participating in math competitions run by Mu Alpha Theta, a mathematics honor society in the United States. At competitions, I take a 30-question multiple choice test. There are five choices per question, labeled A through E. My score on a test is four points for each correct answer, zero point...
[Question] [ This is a somewhat different task. Calculate 1024 hexadecimal digits of π, beginning at the 1024th hexadecimal place. Formally: Your program should complete in less then 1 minute and produce the following output: > > 25d479d8f6e8def7e3fe501ab6794c3b976ce0bd04c006bac1a94fb6409f60c45e5c9ec2196a246368fb6...
[Question] [ This [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenge will give you two positive integers `n` and `k` as inputs and have you count the number of rectangles with integer coordinates that can be drawn with vertices touching all four sides of the \$n \times k\$ rectan...
[Question] [ Take an arbitrarily sized string as input. This string represents a baseball plate appearance, in which each character represents a pitch as follows: * Strike: `S` * Ball: `B` * Foul ball: `F` * Hit by pitch: `H` * Ball in play: `X` (For those wondering, this is a very *very* simplified version of [Ret...
[Question] [ Lets define a pointer sequence to be any sequence such that **a(n) = a((n-1)-(a(n-1)))** forall **n** greater than some finite number. For example if our sequence begun with ``` 3 2 1 ``` Our next term would be `2`, because **a(n-1) = 1**, **(n-1)-1 = 1**, **a(1) = 2** (this example is zero index howe...
[Question] [ The idea is simple. You've to create a "visualised" letter-replacement, by providing 3 strings (input can be comma separated, separate inputs, or as an array). The first segment is the word you want to correct, and the second segment is the letters you want to replace, and the third segment is the repl...
[Question] [ Given a matrix of positive integers, output whether it's possible to generate it by starting with an empty1 matrix of the same dimensions and repeatedly filling a whole row or a whole column with the same value, overwriting any values already written. ### Example The following matrix: $$\begin{pmatrix}...
[Question] [ > > Compute, O friend, the number of the cattle of the sun which once grazed upon the plains of Sicily, divided according to color into four herds, one milk-white, one black, one dappled and one yellow. The number of bulls is greater than the number of cows, and the relations between them are as follo...
[Question] [ To celebrate the 2497th anniversary of the Greek victory at Salamis in 480 BC. Draw the lambda blazon. The lambda blazon was the lambda painted on greek shields like so: [![images of red capital lambda on circular white and gold shield backgrounds](https://i.stack.imgur.com/13rw9.jpg)](https://i.stack....
[Question] [ 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 `11...
[Question] [ Write a program that outputs all 64 layers of this representation of [Graham's number](http://en.wikipedia.org/wiki/Graham's_number) from Wikipedia:   ![Graham's number](https://i.stack.imgur.com/Jjuqn.png) Your output **must exactly match** this ASCII version (in which `^` represents [Knuth's up-arrow...
[Question] [ Welcome, brave code golfer! Today you will stand in the midst of a great battle between a goblin and an elf! ``` goblin attacks elf! elf dodges! elf attacks goblin!     elf hits goblin for 13 damage!     goblin has 37 health left.     goblin attacks elf!     goblin hits elf for 1 damage!   ...
[Question] [ **Closed.** This question is [off-topic](/help/closed-questions). It is not currently accepting answers. --- Questions without an **objective primary winning criterion** are off-topic, as they make it impossible to indisputably decide which entry should win. Closed 6 years ago. [Improve this quest...
[Question] [ # The Challenge Your goal is to write the shortest program possible that will take a list of events (such as upvote, downvote, etc) and return the user's reputation and the privileges that he has earned. ## What sort of events? Here is a chart of the events, listed in order of reputation earned: ``` -1...
[Question] [ The program will be provided as the first argument, stdin should be used for all read requests by the program and stdout for all write requests. It can be assumed that the program is less than 80 characters wide and less than 25 lines high. * `~` should push -1 if there is nothing to read. * Any pop of...
[Question] [ Recently a friend of mine posed the following: > > What subset of the integers satisfies the condition if distinct a and b are in the subset, their average is not in the subset? I know the set of non-0 squares satisfies the condition, but I wonder if there exists a more... dense set that satisfies the...
[Question] [ [Github](https://github.com/Artemis21/guessers-and-liars) You have probably played, and may even have written a program to play, a simple number guessing game. If so, this probably looks familiar: ``` Try to guess my number (1 to 100)! Please enter a guess: 50 Too small, guess again! Please enter a gue...
[Question] [ [Gaussian blur](https://en.wikipedia.org/wiki/Gaussian_blur) is a method used for blurring images smoothly. It involves creating a matrix which will be used by convolving it with the pixels of an image. In this challenge, your task is to construct that matrix used in Gaussian blur. You will take an inp...
[Question] [ In this challenge, your task is to make write a program **with less than 300 characters** that takes a short paragraph or a few sentences that a candidate has said and output who said it. **Input**: Can be taken as a parameter to a function, input to a program etc. It will be a short paragraph, properl...
[Question] [ The goal of this challenge is to receive an input and output that input but with sentence order reversed. Example Input: ``` Hello friend. What are you doing? I bet it is something I want to do too! ``` Example Output: ``` I bet it is something I want to do too! What are you doing? Hello friend. ``` As...
[Question] [ Two points `p`and `q` in a topological space can be separated if there are open sets `U` and `V` such that: 1. `p` is an element of `U` and `q` is an element of `V` 2. `U` and `V` do not have any elements in common Your task is given a topology (a set of open sets) and two points `p` and `q` (`p!=q`) t...
[Question] [ The [persistence](https://en.wikipedia.org/wiki/Persistence_of_a_number) of a number \$x = d\_1d\_2d\_3...d\_n\$, with \$d\_1 \ne 0\$, under some function \$f : \mathbb N\_0 \times \mathbb N\_0 \to \mathbb N\_0\$ is defined as the number of applications of \$f\$ to the digits of \$x\$ before it reaches...
[Question] [ Part of [**Advent of Code Golf 2021**](https://codegolf.meta.stackexchange.com/q/24068/78410) event. See the linked meta post for details. Related to [AoC2017 Day 3](https://adventofcode.com/2017/day/3), Part 2. --- You come across an experimental new kind of memory stored on an infinite two-dimensiona...
[Question] [ *Rest in peace, John Horton Conway* There are a **ton** of different Game of Life interpreters out there! A **ton**! Currently for you, getting an interpreter is just a dozen types and a couple of clicks away. But wait, do you notice a common thing in the interpreters? Every interpreter is *graphical*,...
[Question] [ ## Introduction One of the first things I learned in chemistry, was giving the formula for the combustion of alkanes. The most basic example was: `2CH4 + 4O2 -> 4H2O + 2CO2`. **Note that the equation could have been simplified by dividing every coefficient by 2, we would get** `CH4 + 2O2 -> 2H2O + CO2`...
[Question] [ **Edit: There will be a bonus of -20 for random masking** Hello fellow Whistleblowers and carriers of secret knowledge. I am due to an interview by mail and I - of course - cannot say specific names in full length. But as I want to disclose it in a rather not-so-obvious-way I need your help. I will pro...
[Question] [ **Closed**. This question needs [details or clarity](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** Add details and clarify the problem by [editing this post](/posts/21841/edit). Closed 3 years ago. [Improve this question](/posts/21841/edit) ...
[Question] [ The objective is to write java code that detects the JVM version relying in compatibility changes, side effects, bugs and/or undefined behavior that works in a way in one version and another way in another version. Further, the code should be at least a bit readable, without sacrificing whitespaces and...
[Question] [ The following picture shows the problem: ![enter image description here](https://i.stack.imgur.com/XmqFf.png) Write a function that, given an integer as the circle radius, calculates the number of lattice points inside the *centered* circle (including the boundary). The image shows: ``` f[1] = 5 (bl...
[Question] [ Given a list of countries in alphabetical order, put them in the same order as they are given in the song ["Yakko's World"](https://animaniacs.fandom.com/wiki/Yakko%27s_World_(song)). Specifically, you are given the following list of countries\* exactly: ``` Abu Dhabi, Afghanistan, Albania, Algeria, Al...
[Question] [ A listening party is an event where a bunch of people get together to listen to some music (like a viewing party, but for music). In the age of the internet you can do Listening Parties online with friends, where you just all hit play together. The problem is on the internet everyone is in different ti...
[Question] [ The \$d\$-dimensional vector space \$\mathbb{F}\_2^d\$ over the field with two elements \$\mathbb{F}\_2\$ is the set of vectors of \$d\$ bits. Addition of vectors is bitwise xor. A linear dependence is a set of vectors whose total (xor them all together) is \$0\$. Every set of \$d+1\$ vectors in \$\mat...
[Question] [ ## Task The prepend,append-Sequence is defined recursively, like this * a(1) = 1 * a(n) = a(n-1).n , if n is even * a(n) = n.a(n-1) , if n is odd where the . represents an integer concatenation. So the first few terms are: `1,12,312,3124,53124,531246,7531246,...` This is [A053064](http://oeis.org/A0530...
[Question] [ The goal of this challenge is to write a program where the length of the following three are exactly the same: * the length of the source code * the length of the output it prints to the standard output * the length of the compiler warnings it generates with the (unmodded) compiler of your choice **The...
[Question] [ Your task is to write a program \$p\$ which outputs a string \$s\$ with the same length as \$p\$, where \$s \neq p\$. If I remove the \$n\$th byte from your program to get program \$q\$, then either \$q\$ outputs \$s\$ with the \$n\$th byte removed, or it does something else. Your score is the number o...
[Question] [ Write the shortest program or function that will determine if an input is a valid Go type. ## Spec This challenge will use the following simplified subset of Go types. For more information, see the [Golang specification](https://go.dev/ref/spec#Types). * "Primitive" types: + `bool` + `int`,`uint`,`fl...
[Question] [ [Inverse function of this challenge](https://codegolf.stackexchange.com/questions/132002/) > > To (properly) multiply an string by an integer, you split the string into characters, repeat each character a number of times equal to the integer, and then stick the characters back together. If the integer...
[Question] [ Given a matrix of integers \$M\$ and a list of four integers \$L\$, find the sub-matrix \$N\$ whose corners are given by \$L\$ and return the sum of its elements. Suppose you're given the list \$L = [-8, -3, 2, 9]\$ and the following matrix \$M\$. The numbers in the list are highlighted in blue to illu...
[Question] [ [Carryless multiplication](https://en.wikipedia.org/wiki/Carry-less_product) is an operation similar to binary long multiplication, but with XOR instead of addition: ``` 1011 11 × 101 5 ----- 1011 0 1011 ------ 100111 39 ``` In this challenge, you'll be given a positive integer `>= ...
[Question] [ It's time to conclude [the series of John Conway challenges of mine](https://codegolf.stackexchange.com/search?tab=newest&q=conway%20is%3aq%20user%3a78410). ## Background A **FRACTRAN** program consists of an ordered list of fractions. The program starts by taking a single integer as input. Each iterat...
[Question] [ We say two positive integers are *anagrams* of each other if the digits in one of them (in decimal representation) can be rearranged to form the other. Leading zeros don't count. For example, 110020222 is an anagram of 212102020, but not of 221100011; neither is 22002211 even though it can be written a...
[Question] [ # Summary A teacher was told to prepare word problems for the students. She is given a list of equations and told to write them as the corresponding word problem. However, she is very lazy, so she doesn't put much creativity into it. Instead, she simply writes it literally. For example, when she reads ...
[Question] [ Given a set of two strings guaranteed to be the same length, print their *criss cross*. The *criss cross* of two strings is obtained as follows. 1. Yield the second character of the second string, then the first character of the first string. 2. Yield the first character of the second string, then the ...
[Question] [ Given a number *N*, draw a left aligned *N*x*N* board of numbers, leaving 1 blank (as a space) (I will show diagrams with *N*=5) ``` 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ``` Your job is to construct the Sieve of Eratosthenes, step by step. First, start with 2. It's ...
[Question] [ # Challenge Forsyth–Edwards Notation (FEN) is a standard notation for describing a particular board position of a chess game. Your challenge is to evaluate the score using the FEN string. This is an example of a FEN string: ``` 5k2/ppp5/4P3/3R3p/6P1/1K2Nr2/PP3P2/8 ``` Using this string, you can calcula...
[Question] [ Part of [**Code Golf Advent Calendar 2022**](https://codegolf.meta.stackexchange.com/questions/25251/announcing-code-golf-advent-calendar-2022-event-challenge-sandbox) event. See the linked meta post for details. --- Oh no, Santa spilled wine all over his great book. Now most of the letters are illegib...
[Question] [ ## Specification Write the shortest possible code in any language that does the following: It takes two arguments, x and y, and generates x + y lines of text. The first x lines should consist of y nested pairs of square brackets separated by a space surrounding a single digit, which cycles from 1 to 9,...
[Question] [ The International Phonetic Alphabet is a system of phonetic notation intended to be able to accurately represent every sound used in spoken language. The alphabet contains 29 vowel letters `iyɨʉɯuɪʏʊeøɘɵɤoəɛœɜɞʌɔæɐaɶäɑɒ` and 81 consonant letters, although I missed three (`ɦǀǂ`) when I first posted this...
[Question] [ Create a program that can be run in 4 different languages such that: * One language prints "Hello World!" * One language outputs its own source code * One language outputs 99 bottles of beer on the wall, that is: ``` 99 bottles of beer on the wall 99 bottles of beer Take one down, pass it around 98 bot...
[Question] [ With this challenge we pay homage to everyone around the whole world fighting against the coronavirus crisis; particularly represented are the people tied to medicine, as the [*Rod of Asclepius*](https://en.wikipedia.org/wiki/Rod_of_Asclepius) is a symbol associated with medicine and health care. For t...
[Question] [ ## Introduction > > Adam (A) and Bubbler (B) are playing coin toss, where the one who wins 5 times first would win the prize of $32. If the game is aborted when the scores are `A:B = 4:3`, how should they distribute the prize? Assume the coin toss is fair, so the winning chance of either player is 1/2...
[Question] [ [Sandbox](https://codegolf.meta.stackexchange.com/a/17035/78039) The major scale (or Ionian scale) is one of the most commonly used musical scales, especially in Western music. It is one of the diatonic scales. Like many musical scales, it is made up of seven notes: the eighth duplicates the first at d...
[Question] [ Your task is to create a program which, given an input string, will output the first Google autocomplete result for that search. The format of input/output is up to you. ## Rules 1. Your program must take 1 input, a string, and output the top Google autocomplete/auto-fill suggestions result. The format...
[Question] [ # Task There is a set of numbers `x`, such that `x^2` divides `7^x-1`. Your task is to find these numbers. Given an input of n, the code will print the nth number that follows this rule. # Examples 1-index ``` In Out 3 3 9 24 31 1140 ``` The relevant sequence can be found [here](http://oeis.o...
[Question] [ Write a program which gets a string as its input, and counts the number of alphanumeric and non-alphanumeric characters in it. It has to display its result like this: input: `http://stackexchange.com` output: `20 + 4 = 24` The catch is, your source code has to have the same number of alphanumeric cha...
[Question] [ # Input A single positive integer \$ 10 \geq n \geq 2\$ # Output A list of strings, each of length \$2n\$, satisfying the following properties. * Each string will contain each of the first \$n\$ lowercase letters of the alphabet exactly twice. * No letter can occur twice consecutively. That is `abbcac`...
[Question] [ Let \$\sigma(n)\$ represent the divisor sum of \$n\$ and \$\sigma^m(n)\$ represent the [repeated application](https://en.wikipedia.org/wiki/Iterated_function) of the divisor function \$m\$ times. [Perfect numbers](https://en.wikipedia.org/wiki/Perfect_number) are numbers whose divisor sum equals their ...
[Question] [ This problem is based on non-terminating, repeating decimal points. Let \$n\$ be any positive integer \$(n > 1 \text{ and } n < 10000)\$, say \$7\$. Then, \$1/n = 1/7 = 0.142857142857142857...\$ We see a pattern like, `0. 142857 142857 142857 ...` In this, the `142857` part is always repeating, whic...
[Question] [ We all know what a quine is. A quine is a program which prints its own source code. And we also know about the printable ASCII characters. Well... this challenge mixes both. Your mission, should you accept it, is to create an *index quine*. An index quine is a non-empty program, composed only of the pr...
[Question] [ The Seidel Triangle is a mathematical construction similar to Pascal's Triangle, and is known for it's connection to the Bernoulli numbers. The first few rows are: ``` 1 1 1 2 2 1 2 4 5 5 16 16 14 10 5 16 32 46 56 61 61 ``` Each row is generated as follows: If the row number is ...
[Question] [ **Sequence:** 1. We start at `1`. 2. We first add the current 1-indexed value to the previous number in the sequence. 3. Then we apply the following mathematical operations in order if they apply to this current value: * Divisible by `2`? => Addition * Divisible by `3`? => Subtraction * Divisible by...
[Question] [ There exists a very simple cipher that replaces a letter with it's position in the alphabet. For example, `abc` would become `1 2 3` in this cipher. This challenge is an alternative take on this cipher. --- # The Challenge Create a program that takes an input of ASCII characters, and outputs a space-se...
[Question] [ # Challenge Write the shortest program that converts a human readable time interval to date components of the form: ``` {±YEARS|±MONTHS|±DAYS|±HOURS|±MINUTES|±SECONDS} ``` # Sample cases Each test case is two lines, input followed by output: ``` 1 year 2 months 3 seconds {1|2|0|0|0|3} -2 day 5 year 8mo...
[Question] [ In this challenge, your task is to construct an undirected graph from a sequence of directives. There is one directive for each nonnegative integer, and each transforms a given graph into a new one. * Directive `0`: Add a new disconnected node. * Directive `1`: Add a new node, and connect it to every e...
[Question] [ The JavaScript compressor [RegPack](https://siorki.github.io/regPack.html) uses a very simple string compression algorithm. Given a piece of code, it will make a list of characters that aren't used in that code and use them to delimit repeated strings that are inserted back into the string. To show how...
[Question] [ *This is a simpler variant of my previous challenge [Don't touch the walls!](https://codegolf.stackexchange.com/q/248571), as suggested by [Jonah](https://codegolf.stackexchange.com/users/15469/jonah).* Given a multi-dimensional rectangular array of integers between 0 and 9, output all the elements whi...
[Question] [ Consider you have a [hash function](https://en.wikipedia.org/wiki/Hash_function) \$\mathcal{H}\$ which takes strings of length \$2n\$ and returns strings of length \$n\$ and has the nice property that it is [*collision resistant*](https://en.wikipedia.org/wiki/Collision_resistance), i.e. it is hard to ...
[Question] [ I ran into this problem while working on another challenge I'm making for this site. In that challenge I utilize "[Mario Kart 8 Scoring](http://mariokart.wikia.com/wiki/Driver%27s_Points)". The amount of points the player in *k*th place gets is represented by this 1-indexed array: [15,12,10,9,8,7,6,5,4...
[Question] [ Given a positive integer `N`, output the number of pairs of integers `0 <= a <= b < 2**N` such that `a*b >= 2**N`. ## Rules * You may assume that `N` is less than or equal to the maximum bit width for integers in your language (e.g. for C, `N` will not exceed `32` or `64`, depending on the architecture...
[Question] [ A language that is very useful in restricted source and other such challenges is [Unary](http://esolangs.org/wiki/Unary), a brainfuck derivative in which programs are written in with only one character. Your job is to write a program to convert programs from brainfuck to unary and a program to do the o...
[Question] [ Transposition is an operation on 2-dimensional arrays that flips every element across the main diagonal: ``` [[1,2,3], [[1,4], [4,5,6]] -> [2,5], [3,6]] ``` If we call the above array `m`, then the `2` is the second item of the first row of `m`, or `m[0][1]`. The `2` can be thought o...
[Question] [ Say I have a grid with some obstacles: ``` ---- | X | | | |XX | | | ---- ``` I can fill this with numbers, as distance from the top left corner. But, because there are obstacles in the way some cells will take further to reach than a straight line: ``` ---- |01X5| |1234| |XX45| |7656| ----...