What is the Sandbox?

This "Sandbox" is a place where Code Golf users can get feedback on prospective challenges they wish to post to the main page. This is useful because writing a clear and fully specified challenge on the first try can be difficult. There is a much better chance of your challenge being well received if you post it in the Sandbox first.

To post to the Sandbox, scroll to the bottom of this page or click on the "Add Proposal" link below, and click "Answer This Question". Click "OK" when it asks if you really want to add another answer. Write your challenge just as you would when actually posting it. You may also add some notes about specific things you would like to clarify before posting it. Other users will help you improve your challenge by rating and discussing it. When you think your challenge is ready for the public, go ahead and post it, replace the post here with a link to the challenge and delete it.

See the Sandbox FAQ for more information on how to use the Sandbox.

The Sandbox works best if you sort posts by "active".

Add Proposal

Search the Sandbox

Browse your pending proposals

Get the Sandbox Viewer to view the sandbox more easily

To add an inline tag to a proposal use shortcut link syntax with a prefix: [tag:king-of-the-hill]

| |

2973 Answers 2973

87 88
90 91

Quineoid Triple Uniqueness Optimization

This is a variant of Quineoid Triple with the same requirements but different scoring.

Write three different programs such that when any one program is provided as input to one of the other two, you get the source of the remaining program as output. More explicitly, given programs \$A\$, \$B\$, and \$C\$, where \$f(g)\$ denotes the output obtained from inputting the text of program \$g\$ into program \$f\$, all of the following must hold:

  • \$ A(B) = C \$
  • \$ A(C) = B \$
  • \$ B(A) = C \$
  • \$ B(C) = A \$
  • \$ C(A) = B \$
  • \$ C(B) = A \$


The goal is to have the three programs be as different as possible.

Your score is the sum of:

  • Number of unique bytes found in program \$A\$, but not \$B\$ or \$C\$
  • Number of unique bytes found in program \$B\$, but not \$A\$ or \$C\$
  • Number of unique bytes found in program \$C\$, but not \$A\$ or \$B\$

The theoretical maximum score is 256.

Additional Rules

  • Standard quine rules apply.
  • Each program can be in any language. Any number of them may share languages or each may use a different language.
  • Use any convenient IO format as long as each program uses a consistent convention.
    • Functions are allowed, as this counts as "any convenient IO".
  • The result of feeding a program its own source code is undefined
  • The result of feeding anything other than program text of either of the other two programs is undefined.
  • Byte encoding should be taken into account for languages with dedicated codepages.

SANDBOX: this is kind of -ish. Should I call it a bowling challenge?

| |

Anti-codegolf, unique characters


Write a program/method whose source code's characters are unique. You shall put as many characters as you can.


There is no input.

Valid characters

All characters are identified by their Unicode code point. The following characters are invalid, and shall not appear in the source code nor the output:

  • C0 and C1 control characters (U+0000 – U+001F and U+0080 – U+009F) except Character Tabulation (U+0009), Line Feed (U+000A), Line Tabulation (U+000B), Form Feed (U+000C), Carriage Return (U+000D), and Next Line (U+0085)

    • Outputting these characters are banned, even if they have special effect on an output stream.
  • Low and High surrogates (U+D800 – U+DFFF)

  • Noncharacters (U+FDD0 – U+FDEF, and U+xxFFFE and U+xxFFFF for xx = 00 – 10)

  • Code points that are outside of U+0000 – U+10FFFF

A character is valid otherwise. In particular, whitespaces, combining characters, and private uses, and even reserved characters are valid.

Restrictions and output

Your program shall halt.

The output shall be a string. This includes string returned by a function, or string printed to stdout, stderr, a file, or a dialog box.

The set of the characters in the source code shall be a subset of the set of the characters in the output. Note that the output doesn't need to consist of unique characters.

The output may be arbitrarily many strings, for which their concateration will be considered for the restriction above.


This is an anti-codegolf. The submission with the longest source code wins.

| |
  • \$\begingroup\$ Can we output though an error message? \$\endgroup\$ – Adám Aug 24 at 4:37
  • \$\begingroup\$ @Adám I'd permit it. \$\endgroup\$ – Dannyu NDos Aug 24 at 4:45
  • 1
    \$\begingroup\$ Explicitly stating the range of valid codepoints would be useful. \$\endgroup\$ – Bubbler Aug 24 at 4:45
  • \$\begingroup\$ So then any expression that generates an error message containing the offending line, followed by a comment symbol and all the unneeded characters, would be the perfect solution? \$\endgroup\$ – Adám Aug 24 at 4:47
  • \$\begingroup\$ @Adám Welp. Then I should add a restriction. \$\endgroup\$ – Dannyu NDos Aug 24 at 4:48
  • \$\begingroup\$ Be careful about that restriction. Putting restrictions on code is notoriously difficult to get right. \$\endgroup\$ – Adám Aug 24 at 4:49
  • \$\begingroup\$ Also, the languages whose inline comment starts with single char (say Python's # or APL's ), or any esolangs that ignore non-commands will likely get perfect score on any task solvable in that language. \$\endgroup\$ – Bubbler Aug 24 at 4:53
  • \$\begingroup\$ Not only that, many languages could probably just use an unfinished string (i.e. missing the closing quote) containing all the other necessary characters. \$\endgroup\$ – Adám Aug 24 at 5:05
  • \$\begingroup\$ @Adám What about now? \$\endgroup\$ – Dannyu NDos Aug 24 at 5:08
  • \$\begingroup\$ Did you intentionally remove the requirement that the output be longer than the input? \$\endgroup\$ – Adám Aug 24 at 5:10
  • \$\begingroup\$ What are "Reserved characters"? \$\endgroup\$ – Adám Aug 24 at 5:10
  • \$\begingroup\$ @Adám Yes. I tried to find a better restriction. \$\endgroup\$ – Dannyu NDos Aug 24 at 5:10
  • \$\begingroup\$ @Adám Reserved characters are code points that are not assigned a unicode character. \$\endgroup\$ – Dannyu NDos Aug 24 at 5:11
  • 1
    \$\begingroup\$ You've now banned line breaks. Lots of languages will have problems using only one-liners. \$\endgroup\$ – Adám Aug 24 at 5:29
  • 4
    \$\begingroup\$ [code-bowling]. \$\endgroup\$ – user202729 Aug 24 at 5:36

Modular Chain Compression

A common trope in some kolmogorov-complexity challenges is to use repeated application of the modulo operator in order to compress large integers or string hashes into some range. For example, we can squash the numbers \$13,4,16\$ into \$0,1,2\$ by taking each number mod \$7\$ and then mod \$3\$. We call this sequence the modular chain \$7,3\$. In general, reducing a number \$k\$ by the modular chain \$n_1,n_2,\ldots,n_i\$ is equivalent to evaluating

$$(((k\ \text{mod}\ n_1)\ \text{mod}\ n_2)\ \ldots\ )\ \text{mod}\ n_i$$

In this challenge, you will be challenged to compress an arbitrary set of integers in this way. We say the length of the modular chain is the number of elements in the chain (not the number of bytes).


You are given a fixed set of \$100\$ random 32-bit integers. Here they are:

... (more on the actual post) ...


