text
stringlengths
180
608k
[Question] [ ### Introduction In the strange world of integer numbers, divisors are like assets and they use to call "rich" the numbers having more divisors than their reversal, while they call "poor" the ones having less divisors than their reversal. For example, the number \$2401\$ has five divisors : \$1,7,49,34...
[Question] [ <https://en.wikipedia.org/wiki/Connect_Four> Does anyone remember the 2 player game connect 4? For those who don't it was a 6x7 board that stands vertical on a surface. The goal of connect 4 is to, well connect 4! The connection is counted if it is horizontal, diagonal, or vertical. You place your piec...
[Question] [ ### Input Two integers: * A non-negative integer ***W*** in the range 0 to 2^64-1, specifying the weave. * A positive integer ***S*** in the range 1 to 255, specifying the side length. These can be taken in whichever order suits you. ### Output An ***S*** by ***S*** ASCII representation of the requeste...
[Question] [ ## Challenge > > In this task you would be given an integer N (less than 106), find the minimum way in which you could sum to N using only Fibonacci numbers - this partition is called [Zeckendorf representation](https://en.wikipedia.org/wiki/Zeckendorf's_theorem). > > > You could use any Fibonacci ...
[Question] [ Two or more positive integers are said to be "[friendly](https://en.wikipedia.org/wiki/Friendly_number)" if they have the same "abundancy". The abundancy of an positive integer \$n\$ is defined as $$\frac {\sigma(n)} n,$$ where [\$\sigma(n)\$](https://en.wikipedia.org/wiki/Divisor_function) is the sum ...
[Question] [ Let's consider the following sequence: $$9,8,7,6,5,4,3,2,1,0,89,88,87,86,85,84,83,82,81,80,79,78,77,76,75,74,73,72,71...$$ This is the sequence of \$9\$'s complement of a number: that is, \$ a(x) = 10^d - 1 - x \$ where \$ d \$ is the number of digits in \$ x \$. ([A061601](https://oeis.org/A061601) in...
[Question] [ ## Background The number of values for a given type is called the *cardinality* of that type, and that of type T is written as `|T|`. Haskell and a few other languages have a certain set of enum types, each of which has a small finite number of values (the exact names vary, so this challenge uses some ...
[Question] [ ## Challenge Write a program or a function that returns or prints a square-random-symmetrical matrix. --- ## Input **N**: The size of the matrix i.e `6 x 6` --- ## Output The matrix. You can either print it, return it as string (with the newlines) or as a list/array of lists/arrays. --- ## Rules 1. You...
[Question] [ # We are searching for a sequence Take the **natural numbers** `1,2,3,4,5,6,7,8,9,10,11,12,13,14...` Convert to **base-2** `1,10,11,100,101,110,111,1000,1001,1010,1011,1100,1101,1110...` **Concatenate** the above numbers `110111001011101111000100110101011110011011110...` **Partition** this number...
[Question] [ Given a real number, convert it to a list of lists, with the negative sign (if any) becoming an empty list, the integer part becoming a list of digits, and the fractional part (if any) becoming a list of digits. The digits must be actual numbers, not strings. ### Examples `0` ‚Üí `[[0]]` `123` ‚Üí `[[1...
[Question] [ This is a very very simple algorithm, that I am sure can be solved in many many different languages. In Spain ID cards (known as [*DNI*](https://en.wikipedia.org/wiki/Documento_Nacional_de_Identidad_(Spain))) consist of 8 numbers and a control character. The control character is calculated with the fol...
[Question] [ # Code Golf *Totally real* backstory: I'm a contractor working on a website www.**Sky.Net** and one of our tasks it to create some self-aware program or something, I don't know I wasn't really listening to the boss. Anyways in an effort to make our code more self-aware we need *IT* to be able to know w...
[Question] [ What general tips do you have for golfing in [dc](https://en.wikipedia.org/wiki/Dc_(computer_program))? dc is a calculator utility for UNIX/Linux that predates the C language. I am interested in how to make my dc programs (calculations?) shorter. I'm looking for ideas that can be applied to general [c...
[Question] [ What general tips do you have for golfing in [Racket](http://racket-lang.org) / [Scheme](http://scheme.com)? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Racket / Scheme (e.g. "remove comments" is not an answer). --- I'm aware [Scheme...
[Question] [ In this challenge you will need to determine whether it's Pi Day, Pi Minute, or Pi Second. Because Pi is irrational, it wants your code to be as short as possible. # Examples **No input is provided**, your program should use the system time. I've just added it for clarity ``` March 14, 2016 0:00:00 Pi ...
[Question] [ From Wikipedia [Set-theoretic definition of natural numbers](http://en.wikipedia.org/wiki/Set-theoretic_definition_of_natural_numbers) > > The set N of natural numbers is defined as the smallest set containing > 0 and closed under the successor function S defined by S(n) = n ∪ {n}. > > > The first ...
[Question] [ In [my previous code challenge](https://codegolf.stackexchange.com/questions/16349), I asked you to write a function that tells you which of its lines has been removed. The instructions were: > > Write a function that contains five lines. > > > If you run the function as-is, it should return 0. > >...
[Question] [ Yesterday I asked [this](https://codegolf.stackexchange.com/q/152281/56656) question about riffle shuffles. It seems that yesterdays question was a bit too hard so this question is a related but much easier task. Today you are asked to determine if a permutation is in fact a riffle shuffle. Our definit...
[Question] [ **In:** a string without line breaks\* **Allow the user to edit and submit the line** **Out:** the modified string (optionally with a trailing linebreak) The line editor must at minimum allow the user to: 1. move a visible cursor left and right 2. insert and/or overwrite characters at the cursor po...
[Question] [ The challenge here is to accurately depict the flower of life (which is a sacred geometrical figure according to some) in the language of your choice. ![flower of life](https://i.stack.imgur.com/LyFnL.jpg) The design consists an arrangement of circles and partial circles of radius 1 as shown whose cent...
[Question] [ > > This challenge is inspired from [this](https://askubuntu.com/a/699587) answer at the Ask Ubuntu Stack Exchange. > > > # Intro Remember the [Windows ME screensaver with the pipes](https://www.youtube.com/watch?v=Uzx9ArZ7MUU)? Time to bring the nostalgia back! [![enter image description here](htt...
[Question] [ Convert a large int (e. g. 1234567890) into a string containing the usual decimal prefixes k, M, G, T, etc. for kilo, mega, giga, tera, etc. The result shall be groups of three digits, interspersed by the prefixes (e. g. `1G234M567k890`), so that it is easy to glance the order of magnitude of the numbe...
[Question] [ ### 0. DEFINITIONS A *sequence* is a list of numbers. A *series* is the sum of a list of numbers. The set of *natural numbers* contains all "non-negative integers greater than zero". A *divisor* (in this context) of a natural number *j* is a natural number *i*, such that *j*÷*i* is also a natura...
[Question] [ There have of course been challenges to render ASCII art fonts [here](https://codegolf.stackexchange.com/q/99913/72726) and [there](https://codegolf.stackexchange.com/q/80940/72726). This challenge doesn't add anything to those. In contrary, it subtracts from them for a good reason. If you allow all ch...
[Question] [ In this challenge you will write a function that takes a list (ordered set) containing real numbers (the empty list is an exception, as it has nothing) and calculates $$f(x)=\begin{cases}1 & \text{if } |x|=0 \\ x\_1+1 & \text{if } |x|=1 \\ \log\_{|x|}\sum\_{n=1}^{|x|}{|x|}^{x\_n} & \text{otherwise} \en...
[Question] [ You know those letterboards outside old-style cinemas which show upcoming films - perhaps you have a miniature one in your home? [![enter image description here](https://i.stack.imgur.com/E5cdlm.png)](https://i.stack.imgur.com/E5cdlm.png) If you've operated one, you'll know that you can normally add le...
[Question] [ ## Content You count numbers every day (I think), and most of you know how to count properly, the one next to `1` is `2`, and the next is `3`, so go on, no matter what number you receive, you can easily know what next number is. Anyway, the program doesn't know, they are incredibly stupid, if I make a ...
[Question] [ Let \$R, C\$ be positive integers and let \$0 < s \leq 1\$. Consider the \$R \times C\$ **matrix** \$\mathbf M\$ defined as \begin{equation} M(i,j) = \frac{\mathrm{mod}\,(j, i^s)}{R^s}, \quad i = 1, \ldots, R, \quad j = 1, \ldots, C \end{equation} where \$\,\mathrm{mod}\,\$ denotes the [modulo operatio...
[Question] [ Output either the text below, or a list of lists of integers (more details below). ``` 0 10 1 20 11 2 30 21 12 3 40 31 22 13 4 50 41 32 23 14 5 60 51 42 33 24 15 6 70 61 52 43 34 25 16 7 80 71 62 53 44 35 26 17 8 90 81 72 63 54 45 36 27 18 9 91 82 73 64 55 46 37 28 19 92 83 74 65 56 47 38 29 ...
[Question] [ # Definitions * A subsequence may not be contiguous, e.g. `[1, 1, 1]` is a subsequence of `[1, 2, 1, 2, 1]`. * An equal subsequence is a subsequence in which every element is equal. * The longest equal subsequence may not be unique, e.g. `[1, 1]` and `[2, 2]` are both longest equal subsequences of `[2,...
[Question] [ A perfect power is a number of the form \$a^b\$, where \$a>0\$ and \$b>1\$. For example, \$125\$ is a perfect power because it can be expressed as \$5^3\$. # Goal Your task is to write a program/function that finds the \$n\$-th perfect power, given a positive integer \$n\$. # Specs * The first perfect ...
[Question] [ Let's take a grid of 16x16 printable ASCII characters (code points 0x20 to 0x7E). There are 30-choose-15 paths from the top left to the bottom right corner, making only orthogonal moves, like the following example: ``` ##.............. .#.............. .######......... ......##........ .......##..........
[Question] [ First attempt at a question. --- # Calculating Transitive Closure ![](https://upload.wikimedia.org/wikipedia/commons/thumb/9/9e/Complete_graph_K7.svg/300px-Complete_graph_K7.svg.png) According to [Wikipedia](https://en.wikipedia.org/wiki/Transitive_closure), "the transitive closure \$R^\*\$ of a homoge...
[Question] [ Given a set of substrings, such as `[ca, ar, car, rd]`, it's possible to create infinitely many strings by concatting them together. Some examples of this for the given substrings could be: ``` ca caar card rdca carrd rdrd ... ``` One interesting property of this set of substrings is that any string ca...
[Question] [ Given two strings `a` and `b`, count how many times `b` occurs as a substring in `a`, but only when it overlaps with another instance of `b`. (This means that `1` will never be a valid output, because in order for the substring to be strictly overlapping, there must be at least one other instance for i...
[Question] [ *Inspired by [this](https://codegolf.stackexchange.com/questions/135417/reverse-array-sum)* In the linked challenge, we are asked to apply addition to the elements of the original and the reverse of the input array. In this challenge, we are going to make it slightly more difficult, by introducing the ...
[Question] [ The [Penrose triangle](https://en.wikipedia.org/wiki/Penrose_triangle), also known as the Penrose tribar, or the impossible tribar, is an impossible object. The goal in this challenge is to display a Penrose triangle in the fewest bytes possible. [![Penrose triangle](https://i.stack.imgur.com/s8SNl.png...
[Question] [ In this challenge, an *infinitely proportional sequence* is defined as a infinite sequence of positive integers such that: * All positive integers are contained infinitely many times within the sequence. * As more and more terms are added to the sequence, for all positive integers \$n\$, the ratio of t...
[Question] [ A palindrome is a word that is its own reverse. I will define the left palindromic root of a word as the shortest prefix of the word for which the shortest possible palindrome that begins with that prefix is the original word. So the left palindromic root of `racecar` is `race` and the left palindromic...
[Question] [ Given a compressed string \$s\$ made of printable ASCII characters (32 to 126), your task is to print or return the original text by applying this simple decompression algorithm: 1. Start with \$k=0\$ 2. Look for the first occurrence of the digit \$k\$ in \$s\$ and the sub-string \$s'\$ consisting of t...
[Question] [ Your task is to write a computer program or function that takes a list of nonnegative integers of at least length 2 and determines if they are a "zigzag". A sequence is a zigzag if and only if the numbers alternate in being larger and smaller than the number that comes before them. For example \$[1,2,0...
[Question] [ I found it quite hard to achieve a range of numbers as rows in `MySQL`. For example the range 1-5 is achieved by: ``` SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 ``` will result in: > > > ``` > 1 > 2 > 3 > 4 > 5 > > ``` > > for 0-99 I can cross join two 0-9 tables: ``` CR...
[Question] [ Given a positive integer *n* and a number *a*, the *n*-th [tetration](https://en.wikipedia.org/wiki/Tetration) of *a* is defined as *a*^(*a*^(*a*^(...^*a*))), where *^* denotes exponentiation (or power) and the expression contains the number *a* exactly *n* times. In other words, tetration is right-ass...
[Question] [ Create a function or program that takes two inputs: * A list of integers that shall be sorted (less than 20 elements) * A positive integer, `N`, saying how many comparisons you should take The function shall stop, and output the resulting list of integers after `N` comparisons. If the list is fully sor...
[Question] [ *[Related](https://codegolf.stackexchange.com/questions/249908/extract-strings-from-text)* We start with the string `a`, and forever append to the string a comma followed by the string quote-escaped, where quote-escaping means doubling all quotes in a string, and then surrounding it with an additional ...
[Question] [ Given a number `n` and an upper limit `l` list the numbers that can be created by multiplying two or more numbers consisting of **only sevens** of length `n` or less that are less than `l`. [A161145](http://oeis.org/A161145) is close to this challenge, however, you will NOT be including the 7, 77, 777,...
[Question] [ Chameleon challenges are a [bad thing](http://meta.codegolf.stackexchange.com/a/8214/13486 "I actually got the idea for this challenge after reading this post on Meta"), apparently. Too bad, chameleons are beautiful creatures. Time for a change! ![Picture of a chameleon](https://kingofwallpapers.com/ch...
[Question] [ This challenge is to find the longest chain of English words where the first 3 characters of the next word match the last 3 characters of the last word. You will use an common dictionary available in Linux distributions which can be downloaded here: <https://www.dropbox.com/s/8tyzf94ps37tzp7/words?dl=0...
[Question] [ As the title says, I was thinking to contest in which one must detect edges of an ASCII art. The code should accept a B/W ASCII art as input. A *B/W ASCII art* is defined as (by me) an *ASCII art* with only one kind of non-white-spaces character (in our case: an asteriks `*`). And as *output* produce a...
[Question] [ In Java/.NET/C/JavaScript/etc. you can use ternary-ifs to shorten if-statements. For example (in Java): ``` // there is a String `s` and an int `i` if(i<0)s="Neg";else if(i>0)s="Pos";else s="Neut"; ``` Can be shortened with a ternary-if to: ``` s=i<0?"Neg":i>0?"Pos":"Neut"; ``` ## Challenge: **Input:**...
[Question] [ Many digital clocks display the time using simplified digits comprised of only seven different lights that are either on or off: [![](https://i.stack.imgur.com/kfYal.png)](https://i.stack.imgur.com/kfYal.png) When mirrored horizontally, the digits `018` don't change because they are symmetrical. Also, ...
[Question] [ A subsequence is any sequence that you can get from another by deleting any amount of characters. The distinct non-empty subsequences of `100` are `0`, `1`, `00`, `10`, `100`. The distinct non-empty subsequences of `1010` are `0`, `1`, `00`, `01`, `10`, `11`, `010`, `100`, `101`, `110`, `1010`. Write a...
[Question] [ Given a matrix consisting of positive integers, output the path with the lowest sum when traversing from the upper left element to the bottom right. You may move vertically, horizontally and diagonally. Note that it's possible to move both up/down, right/left and diagonally to all sides. ### Example: `...
[Question] [ > > This is a [cops-and-robbers](/questions/tagged/cops-and-robbers "show questions tagged 'cops-and-robbers'") challenge, the robbers thread can be found [here](https://codegolf.stackexchange.com/questions/137382/solving-secret-swapping-sequences). > > > Your task is to write some code that output...
[Question] [ 3D-modeling software mainly uses [UV Mapping](https://en.wikipedia.org/wiki/UV_mapping) to map textures onto a 3D object. The valid values for both U and V are usually located in an inclusive `[0..1]` range. ## Challenge You bought a new 3D-modeling software which is super-easy to use. However there is...
[Question] [ Getting the area covered by a rectangle is really easy; just multiply its height by its width. However in this challenge we will be getting the area covered by multiple rectangles. This is equally easy ... so long as the rectangles don't overlap. If the rectangles don't overlap the total area covered i...
[Question] [ [Sociable numbers](https://en.wikipedia.org/wiki/Sociable_number) are a generalisation of both [perfect](https://en.wikipedia.org/wiki/Perfect_number) and [amicable numbers](https://en.wikipedia.org/wiki/Amicable_number). They are numbers whose proper divisor sums form cycles beginning and ending at th...
[Question] [ **The Challenge** Given an integer input, return the first Fibonacci number that contains the input within itself along with the index of that Fibonacci number (indexes starting at 0 or 1 - up to you, but please mention which in your answer). For example, if given the input of 12, the program would ret...
[Question] [ Consider the string `160615051`. It can be "triangulated" as such: ``` 1 606 15051 ``` Then, each row is a palindrome. Also note that each side on the perimeter is also a palindrome: ``` 1 | 1 | 6 | 6 | 1 | 1 | 15051 ``` Therefore, this string can be considered to be a...
[Question] [ # Challenge Given a graphical input of a shape, determine how many holes there are in it. # Not Duplicate This question was marked as a possible duplicate of [Count Islands](https://codegolf.stackexchange.com/questions/6979/code-golf-count-islands). I believe this challenge is different from the Count ...
[Question] [ **RNA**, like DNA, is a molecule found in cells encoding genetic information. It consists of *nucleotides*, which are represented by the bases adenine (A), cytosine (C), guanine (G) and uracil (U).\* A **codon** is a sequence of three nucleotides. **Proteins** are large molecules which perform a vast a...
[Question] [ Given a string of printable ASCII text (including newlines and spaces) that contains at least one character that is neither a newline nor a space, output a truthy value if the string is rectangular, and a falsey value otherwise. **Additionally, the source code for your solution must be rectangular**. A...
[Question] [ **This challenge was posted as part of the [April 2018 LotM challenge](https://codegolf.meta.stackexchange.com/questions/16116/language-of-the-month-for-april-2018-brain-flak)** --- [Brain-Flak](https://github.com/DJMcMayhem/Brain-Flak) is a turing-tarpit language which has gained quite a lot of fame h...
[Question] [ # The task: Output a value for `x`, where `a mod x = b` for two given values `a,b`. # Assumption * `a` and `b` will always be positive integers * There won't always be a solution for `x` * If multiple solutions exist, output at least one of them. * If there aren't any solutions, output nothing or some ...
[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] [ ## Background A [magic square](https://en.wikipedia.org/wiki/Magic_square) is an `n×n` matrix consisting of one of each of the integers from \$1\$ to \$n^2\$ where every row, column, and diagonal sum to the same value. For example, a 3×3 magic square is as follows: ``` 4 9 2 3 5 7 8 1 6 ``` Here, each ...
[Question] [ ## The sequence Given an integer \$n>0\$, we define \$a(n)\$ as the lowest positive integer such that there exists exactly \$n\$ positive integers smaller than \$a(n)\$ whose sum of digits is equal to the sum of the digits of \$a(n)\$. *Edit: this sequence has since been published as [A332046](https://...
[Question] [ Given a non-empty matrix of non-negative integers, answer which unique rows contribute most to the sum total of elements in the matrix. Answer by any reasonable indication, for example a mask of the unique rows order of appearance (or sort order), or indices (zero- or one- based) of those, or a submatr...
[Question] [ Given as input a positive integer `n>=1`, output the first `n` rows of the following triangle: ``` 1 1 0 1 0 0 1 0 0 1 1 1 0 1 1 1 0 0 0 0 1 0 0 0 0 1 1 1 1 1 0 1 1 1 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 1 1 1 1 0 1 ...
[Question] [ My challenges tend to be a little bit hard and unattractive. So here something easy and fun. ## Alcuin's sequence [Alcuin's sequence](http://en.wikipedia.org/wiki/Alcuin%27s_sequence) `A(n)` is defined by counting triangles. `A(n)` is the number of triangles with integer sides and perimeter `n`. This ...
[Question] [ **Closed.** This question is [off-topic](/help/closed-questions). It is not currently accepting answers. --- **Want to improve this question?** [Update the question](/posts/3994/edit) so it's [on-topic](/help/on-topic) for Code Golf Stack Exchange. Closed 11 years ago. [Improve this question](/post...
[Question] [ # Scramble a Megaminx! A megaminx is a dodecahedral version of the familiar Rubik's cube. Since 2008, the World Cube Association uses [Stefan Pochmann's](https://codegolf.stackexchange.com/users/40544/stefan-pochmann) [megaminx scrambler](https://www.stefan-pochmann.info/spocc/other_stuff/tools/scrambl...
[Question] [ # Summary Videos which are sped up every time a particular word is said exist for everything from [the Bee Movie](https://www.youtube.com/watch?v=JMG1Nl7uWko) to the classic [Rick Roll](https://www.youtube.com/watch?v=ZXpThNX9IRc). The goal for this challenge is to figure out how much you'd have to slo...
[Question] [ This is how the Kolakoski sequence (OEIS [A000002](https://oeis.org/A000002)) is defined: > > The Kolakoski sequence is a sequence that contains `1` and `2`, and the `n`th element of the sequence is the length of the `n`th group of equal elements (run) in the sequence itself. The first 20 terms of the...
[Question] [ This is a cake: ``` _========_ | | +________+ | | +________+ | | +________+ ``` It is 8 wide, 3 tall, and 1 deep. You must write a program that makes a cake from 3 inputs. The first input controls how many underscores there are in the middle and `=`s on the top. Here's the first ca...
[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/240225/edit). Closed 2 years ago. [Improve this question](/posts/240225/edit)...
[Question] [ Given a positive integer \$n\$, your task is to find out the number of partitions \$a\_1+a\_2+\dots+a\_k=n\$ where each \$a\_j\$ has exactly \$j\$ bits set. For instance, there are \$6\$ such partitions for \$n=14\$: $$\begin{align}&14 = 1\_2+110\_2+111\_2&(1+6+7)\\ &14 = 10\_2+101\_2+111\_2&(2+5+7)\\ ...
[Question] [ In Lisp style languages, a list is usually defined like this: ``` (list 1 2 3) ``` For the purposes of this challenge, all lists will only contain positive integers or other lists. We will also leave out the `list` keyword at the start, so the list will now look like this: ``` (1 2 3) ``` We can get th...
[Question] [ Several months ago I had this question as a pre-screening puzzle for an interview. Recently when thinking about blog material, it popped in my head as a good example to use for solving a problem functionally. I'll post my solution to this as soon as I'm done writing my blog post. NOTE: [This question w...
[Question] [ In [FIPS-197](http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf) (the [Advanced Encryption Standard](http://en.wikipedia.org/wiki/Advanced_Encryption_Standard), known as AES), it is made heavy use of `SubBytes`, which could be implemented as ``` unsigned char SubBytes(unsigned char x) { stati...
[Question] [ I've been developing some programs involving me fetching a vector from a url using Alpha-2 country codes (such as `GET /jp.svg` for Japan). Except, oh no! All the country data on my computer uses Alpha-3! That just won't do... The task is simple: Take an Alpha-3 country code (e.g. `UKR`) and retur...
[Question] [ ## Challenge Given a base \$1 < b < 10\$ and an index \$t \ge 1\$, output term \$x\_t\$, defined as follows: * \$x\_1 = 11\_{10}\$ * \$x\_{i+1}\$ is obtained by converting \$x\_i\$ to base \$b\$ and then reinterpreting its digits in base \$10\$ * Output should be in base \$10\$ A walk through for base ...
[Question] [ Challenge Taken from my university code challenge contest This is actually Day 0 but yesterdays' challenge was too easy and can be a dupe of another question here. --- Tetris is a video game that became popular in the 80s. It consists of placing a series of pieces with different shapes that fall on a b...
[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/132834/edit). Closed 6 years ago. [Improve this question](/posts/132834/edit)...
[Question] [ Write a program that terminates without an error. If any single byte is substituted by any other byte the program should output ``` CORRUPTED ``` * Do not read your source code from a file * Your program should not produce any other output This is [code-golf](/questions/tagged/code-golf "show questions...
[Question] [ I noticed that my car's odometer was at 101101 when I got to work today. Which is a cool number because it's binary (and a palindrome, but that's not important). Now, I want to know when the next time I'll have a binary odometer reading. I can't read the odometer while I'm driving, because that would b...
[Question] [ Write code to determine who wins a four-card trick in a game of [Spades](http://en.wikipedia.org/wiki/Spades). Fewest bytes wins. The input is a string that lists the four cards played in sequence like `TH QC JH 2H` (Ten of Hearts, Queen of Clubs, Jack of Hearts, Two of Hearts). A card is given by two ...
[Question] [ To shuffle a string \$s\$, Alice applies the following algorithm: * She takes the ASCII code of each character, e.g. `"GOLF"` → \$[ 71, 79, 76, 70 ]\$ * She sorts this list from lowest to highest: \$[ 70, 71, 76, 79 ]\$ * She reduces each value modulo the length of the string (4 in this case), leading ...
[Question] [ We can roll up the natural numbers in a rectangular spiral: ``` 17--16--15--14--13 | | 18 5---4---3 12 | | | | 19 6 1---2 11 | | | 20 7---8---9--10 | 21--22--23--24--25 ``` But now that we have them on a rectangular grid we can unwind the spira...
[Question] [ Write a program that translates ASCII text to [braille](https://en.wikipedia.org/wiki/Braille) output. Requirements: * Input may come from stdin, command line, or some other external input source. * Output should be recognisable as braille, the form of output is up to you. An example would be `o` for a...
[Question] [ Choose Your Own Adventure books are a form of interactive literature where the reader must make decisions that affect the outcome of the story. At certain points in the story, the reader has multiple options that can be chosen, each sending the reader to a different page in the book. For example, in a ...
[Question] [ The Dutch system for naming one's ancestors is a lot more interesting than the English version. For English, the sequence goes "parent", "grandparent", "great-grandparent", "great-great-grandparent", "great-great-great-grandparent"; and in Dutch those terms are "ouder", "grootouder", "*over*grootouder"...
[Question] [ Given an integral polynomial \$p\$, determine if \$p\$ is a square of another integral polynomial. An *integral polynomial* is a polynomial with only integers as coefficients. For example, \$x^2+2x+1\$ should gives truthy, because \$x^2+2x+1 = (x+1)^2\$. On the other hand, \$2x^2+4x+2\$ should gives fa...
[Question] [ ## Input An \$m\$ by \$n\$ binary matrix, with \$m\$ and \$n\$ both at least 2. Think of the ones as gobs of melted cheese, which stretch as we expand the matrix horizontally and vertically. More precisely... ## Output A \$2m-1\$ by \$2n-1\$ binary matrix, constructed as follows... First insert rows of...
[Question] [ ### Introduction This challenge is inspired by the Meta Stack Exchange question [The longest consecutive days streak](https://meta.stackexchange.com/q/362489/295232); it turns out that the URL `https://codegolf.stackexchange.com/users/daily-site-access/[user id]`, where the last number is your user ID ...
[Question] [ Let us say that we have a particular set of functions on strings. These functions are kind of like fill in the blanks or madlibs, except that they only take one input and use that to fill in all of their blanks. For example we might have a function that looks like ``` I went to the ____ store and bough...
[Question] [ Take a positive integer \$k\$ as input. Start with \$n := 1\$ and repeatedly increase \$n\$ by the largest integer power of ten \$i\$ such that \$i \le n\$ and \$i + n \le k\$. Repeat until \$n = k\$ and return a list of all intermediate values of \$n\$, including both the initial \$1\$ and the final \...
[Question] [ A [bronze plaque](https://upload.wikimedia.org/wikipedia/commons/3/3a/Emma_Lazarus_plaque.jpg) in the pedestal of the [Statue of Liberty](https://en.wikipedia.org/wiki/Statue_of_Liberty) displays the poem "[The New Colossus](https://en.wikipedia.org/wiki/The_New_Colossus)" by Emma Lazarus, part of whic...
[Question] [ SF(n) is a function which computes the smallest prime factor for a given number n. We'll call T(N) the sum of every SF(n) with 2 <= n <= N. T(1) = 0 (the sum is over 0 summands) T(2) = 2 (2 is the first prime) T(3) = 5 = 2 + 3 T(4) = 7 = 2 + 3 + 2 T(5) = 12 = 2 + 3 + 2 + 5 ... T(10000) = 5786451 The wi...
[Question] [ ![WARNING: Answers may be useful to some code golfers.](https://i.stack.imgur.com/mT3Lt.png) In many [image-processing](/questions/tagged/image-processing "show questions tagged 'image-processing'") challenges, the post contains images, which must be saved to a file in order to be able to work on the p...