text
stringlengths
180
608k
[Question] [ In traditional FizzBuzz, you are asked to print the numbers from 1 to 100, but replacing every multiple of 3 with "Fizz", every multiple of 5 with "Buzz", and every multiple of both 3 and 5 (i.e. 15) with "FizzBuzz". However, as an evil interviewer, I've invented my own twisted version of FizzBuzz, whi...
[Question] [ A [bracelet](https://en.wikipedia.org/wiki/Necklace_(combinatorics) "Wikipedia") consists of a number, \$\mathit{N}\$, of beads connected in a loop. Each bead may be any of \$\mathit{C}\$ colours. Bracelets are invariant under rotation (shifting beads around the loop) and reflection (turning the bracel...
[Question] [ # Let's talk about divisors... Leaving out perfect squares (for a moment), all positive integers can be expressed as the **product** of 2 of their divisors. Quick example for `126`: Here are all the divisors of `126` [![enter image description here](https://i.stack.imgur.com/GI2NM.jpg)](https://i.sta...
[Question] [ **See also: [Parsing](https://codegolf.stackexchange.com/questions/90333/number-plate-golf-parsing)** ## Introduction You're working on a government programming team, who have been programming the speed cameras. However, the group of people who have programmed the speed calculator have taken up too muc...
[Question] [ [Martin](https://codegolf.stackexchange.com/users/8478/martin-b%C3%BCttner) has created a [nice snippet](https://codegolf.meta.stackexchange.com/questions/5139/leaderboard-snippet) that can be used to keep track of the score for answers to challenges. That's great and all, but wouldn't it be better if ...
[Question] [ Given an unsorted list of unique strictly positive integers, minimally sort it into a 2D matrix. The input list is guaranteed to be of composite length, which means the output matrix is not necessarily square, but is of size `n x m` with `n,m > 1`. "Minimally sort" here means the following: * Sort the ...
[Question] [ ### Introduction The *middle-square* method is used for the generation of pseudorandom numbers. However, this is not a good method in practice, since its period is usually very short and has some severe weaknesses. How does this work? Let's take an example: For the seed, we pick `123456`: ``` Seed ...
[Question] [ The goal of this challenge is to compute *one kind of* numerology digit from strings containing characters and numbers. * The input may be through any convenient method (standard input, arguments, separated file). * The input may contain any printable ASCII chars, but only alphanumerical (`A-Z`, `a-z`,...
[Question] [ *This is my first code golf so please let me know if it's too broad or if I'm missing any information for a good puzzle!* # Challenge In Ontario and possibly other areas of the world, electricity is billed using [Time-Of-Use (TOU) pricing](https://hydroottawa.com/residential/time-of-use/rate-periods/),...
[Question] [ We are going to bring down an imaginary building with a series of explosions. Our building is a 5x5 matrix of integers ranging 1-9, each representing a single brick. The challenge is to set of a series of explosions to bring down our building as much as we can, why not! Each brick that is connected (ho...
[Question] [ Given some input array `a = [a1, a2, ..., an]` and a positive integer `k`, shuffle the input array `a` such that no entry is farther than `k` from its initial position. ### Example Given the array `[1, 2, 3, 4, 5, 6]` and `k = 1`, this means the entry `3` can be at following positions: ``` [*, 3, *, *,...
[Question] [ ## Background [Tetris](https://en.wikipedia.org/wiki/Tetris) is a single-player game played on a rectangular grid with tetromino pieces. When you fill one or more lines with tetrominoes, the filled lines are removed, and all blocks above them move down accordingly. In the following diagrams, `.` is an ...
[Question] [ Suppose an infinite tiling of hexagons composed of `|/\` characters. ``` / \ / \ / \ / \ | | | | | \ / \ / \ / \ / etc. | | | | \ / \ / \ / ``` Given input `n > 0`, output a triangular portion of that tiling as depicted in the below examples, anchored with a `_` in the middle of a...
[Question] [ The [3BV](http://www.minesweeper.info/wiki/3BV) of a [Minesweeper](https://en.wikipedia.org/wiki/Minesweeper_(video_game)) 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](...
[Question] [ ## Introduction Gijswijt's sequence ([A090822](https://oeis.org/A090822)) is famously really, REALLY slow. To illustrate: * The first 3 appears in the 9th term (alright). * The first 4 appears in the 220th term (a long way away, but feasible). * The first 5 appears at (approximately) the **10^(10^23)th...
[Question] [ *This is the 2-dimensional generalisation [of this challenge](https://codegolf.stackexchange.com/q/5529/8478).* For our purposes, one matrix (or 2D array) *A* is considered a **submatrix** of another matrix *B*, if *A* can be obtained by completely removing a number of rows and columns from *B*. *(Note...
[Question] [ [Wordle](https://en.wikipedia.org/wiki/Wordle_(video_game)) is a [daily online word game](https://www.powerlanguage.co.uk/wordle/) that has received [considerable attention recently](https://www.nytimes.com/2022/01/03/technology/wordle-word-game-creator.html). # The Game The object is to guess a secret...
[Question] [ You are given 3 non negative numbers: \$x\$, \$y\$ and \$z\$, and must minimize the number of digits (non negative) inserted at any place in the numbers \$x\$, \$y\$, or \$z\$ to make $$x + y = z$$ (a clarification: you can add any non negative digit any number of time at any place ) (you can assume th...
[Question] [ You've probably heard of Fibonacci numbers. Ya know, that integer sequence that starts with `1, 1`, and then each new number is the sum of the last two? ``` 1 1 2 3 5 8 13... ``` And so on. Challenges about Fibonacci numbers [are pretty popular 'round here](https://codegolf.stackexchange.com/questions/...
[Question] [ Your task here is simple: Given a list of integer sets, find the set union. In other words, find the shortest list of integer sets that contain all the elements in the original list of sets (but no other elements). For example: ``` [1,5] and [3,9] becomes [1,9] as it contains all of the elements in bot...
[Question] [ ## Introduction Suppose you have a list of lists of integers (or any objects really, but let's stick to integers for simplicity). The lists may be of different lengths, and some of them may be empty. Let's write the lists in a tabular format: ``` [[ 1, 2, 3, 4, 5], [ 6, 7], [ 8, 9, 10, ...
[Question] [ # Challenge Given the phase of the moon, draw it using ASCII art. Your program must handle new moon, waxing crescent, first quarter, waxing gibbous, full moon, waning gibbous, last quarter, and waning crescent. Your input will be an integer. ``` 0 -> new moon 1 -> waxing crescent 2 -> first quarter 3 -...
[Question] [ # 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 Fib...
[Question] [ Given a number \$n\$, write a program that finds the smallest base \$b ≥ 2\$ such that \$n\$ is a palindrome in base \$b\$. For example, an input of \$28\$ should return the base \$3\$ since \$28\_{10} = 1001\_3\$. Although \$93\$ is a palindrome in both base \$2\$ and base \$5\$, the output should be ...
[Question] [ A friend has an add-on card in their computer which generates a perfectly random number from 1 to 5 inclusive. Unfortunately, they spilt cola on it somehow, and it now generates only 2's for all numbers from 1 to 4. Luckily the randomness is preserved, but 2 has a probability of 80% and 5 has a probabi...
[Question] [ **Challenge:** I want to know about the real roots of polynomials. As a pure mathematician, I care about the existence of such roots, rather than their numeric values. The challenge is to write the shortest program that takes a polynomial, of degree at most 4, and simply returns how many distinct real ...
[Question] [ ## Background [SKI combinator calculus](https://en.wikipedia.org/wiki/SKI_combinator_calculus), or simply SKI calculus, is a system similar to lambda calculus, except that SKI calculus uses a small set of *combinators*, namely `S`, `K`, and `I` instead of lambda abstraction. Unlike lambda calculus, bet...
[Question] [ One of my favorite mathematical pastimes is to draw a rectangular grid, then to find all of the rectangles that are visible in that grid. Here, take this question, and venture for yourself! **Can you count the number of rectangles?** ``` +-----+-----+-----+-----+ | | | | | | | |...
[Question] [ Most people would cut circular pizzas into [circular sectors](https://en.wikipedia.org/wiki/Circular_sector) to divide them up evenly, but it's also possible to divide them evenly by cutting them vertically like so, where each piece has the same area (assume the pizza has no crust): ![](https://i.stack...
[Question] [ This problem will have you analyzing circles drawn on the grid, with the gridlines drawn at integer values of \$x\$ and \$y\$. Let \$\varepsilon\$ be a very small number (think, \$\varepsilon = 0.0001\$). If we paint a filled-in circle of radius \$\varepsilon\$ centered at the origin, it will require p...
[Question] [ This challenge is inspired by [this app](https://play.google.com/store/apps/details?id=com.andreasabbatini.logicgamestk). The test cases are borrowed from that app. --- This is a [fastest-code](/questions/tagged/fastest-code "show questions tagged 'fastest-code'") challenge, where the objective is to s...
[Question] [ Output this binary sequence of length 1160: ``` -++-+--++-++-+--+--++-+--+--++-+--++-++-+-++--++-+---+-++-+--+--++++--+--++-+--++-++----++-++-+-++--++-+-+---++-+--++-++-+--++-+--+---+-++-+--++-++-+--+--++-++-+--++-+--+++-+-+----+++-+--+--+++---++-++-+--+--+++--+-+-+--+-+++-++-+--+--++-+--++-++-+--+--++...
[Question] [ Poker has etiquette in how you arrange your chips, often enforced in tournaments - your chips may not be "hidden" from your opponents by being behind others, mostly to not hide some large denomination chip(s). --- **The Challenge** We are going to be playing poker in ASCII, so we need to write a functi...
[Question] [ # Introduction **tl;dr** Continuously output the current distance from the Earth to the Sun. --- Simplified, the orbit of the Earth around the Sun is an ellipse. So the actual distance between both is constantly changing. This distance can be calculated for any given day using [this formula](https://ph...
[Question] [ In this task you will take as input a non-negative integer \$n\$, and output the number of pairs of non-negative integers \$a,b\$ such that both are palindromes\*, \$a \leq b\$, and \$a+b = n\$. For example if \$n\$ is \$22\$ then the valid pairs are \$ \begin{array}{c|c} a & b \\ \hline 0 & 22 \\ 11 &...
[Question] [ Given 4 points on the 2D planes `A, B, C, D`, calculate the area of the intersection region of the triangles `OAB` and `OCD`, where `O` is the center of the plane, having coordinate `(0, 0)`. Algorithms that runs in constant time complexity (in terms of arithmetic operations) are encouraged, but not fo...
[Question] [ You should write a 100-byte long brainfuck (BF) program. One character will removed from it in every possible way the resulting 100 new (99-byte long) programs. E.g. for the program `++.>.` the 5 subprograms are `+.>.`, `+.>.`, `++>.`, `++..` and `++.>` . Your score will be the number of unique outputs...
[Question] [ # Input The first line will be a certain string repeated any amount of times. For example, it could be `abcabcabcabc`, `[];[];[];`, etc. It may be cut off; for example: `1231231231`. Always find the shortest string; for example, if the line is `22222`, then the string is `2`, not `22` or `22222` or any...
[Question] [ The [Utah teapot](http://en.wikipedia.org/wiki/Utah_teapot), originally created by Martin Newell, is a convenient object for testing 3D graphics programs. The task is to create a wireframe image of the teapot in perspective projection. To encourage the idea of a *source-code application*, the viewing a...
[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 7 years ago. [Improve this quest...
[Question] [ # Introduction Often, people refer to dates as the "second Friday in August, 2018" or the "fourth Sunday in March, 2012". But it's hard to tell what date that is! Your task to is to write a program that receives a year, a month, a day of the week, and an integer, and output that date. # Challenge * For...
[Question] [ ## The setup: A social network reports the number of votes a post has in two ways: the number of **net upvotes** (total upvotes - total downvotes), and the **% of votes that were upvotes**, rounded to the nearest integer (.5 rounds up). The number of net upvotes is an integer (not necessarily positive)...
[Question] [ Consider the process of "picking" a nested list. Picking is defined as follows: * If the argument is a list, take an element from the list at random (uniformly), and pick from that. * If the argument is not a list, simply return it. An example implementation in Python: ``` import random def pick(obj): ...
[Question] [ ### Description I guess everyone knows the fairy tale of Rapunzel and the prince. For those who do not: [read it here.](http://www.pitt.edu/%7Edash/grimm012.html) However, Rapunzel had just had her hair cut, so it might not be long enough to let her prince climb up! She may get very sad.. ### Challenge...
[Question] [ **The simple part:** Given an input string containing only printable ASCII-characters (space - tilde), count the number of occurrences of each character and return the result on any convenient format. The result for a string `a%hda7a` should be something like: `a:3, %:1, h:1, 7:1, d:1`. Sorting is unne...
[Question] [ Good Evening Ladies and Gentleman. Tonight - we have a code challenge. A competition that will be defined not in the amount of points (a la Asteroids) but simply whether you can finish it (a la Zelda). And for the sake of comparison, the amount of bytes (uh... but you said...). Your challenge is to com...
[Question] [ Hashiwokakero ("build bridges" in Japanese) is a puzzle where you are tasked with connecting a group of islands with bridges. The rules are: 1. Bridges must run either vertically or horizontally between two islands. 2. Bridges may not cross each other. 3. A pair of islands may be connected by at most t...
[Question] [ Given a number N from 2 to 8, place any nonzero number of queens on a grid of any size so that every queen has exactly N queens (counting itself) in each of its row, column, and each diagonal. **This challenge has a significant [restricted-time](/questions/tagged/restricted-time "show questions tagged ...
[Question] [ You are given a square matrix of width \$\ge2\$, containing square numbers \$\ge1\$. Your task is to make all square numbers 'explode' until all of them have disappeared. You must print or return the final matrix. More specifically: 1. Look for the highest square \$x^2\$ in the matrix. 2. Look for its ...
[Question] [ Given a string as input, output one or more variants of the string such that: * No character is in it's original position * No character is adjacent to a character that it was originally adjacent to You can assume this will always be possible for the given string, and will only contain single case alph...
[Question] [ 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*.4*th number? The 2.4th number is 0.4 times the differe...
[Question] [ # Challenge Given the following C# method: ``` private static bool Test(bool a, bool b) { if (a && b) return false; if (a) if (b) return true; return false; } ``` Supply the values `a` and `b` so that `true` is returned. # Winning condition The first entry who can supply the correct argumen...
[Question] [ A [fountain](http://mathworld.wolfram.com/Fountain.html) is arrangement of coins in rows so that each coin touches two coins in the row below it, or is in the bottom row, and the bottom row is connected. Here's a 21 coin fountain: [![From http://mathworld.wolfram.com/Fountain.html](https://i.stack.imgu...
[Question] [ Write the shortest possible program that draws a Bresenham line in ASCII art. Your program should take two integers `x` and `y` (command line or stdin, your choice) and draw an ASCII line which starts in the upper left and goes right `x` units and down `y` units. You must use `_` and `\` characters and...
[Question] [ Inspired by a recent question on SO... Write a function to print a binary tree in the following format: ``` 3 / \ 1 5 \ / \ 2 4 6 ``` 1. The output should consist of a line of nodes, followed by a line of `/` and `\` characters indicating relationships, followed by a line of nodes, etc...
[Question] [ This [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenge will have you computing OEIS sequence [A300154](https://oeis.org/A300154). > > Consider a spiral on an infinite hexagonal grid. a(n) is the number of cells in the part of the spiral from 1st to n-th cell that a...
[Question] [ # Can Alice win the game? The game's rules are as follows. First, a finite non empty set of positive integers \$X\$ is defined. Then, Alice and Bob take turns choosing positive integers, with Alice going first. Each integer must be strictly less than the previous one, and the game ends when one of the ...
[Question] [ The task is to write a radiation-hardened irradiator. What do I mean by that, exactly? An irradiator is a program that, when given a string as input, will output all possible versions of the string with one character removed. For example, given the input `Hello, world!`, the program should output: ``` ...
[Question] [ Let's start by re-defining a **reflection** of a character in a 2-d array of characters: > > Given a square 2-d array of characters with distinct lowercase alphabetical letters, define a reflection of a letter in the matrix as swapping it with the character directly across from it through the center o...
[Question] [ ## Challenge Given a time and a timezone as input, output the time in that timezone. ## Time The time will be given in 24 hour format like so: ``` hh:mm ``` Where hh is the two digit hour and mm is the two digit minute. Note that the hour and the minute will always be padded with zeroes like so: ``` 06...
[Question] [ You should write a program or function which receives a string as input and outputs or returns if the input is an ASCII tree. ``` _ \/ / \_/ | | ``` ASCII trees consist of characters `/ \ | _ spaces` and `newlines`. The non-whitespace characters connect two edge points of their cells by a line ...
[Question] [ In 2009, [Hannah Alpert described](https://www.emis.de/journals/INTEGERS/papers/j57/j57.pdf) the "far-difference" representation, a novel way of representing integers as sums and differences of Fibonacci numbers according to the following rules: * every two terms of the same sign differ in index by at ...
[Question] [ There are several ways to create headers on posts on the Stack Exchange network. The format that's most commonly1 used on PPCG seems to be: ``` # Level one header ## Level two header ### Level three header ``` Note the space after the hash marks. Also, note that trailing hash marks are not included. #...
[Question] [ ## Introduction I've previously created [two](https://codegolf.stackexchange.com/questions/48089/reconstruct-a-permutation) [challenges](https://codegolf.stackexchange.com/questions/69799/know-a-sequence-by-its-subsequences) where the idea is to reconstruct an object using as few query-type operations ...
[Question] [ ## Challenge You just bought a brand new chair! Problem is, you have no idea how to control it so you'll need to write a program to do it for you. [![Example of an adjustable chair](https://i.stack.imgur.com/dg3mt.jpg)](https://i.stack.imgur.com/dg3mt.jpg) You can only sit in the unadjusted chair for s...
[Question] [ You are given a partially filled Connect 4 grid (7x6). ``` O X O X X O X O O X O X O X X O X X X O O X O O O X X O X ``` (Input can be given as a 1D or 2D array and as letters or numbers, etc.) Assume that * X started the game. * Nobody has won yet. * Players may not have p...
[Question] [ Without using any built-in factoring/polynomial functions, factor a polynomial completely into irreducibles over the integers or a finite field. # Input Your program/function will receive some prime (or zero) number `n` as input. The field/ring is the finite field of that order (ie `Z/nZ`), or just `Z`...
[Question] [ Imagine the following diagrams as sets of vertical criss-crossing tubes. ``` 1 2 1 2 1 2 3 4 \ / \ / \ / \ / X | | | / \ / \ / \ / \ 2 1 1 2 | X | \ / \ / X X / \ / \ 3 1 4 2 ``` In the leftmost diagram, ...
[Question] [ The general [SAT](http://en.wikipedia.org/wiki/Boolean_satisfiability_problem) (boolean satisfiability) problem is NP-complete. But [2-SAT](http://en.wikipedia.org/wiki/2-satisfiability), where each clause has only 2 variables, is in [P](http://en.wikipedia.org/wiki/P_%28complexity%29). Write a solver ...
[Question] [ An "Egyptian fraction" is a list of *distinct* fractions with a numerator of \$1\$. For example: \$ \frac 1 1+ \frac 1 2 + \frac 1 3 + \frac 1 6 \$ The "size" of an Egyptian fraction is just the number of terms involved. Your task is to take a positive integer \$n\$ and output the smallest Egyptian fr...
[Question] [ As many of you will know, almost every programming language has a standard casing system; unfortunately, we have not been able to agree on a singular system to use and now must frequently switch between camelCase, snake\_case, PascalCase and kebab-case. Now I know what you're thinking... wouldn't it be...
[Question] [ Let me explain one by one the above terms... We will call \$\text{Z-Factorial}(n)\$ of a positive integer \$n\$, \$n!\$ (i.e. \$n\$ factorial) without any trailing zeros. So, \$\text{Z-Factorial}(30)\$ is \$26525285981219105863630848\$ because \$30!=265252859812191058636308480000000\$ We will call `Mod...
[Question] [ Write a function that takes a string of letters and spaces (no need to handle non-letters) and performs the ANNOUNCER VOICE translation algorithm as follows: * First, uppercase everything. * For each word, + *Elongate* each consonant cluster by tripling each letter; except, if the word *begins* with a...
[Question] [ **Challenge:** You are given a base 10 number. For each base from 10 counting down to base 2: 1. Take the original input number as a base 10 string, and remove any digits of the number which are invalid for the base. 2. Interpret the resulting number string in the that base. If this gives 1 or 0, termi...
[Question] [ Suppose we use the following rules to pull a single string from another string, one containing only ASCII printable characters and called an `*`-string. If the string runs out before the process halts, that is an error, and the result of the process is undefined in that case: 1. Start with `d=1, s=""` ...
[Question] [ Write the shortest code that calculates all possible (legal) moves of current player from a given FEN string. [What is FEN string? (Wikipedia)](http://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation) * Shortest code wins, language doesn't matter. * Output moves must obey [chess rules of movemen...
[Question] [ *This was written as part of the [First Periodic Premier Programming Puzzle Push](http://meta.codegolf.stackexchange.com/q/298/15).* ### The Game A starting and ending word of the same length are provided. The objective of the game is to change one letter in the starting word to form a different valid ...
[Question] [ The Pascal's triangle and the Fibonacci sequence have an interesting connection: [![enter image description here](https://i.stack.imgur.com/31e0v.png)](https://i.stack.imgur.com/31e0v.png) *Source: [Math is Fun - Pascal's triangle](https://www.mathsisfun.com/pascals-triangle.html)* Your job is to prove...
[Question] [ ## Background In Haskell and many other functional languages, function application `f(x)` is simply written as `f x`. Also, this form of function application is left-associative, which means `f x y z` is `((f x) y) z`, or `((f(x))(y))(z)`. Haskell also has a binary operator called `$`. `f $ x` does fun...
[Question] [ This challenge is from a game called [Keep Talking And Nobody Explodes.](http://www.keeptalkinggame.com/) *Memory is a fragile thing but so is everything else when a bomb goes off, so pay attention!* – from the [manual](https://ktane.timwi.de/HTML/Memory.html) # The Objective A number from 1–4 is given...
[Question] [ The [Māori language](https://en.wikipedia.org/wiki/M%C4%81ori_language) has quite simple pronouns. It uses a single word for he/she/they/etc (`ia`), and the words for "you" and "me" are `koe` and `au` respectively. There are also words for groups of exactly two people: * `tāua` - You and me (we, `au` a...
[Question] [ So you want to create a haiku, but you're not sure if it follows the syllable rules for a haiku. I couldn't be bothered to write a proper blurb like I usually do, so you'll have to make do with this. Let's get stuck right in. ## Finding a haiku out in the wild For the purposes of this challenge, we wil...
[Question] [ (This is part 1 in a two-part challenge.) Your task is to solve a Hexasweep puzzle. A Hexasweep puzzle is set out on a grid of diamonds arranged in hexagonal shapes, of which the board looks like a hexagon, like so: ``` _____ /\ \ _____/ X\____\_____ /\ \ / XX /\ \ /X \___...
[Question] [ # 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 `0`s and `1`s, your program should find the shortest simple regex matching the **full** ...
[Question] [ Well, turns out [Doorknob's](https://codegolf.stackexchange.com/users/3808/doorknob) username on GitHub, Reddit, and other sites is [KeyboardFire](https://github.com/KeyboardFire). That gives me an idea... ## The task You work at KeyboardFire Inc., a company that makes special keyboards. And, by "speci...
[Question] [ ## Objective Write a routine that accepts a string of printable ASCII characters, *s*, and returns a string containing the same characters as *s*, reordered so that no two-character substring appears more than once. The program must process all benchmark strings (see below) in under one minute each on ...
[Question] [ Imagine a countable infinite amount of empty rooms. When an infinite amount of guests come, they occupy the 1st, 3rd, 5th...(all odd) empty rooms. Therefore there's always an infinite amount of empty rooms, and occupied guests needn't move when new guests come. ``` - - - - - - - - - - - - - - - - - 1 -...
[Question] [ We're graduating to a full site soon, and there's only one thing left to do before graduation: pull a senior prank! I think we should do a variation on the classic "fill a hallway with cups of water" gag. ## Challenge Your program will read in text and output that text, covered in upside-down cups of w...
[Question] [ ## Background The [birthday paradox](http://en.wikipedia.org/wiki/Birthday_problem) is a popular problem in probability theory which defies (most people's) mathematical intuition. The problem statement is: > > Given *N* people, what is the probability that at least two of them have the same birthday (...
[Question] [ The [major system](http://en.wikipedia.org/wiki/Mnemonic_major_system) is a [mnemonic](http://en.wikipedia.org/wiki/Mnemonic) device for converting numbers into words so they can be memorized more easily. It is based on how words sound phonetically, but to keep things simple for the challenge we'll onl...
[Question] [ Consider an expression `2^2^...^2` with `n` operators `^`. Operator `^` means exponentiation ("to the power of"). Assume that it has no default assosiativity, so the expression needs to be fully parenthesized to become unambiguous. The number of ways to parenthesize the expression are given by [Catalan...
[Question] [ Your task is to make a quine, that is a non-empty computer program that prints it's own source without reading it. In addition if you remove any one byte from your original program the new program should print the source of your original program. This is [code-golf](/questions/tagged/code-golf "show qu...
[Question] [ *This challenge is based on, and contains test cases from, [a programming course](http://mooc.aalto.fi/ohjelmointi/scala_2017.html) I took at Aalto University. The material is used with permission.* Two and a half years ago there was a challenge about [spoonerisms in English](https://codegolf.stackexch...
[Question] [ ### Challenge Given a polynomial \$p\$ with real coefficients of order \$1\$ and degree \$n\$, find another polynomial \$q\$ of degree at most \$n\$ such that \$(p∘q)(X) = p(q(X)) \equiv X \mod X^{n+1}\$, or in other words such that \$p(q(X)) = X + h(X)\$ where \$h\$ is an arbitrary polynomial with \$o...
[Question] [ Create a bootloader that executes given Brainfuck program. This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the program with least bytes wins. Being a bootloader, the size of the program is counted in non-zero bytes in the compiled code. ## Brainfuck 30000 8-bit ...
[Question] [ I define the method of combining a sequence to mean that every number in the sequence is concatenated as a string, then that result is made an integer. ``` [1, 2, 3] -> 123 ``` For every finite sequence of at least 3 consecutive integers, missing exactly one element in the sequence, and this missing el...
[Question] [ # X Marks the spot Your goal is to add a cross-hair around the capital X: ## Example Input / Output Input: ``` mdhyyyyyyyhhhddmmm mdyyssoo oooosyyyhhhdmm hsso oossoooooyyhhdhhdmmm yoooooo oo ssysssyhhdyyyhmm...
[Question] [ In Dungeons and Dragons, some of the most important atributes of a character are the ability scores. There are 6 ability scores, for the six abilities. The abilities are Strength, Dexterity, Constitution, Intelligence, Wisdom and Charisma. When determining the scores for a character, I use the followin...
[Question] [ This image was made by overlaying 7 differently colored rectangles on top of each other: [![main image](https://i.stack.imgur.com/IVYvE.png)](https://i.stack.imgur.com/IVYvE.png) The black and maroon rectangles are *unobstructed*, that is, no other rectangles are above them. Write a program that takes ...
[Question] [ ## Local periods Take a non-empty string **s**. The *local period* of **s** at index **i** is the smallest positive integer **n** such that for each **0 ≤ k < n**, we have **s[i+k] = s[i-n+k]** whenever both sides are defined. Alternatively, it is the minimal length of a nonempty string **w** such that...