Via whatever means necessary (brute-force, mathematics, etc) design a modular chain to compact these numbers into a small a range as possible. The modular chain must have a distinct output for each input number.


In code-golf challenges, a modular chain is usually desirable if it achieves two things:

  • It compacts the input numbers or hashes into a small range.
  • It is short.

In this spirit, your score is the sum of the maximum output number of your modular chain and the length of your modular chain for the given input numbers.

Note an optimal modular chain could compress the input numbers into the range \$0 \ldots 99\$ with a single modulo operation, making the theoretical minimum score \$99 + 1 = 100\$.

The lowest scoring answer wins. You are encouraged (but not required) to post any code, mathematical background etc. that helped you design your modular chain.

| |
  • \$\begingroup\$ Length in modulo operations or bytes? \$\endgroup\$ – user253751 Aug 25 at 9:41
  • \$\begingroup\$ @user253751 The number of operations. Clarified. \$\endgroup\$ – Sisyphus Aug 25 at 10:28

The fastest code to find a subset-sum

Given k sorted integers from low to high, output n permutations of those integers with sum as close as possible to m but not exceeding m. The output needs to be sorted from highest to lowest sum.


k integers, n, m - as described above. All the k integers and m are positive 31-bit integers. Now since this is NP-complete problem, both k and n are small integers, 20 at most.


One row for each premutation, with integers sorted from high to low. Also, the rows need to be sorted from highest to lowest sum

The fastest code wins

For the performance test, we will use the below input:

  • k = [67, 613, 2111, 2179, 2203, 2269, 3433, 3583, 4219, 5011]
  • m = 14,213
  • n = 10
| |
  • 3
    \$\begingroup\$ 1) You might want to provide multiple test cases, so that the submissions don't use an algorithm that is fast only in some of them and very slow in the others. 2) For fair evaluation of speed, you need to run all submissions on your machine, so you need to provide some information about your machine's OS, RAM, CPU (also GPU if you want to allow using it). 3) Is the sum of all k integers guaranteed to be positive 31-bit integers? Otherwise we might face overflows during calculation. 4) I think you mean subsets instead of permutations. \$\endgroup\$ – Bubbler Aug 28 at 4:42


This challenge is based on a somewhat unusual premise; the goal is to create a rectangular program (box) which is as large as possible, where each row and column will be a solution to a different challenge on this site.

For example, a 3×4 box might look like this:


As all solutions will be read from left to right or top to bottom, this would expand into seven programs:

a 1

For an answer to be valid, each one of these must be a valid solution to a different challenge on this site, in the same language. The box may be padded by whitespace, but must be rectangular (x groups of y bytes, separated by newlines). This is code bowling, so the longest answer in bytes wins.

Additional rules/clarifications:

  • Solutions cannot contain newlines (because otherwise they would be two separate rows/columns)
  • Yes, it will be possible to trivially get very high scores with some languages (like unary), but as with most challenges it's a competition within each language
  • Solutions do not have to be original, but ones copied from other answers should link to them
| |
  • \$\begingroup\$ Unary won't be able to compete because the number of challenges on our site is lower than most Unary programs. It will be very hard to compete even in golfing languages, as the answerer will need to manually find the appropriate challenge to use. I don't really think a challenge that makes use of "all challenges on our site" is fun. \$\endgroup\$ – Bubbler Sep 10 at 1:40
  • \$\begingroup\$ @Bubbler Yeah, now that I think about it I agree. I still like the concept, maybe there's something similar that might actually be fun. \$\endgroup\$ – Redwolf Programs Sep 10 at 2:37
  • \$\begingroup\$ Maybe you could select a subset of challenges - something like what was done for this challenge? \$\endgroup\$ – Dingus Sep 17 at 11:43
  • \$\begingroup\$ @Dingus Good idea! I'll see if I can fix a few other things, too. \$\endgroup\$ – Redwolf Programs Sep 17 at 12:39

Targeted sum and difference of a sequence

You are given two things: a target integer(not necessarily positive) n, and a sorted list/array/etc. of non-negative integers a. (The list will have at least two elements). Your goal is to choose one element of a as your total, and then one by one, take elements of a, and either add or subtract them from your total. Print out all possible combinations(duplicates can be removed, but it is optional) of [a_1]±[a_2]±[a_3] or return them as a list/array/etc. .

In other words, find all solutions to n=[a_1]±[a_2]±[a_3]. The first element of a is not guaranteed to be a_1, nor is the second element guaranteed to be n_2.

Test cases:

n = 10, a = [1,2,3,4] :  10 = 1+2+3+4 and 2+1+3+4 ...
# The output should be 1+2+3+4(and 4+2+3+1, and every combination like that)
n = 1, a = [2,3]: 1 = 3-2, so 3-2. 
# (-2+3 wouldn't work, since it is strictly addition or subtraction of positive integers).
# -2 isn't a part of [2,3]. You should think of the steps as [a_1]±[a_2]±[a_3].
# n = -5, a = [0,5,1]. -5 = 0-5, and nothing else.
n=95, a = [50,50,5]. 95 = 50+50-5, 50-5+50. (A second 50+50-5 is optional)

Criteria: Shortest code wins


Is this clear enough(and what should I do to make this more clear)? Also, has this been done before? Finally, should I remove the restriction on the first number being positive?

Thank You!

| |
  • \$\begingroup\$ What do you mean by "The first element of a is not guaranteed to be a_1"? \$\endgroup\$ – Zgarb Sep 11 at 7:01

Plot a circle


| |
  • \$\begingroup\$ Thanks for the feedback, I changed the question to be more specific. \$\endgroup\$ – Razetime Aug 16 at 10:34
  • 4
    \$\begingroup\$ Eh, i think this would be clearer without the no built-ins rule. For example, would the hypothetical Circle().draw() program be invalid? Neither functions are specifically for drawing circles (assuming Circle() is a function for generating a circle, and draw() can draw an arbitrary shape). If a language somehow has a built-in for drawing a circle, then c'est la vie and just be impressed. \$\endgroup\$ – Jo King Aug 16 at 10:42
  • 3
    \$\begingroup\$ Please read this meta post. \$\endgroup\$ – Adám Aug 16 at 10:45
  • \$\begingroup\$ so basically, allow any method through, so long as it fits the rules. makes sense. \$\endgroup\$ – Razetime Aug 16 at 11:09
  • 1
    \$\begingroup\$ What output is expected if \$x\$ or \$y\$ is less than \$r\$? But actually, I'm not sure that arbitrary centre co-ordinates add much to the challenge. Why not just ask for a circle of radius \$r\$ (centred anywhere such that the whole circle is visible)? \$\endgroup\$ – Dingus Aug 17 at 8:39
  • \$\begingroup\$ I'll change it to a circle at the center of the screen with 5px padding on all sides of the canvas. \$\endgroup\$ – Razetime Aug 17 at 8:42
  • 2
    \$\begingroup\$ I don't think your algorithm works for large circles (I tested via processing.js, but the problem here is in the algorithm, so it doesn't matter) \$\endgroup\$ – the default. Aug 17 at 12:40
  • \$\begingroup\$ oh, sorry about that. Will change it now. \$\endgroup\$ – Razetime Aug 20 at 3:31
  • 1
    \$\begingroup\$ This is still not a circle but a 72-gon (plotting circles seems to be annoyingly complicated; possibly helpful google result: en.wikipedia.org/wiki/Midpoint_circle_algorithm) \$\endgroup\$ – the default. Aug 20 at 3:50
  • \$\begingroup\$ Thanks, that was very helpful. Now it plots a proper circle. \$\endgroup\$ – Razetime Aug 20 at 4:00

