text
stringlengths
180
608k
[Question] [ For golfing practice, I have been doing the assignments in my girlfriend's Intro to Python class. I found that for this assignment, there were multiple strategies that came very close in character count, and I'm sure people here can find even better ways. Although I am most interested in ways to do thi...
[Question] [ This is a chess-KOTH with simplified rules (because chess itself is already complicated, playing it via a simple program doesn't make it easier). At the moment it is limited to java (version 8), but creating a wrapper-class isn't that difficult (in case someone wants to do this). ## Chessboard The ches...
[Question] [ Your task here is to write two regular expressions, each of which matches the other one but does not match itself. Both regular expressions should have this form: ``` /pattern/optional-flags ``` This is also the form in which they should be matched. The shortest solution wins. The solution length is co...
[Question] [ This is sequence [A054261](https://oeis.org/A054261). The \$n\$th prime containment number is the lowest number which contains the first \$n\$ prime numbers as substrings. For example, the number \$235\$ is the lowest number which contains the first 3 primes as substrings, making it the 3rd prime conta...
[Question] [ # Background Most of you know what a [Fibonacci number](https://en.wikipedia.org/wiki/Fibonacci_number) is. Some of you may know that all positive integers can be represented as a sum of one or more distinct Fibonacci numbers, according to [Zeckendorf's Theorem](https://en.wikipedia.org/wiki/Zeckendorf...
[Question] [ Define the "maximum sub-array" of a given array as "a (consecutive) sub-array that has the biggest sum". Note there's no "non-zero" requirement. Output that sum. Give a description of your code if possible. Sample input 1: ``` 1 2 3 -4 -5 6 7 -8 9 10 -11 -12 -13 14 ``` Sample output 1: `24` Description...
[Question] [ [MATL](https://esolangs.org/wiki/MATL) is a golfing language created by [Luis Mendo](https://codegolf.stackexchange.com/users/36398/luis-mendo). MATL has proven to be highly competitive, often [beating](https://codegolf.stackexchange.com/a/75002/31516) submissions in other golfing languages such as Pyt...
[Question] [ The [Pareto Distribution](https://en.wikipedia.org/wiki/Pareto_distribution) is a probability distribution that comes up a lot in nature. It has lots of special properties, such as an infinite mean. In this challenge, you will output a number sampled from this distribution. The Pareto Distribution is d...
[Question] [ Write a program or function that takes in a positive integer N. When N is 1, output ``` /\ \/ ``` When N is 2, output ``` /\/\ \/ / / / \/ ``` When N is 3, output ``` /\/\/\ \/ / / / / / \/ / / / \/ ``` When N is 4, output ``` /\/\/\/\ \/ / / / / / / / \/ / / / / / \/ / / / \/ ``` For larger N the patt...
[Question] [ **This question already has answers here**: [Say What You See](/questions/70837/say-what-you-see) (34 answers) Closed 8 years ago. The look and say sequence is a basic form of run length encoding. The sequence starts with the number 1 and each additional number encodes the number of digits that...
[Question] [ Given a binary number A as input with d > 1 digits, output a binary number B with d digits according to the following rules for finding the nth digit of B: * The first digit of B is zero if the first and second digits of A are equal; otherwise, it is one. * If 1 < n < d, then if the (n-1)th, nth and (n...
[Question] [ Sometimes I see a claim like "80% of respondents agreed" and I think "what was your sample size? 5?" because, of course, with a sample size of 5 it's possible to get 80% to agree on something. If the claim is "47% of respondents agreed" then I know it must be a larger sample size.[1] ## challenge Given...
[Question] [ [hgl](https://gitlab.com/WheatWizard/haskell-golfing-library/-/blob/master/src/P.hs) has a "scan" function called `sc`. What it does in general is a little bit abstract, so we will just talk about one specific way you can use it. If we want to take a list of integers and get the partial sums of every p...
[Question] [ Given a list of integers find the "trajectory" that results from indefinitely moving the instructed steps to the right (left if negative), wrapping if necessary, starting at the first element. A "trajectory", here, is defined as a list containing the elements that are visited only one time, in the orde...
[Question] [ For this challenge, a list is considered valid if and only if it consists entirely of integers and valid lists (recursive definitions \o/). For this challenge, given a valid list and an integer, return a list of all depths at which the integer can be found. # Example Let's consider list `[1, [2, [3, [1...
[Question] [ # Background (Based on a true, heart-wrenching story) In my time, I've played around with Lisp and similar languages often. I've written with them, ran them, interpreted them, designed them, and made machines write with them for me... And if there is one thing that bothers me, it's seeing Lisp that doe...
[Question] [ # Challenge Write a program or function that takes in a string `s` and integer `n` as parameters. Your program should print (or return) the string when transformed as follows: Starting in the top-left and moving down and to the right, write `s` as a wave of height `n`. Then, from top to bottom, combine...
[Question] [ Letter dice are common in word games. It can be fun to try to spell funny words with boggle dice, for instance. If you grab a handful of dice, chances are you won't be able to spell certain words. This challenge is a generalization of that idea. # Challenge Given a list of dice which each have at least...
[Question] [ Recently there have been a couple of ASCII pet snake challenges (e.g. [here](https://codegolf.stackexchange.com/questions/156369/code-golf-your-own-horizontal-pet-ascii-snake)) ``` 0 0 0 0 0 000 00 0 00 000 0 0 000 0 0 0 00...
[Question] [ Given a string as argument, output the length of the longest(s) non-overlapping repeated substring(s) or zero if there is no such string. You can assume the input string is not empty. ## Examples `abcdefabc` : the substring `abc` is repeated at positions 1 and 7, so the program should output **3** `abc...
[Question] [ # Introduction The **Parsons code** is just a simple way to describe *pitch variations* in a piece of music, whether a note is higher or lower than the previous one. Even if you suck at remembering tunes, you can still pretty much remember if a note goes up or down, thus the *Parsons code* can help you...
[Question] [ **Monday Mini-Golf:** A series of short [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") challenges, posted (hopefully!) every Monday. (Sorry this one's a little late.) I'm sure most of you folks have heard of [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtei...
[Question] [ There's a little improv warm up game where you arrange yourselves in a circle and send zips, zaps, and zops around by pointing to a person and saying the next word in the sequence, then they do the same until all of you are warmed up or whatever. Your task is to create a program that gives the next wor...
[Question] [ # Challenge Given a list of positive integers, find if there exists a permutation where taking up to one bit from each of the integers, a binary number consisting of all `1`s can be created. The number of bits in the resulting binary number is equal to the highest [MSB](https://en.wikipedia.org/wiki/Mo...
[Question] [ The alphanumeric characters have ASCII-values: ``` 0-9 -> 48-57 A-Z -> 65-90 a-z -> 97-122 ``` Your challenge is to take an integer as input, and output how many characters can be made using consecutive digits of that number. The character codes may be overlapping. `666` should result in `2`, sin...
[Question] [ Write a program or function that takes in two positive integers, a width and a height, and draws an ASCII art [houndstooth](https://en.wikipedia.org/wiki/Houndstooth) grid pattern with those dimensions using this 25×26 text grid as the base cell: ``` .......#.....#####....... .......##.....#####...... ...
[Question] [ *Too bad! I had such a beautiful equation, but I lost all my `=+-*`, so there is nothing left but a chain of digits, looking like a number: `7512`. But was it `7+5=12` or `7-5=1*2` or `7=5*1+2` or `7=5+1*2`? Or are there even more valid possibilities?* Your task: **For a given positive integer number, ...
[Question] [ # About the Series First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You can find the leaderboard along with some more information about the series [in the first post](https://...
[Question] [ In 2015 [the Portland International Airport](https://en.wikipedia.org/wiki/Portland_International_Airport) began the replacement of [their iconic carpet](https://en.wikipedia.org/wiki/Portland_International_Airport_carpet). I want you to write a program to draw their old carpet in as few bytes as possi...
[Question] [ > > Consider the number 99999999. That number is obviously a palindrome. The largest prime factor of 99999999 is 137. If you divide 99999999 by 137, you get 729927. This number is also a palindrome. > > > The largest prime factor of 729927 is 101. 729927/101=7227 which again is a palindrome. > > >...
[Question] [ Following [last year's event](https://codegolf.meta.stackexchange.com/q/24068/78410), we're doing [**Code Golf Advent Calendar 2022**](https://codegolf.meta.stackexchange.com/q/25251/78410)! On each day from today (Dec 1) until Christmas (Dec 25), a Christmas-themed challenge will be posted, just like ...
[Question] [ A pyramidal matrix is a square matrix where all numbers increase or decrease from the center point, like the two matrices below: ``` 1 1 1 1 1 1 2 2 2 1 1 2 3 2 1 1 2 2 2 1 1 1 1 1 1 ``` Or: ``` 3 3 3 3 3 3 2 2 2 3 3 2 1 2 3 3 2 2 2 3 3 3 3 3 3 ``` Given a non-ze...
[Question] [ This challenge was inspired by programming an Arduino microcontroller. I have 6 LEDs and 6 buttons connected to various pins on the board. In the code, each button and LED is assigned an ID number (1-6). Pin numbers (ranging from 0-13) corresponding to the ID numbers are looked up using a `switch` stat...
[Question] [ ### Introduction When building an electronics project, a schematic may call for a resistor of an unusual value (say, 510 ohms). You check your parts bin and find that you have no 510-ohm resistors. But you do have many common values above and below this value. By combining resistors in parallel and ser...
[Question] [ ## Task You are playing [Hangman](https://en.wikipedia.org/wiki/Hangman_(game)), and your opponent uses a simple but effective strategy: Each turn, from the remaining letters, they guess the letter that appears most frequently across all possible words. When multiple letters appear with the same maximu...
[Question] [ ### Introduction We have 22 Collatz conjecture-related challenges as of October 2020, but none of which cares about the restrictions on counter-examples, if any exists, to the conjecture. Considering a variant of the operation defined in the conjecture: $$f(x)= \cases{ \frac{x}{2}&for even x \cr \frac...
[Question] [ Write a [proper quine](https://codegolf.meta.stackexchange.com/q/4877/48934) whose every rotation is itself a proper quine. For example, if your source code is `abcdef`, then: * `abcdef` would output `abcdef` * `bcdefa` would output `bcdefa` * `cdefab` would output `cdefab` * `defabc` would output `def...
[Question] [ K is a programming language in the APL family designed by Arthur Whitney. While the official interpreter is closed-source and commercial, a trial version with a workspace limit of 32 bits of addressing space (which shouldn't pose problems for code golf) can be found at the [Kx Systems](http://kx.com/so...
[Question] [ An palindrome is a word that is its own reverse. Now there are some words that might look like palindromes but are not. For example consider the word `sheesh`, `sheesh` is not a palindrome because its reverse is `hseehs` which is different, however if we consider `sh` to be a single letter, then it's r...
[Question] [ # Where am I now? Given a string `d`, containing only the letters `NSWE`, determine the coordinates I've traveled (from left to right, consuming greedily) and the final coordinate where I reside. The rules for reading coordinates from left-to-right: * ***If the next character is `N` or `S`***: + **If ...
[Question] [ Based on my previous question of the same type, [Build an adding machine using NAND logic gates](https://codegolf.stackexchange.com/questions/10845/build-an-adding-machine-using-nand-logic-gates), this time you're being asked to multiply instead of add. Build a diagram of (two-wire) NAND logic gates th...
[Question] [ I'm sure most, if not all, of you have [come across this](http://www.mrc-cbu.cam.ac.uk/people/matt.davis/Cmabrigde/) at some point or another: > > Aoccdrnig to a rscheeachr at Cmabrigde Uinervtisy, it deosn't mttaer > in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is > taht the fris...
[Question] [ In most programming languages, the string `Hello, World!` can be represented as `"Hello, World!"`. But if you want to represent `"Hello, World!"` you need to escape the double quotes with backslashes for `"\"Hello, World!\""`, and to represent *that* you also need to escape the backslashes resulting in...
[Question] [ If we have a list of integers we can "squish" one of them by: * decrementing it * replacing adjacent values with its new value For example in this list: ``` [1,2,8,3,6] ``` If we squish the `8` we get: ``` [1,7,7,7,6] ``` The question is: **Given a starting array, what is the largest we can make its su...
[Question] [ *(inspired by a [question](https://codereview.stackexchange.com/q/171190) over on Code Review)* Suppose two people are playing [Hangman](https://en.wikipedia.org/wiki/Hangman_(game)), but you've only overheard the game and want to draw the current status. Given two words as input, where the words each ...
[Question] [ Given a string of digits or an integer as input, you will have to indexize it. This is how you modify the input. We will use `30043376111` as an example: First, find the sum of the indices of each occurrence of the respective digits: ``` 0: 1 + 2 = 3 1: 8 + 9 + 10 = 27 3: 0 + 4 + 5 = 9 4: 3 6: 7 7: 6 ...
[Question] [ In this [fastest-code](/questions/tagged/fastest-code "show questions tagged 'fastest-code'") challenge, you take a positive integer as input, which represents the height of a sand pile, located at (0,0) on an infinite square grid. For example, if our input is `123`, the sand grid looks initially like ...
[Question] [ Multi-dimensional chess is an extension of normal chess that is played on an 8x8x8x8... "board". In normal 2D chess, a knight's move is a movement by a vector of \$ \begin{bmatrix} \pm 2 \\ \pm 1 \end{bmatrix} \$ or \$ \begin{bmatrix} \pm 1 \\ \pm 2 \end{bmatrix} \$, as long as it doesn't cause the kni...
[Question] [ Interval notation is a way to write complicated range bounds more conveniently and concisely than writing an inequality. The challenge, should you choose to accept it, is to write a program or function that interprets a subset of interval notation. In this subset, intervals are a comma-separated pair o...
[Question] [ Consider a one-dimensional sequence of numbers within a fixed range, i.e. ``` [1, 2, 4, 6, 8, 0, 2, 7, 3] in range [0, 10⟩ ``` The Ever-Increasing Graph\* \*\* is a line that connects all the points in this sequence left to right, and always goes upwards or stays level. If necessary, the line wraps aro...
[Question] [ ## Task Write a function that accepts two integers \$a,b\$ that represent the Gaussian integer \$z = a+bi\$ (complex number). The program must return true or false depending on whether \$a+bi\$ is a [Gaussian prime or not](http://mathworld.wolfram.com/GaussianPrime.html). ## Definition \$a+bi\$ is a Ga...
[Question] [ # Task Write a program/function that when given a positive integer \$n\$ splits the numbers from \$1\$ to \$n\$ into two sets, so that no integers \$a, b, c\$, satisfying \$a^2 + b^2 = c^2\$ are all in the same set. For example, if \$3\$ and \$4\$ are in the first set, then \$5\$ must be in the second ...
[Question] [ You are the roughest, toughest, coolest cowboy west of the Mississippi. However, some weird guy on a wacky nerd website decided that it would be cool to plop you into random unfinished landscapes and fight. No matter, you'll still win. However, to help you win those grueling gunfights you'll write home...
[Question] [ > > An [**emirp**](https://en.wikipedia.org/wiki/Emirp) is a ***non-palindromic*** prime which, when reversed, is also prime. > > > The list of base 10 emirps can be found on [**OEIS**](http://oeis.org/A006567). The first six are: ``` 13, 17, 31, 37, 71, 73 ``` However, due to the reversal rule, em...
[Question] [ There was a discussion going on in TNB once about the best temperature scale, and we agreed on something: Take the average of all four main temperature scales! That is, [Celsius](https://en.wikipedia.org/wiki/Celsius), [Kelvin](https://en.wikipedia.org/wiki/Kelvin), [Fahrenheit](https://en.wikipedia.or...
[Question] [ **Objective** Write a full program that outputs (to STDOUT or closest alternative) an arbitrary string of text, no more than 64 characters long. Simple enough, right? Well, here's the catch: You may not use any characters that were present in the previous answer's output. That's right, *none* of them. ...
[Question] [ For many games played on a grid, hexagons are the Clearly Superior Choice™. Unfortunately, many free game art sites only have seamless tile sets for square maps. On a past project, I used some of these, and manually converted them to hexagons. *However*, I've gotten lazy in my old age. It should be eas...
[Question] [ Given a list of strings, replace each string by one of its non-empty substrings which is not a substring of any of the other strings in the list and as short as possible. ### Example Given the list `["hello","hallo","hola"]`, `"hello"` should be replaced by just `"e"` as this substring is not contained...
[Question] [ Sometimes, when I'm idly trying to factor whatever number pops up in front of me¹, after a while I realize it's easier than I thought. Take `2156` for example: it eventually occurs to me that both `21` and `56` are multiples of `7`, and so certainly `2156 = 21 x 100 + 56` is also a multiple of `7`. You...
[Question] [ ## Braid Description In this braid, when a strand crosses over the top of another strand it adds the other strand's value to itself and all other strand values pass through. The braid has three strands and each strand begins at 1. The first crossover is the leftmost strand crossing over the middle stra...
[Question] [ ## Background Countless generations of children have wondered where they would end up if they dug a hole directly downwards. It turns out that this would, unsurprisingly, be [rather dangerous](https://what-if.xkcd.com/135/), but anyway... Antipodes are points that are directly opposite each other on th...
[Question] [ Santa needs some help determining how many elves he will need to help him deliver gifts to each house. Coal is considerably heavier than presents, so santa will need three elves for every naughty person in the house. Only two elves are needed to help santa carry presents. On santa's map, a house is rep...
[Question] [ The game of [Chinese checkers](http://en.wikipedia.org/wiki/Chinese_checkers) is played on a board with spaces in the shape of a six-pointed star: ![Board image](https://i.stack.imgur.com/vNW7w.png) [Image from Wikipedia](http://en.wikipedia.org/wiki/File:Chinese_checkers_start.png) We can create an AS...
[Question] [ *Note: This challenge was inspired by [Joe Z's](https://codegolf.stackexchange.com/users/7110/joe-z) many excellent questions surrounding NAND golfing.* ## Description Your goal in this challenge, should you choose to accept it, is to implement a very simple ALU using just NAND gates. The ALU can only ...
[Question] [ # Guidelines ### Task Given two notes, inputted as strings or lists/arrays, calculate how many semitones apart they are (inclusive of the notes themselves), outputting as a number. **Explanation of a semitone:** A semitone is one step up or down the keyboard. An example is C to C#. As you can see below...
[Question] [ A collection of positive integers `d_1 d_2 ... d_k` is a *factorisation* of a positive integer `n` if ``` d_1 * d_2 * ... * d_k = n ``` Each positive integer has a unique *prime factorisation*, but in general they also have factorisations in which some of the terms are composite. E.g. ``` 12 = 6 * 2 = ...
[Question] [ ``` ⢣⠃⢎⠆⣇⡇⡯⡂⠈⡏⢰⢵⢐⡭⢸⠪⡀⢸⢐⡭⠀⢹⠁⢎⠆⢸⣱⢸⡃⢎⠰⡱⢸⣱⢸⡃⠈⡏⢸⡃⡱⡁⢹⠁⢸⡀⡇⡗⢅⢸⡃⠈⡏⢸⢼⢸⢐⡭⠀ ⣇⢸⡃⢹⠁⢹⠁⣟⢸⢕⢐⡭⠀⡮⡆⡯⡂⣟⠀⡯⠰⡱⢸⣸⢸⢕⠀⣏⡆⢎⠆⢹⠁⣪⠅⢸⢼⢸⠰⣩⢸⢼⠀⡮⡆⡗⢼⢸⣱⠀⢎⠆⡯⠀⢇⠇⡮⡆⡯⡂⡇⡮⡆⣟⡆⣇⢸⡃⠸⡰⡸⢸⢸⣱⠈⡏⢸⢼⠀ ⢎⠆⡗⢼⢸⡃⢸⡃⡗⠔⡇⡯⠂⢹⠁⢣⠃⠸⡸⢸⡃⡯⡂⢹⠁⡇⢎⢰⢵⢸⡀⢸⡀⡇⡗⢼⢸⡃⢐⡭⢸⡃⡯⠂⡮⡆⡯⡂⡮⡆⢹⠁⣟⢐⡭⠀⢎⢸⢼⢰⢵⢸⢕⢰⢵⠰⡁⢹⠁⣟⢸⢕⢐⡭⠀ ⡮⡆⢐⡭⢸⠕⢰⢵⠰⡁⣟⠀⡇⣪⠅⢈⣝⢸⡃⡯⡂⢎⠆⠸⡰⡸⢸⢸⣱⠈⡏⢸⢼⠀ ⣪⠅⢎⠆⢸⠈⡏⠀⣇⠰⡱⠰⡱⢸⠪⡀⣪⠅⢸⡀⡇⡗⢅⢸⡃⠸⡰⡸⠰⡱⢸⢕⢸⣱⢐⡭⠀⡮⡆⡯⡂⣟⠀⣪⠅⣟⢸⠕...
[Question] [ Bubble-wraps are maximum-level entertainment. Everyone can agree to that. Now, you will make even computers enjoy bubble-wraps. # Specs You will be given two integers, w, and h.(each are responsively width and height) Your program should output all w\*h phases waiting 1 second between each one and term...
[Question] [ The residents of Flapus use a base-8 number system. The numbers are: 0 - Kuzla 1 - Ponara 2 - Boqkel 3 - Colopee 4 - Vruenat 5 - Foham 6 - Stikty 7 - Kricola For numbers over 7, the full name of the last digit comes first, followed by apostrophe and the first characters of the other dig...
[Question] [ ## Task Given an integer \$n\in[0,10^{12})\$ in any convenient format, return the number of strokes needed to write that character in simplified Chinese. ### Background Chinese numerals are expressed in base 10 with a system of digits and places, with an important distinction that digits are in groups ...
[Question] [ *Based on [this](https://www.youtube.com/watch?v=W20aT14t8Pw) Numberphile video* A self-locating string is a number (or set of numbers) in a decimal expansion which corresponds to its location, from the start of the decimal. For example, take the number: ``` .2734126393112 ``` Here, we can identify cer...
[Question] [ This challenge is about finding the smallest disk that contains some given points. This is made somewhat trickier, however, by the fact that in this challenge, the disk's coordinates and radius must both be integers. Your input will be a list of points with integer coordinates `x` and `y`. You can take...
[Question] [ # Drunkard's Journey Home In this challenge you are to write a program which simulates a drunkard stumbling his way home from the bar. ### Input: The input will be an adjacency matrix (representing a directed graph) which represents paths the drunkard can take. At each location, the drunkard will choos...
[Question] [ # Play the Fruit Box Game ## Intro Fruit Box is a game consisting of a 10x17 grid of numbers, each between 1 and 9, where the goal is to clear as many numbers as possible in a two-minute time window. In order to clear numbers, one selects a rectangle aligned with the grid, and if the numbers inside of ...
[Question] [ # Introduction Cacti come in various different sizes, shapes and colors. However, the most iconic cactus and must-have in every Western has to be the [saguaro](https://en.wikipedia.org/wiki/Saguaro). Important features are its size and arms, which have defined the stereotypical cactus appearance. Your...
[Question] [ Write a program or function that given an integer radius *r* returns the number of unit squares the circle with radius *r* centered at the origin passes through. If the circle passes exactly through a point on the grid that does not count as passing through the adjacent unit squares. Here's an illustra...
[Question] [ ### Background: Jack is a pumpkin that enjoys spooking the citizens of the villages near his pumpkin patch every Halloween. However, every year after someone lights the candle inside of him, he has a limited amount of time to spook everyone before the candle burns out, thus being unable to spook any mo...
[Question] [ You live inside a terminal that is 80 characters wide. You are bored, so you decide to play dominoes. No, not the boring kind that look like Scrabble, the fun kind where you spend an hour setting them to watch them fall in a second. In terminals, dominoes look like this: ``` | upright domino \ left...
[Question] [ ## Task: Your program is given a [proper](//en.wikipedia.org/wiki/Fraction_(mathematics)#Proper_and_improper_fractions), positive [simple fraction](//en.wikipedia.org/wiki/Fraction_(mathematics)#Simple.2C_common.2C_or_vulgar_fractions) in the format `<numerator>/<denominator>`. For this input, it must ...
[Question] [ Write a program that inputs the dimensions of a painting, the matting width, and the frame width for a framed portrait. The program should output a diagram using the symbol `X` for the painting, `+` for the matting, and `#` for the framing. The symbols must be space-separated. Trailing whitespace is al...
[Question] [ ​Your task is to write a program or function that outputs the first character of its source code, then the second, then the third... each time it is run. For example, if your program was `foo` in language `bar` in file `baz.bar`, then you should get output similar to this: ``` λ bar baz.bar f λ bar baz...
[Question] [ The [Chinese Remainder Theorem](http://en.wikipedia.org/wiki/Chinese_remainder_theorem) tells us that we can always find a number that produces any required remainders under different prime moduli. Your goal is to write code to output such a number in polynomial time. Shortest code wins. For example, s...
[Question] [ **Background:** I originally posted this question last night, and received backlash on its vagueness. I have since consulted many personnel concerning not only the wording of the problem, but also its complexity (which is not O(1)). This programming problem is an evil spin on an Amazon interview questi...
[Question] [ Given an input of a list of integers representing dates, output an ASCII art timeline like the following: ``` <-----------------------------> A B C D E ``` The above timeline is the output for input `[1990, 1996, 1999, 2011, 2016]`. Note several things about the timeline: * The firs...
[Question] [ Input: ``` 1 X X X X XX XXXXXX X X X X XX XXXXXX X X X XXX X XX XXXXXX X X X XXX X XX XXXXXX X X X ``` Output...
[Question] [ The solar year is 365 days, 5 hours, 48 minutes, 45 seconds, and 138 milliseconds, according to [this video](https://www.youtube.com/watch?v=qkt_wmRKYNQ). With the current Gregorian calendar, the rules for leap years are as follows: ``` if year is divisible by 400, LEAP YEAR else if year is divisi...
[Question] [ ## Background Inspired by [I'm a palindrome. Are you?](https://codegolf.stackexchange.com/questions/110582/im-a-palindrome-are-you), where it is presented the [shocking](https://www.reddit.com/r/Showerthoughts/comments/5vkrg5/) fact that “`()()` is not a palindrome, but `())(`”, I asked myself what ins...
[Question] [ As [everyone knows](https://pics.me.me/i-am-mr-clever-am-ovin-fact-adding-inator-3000-to-anything-makes-12173475.png), adding `inator-3000` to the end of any noun makes it way cooler. But what else can make a word cooler? Given an ASCII string as input, output the ***coolness*** of the word. ## Calcula...
[Question] [ ## Introduction Let's define a new arithmetical operation, which I call *zipper multiplication*. To zipper multiply two nonnegative integers, you add leading zeros to make the lengths match, multiply the corresponding base-10 digits of the numbers, add leading zeros to the results to get 2-digit number...
[Question] [ A [highly composite number](https://en.wikipedia.org/wiki/Highly_composite_number) is a positive integer that has more divisors than any smaller positive integer has. This is [OEIS sequence A002182](https://oeis.org/A002182). Its first 20 terms are ``` 1, 2, 4, 6, 12, 24, 36, 48, 60, 120, 180, 240, 360...
[Question] [ ### Groups In abstract algebra, a *[group](https://en.wikipedia.org/wiki/Group_(mathematics))* is a tuple \$(G,\ast)\$, where \$G\$ is a set and \$\ast\$ is a function \$G\times G\rightarrow G\$ such that the following holds: * For all \$x, y, z\$ in \$G\$, \$(x\ast y)\ast z=x\ast(y\ast z)\$. * There e...
[Question] [ Write a function that accepts a rectangular grid of ids in any reasonable format, for example a multi-line string: ``` IIILOO ILLLOO ``` and a string or list of box drawing charcters such as: ``` ' ═║╔╗╚╝╠╣╦╩╬' ``` or ``` [0x20, 0x2550, 0x2551, 0x2554, 0x2557, 0x255a, 0x255d, 0x2560, 0x2563, 0x2566, 0x...
[Question] [ 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`.) [![Color #49de5f](https://i.stack.imgur.com/CU4Ez.png)](https://i.stack.imgur.com/CU4Ez.png)[![Color ...
[Question] [ Here's a deceptively challenging geometry puzzle for you! Given a circle `A`, and `n` other circles `B[n]`, find the total area contained within `A` that is *not* within any circle of `B`. Your code should be as short as possible. # Input Your input should contain the following information: * A floatin...
[Question] [ Over at <https://math.stackexchange.com/questions/33094/deleting-any-digit-yields-a-prime-is-there-a-name-for-this> the following question is asked. How many primes are there that remain prime after you delete any one of its digits? For example `719` is such a prime as you get `71`, `19` and `79`. Whil...
[Question] [ ## Introduction Given a set of percentages of choices in a poll, calculate the minimum number of voters there must be in the poll to generate those statistics. Example: What is your favorite pet? * Dog: `44.4%` * Cat: `44.4%` * Mouse: `11.1%` Output: `9` (minimum possible # of voters) ## Specs Here are...
[Question] [ ## Non-math explanation *This is an explanation that is meant to be approachable regardless of your background. It does unfortunately involve some math, but should be understandable to most people with a middle school level of understanding* A pointer sequence is any sequence such that \$a(n+1) = a(n-a...
[Question] [ Write a program to draw a 2-D diagram of a knot based on the knot's structure. A knot is exactly what it sounds like: a loop of rope that's tied up. In mathematics, a knot diagram shows where a piece of rope crosses over or under itself to form the knot. Some example knot diagrams are shown below: [![e...
[Question] [ > > Given a list of points, find the shortest path that visits all points and returns to the starting point. > > > The [Travelling Salesman Problem](http://en.wikipedia.org/wiki/Travelling_salesman_problem) is well-known in the computer science field, as are many ways to calculate/approximate it. I...
[Question] [ Scoring a [Go](http://en.wikipedia.org/wiki/Go_(game)) game is a task that is not all too easy. In the past there have been several debates about how to design rules to cover all the strange corner cases that may occur. Luckily, in this task you don't have to do complicated stuff like life and death or...