A centered hexagonal number is a centered figurate number that represents a hexagon with a dot in the center and all other dots surrounding the center dot in a hexagonal lattice.

Illustration of initial terms:

                                 o o o o
                   o o o        o o o o o
         o o      o o o o      o o o o o o
   o    o o o    o o o o o    o o o o o o o
         o o      o o o o      o o o o o o
                   o o o        o o o o o
                                 o o o o

   1      7          19             37

Write a function that takes an integer \$n\$ and returns "Invalid" if \$n\$ is not a centered hexagonal number or its illustration as a multiline rectangular string otherwise.

Sample Output :-

hexLattice(1) ➞ " o "
// o

hexLattice(7) ➞ "  o o  \n o o o \n  o o  "
//  o o
// o o o
//  o o

hexLattice(19) ➞ "   o o o   \n  o o o o  \n o o o o o \n  o o o o  \n   o o o   "
//   o o o
//  o o o o
// o o o o o
//  o o o o
//   o o o

hexLattice(21) ➞ "Invalid"


Shortest Code Wins!

| |
  • 4
    \$\begingroup\$ I like the challenge concept! Usually, we advise against input validation; that is, rather than outputting "Invalid", solutions should assume the input is valid, though if you do that this challenge is almost a duplicate and so I think in this case it could make for an interesting challenge to leave it in. \$\endgroup\$ – HyperNeutrino Sep 23 at 13:11
  • 4
    \$\begingroup\$ Another thing is usually we encourage flexible input/output formatting; in this case, in addition to a multiline string, I would also allow a list of strings or a matrix of characters as output, and rather than strictly outputting "Invalid", I would suggest allowing solutions to state any reasonable parameters for how they'll indicate invalid input. \$\endgroup\$ – HyperNeutrino Sep 23 at 13:13
  • \$\begingroup\$ Related-ish. There are several other hexagon related challenges but this was the only one I could find that required computing the centred hexagonal numbers. \$\endgroup\$ – FryAmTheEggman Sep 24 at 18:58

Word Length-Sum Multiples

| |
  • \$\begingroup\$ Now that this has been posted, I've edited it down to save space and I'd recommend you delete the proposal \$\endgroup\$ – caird coinheringaahing Sep 25 at 0:15

Double Prime Words

| |
  • 1
    \$\begingroup\$ tags would be decision-problem, code-golf, primes, I think? \$\endgroup\$ – Giuseppe Sep 8 at 19:07
  • 1
    \$\begingroup\$ I think if and only if x is prime should be if and only if n is prime? \$\endgroup\$ – Giuseppe Sep 8 at 19:08
  • \$\begingroup\$ Additional exampleː Is this word a double primeː Hello Worlds aardvark aalii Aani \$\endgroup\$ – Xwtek Sep 10 at 12:36
  • \$\begingroup\$ @Xwtek Is that 4 separate examples, or 1 long example? \$\endgroup\$ – Sumner18 Sep 10 at 15:09
  • \$\begingroup\$ Now that this has been posted, I've edited the post down to save space and I'd recommend you delete this proposal \$\endgroup\$ – caird coinheringaahing Sep 25 at 0:19

\$d\times n\$ dimensional word matrices [WIP]

Given two positive integers \$n\$ and \$d\$, and a list of words \$a\$, produce a \$d\$-dimensional matrix \$m\$ with each dimension having length \$n\$, filled with letters, that contains the words from \$a\$ placed such that they form a directly adjacent contiguous path through the dimensions.

For example, given \$d = 1\$, \$n = 3\$ and \$a = \$['cat'] output one of:




Given \$d = 2\$, \$n = 3\$ and \$a = \$['cat', 'hat', 'mat'] output something similar to:


Given \$d = 3\$, \$n = 3\$ and \$a = \$['low', 'complexity'] output something similar to:




or, if it's easier to visualise in an array structure:

    ['c', 'o', 'q'],
    ['i', 'g', 'w'],
    ['t', 'y', 'p'],
    ['k', 'm', 'c'],
    ['x', 'e', 'o'],
    ['b', 'u', 'f'],
    ['k', 'p', 'r'],
    ['d', 'l', 'l'],
    ['s', 'c', 'm'],

Which contains low at nested indices \$m[2][1][2]\$, \$m[1][1][2]\$, \$m[0][1][2]\$ and complexity at \$m[0][0][0]\$, \$m[0][0][1]\$, \$m[1][0][1]\$, \$m[2][0][1]\$, \$m[2][1][1]\$, \$m[1][1][1]\$, \$m[1][1][0]\$, \$m[0][1][0]\$, \$m[0][2][0]\$, \$m[0][2][1]\$.

I'd like to add some more complicated examples beyond three dimensions here.

Test Cases



  • Unused spaces should be filled with randomly selected letters.
  • There will always be enough space in the dimensions provided to allow the words to be added without re-using letters.
  • There is no requirement to ensure the words don't also appear elsewhere in the grid, so for example if the filler letters happen to spell one of the provided words, that is acceptable.

Questions for meta

  • This seems fun to me, any thoughts?
  • Is it too easy/hard?
  • Any other tags that are relevant?
  • As a follow up, I'd like to have a nested matrix provided and have programs solve it - but that might be better as a fastest-code challenge - is this a reasonable precursor?
| |
  • \$\begingroup\$ Is d^n large enough to contain all the words without sharing letters? \$\endgroup\$ – Bubbler Jul 23 at 8:18
  • \$\begingroup\$ Yeah, you won't have to be concerned with that, I'll add that to the rules. \$\endgroup\$ – Dom Hastings Jul 23 at 8:21

Find a 3-Language Polyglot

What I had in mind was that cops would create a polyglot with in 3 languages (languages A, B, and C). When run in A, the program would print the name of language B; when run in language B, the program would print the name of language C; and when run in C, it would print the name of language A.

Cops have to provide the names of these 3 languages, as well as their original polyglot's characters scrambled in no particular order. as well as a valid program in A that has the same behavior as the polyglot (prints the name of B). This program must be able to be created by deleting characters from the original polyglot, i.e., all the letters in it are included in the hidden polyglot.

Given the languages and the scrambled programand the sample program, robbers have to find the polyglot (or a polyglot that has the same behavior as the one the cop wrote).


  • Any language chosen must be able to be run on TIO, repl.it, ideone, or someplace else online. If the language is obscure, please provide a link to some such website.
  • Any language used must have documentation on Esolangs, Wikipedia, GitHub, or someplace else. Unless the language is very commonly used and has tons of tutorials everywhere, such as Java, Haskell, or C, please provide a link to documentation. Any feature used in the program must be included in that documentation - it shouldn't be something people have to dig through layers of source code to find.

Questions for meta:

  • Is this too easy/hard? Should I not include the extra A program? Should I only make it for 2 languages?
  • Is there anything unclear about the instructions? How can I improve the phrasing?
  • Should cops also give the length of their programs as an extra hint?
| |
  • 1
    \$\begingroup\$ one thing to consider: you would need some way of restricting languages that are allowed. Otherwise people could just make up their own languages or use really, really obscure languages. \$\endgroup\$ – thesilican Aug 18 at 23:04
  • 2
    \$\begingroup\$ IIRC, the usual way to limit the language list is to specify "the language should be on at least one of Wikipedia, TIO, or esolangs.org", though esolangs is already crazy these days. \$\endgroup\$ – Bubbler Aug 19 at 5:05
  • \$\begingroup\$ @Bubbler Yup, I've edited my question with some restrictions now \$\endgroup\$ – user Aug 20 at 15:01

Terminal Punch Card

moved because apparently it's not clear enough.

So back in the day, computers didn't have fancy keyboard and mouse inputs, and didn't have your fancy screens. Instead they had punch cards.

Punch card

Punch cards punchers punched (try saying that 10 times fast) a hole out of a card to represent a 1-bit, and left it filled to represent a 0-bit. The cards were some number of holes wide, with each hole representing a bit in a byte.

Recently, you discovered an old mainframe at your local university that accepted punch cards that were 8 holes wide. For this challenge, you will be given data as an input, and your job is to punch a punch card to the terminal output, like this:

Hello, World!

: *  *   :
: **  * *:
: ** **  :
: ** **  :
: ** ****:
:  * **  :
:  *     :
: * * ***:
: ** ****:
: ***  * :
: ** **  :
: **  *  :
:  *    *:

The input will be a string or bytes representing the punched data payload. The output data must include rows, which start and end with a :, and have 8 bits between them, represented as a for 0, or a * for 1. There must be one row for each byte of data.

Here's the catch: The punch card puncher only punched one hole at a time, so in your program, must print (or add to the output string) only one character at a time.

Example of unacceptable method call:

# `binary` is some string with the binary bits.
print(":" + binary.replace("0", " ").replace("1", "*") + ":")

Acceptable method call:

for bit in binary:
   print(bit == "1" ? "*" : " ", "")

Also acceptable method call:

output = ""
for bit in binary:
   output += bit == "1" ? "*" : " "

The challenge is code golf, so least number of bytes wins. Standard rules/loopholes are in effect.

| |
  • 4
    \$\begingroup\$ A word about catches before we even discuss observability and clarity issues: Catches are rarely a good idea for two reasons. The first is that challenge writers frequently add catches because they somehow feel their challenge is deficient or too easy and want to salvage it somehow. This coping mechanism usually fails, they are better off writing a new challenge. \$\endgroup\$ – Wheat Wizard Oct 4 at 12:17
  • 3
    \$\begingroup\$ Note also there are already comments here regarding observability, assuming language features, and assuming implementation details \$\endgroup\$ – Luis Mendo Oct 4 at 12:19
  • 4
    \$\begingroup\$ The second, which I think is more relevant to you, is that structuring your challenge with a catch is often confusing. You have already written what is a complete challenge, but then in the last 10% or so the whole task changes. Some people don't read the whole challenge once they think they have it, miss the last bit or become frustrated when things are pulled out from under them. Regardless of how you feel about these people, It is really just better to phrase your challenge in a straight forward and upfront way. Nothing should seem tacked on if you can avoid it. \$\endgroup\$ – Wheat Wizard Oct 4 at 12:21
  • 3
    \$\begingroup\$ One way you could easily make your catch observable is to take a string and an index and output the character at that index. Of course answerers can just produce the entire string and index it, but they could already do that with your existing version (probably, it's a little unclear). \$\endgroup\$ – Wheat Wizard Oct 4 at 12:26

Socially distanced seating

Lord Lloyd Warbler wants to minimise the harm to his theatre's seating capacity for his hit show, Birds, of maintaining social distancing.

The social distancing rules in Westendland are:

  • Groups may sit together without distancing
  • Between groups there must be at least 2 empty seats along the row, and 1 empty row in front and behind.
  • The closest diagonal permitted is a knight's move - only 1 horizontal space empty.


 A _ _ B


 A _ _
 _ _ B

Given a list of group sizes and the theatre size (rows and columns), can you pack them all into the theatre? Groups can sit in any contiguous (connected) arrangement of seats.

Sample tests

(Rows, cols), [groups] -> canFitBool
(1,1), [1] -> true
(2,2), [1,1] -> false
(2,3), [1,1] -> true   // knight's move
(5,2), [4,4] -> true   // 2x2 in rows a,b, gap in c, 2x2 in d,e


  • Should I just provide a list of cases of varying difficulty? Like, some of these could be pretty difficult.
  • Is the knight's move rule too complicated?
  • Is the contiguous rule too permissive, and therefore complicated? It could mean some edge cases are possible if you have a weird shaped group. Could make it rectangular blocks only?
| |
  • \$\begingroup\$ Groups can sit in any contiguous (connected) arrangement of seats You need to decide, and specify in the text, if contiguous means 4-connectivity (up, down, left, right) or 8-connectivity (diagonals count as connected too) \$\endgroup\$ – Luis Mendo Oct 4 at 12:17

I have abandoned this challenge. If you would like to take it over, feel free to take the idea, and maybe leave a comment so people know you've taken over.

File Selection

(See revision history)

| |
  • 1
    \$\begingroup\$ "You may not open a file explorer and run the commands" and "No builtin for this exact challenge" - why? This just rules out what could have been an interesting/laughable solution. \$\endgroup\$ – NieDzejkob Nov 27 '17 at 15:37
  • 1
    \$\begingroup\$ @NieDzejkob Yeah but anyone who posts one will probably end up getting a ton of undeserved upvotes having done next to no work. It shouldn't be a huge problem because probably approximately 0 languages have a builtin to do this, but still. \$\endgroup\$ – HyperNeutrino Nov 27 '17 at 15:43
  • \$\begingroup\$ It's kind of implied that there is only one column, but if that's the case that should be explicit as things like Shift-UpArrow function very differently if there are multiple columns. \$\endgroup\$ – AdmBorkBork Nov 29 '17 at 14:55

I have abandoned this challenge. If you would like to take it over, feel free to take the idea, and maybe leave a comment so people know you've taken over.

Balanced City Splitting

(See revision history)

| |
  • \$\begingroup\$ Can't this be done rather easily in O(n)? For fastest code the I/O performance would be the bottleneck. \$\endgroup\$ – user202729 May 22 '19 at 3:59
  • \$\begingroup\$ @user202729 I'll have to think about that; that might be true. I remember I solved it in theory at some point (untested); if so I'll just make it code-golf. \$\endgroup\$ – HyperNeutrino May 22 '19 at 4:00
  • \$\begingroup\$ The test data should be publicly available so that the scoring is objective. \$\endgroup\$ – Peter Taylor May 23 '19 at 14:50
  • 1
    \$\begingroup\$ It's quite easy to do in linear time: pick an arbitrary vertex at which to root the tree and perform DFS, labelling each vertex with the size of the subtree rooted there. Then for each vertex the sizes of the parts remaining if you delete it are the sizes of its children and n-1 minus the sizes of its children; the latter can be calculated and the min and max found in time linear in the number of children, and the sum of the number of children over all vertices is linear in the number of vertices because it's a tree. \$\endgroup\$ – Peter Taylor May 23 '19 at 15:12
  • \$\begingroup\$ @PeterTaylor Right. i remember how to do this now. Thanks, I'll make it code-golf and make examples public once I make them \$\endgroup\$ – HyperNeutrino May 23 '19 at 23:16

AOG Day 2: The Calendar Theft

You wake up and find out that your Advent Calendar has been stolen! Fortunately, it's only been a day, so you could get a new one, but you need to find out who did it so they won't go steal other Advent Calendars or steal yours again later on! You have a few sensors and scanners, but unfortunately it's incomplete, so you want to find and rank your suspects for further investigation.

Your calendar is an MxN rectangle, and your camera caught a bunch of people walking around with packages; however, there's a gift shop near your house so you can't be sure (and the camera footage doesn't seem to show if anyone went into your house). Based on that information, you want to determine who most likely stole your package.


You will be given the dimensions of your calendar and a list of rectangular gifts at the store by their dimensions. You will also be given a list of packages that people are holding as rectangle dimensions.

You are then to rank them by suspicion. A gift is said to fit in a package if its width and height are less than or equal to the package's width and height respectively, or height and width respectively. That is, basically whether or not it is a smaller rectangle, but with right-angle rotations allowed. If someone's package cannot fit your calendar, then they have absolutely no suspicion. Otherwise, the more gifts they can fit, the less suspicious (basically, if they're carrying a larger package, it's more likely that they are just carrying a large gift rather than your calendar).


The input needs to contain the dimensions of the calendar, the dimensions of all of the gifts, and the dimensions of each person's package. You can take these in any reasonable format.

No two gifts will have the same dimensions and no gift will have the same dimensions as the calendar. No two people will have the same package dimensions. Both of these conditions are true even with rotation (so, no 2x3 and 3x2 gifts).


The output should be a two-dimensional list, where each sub-list contains people with the same suspicion level, and the sub-lists are sorted by suspicion level either up or down. You can output this in any reasonable format; as a 2D list, lines of lists, lines of space-separated values, etc.

You may either represent a person by their package dimensions (in which case you must output the width/height in the same order as the input), or by their index in the input list (you can choose any n-indexing).

Rules and Specifications

  • No dimensions will be smaller than 1, and all dimensions are integers. There may be no people or no gifts.
  • Standard loopholes apply, as always.
  • this is a challenge so your score is determined by your code length in bytes with a lower score being better; however, a solution will not be accepted.


  • is this a duplicate (doubt it)?
  • is this too unclear, trivial, or difficult?
  • test cases will come later
  • other suggestions?
| |

Count the strokes of an ASCII character


Given a printable ASCII character (0x21 – 0x7E), count its strokes (as handwritten), then output it.

Note: The strokes are based on how I write the characters. Those with potential controversy are marked * below.


       ! → 2  " → 2  # → 4  $ → 2* % → 3* & → 1* ' → 1
( → 1  ) → 1  * → 3* + → 2  , → 1  - → 1  . → 1  / → 1
0 → 1* 1 → 1* 2 → 1  3 → 1  4 → 2  5 → 2  6 → 1  7 → 2*
8 → 1* 9 → 1  : → 2  ; → 2  < → 1  = → 2  > → 1  ? → 2
@ → 1  A → 3* B → 2  C → 1  D → 2  E → 3* F → 3  G → 2
H → 3  I → 3* J → 1* K → 2* L → 1  M → 4* N → 3* O → 1
P → 2  Q → 1* R → 2  S → 1  T → 2  U → 1  V → 1  W → 1
X → 2  Y → 2  Z → 2* [ → 1  \ → 1  ] → 1  ^ → 1  _ → 1
` → 1  a → 1  b → 1  c → 1  d → 1* e → 1  f → 2  g → 2*
h → 1  i → 2  j → 2  k → 2  l → 1  m → 1  n → 1  o → 1
p → 1  q → 1  r → 1  s → 1  t → 2  u → 1  v → 1  w → 1
x → 2  y → 2  z → 2* { → 1  | → 1  } → 1  ~ → 1


  • Every character outside of U+0021 – U+007E falls in don't care situation.
| |
  • 1
    \$\begingroup\$ There's no requirement for the *s, because people have to follow your specification anyway. If there's a way to solve this beyond simple compression, then this challenge will be good. \$\endgroup\$ – Razetime Oct 15 at 6:29
  • \$\begingroup\$ Can we take input as an ASCII codepoint? \$\endgroup\$ – pxeger Oct 15 at 16:11
  • \$\begingroup\$ Also can I just say how the hell do you write Q with only one stroke? \$\endgroup\$ – pxeger Oct 15 at 16:17
  • \$\begingroup\$ Does "don't care" mean "assume we won't be given this" or "it doesn't matter what you output"? \$\endgroup\$ – pxeger Oct 15 at 16:17
  • \$\begingroup\$ @pxeger ASCII codepoint is acceptable. "Don't care" means both. For the Q, the tail bisects the bowl, so it can be written in one stroke. \$\endgroup\$ – Dannyu NDos Oct 15 at 21:06

(Pan)consummate Vs

An integer \$v\$ is said to be consummate if there is an integer \$n\$ and a base \$b\$ such that \$n\$ divided by the sum of its base \$b\$ digits is equal to \$v\$.

An integer \$v\$ is said to be pansconsummate if it is consummate in all bases \$b\geq 2\$. Panconsummate numbers are A058226 in the OEIS.

Your task:

Write a full program or function that takes a positive integer \$v\$ and returns two distinct, consistent values, one if \$v\$ is panconsummate, and the other if \$v\$ is not. However, the sum of your code's bytes must be panconsummate as well. Your code must work theoretically for any integer, but

Truthy values:

1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 18, 20, 21, 23, 24, 31, 34, 36, 37, 39, 40, 43, 45, 53, 54, 57, 59, 61, 69, 72, 73, 77, 78, 81, 85, 89, 91, 121, 127, 144, 166, 169, 211, 219, 231, 239, 257, 267, 271, 331, 337, 353, 361, 413, 481, 523, 571, 661, 721, 1093, 1291, 3097

Falsey values:

13, 16, 17, 19, 22, 25, 26, 27, 28, 29, 30, 32, 33, 35, 38, 41, 42, 44, 46, 47, 48, 49, 50, 51, 52, 55, 56, 58, 60, 62, 63, 64, 65, 66, 67, 68, 70, 71, 74, 75, 76, 79, 80, 82, 83, 84, 86, 87, 88, 90, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 122, 123, 124, 125, 126, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 167, 168, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200

Note that panconsummate numbers \$v>3097\$ must be at least \$10^6\$, and the OEIS speculates that the truthy values above are all panconsummate numbers.


| |

Convert hexadecimal to decimal

We have a lot of base conversion challenges. Surprisingly, aside from one closed challenge, there aren't any where the goal is purely to convert hexadecimal to decimal. This is different from challenges like converting hexadecimal to binary, because many languages have features like hexadecimal literals (0x, $, etc.) which can do this in a much shorter or more interesting way.


You should create either a program or function, which takes input and output through one of the allowed methods. The input will be a hexadecimal number, consisting of the characters /[0-9a-f]/ (you may choose the capitalization rules).


This is code golf, shortest answer per language wins.

| |
  • \$\begingroup\$ Feedback is of course useful. If the downvote is because this is a dupe or is unnecessary, that would be useful to comment on. Otherwise, I can't fix any issues without knowing what they are. \$\endgroup\$ – Redwolf Programs Oct 17 at 21:11

Is it a Pythagorean triple?

Given three numbers, determine whether they form a primitive Pythagorean triple. Here is the definition:

  • all three numbers are positive integers
  • they represent the side lengths of a right-angled triangle, that is, \$a^2 + b^2 = c^2\$ for any ordering of \$a\$, \$b\$, and \$c\$
  • no other primitive Pythagorean triple exists with the same ratio of side lengths, that is, they are coprime. For example, \$[6, 8, 10]\$ is not a primitive Pythagorean triple, even though it satisfies the above conditions, because the simper \$[3, 4, 5]\$ exists.


  • Unless your language doesn't support them, you must accept floating-point numbers (even though Pythagorean Triples use, by definition, integers)
    • meta: Is this necessary? Is it too restrictive?
  • You may be given negative numbers, \$0\$, or numbers that cannot form any triangle (right-angled or not, i.e. \$a + b \le c\$), in which cases you must return false.
    • meta: Is this necessary? Does it make it too difficult?
  • You can return any two distinct individual values, or any typical truthy/falsey values for your language.
  • Standard I/O and loophole rules apply.
  • This is , so shortest function or full program in bytes wins.

Test Cases

[0, 3, 3] => false
[3, 4, 5] => true
[5, 3, 4] => true
[3, 4, 6] => false
[3, 4, 10] => false
[6, 8, 10] => false
[3.0, 4.0, 5.0] => true
[3.1, 4.0, 5.0] => false
[-3, -4, -5] => false
[3, 4, -5] => false
[4.5, 6, 7.5] => false
[91, 60, 109] => true
[264, 265, 23] => true
[81, 210, 184] => false
[140, 221, 83] => false


  • Are the first two rules necessary, or do they restrict it too much?
  • Is it clear enough? Are there any additional rules I need to add? Are more test cases needed?
  • Does this suit the and tags? It's kind of tangential to both areas.
  • Is this too similar to the existing questions that want you to generate triples?
| |
  • \$\begingroup\$ possible duplicate of this challenge \$\endgroup\$ – Razetime Oct 18 at 13:38
  • \$\begingroup\$ @Razetime that challenge appeared on the front page today and inspired me to make this one. I thought it was different enough because of the coprime requirement and I added the extra rules about invalid values/floats to make it more interesting as well \$\endgroup\$ – pxeger Oct 18 at 14:32
  • \$\begingroup\$ Input validation tends to make for a challenge that is less fun. The coprime requirement is nice, but I'm not sure if it completely changes the challenge. \$\endgroup\$ – Razetime Oct 18 at 15:04
  • 1
    \$\begingroup\$ This seems to me to be too much a combination of two separate generic tasks, checking that a^2+b^2=c^2 when sorted, and that a and b are relatively prime. \$\endgroup\$ – xnor Oct 19 at 9:40

Heavily based on this closed challenge.

Length of a Sumac Sequence

A Sumac sequence starts with two non-zero integers \$t_1\$ and \$t_2.\$

The next term, \$t_3 = t_1 - t_2\$

More generally, \$t_n = t_{n-2} - t_{n-1}\$

The sequence ends when \$t_n ≤ 0\$ (exclusive). No negative integers should be present in the sequence.


Given two integers \$t_1\$ and \$t_2\$, compute the Sumac sequence, and output it's length.

You may take the input in any way (Array, two numbers, etc.)

Test Cases

Taken from the original question.

t1  t2       length   
120  71      5
101  42      3
500  499     4
387  1       3
3    -128    1
| |
  • \$\begingroup\$ "No negative integers should be present in the sequence." That make the last testcase invalid. \$\endgroup\$ – Shaggy Oct 19 at 14:15
  • \$\begingroup\$ ah. I'll remove that. \$\endgroup\$ – Razetime Oct 19 at 14:16

Position my geohashes

The Challenge

This is the reverse challenge of Geohash my positions. Given a Geohash string of length 8, convert it to a latitude and a longitude. The conversion is done by the following algorithm, using u09tunqu as an example input.

  • For each character of the Geohash string, find its 0-indexed position in the map 0123456789bcdefghjkmnpqrstuvwxyz.
    • u09tunqu becomes 26 0 9 25 26 20 22 26
  • Convert each integer into a binary string of length 5.
    • 26 0 9 25 26 20 22 26 becomes 11010 00000 01001 11001 11010 10100 10110 11010
  • Join the binary strings together.
    • 11010 00000 01001 11001 11010 10100 10110 11010 becomes 1101000000010011100111010101001011011010
  • Separate the odd positions in the joined binary string from the even positions. These represent the longitude and latitude, respectively.
    • 1101000000010011100111010101001011011010 becomes 10000001101000011011 (odd positions: longitude) and 11000101011111001100 (even positions: latitude).
  • The latitude should be somewhere in the range (-90, 90). Narrow down the range, based on the first character in the latitude binary string. If the first character is 0, the latitude should converge to the lower half of this range, i.e. (-90, 0). If the first character is 1, the latitude should converge to the upper half of this range, i.e. (0, 90).
    • The 1st character in 11000101011111001100 is 1, so the new range becomes (0, 90).
  • The remaining characters in the binary string are to be processed in the same way, where 0 represents the lower half of the new range and 1 represents the upper half of the new range.
    • The 2nd character in 11000101011111001100 is 1, so the new range becomes (45, 90).
    • The 3rd character in 11000101011111001100 is 0, so the new range becomes (45.0, 67.5).
    • The 4th character in 11000101011111001100 is 0, so the new range becomes (45.0, 56.25).
    • The 5th character in 11000101011111001100 is 0, so the new range becomes (45.0, 50.625).
    • The 6th character in 11000101011111001100 is 1, so the new range becomes (47.8125, 50.625).
    • ...
    • The 20th character in 11000101011111001100 is 0, so the final range becomes (48.85826, 48.85843).
  • The final latitude is the midpoint of the final range.
    • (48.85826, 48.85843) becomes 48.85835
  • Repeat the same process for the longitude, starting from the range (-180, 180)
    • 10000001101000011011 becomes 2.29460
  • Output the final latitude and longitude.
    • u09tunqu becomes 48.85835, 2.29460


A string of length 8, consisting only of the characters 0123456789bcdefghjkmnpqrstuvwxyz.


Two signed floats in the ranges (-90.0, 90.0) and (-180.0, 180.0) representing the corresponding latitude and longitude.

Test cases

u09tunqu → (48.85835, 2.2946)
dr5r7p62 → (40.68933, -74.04459)
stq4s8cf → (29.97525, 31.13783)
75cm2txp → (-22.9519, -43.21043)
usdkfsq8 → (71.17089, 25.78302)
zzzzzzzz → (89.99991, 179.99983)
00000000 → (-89.99991, -179.99983)
ezs42s00 → (42.60507, -5.60286)
7zzzzzzz → (-0.00009, -0.00017)

General remarks

| |

Is a coincident point in a pair of rotated hexagonal lattices closest to the origin?

I've deleted from here because I agree it is takes too much time to understand at the moment.


This is a question where the technique must search or exclude from search all possibilities. As soon as I figure out how to pose it, there will be a separate question for mathematical techniques other than a simple search, so please don't use them here.

Below is quoted from Math SE determining if a coincident point in a pair of rotated hexagonal lattices is closest to the origin?:

A pair of hexagonal lattices with one scaled by the square root of a rational number \$r = \sqrt{\frac{m}{n}}\$ and then rotated will produce a variety of different hexagonal lattices of coincident points.

For the first lattice let

$$x, y = i+\frac{1}{2}j, \ \frac{\sqrt{3}}{2}j$$

and for the second

$$x, y = r\left(k+\frac{1}{2}l\right), \ r\left(\frac{\sqrt{3}}{2}l\right).$$

Per this and this helpful answer the squares of the distances to unit lattice points are given by Loeschian numbers (A003136) equal to \$i^2+ij+j^2\$ so in this case a point \$i, j\$ on the first lattice will coincide with a point \$k, l\$ on the second lattice once rotated by some amount if

$$n(i^2+ij+j^2) = m(k^2+kl+l^2).$$

For example if \$m, n = 13, 7\$ then both \$(i, j) = (5, 6)\$ and \$(6, 5)\$ will coincide with \$(k, l) = (5, 3)\$ at rotation angles of about 5.2 and 11.2 degrees as given by.

$$\theta = \arctan\left( \frac{\frac{\sqrt{3}}{2}l}{k+\frac{1}{2}l} \right) - \arctan\left( \frac{\frac{\sqrt{3}}{2}j}{i+\frac{1}{2}j} \right)$$

However, while the first solution is part of the hexagonal superlattice built on the much closer point \$(i, j), (k, l) = (1, 3), (1, 2)\$ the second point represents the shortest possible coincident distance and therefore a far lower density coincident lattice.

coincident hexagonal lattices

plotting script: https://pastebin.com/pZFCGXbE


Given the rational number (m, n) e.g. (13, 7) and pairs of known coincident lattice points, e.g. (5, 6), (3, 5) or (6, 5), (3, 5) (besides the origin) we want to find out if this is one of the six closest coincident lattice points, or if it is a member of a coincident lattice with points closer.

  • If it's one of the six closest: return some flag letting us know there wasn't anything closer. You may also return either the same point, or one of the other five of identical distance.

  • If it isn't: return one of the six points that was closest along with (but not only) a flag letting us know that a closer point was found and the original point wasn't one of the closest. Reminder that this will be a closer point in a coincident lattice that also contains the original input.

Do this by some combination of searching/testing all possible pairs of lattice points (one from each lattice) to see if they are coincident and closer and potentially excluding blocks of combinations that don't need searching. The problem is finite because one only searches points that aren't obviously farther from the origin.

Feel free to use tricks to exclude large fractions from search as long as they rely on simple rules, for example a point near the origin in one lattice will never be coincident with a point near a distant point in the other.

But if you find yourself considering computations like matrix division or using Eisenstein integers or Euclid's algorithm in the complex plane please save that for the follow-up question.

This is so shortest code wins.


  • Input will have six integers \$(m, n), (i, j), (k, l)\$ as described above, but can have any order or hierarchy, or additional (but uninformative) place holders (e.g. zero padding, blanks...)
  • \$(m, n)\$ will be positive, but the other four can be positive, negative or zero, excluding a \$(0, 0)\$ pair (the origin).

Recipe for making test cases

In addition to the two mentioned above (13, 7), (5, 6), (5, 3) and (13, 7), (6, 5), (5, 3) you can roll your own:

  1. Pick two Loeschian numbers \$L_1\$ and \$L_2\$ and find some integer pairs (i, j), (k, l) that can make them. (Find all integer pairs that produce a given Loeschian number)
  2. Make new pairs by choosing two nonzero integers \$a, b\$, then:

\begin{align} i' & = ai - bj\\ j' & = aj + b(i+j)\\ k' & = ak - bl\\ l' & = al + b(k+l). \end{align}

If \$i, j\$ and \$k, l\$ were coincident, then \$i', j'\$ and \$k', l'\$ will be as well.

(This just says that the coincidence lattice between two hexagonal lattices is also a hexagonal lattice.)

| |

AOG Day 4: Party Decorations

You've figured out exactly how large your room needs to be. However, they only offer rooms in integer side lengths, so looks like calculating the exact dimensions precisely wasn't so necessary. Whoops!

You are planning on decorating your wall with an image. You're hosting this party for a bunch of coders though, so decorating it with some code would be nice. Even better, these all happen to be quine fans, so maybe some self-referential code would be a good talking point.


Write a program or function that, given a width and height, outputs or returns a box of that size containing your code repeated as many times as needed with all whitespace removed (bytes [0, 9, 10, 11, 12, 13, 28, 29, 30, 31, 32] in ASCII encoding). If your program uses a different byte set, you may choose to either remove characters that are equivalent to the characters I specified, or to remove characters with the bytes that I specified, but this must be consistent for all values.


Two integers, W and H in any reasonable format (can be taken reversed).


W*H characters of your code, with all whitespace characters removed, repeated until it's long enough, split into H rows of W length. You may output in any reasonable format, such as a grid, list of strings, matrix of characters, etc.

Testing Program

If you wish to test if your program is correct, you can use this program as a reference implementation / official metric for validity. Enter your code into the Code section and the input as space-separated integers into the Input section, and the output will be what your program should output for those inputs. This removes the exact characters; you can change the part in the Footer after if c not in between the triple-quotes if you have a different character set you need to remove.

Rules and Specifications

  • Your code must contain at least one non-whitespace character (sorry Whitespace programmers).
  • You may not read your source code through a file or via any other direct method, as is standard for quine-related challenges.
  • Standard loopholes apply, as always.
  • this is a challenge so your score is determined by your code length in bytes with a lower score being better; however, a solution will not be accepted.


  • is this a duplicate?
  • is this clear enough?
  • is there anything else in quine challenges that needs to be well specified to make the challenge properly defined / close loopholes?
| |
  • \$\begingroup\$ I don't really understand what the output is and how it is supposed to be related to the input. What does "repeating" code do? When is "enough"? It seems like you are removing newlines. Are we supposed to be wrapping our code around somehow? Are we filling up the box? I tried to look at your tester, but it is not exactly very readable and seems to crash on some inputs. If so you might want to consider what programs consisting of only whitespace are intended to do. \$\endgroup\$ – Wheat Wizard Oct 25 at 16:32

AOG Day 6: Filtering the Playlist

I promise the next one will be better

You've sent the invitations for the party (and made the postperson do a whole lot more work than they should have, smh), made the decorations as interesting as possible (who doesn't love a painstakingly written quine) and made sure that the event won't kill anyone (at least, not due to COVID). The next thing that needs to be planned is the music.

Now, of course, you could go ahead and create a YouTube playlist by hand, but that's way too tedious and, well, predictable. Instead, you've decided to write a program that randomly chooses songs from the music genre (I know...very efficient isn't it).

But of course, there's just one problem with that plan: there's a very small chance that a song selected at random might just ruin the party vibes for everyone (even though people such as myself would consider it a Christmas miracle, others would probably see it as a lame stunt and potentially leave the party).

Thankfully, the magic of code allows us to check the html of the YouTube video before hand to tell if it is indeed a rickroll.

The Challenge

Given a YouTube link as input (not shortened, but a full standard link), retrieve the title and description of the video and output whether or not it is a rickroll. In order for a video to be considered a rickroll, it must have either the unbroken phrase Never Gonna Give You Up or Rickroll in the title or description.

Test Cases

Under construction

| |

Is It A Rainbow Color?


The challenge is to determine whether or not a given color is one of the colors in the rainbow.

When supplied with a color, your program should output a truthy-falsy value indicating whether it is a color of the rainbow, with True equating to it IS a color of the rainbow.


  1. The possible input options is exhaustive, and defined in the test cases. You can assume that you will not receive any other input than the ones define.
  2. Character casing for inputs can be one of: UPPER, lower, Title Case - but cannot be a mixture.
  3. Output should be truthy/falsy, with true correlating to it IS a color of the rainbow.
  4. Standard loopholes not allowed

Test Cases:


  • red
  • orange
  • yellow
  • green
  • blue
  • indigo
  • violet


  • purple
  • brown
  • pink
  • cyan
  • maroon
| |
  • \$\begingroup\$ "obviously not an index" isn't so clear. Is 7 "obviously not an index" if we use 0-based indexing? \$\endgroup\$ – Adám Oct 27 at 23:09
  • \$\begingroup\$ Adding to that: In some languages, -1 and false are valid indices. \$\endgroup\$ – Adám Oct 27 at 23:10
  • \$\begingroup\$ Ok updated it to make it a bit more definitive. \$\endgroup\$ – Scott Oct 27 at 23:35
  • \$\begingroup\$ Doesn't this give an unfair advantage to languages that use -1 for "not found" when asking for an index? Other languages give the next index after the last valid index. \$\endgroup\$ – Adám Oct 27 at 23:37
  • \$\begingroup\$ What would you suggest then? I feel no matter what, there's always going to be some languages that are better suited to a particular challenge. I tried to offer as many ways as possible for handling invalid input to be more language-inclusive. \$\endgroup\$ – Scott Oct 28 at 0:40
  • 1
    \$\begingroup\$ Well, let's take a step back and look at the essence of the challenge. There are two things: a look-up, and the compression of the words. I'd focus on one, i.e. either let "not found" have undefined behavior, or simply be a cover for look-up (given a list and a value, find the index, or … if not found). Since the latter is probably too boring, go with the simple lookup. \$\endgroup\$ – Adám Oct 28 at 0:44
  • \$\begingroup\$ I strongly recommend removing the invalid-input case and just guaranteeing that the input is valid. It means answers don't have to store all valid inputs in some form to check against them, which gives rooms for more interesting methods of fingerprinting. \$\endgroup\$ – xnor 2 days ago
  • \$\begingroup\$ I feel like we've already have some challenge(s) about mapping a set of n strings to the numbers 1 through n, though I don't quite remember what they were or how to find them. The concept is a good one, but it may have been done already. \$\endgroup\$ – xnor 2 days ago
  • \$\begingroup\$ This is some valuable feedback. I agree that we've had some very similar challenges, how would it work if I rework the challenge to be something along the lines of this: output whether a given color is in the rainbow. The possible inputs would be pre-defined and output can be truthy/falsy \$\endgroup\$ – Scott 2 days ago
  • \$\begingroup\$ I can't help thinking this will boil down to a "let xnor find some magic trick that simplifies it significantly and then adapt it to every other programming language" challenge \$\endgroup\$ – pxeger 21 hours ago

Coronavirus Spread

This question is now on the main site here.

| |

Every number is interesting

We know that every number is interesting but how?

You should write a program or function which:

  • takes a list of N positive integers (>0 and <2^31)
  • outputs N lines each of them showing how the corresponding input number is interesting
  • is not longer than 1024 bytes
  • uses no more than 1 second per number
  • doesn't use external sources


172: 444 in base6
5776: 76*76
9801: 9 * 1089 (reverse)
68101: no 11 in base2 (10000101000000101)
491033: 317 * 1549 (product of 2 big primes)
467808816: no digit 5 from base6 to base10


You should include the output for the following input in your post:

58 92 120 224 358 490 912 1578 7812 222008 1645060 19796411 550453633 

If you care to run your program on a bigger sample and share the result with us use this input data (2500 numbers). (You can upload your output to e.g. pastebin.)

This is a popularity-contest so highest voted answer wins.

Tags: popularity-contest, number

| |
  • 1
    \$\begingroup\$ What sort of criteria are necessary for defining a number as 'interesting'? I see things like square numbers, other bases, etc. But are there any specifics? I'm interested in this challenge (but worried it might be closed as too broad). \$\endgroup\$ – ASCIIThenANSI Apr 7 '15 at 13:18
  • \$\begingroup\$ @ASCIIThenANSI There wasn't a clear definition. That's part of the reason why I abandoned the challenge. \$\endgroup\$ – randomra Apr 8 '15 at 1:55
  • 1
    \$\begingroup\$ Would you mind if I tried taking it up? I would have to post as a new answer, because I can't directly edit. \$\endgroup\$ – ASCIIThenANSI Apr 8 '15 at 2:00
  • \$\begingroup\$ @ASCIIThenANSI Not at all. \$\endgroup\$ – randomra Apr 8 '15 at 2:01
  • \$\begingroup\$ @ASCIIThenANSI Where did you post it? \$\endgroup\$ – wizzwizz4 Jul 24 '19 at 13:33
  • \$\begingroup\$ @ASCIIThenANSI I am also curious \$\endgroup\$ – MilkyWay90 Aug 27 '19 at 23:41

Literally just printing the source code

Wait a second. We already have a contest where you print the source code. Right? Wrong.

The challenge

Print out the source code. Not to STDOUT, but to a physical printer.

The rules:

  • You must write a complete program that prints out its own source code with a printer connected to the computer.
  • No STDIN (or input of any kind), STDOUT, or STDERR.
  • No standard loopholes (includes no file input). No using lp(r/d) or similar commands.
  • The printed code should be a reasonable size (between size 8 and 18) and a legible font (pretty much means no wingdings).
  • You may assume that the user doesn't cancel the process and answers affirmatively to any system print dialogs.
  • You can assume that the printer works, is ready, doesn't need new ink/paper, etc.
  • If the language doesn't support printing, it is ineligible.
  • This is so shortest code, in bytes, wins.
| |
  • \$\begingroup\$ This is a trivial extension of the quine challenge. All you have to do is say you're running it on Unix/Linux and pipe the output to lpr. \$\endgroup\$ – user45941 Nov 1 '15 at 22:21
  • \$\begingroup\$ This needs a much tighter spec on the hardware. E.g. I assume you would consider it cheating to post an ordinary quine and say "On this computer, all console output is also logged to a continuous print spool", but there are computers which are configured like that for audit reasons. \$\endgroup\$ – Peter Taylor Nov 2 '15 at 14:39
87 88
90 91

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .