# 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 your first try can be difficult, and there is a much better chance of your challenge being well received if you post it in the Sandbox first.

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

# Natural Order Sorting

Goal :: Writing a sorting algorithm that doesn't need preceding zeroes to sort music files properly.

Natural Order Sorting will be defined in this way:

• Consecutive Digits (ie [0-9]+) are considered one character and its value is the evaluation of those digits as an integer (eg int("0123"))
• Uppercase Letters (ie [A-Z]) are each their own character and its value is the ASCII value of the letter
• Lowercase Letters (ie [a-z]) are each their own character and its value is the corresponding uppercase value plus .5
• Symbols (ie [^0-z]) are each their own character and its value is the ASCII value of the symbol
• Symbols are always before Digits which are always before Letters
• If two characters are in the same category, the one with the small value precedes the other

## Specification

• Input :: An unordered list of strings (flexible on how)
• Output :: A list of strings that are naturally ordered (flexible on how)
• Victory :: Shortest program/function in bytes, wins

## Test Cases

Input                             Output
-----                             ------
10,11,8,9                      -> 8,9,10,11
appleA,CiderB,AppleC           -> AppleC,appleA,CiderB
File1,File12,File143A,File031B -> File1,File2,File031B,File143A


## Source code standard deviation

Your program should accept as input a string, convert it to a unsigned byte array using UTF-8 encoding and output the standard deviation of the n bytes.

Standard deviation is given by this formula, where x1...xn are the string's bytes:

Example

Input hello:

• UTF-8 encoding returns the list [104,101,108,108,111]
• mean is 106.4
• standard deviation is 3.49857113690718

More test cases:

• ppcg: 5.678908345800274
• aaaaa: 0
• azazaz: 12.5
• smiley☺: 41.12432220162674

Scoring

Your score is the standard deviation of your source code, using the above algorithm, divided by the length of your source in bytes, using UTF-8 encoding. The higher the better.

For example, the score for the program hello is: 3.49857113690718 / 5 = 0.699714227381436

Related: Calculate Standard Deviation

• Programs can pad their standard deviation by including a huge number of the highest and lowest possible character in equal amounts in a comment. – xnor Jan 12 '17 at 6:18
• @xnor yes, but after some time, the score decreases when adding these characters. For example, hello scores 0.69, hello ÿ scores 6.15, hello ÿ ÿ scores 5.31. – Arnaud Jan 12 '17 at 7:08
• I see you now this doesn't raise your score arbitrarily, though the numbers I'm getting are different. – xnor Jan 12 '17 at 7:19
• @xnor I think you need to use statistics.pstdev, not statistics.stdev – Arnaud Jan 12 '17 at 7:31
• So an answer in Unary is guaranteed to score 0? – Peter Taylor Jan 12 '17 at 10:40
• @PeterTaylor yes, an answer in Unary is guaranteed to lose, as the higher score the better. – Arnaud Jan 12 '17 at 10:42
• @SuperChafouin I see. Putting in pstdev still gives different numbers from yours. – xnor Jan 12 '17 at 21:45
• ÿ is interpreted by the python command ord as integer 255 - while it should be the two bytes 0xC3 0xBF. – Arnaud Jan 13 '17 at 4:09

## The many errors of twin primes

Note: this is a repost of my earlier challenge, but with a different winning condition and better rules.

## Background

Bob was handed the following assignment for his programming class (this is not the actual challenge).

Homework assignment 11: Twin primes

Take as input an integer n ≥ 8 and print a single character, depending on n:

• If n is not a prime number, print N for "Not prime".
• If n is a prime number, but neither of n - 2 and n + 2 is, print I for "Isolated prime".
• If n and n + 2 are both prime numbers, print L for "Lower twin prime".
• If n and n - 2 are both prime numbers, print U for "Upper twin prime".

Bob tried hard to solve the assignment, but his program kept crashing, and in the end, he gave up and submitted it in hope of partial credit. Nevertheless, Bob's program has the curious property that even though it never does what it's supposed to, the input is still classified correctly depending on the program's behavior: non-primes result in no output, isolated primes in a crash, lower twin primes in an infinite loop with no output, and upper twin primes in an infinite loop that keeps printing the correct message.

Your task is to replicate the behavior or Bob's solution: you shall write a program or function that behaves as follows. Your input is a single integer n ≥ 8.

1. If n is not a prime number, print nothing and exit gracefully.
2. If n is a prime number, but none of n - 2 or n + 2 is, print nothing and exit with a runtime error of some kind (like stack overflow or division by 0).
3. If n and n + 2 are both prime numbers, print nothing and keep running indefinitely (or until you run out of memory).
4. If n and n - 2 are both prime numbers, repeatedly print the character U to STDOUT indefinitely (or until you run out of memory). The output can contain newlines, commas or other separators.

Input can be taken with any of our default methods, but all output must go to STDOUT (and STDERR in case of error) or closest alternative.

The lowest byte count wins.

## Test cases

8 -> [no output]
9 -> [no output]
10 -> [no output]
11 -> [infinite loop]
12 -> [no output]
13 -> UUUUUUUUU[continues indefinitely]
14 -> [no output]
15 -> [no output]
16 -> [no output]
17 -> [infinite loop]
18 -> [no output]
19 -> UUUUUUUUU[continues indefinitely]
20 -> [no output]
21 -> [no output]
22 -> [no output]
23 -> [runtime error]
29 -> [infinite loop]
31 -> UUUUUUUUU[continues indefinitely]
37 -> [runtime error]


## Sandbox notes

To keep the rules simple, I decided to only allow output to STDOUT.

• that's not really simplifying? couldn't you allow functions, but mandate output through stdout and stderr? – Destructible Lemon Jan 5 '17 at 9:30
• @DestructibleWatermelon Yeah, that's actually much more reasonable. – Zgarb Jan 12 '17 at 7:49
• Would it not be better to edit the previous question and try to get it reopened? – Peter Taylor Jan 12 '17 at 16:28
• @PeterTaylor Ideally, yes. But it has existing answers, which are not competitive at all in a pure golf context. Won't that be an issue? – Zgarb Jan 12 '17 at 18:15
• Hmm. I noticed that golfing was taken into account in the previous scoring system, but I didn't notice that 2 out of the 3 answers didn't golf. I retract my previous suggestion. – Peter Taylor Jan 12 '17 at 19:47

# Prime Factors that Weren't there Before

Given a list of integers a, calculate the prime factorization for each integer in the array. Then, return a list of factors that do not appear in the original input, even as part of another number. For instance, if you were given:

a = [1243,11311]

The prime factors would be calculated as:

a' = [[11, 113], [11311]] = []

Because 11 appears in 11311, and 113 appears in 11311, the result would be [], an empty set.

Lets look at another example:

a = [270,325,192] = [[2, 3, 3, 3, 5], [5, 5, 13], [2, 2, 2, 2, 2, 2, 3]] = [13]

Another example:

a = [27072,32585,19296] a' = [[2, 2, 2, 2, 2, 2, 3, 3, 47], [5, 7, 7, 7, 19], [2, 2, 2, 2, 2, 3, 3, 67]] a'' = [47,67]

A bigger example:

a = [56,3924,10000,1240124]
a' = [[2, 2, 2, 7], [2, 2, 3, 3, 109], [2, 2, 2, 2, 5, 5, 5, 5], [2, 2, 31, 73, 137]]
a'' = [7,109,31,73,137]

This is code golf, lowest byte-count wins.

# Play time

Hello. It is time to play the most popular portuguese card game: Sueca! So for people who does not know the game, it is needed to print a wall poster to make them know the power and the points each card has.

So, the job is to print an ASCII art wall as:

    11        10        4         3         2        ———       ———       ———       ———       ———

╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮
|A     A| |7     7| |R     R| |V     V| |D     D| |6     6| |5     5| |4     4| |3     3| |2     2|
|♥     ♥| |♥     ♥| |♥    /♥| |♥    /♥| |♥    /♥| |♥     ♥| |♥     ♥| |♥     ♥| |♥     ♥| |♥     ♥|
|       | |  ♥ ♥  | | ♔ /  | | ♗ /  | |  ♕ /  | |  ♥ ♥  | |  ♥ ♥  | |  ♥ ♥  | |       | |   ♥   |
|   ♥   | |   ♥   | |   /   | |   /   | |   /   | |  ♥ ♥  | |   ♥   | |       | |  ♥ ♥  | |       |
|       | |  ♥ ♥  | |  / ♔ | |  / ♗ | |  / ♕  | |  ♥ ♥  | |  ♥ ♥  | |  ♥ ♥  | |   ♥   | |   ♥   |
|A     A| |7 ♥ ♥ 7| |R/    R| |V/    V| |D/    D| |6     6| |5     5| |4     4| |3     3| |2     2|
|♥     ♥| |♥     ♥| |♥     ♥| |♥     ♥| |♥     ♥| |♥     ♥| |♥     ♥| |♥     ♥| |♥     ♥| |♥     ♥|
╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯

╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮
|A     A| |7     7| |R     R| |V     V| |D     D| |6     6| |5     5| |4     4| |3     3| |2     2|
|♦     ♦| |♦     ♦| |♦    /♦| |♦    /♦| |♦    /♦| |♦     ♦| |♦     ♦| |♦     ♦| |♦     ♦| |♦     ♦|
|       | |  ♦ ♦  | | ♔ /  | | ♗ /  | |  ♕ /  | |  ♦ ♦  | |  ♦ ♦  | |  ♦ ♦  | |       | |   ♦   |
|   ♦   | |   ♦   | |   /   | |   /   | |   /   | |  ♦ ♦  | |   ♦   | |       | |  ♦ ♦  | |       |
|       | |  ♦ ♦  | |  / ♔ | |  / ♗ | |   / ♕ | |  ♦ ♦  | |  ♦ ♦  | |  ♦ ♦  | |   ♦   | |   ♦   |
|A     A| |7 ♦ ♦ 7| |R/    R| |V/    V| |D/    D| |6     6| |5     5| |4     4| |3     3| |2     2|
|♦     ♦| |♦     ♦| |♦     ♦| |♦     ♦| |♦     ♦| |♦     ♦| |♦     ♦| |♦     ♦| |♦     ♦| |♦     ♦|
╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯

╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮
|A     A| |7     7| |R     R| |V     V| |D     D| |6     6| |5     5| |4     4| |3     3| |2     2|
|♣     ♣| |♣     ♣| |♣    /♣| |♣    /♣| |♣    /♣| |♣     ♣| |♣     ♣| |♣     ♣| |♣     ♣| |♣     ♣|
|       | |  ♣ ♣  | | ♚ /  | | ♝ /  | |  ♛ /  | |  ♣ ♣  | |  ♣ ♣  | |  ♣ ♣  | |       | |   ♣   |
|   ♣   | |   ♣   | |   /   | |   /   | |   /   | |  ♣ ♣  | |   ♣   | |       | |  ♣ ♣  | |       |
|       | |  ♣ ♣  | |  / ♚ | |  / ♝ | |  / ♛  | |  ♣ ♣  | |  ♣ ♣  | |  ♣ ♣  | |   ♣   | |   ♣   |
|A     A| |7 ♣ ♣ 7| |R/    R| |V/    V| |D/    D| |6     6| |5     5| |4     4| |3     3| |2     2|
|♣     ♣| |♣     ♣| |♣     ♣| |♣     ♣| |♣     ♣| |♣     ♣| |♣     ♣| |♣     ♣| |♣     ♣| |♣     ♣|
╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯

╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮ ╭───────╮
|A     A| |7     7| |R     R| |V     V| |D     D| |6     6| |5     5| |4     4| |3     3| |2     2|
|♠     ♠| |♠     ♠| |♠    /♠| |♠    /♠| |♠    /♠| |♠     ♠| |♠     ♠| |♠     ♠| |♠     ♠| |♠     ♠|
|       | |  ♠ ♠  | | ♚ /  | |  ♝/  | |  ♛ /  | |  ♠ ♠  | |  ♠ ♠  | |  ♠ ♠  | |       | |   ♠   |
|   ♠   | |   ♠   | |   /   | |   /   | |   /   | |  ♠ ♠  | |   ♠   | |       | |  ♠ ♠  | |       |
|       | |  ♠ ♠  | |  / ♚ | |  / ♝ | |  / ♛  | |  ♠ ♠  | |  ♠ ♠  | |  ♠ ♠  | |   ♠   | |   ♠   |
|A     A| |7 ♠ ♠ 7| |R/    R| |V/    V| |D/    D| |6     6| |5     5| |4     4| |3     3| |2     2|
|♠     ♠| |♠     ♠| |♠     ♠| |♠     ♠| |♠     ♠| |♠     ♠| |♠     ♠| |♠     ♠| |♠     ♠| |♠     ♠|
╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯ ╰───────╯

• You should specify which specific characters should be used. Of note, several of the ones you used don't appear to fall in the ASCII range. – FryAmTheEggman Jan 13 '17 at 0:51
• @FryAmTheEggman: Should I call it Unicode Art? – sergiol Jan 13 '17 at 1:30
• @FryAmTheEggman If you know better chars than ♔♗♕ ♚ ♝ ♛ for me to put in the question, please tell me. I don't like the effect they have on the white space width after them. – sergiol Jan 13 '17 at 1:33
• I'm afraid I don't know of any better characters, but yes, that would be less confusing. I still think adding the exact character codes would be a good idea. – FryAmTheEggman Jan 13 '17 at 1:47
• The "ascii-art" looks aweful in my browser (firefox on win): i.stack.imgur.com/keYgN.jpg – flawr Jan 13 '17 at 14:48
• @flawr: In mine (Vivaldi on Windows) they look better: i.imgur.com/OIILDbB.png but not perfectly drawn; it is due to the chess Unicode characters. I am waiting for opinions on better characters, please. The queen card (D) seems a lot the King card! The Jack (V) doesn't even seem to be a Jack! And the King (R) also does not seem the King! – sergiol Jan 13 '17 at 19:42

# Left-to-Right calculator

Given the opinion I posted on https://ux.stackexchange.com/a/99984/51560 , I want to have a calculator where the least-significant least digits are placed on the left.

The input must come from stdin. It only needs to support non-negative integers. Additions must support any number of parcels, and to end the input of parcels input an empty line. In every example, all above the first ——— line is input, the first ——— line itself and the lines below are output.

Example:

+
2134
254
89
————
0684


Subtractions input is always composed by two operators:

-
3351547
945613
———————
4894317


Multiplications input is also two operands.Must support at multiplications where the second operator is < 100 and output the auxiliary addition like the way it is done by hand.

*
94651
74
———————
345901
69526
———————
305537


# Contiguous Palindromic Subsequencing

Given a word a, perform the following operations:

1. Group string into palindromic subsequences of length > 2 and non-palindromic subsequences. (You should prioritize partition length over partition index, for instance esse shouldn't result in ['e','ss','e'], it should be ['esse']. However, if the lengths are the same for two subsequences, use index to prioritize which you choose).
2. Make all non-palindromic subsequences palindromic (single characters are palindromic here).
3. Put it back together.

You may assume only printable ASCII characters are used.

# Examples:

raggamuffin -> ['r','agga','muffin'] -> ['r','agga','muffiniffum'] -> raggamuffiniffum

bananaracecar -> ['b','anana','racecar'] -> ['b','anana','racecar'] -> Unchanged.

(Since each palindrome grouping would be the same length, use the first one).
SIZE OF GROUP > INDEX OF GROUP
abaca -> ['aba', 'ca'] -> ['aba','cac'] -> abacac

(Always choose the bigger palindrome, THEN go by index)
cheesewheels -> ['che','ese','wh','ee','ls'] -> ['chehc','ese','whw','ee','lsl'] -> chehcesewhweelsl

(Always choose the bigger palindrome, THEN go by index)
1223224 -> [1,22322,4] -> Unchanged.

abbabbababbababba -> ['a', 'bb', 'abbababbababba'] -> Unchanged.

abcdefg -> ['abcdefg'] -> ['abcdefgfedcba'] -> abcdefgfedcba

slammedintoacardoor -> ['sla', 'mm', 'edinto', 'aca', 'rd', 'oo', 'r'] -> ['slals', 'mm', 'edintotnide', 'aca', 'rdr', 'oo', 'r'] -> slalsmmedeintotniacardroor

eeefffgegffhi -> ['eee','f','ffgegff','hi'] -> ['eee','f','ffgegff','hih'] -> eeefffgegffhih

This will be , lowest byte-count wins.

• The term "subsequence" doesn't usually imply that they are contiguous. ac is a subsequence of abc. You should either use "substring" or "contiguous subsequence" to avoid confusion. – Martin Ender Jan 13 '17 at 8:42
• I can't tell whether this is covered by any of your test cases, but it's also not explicitly mentioned in the rules, what about a test case like abaca. Is it ab,aca or aba,ca, since the palindromes have the same length? What about abacada? aba,c,ada? ab,aca,da? – Martin Ender Jan 13 '17 at 8:46
• Also, string challenges should specify which characters can appear in the input. – Martin Ender Jan 13 '17 at 8:46
• In test case slammedintoacardoor, shouldn't ed and into be combined into one substring? – Zgarb Jan 13 '17 at 12:09
• @MartinEnder I worded it wrong, you should be prioritizing length of substring, THEN position. So it would be aba,ca. – Magic Octopus Urn Jan 13 '17 at 14:43
• @Zgarb yes, you're right. – Magic Octopus Urn Jan 13 '17 at 14:43
• @MartinEnder aba,c,ada because aba is before both aca and ada using index. Then ada and c are what would be prioritized to be grouped next. – Magic Octopus Urn Jan 13 '17 at 15:49

# 1 line ASCII Domino play

The game is described on my own question I posted on Domino game maximum achievable points.

The rules for scoring are on the link, and I am reposting them here:

The rules for scoring are: every time a part is placed, if the sum of both ends of the dominoes chain is a multiple of 5, you add it to you current score.

example: [4|2] [2|1] makes 5 points

A double (every part where the two halfes are equal) is always placed rotated by 90º; so for accounting purposes, unlike other pieces, both sides ot the part are taken into account.

Example:

___       ___
|6|       |4|
——— [6|4] ———
|6|       |4|
———       ———


makes for 20 points.

One single part placed accounts as the two tips.

Example [2|3] accounts as 5 points

And

___
|5|
———
|5|
———  accounts as 10 points.


The challenge is to write a game that is an ASCII one line domino game for me to play.

Rules:

• You must output to stderr/stdout
• Line Width is 80 chars
• The first two chars are reserved for displaying points, aligned at right. By definition, it will always be a multiple of 5; and the third is always a space
• Given space is limited:

• Every join of two parts will conjoin and they will be separed by a | they will share instead of ][
• Double parts (those where the two halves are equal) will be represented abbreviate:

• [ | ] => [ ]
• [1|1] => [=]
• [2|2] => [+]
• [3|3] => [*]
• [4|4] => [&]
• [5|5] => [X]
• [6|6] => [%]
• Except for white double, all whites are represented by only the other half
• Every other part is represented by [NM], where N and M are the number of each half
• The ends of the whole dominoes chain are always terminated by []
• The initial state is an empty table. First piece placed will be at the center
• When chain begins to not fit, at one of the ends, it must be adjusted to fit by pushing the whole placing a little bit to the left or the right.
• The last 3 chars of the line are reserved for user input. User can only input a piece not yet placed. User input is NM which is displayed; and a keypress of + or - which will NOT be displayed to avoid a newline feed. The key press tells what side of the chain will the new piece will be snapped:
• - to left
• + to right
• It also must validate the snapping. If user snaps to a non-matching piece, just do nothing. The program will NOT be smart enough to make guesses; so it will NOT make a piece to snap on the other side if piece does not match user specified side
• And after each valid placing of a piece, must update the points display if there are some to score.

Example of an INVALID placed chain, containing a sequence which would not be possible, because there are pieces snapped to not-matching pieces.

  5 [ |=|+|*|&|X|%|1|2|3|4|5|6|12|13|14|15|16|23|24|25|26|34|35|36|45|46|56] 12{+}


The {+} is not displayed, it is there just to illustrate the input:

• I find this rather confusing. After reading it three times I think I begin to understand the spec, but 1. Why those random characters for the doubles? IMO !@#$%& would be preferable: it's easy to refer to for people with a US-layout keyboard, and it corresponds to the ASCII characters at an offset of 32 from the digits. 2. What's all that about ][? The question should be self-contained: don't confuse things by assuming that people have read another related question. 3. Following on from that, you should explain the scoring. – Peter Taylor Jan 13 '17 at 13:30 • 4. Don't give an example of an invalid chain: the example which would be actually useful is a valid chain. 5. Doesn't the abbreviated form for 0s create ambiguities? If the board is currently [6] then which is valid out of 46-, 46+, 64-, 64+, 4-, 4+? 6. What's the initial state? Empty board, and either of - or + does the same thing? – Peter Taylor Jan 13 '17 at 13:31 • @PeterTaylor: Those chars have been decided on the appearance they have. = seems [11] rotated vertically; + being a four-point star is the most similar I get to [22]; the same goes for * as it is a 6 point star; & seems an 8, which are the points of [44]; X is an way to say 10, which are the number points of a [55]; % seems to have a 10 and a 2 number implicit on it, as the slash and final ball seem a 10, and the existent balls are two, then twelve which are the points of [66]. – sergiol Jan 14 '17 at 12:04 • Given the space is limited, the joining of two pieces must conjoin, so ][ becomes | to save space. Example: [23][34] becomes [23|34] – sergiol Jan 14 '17 at 12:09 • Reproduced ipsis verbis from the link the rules for scoring. – sergiol Jan 14 '17 at 13:29 • @trichoplax: It is clearly stated: "User can only input a piece not yet placed". There are only 28 dominoes and the statement makes clear there are no repetitions. I am already getting issues trying to put the whole chain in only one line and you want to make the problem even worse?! – sergiol Jan 14 '17 at 14:48 • @PeterTaylor :Just made clear The initial state is an empty table – sergiol Jan 14 '17 at 15:02 • @trichoplax: I upvoted your comment: Is there a missing second half of sentence after "When chain begins to not fit"?.Sentence is now fixed! – sergiol Jan 14 '17 at 15:03 • My apologies for overlooking "User can only input a piece not yet placed". I've deleted both my comments now that they have been addressed. – trichoplax Jan 14 '17 at 17:41 • @trichoplax: I made now clear the program will not have any kind of "smartness". So if user specifies 64- and left side is not a 4, placing is simply rejected. – sergiol Jan 14 '17 at 18:32 ## Graphical Borromean Rings Here is an SVG rendering of the Borromean Rings: <svg xmlns="http://www.w3.org/2000/svg" height="200" width="200"> <defs> <radialGradient id="green"> <stop stop-color="transparent" offset="70%"/> <stop stop-color="#0F0" offset="75%"/> <stop stop-color="#CFC" offset="85%"/> <stop stop-color="#0F0" offset="95%"/> <stop stop-color="transparent" offset="100%"/> </radialGradient> <radialGradient id="blue"> <stop stop-color="transparent" offset="70%"/> <stop stop-color="#00F" offset="75%"/> <stop stop-color="#CCF" offset="85%"/> <stop stop-color="#00F" offset="95%"/> <stop stop-color="transparent" offset="100%"/> </radialGradient> <radialGradient id="red"> <stop stop-color="transparent" offset="70%"/> <stop stop-color="#F00" offset="75%"/> <stop stop-color="#FCC" offset="85%"/> <stop stop-color="#F00" offset="95%"/> <stop stop-color="transparent" offset="100%"/> </radialGradient> <mask height="100" width="100" y="0" x="0" id="back"> <rect fill="#FFF" height="100" width="50" y="0" x="0"/> <rect fill="#FFF" height="50" width="50" y="25" x="50"/> </mask> <mask height="100" width="100" y="0" x="0" id="front"> <rect fill="#FFF" height="25" width="50" y="0" x="50"/> <rect fill="#FFF" height="25" width="50" y="75" x="50"/> </mask> </defs> <circle mask="url(#back)" fill="url(#green)" r="50" cy="50" cx="50"/> <circle fill="url(#blue)" r="50" cy="93.3" cx="75"/> <circle fill="url(#red)" r="50" cy="50" cx="100"/> <circle mask="url(#front)" fill="url(#green)" r="50" cy="50" cx="50"/> </svg> Please write a full program to generate a which resembles the above rendering reasonably well. In particular: • Solid colours, aliased pixels or overlap artefacts are not acceptable • Your colours should contrast with each other • Your circles must default to at least 100px in diameter (I wanted larger circles in my snippet but I get a scroll bar if I try) • Your circles must have the appearance of overlapping impossibly • Rotations and reflections are perfectly acceptable Output is via any generally acceptable output format e.g. writing to vector or raster image format or displaying directly to the screen. This is , so the shortest program wins. Related: ASCII Borromean Rings • – DLosc Jan 19 '17 at 10:35 • @DLosc Well, those are interlocking rings... Borromean rings don't interlock in pairs ;-) – Neil Jan 19 '17 at 16:25 # Number that includes the amount of digits of itself Create a number where each digit represents the amount of this digit the number itself contains. Maybe my english is too bad to describe it clearly so here is an example: 6210001000 explanation: 6 -> this number contains 6 times '0' 2 -> this number contains 2 times '1' 1 -> this number contains 1 time '2' 0 -> this number contains 0 times '3' 0 -> this number contains 0 times '4' 0 -> this number contains 0 times '5' 1 -> this number contains 1 time '6' 0 -> this number contains 0 times '7' 0 -> this number contains 0 times '8' 0 -> this number contains 0 times '9'  We will call those numbers self-describing. Each self-describing number must be 10 digits long to be able to represent all digits from 0 to 9. I have two possible goals for this challenge: 1. Create a program which prints out all self-describing numbers in the range 0000000000 < X < 99999999999 2. For a given integer in the range 0000000000 < X < 99999999999 print out true if it's a self-describing number, else false. I can add further examples and rules if i move it out of the sandbox. • @Fatalize Yes my bad i will search for a correct number – izlin Jan 16 '17 at 15:52 • "I can add further examples": no, you can't. That's the only one. If you want to get an interesting question out of this you're going to have to open it up to other bases. – Peter Taylor Jan 16 '17 at 17:11 • – user62131 Jan 18 '17 at 19:45 # Digit stream with no 42 You should write a program or function which receives no input and outputs a stream of digits. • The stream should contain at least once every positive integer number which does not contain the digit sequence 42. E.g. The string 1231 contains the integers 1 12 123 1231 2 23 231 3 31 (and 1 again) • The stream should not contain the digit sequence 42. • If your interpreter can't handle infinite output gracefully you can add code to only print the first n digits. This added code does not count to your score. • Note that the stream 203204205... contains 42. • No randomness should be used. This is code-golf so the shortest entry wins. Do we have infinite output tag? • I think you need to say something about random numbers. Either require that the program always outputs the same stream or be very specific about requirements on the RNG for an answer which outputs random digits avoiding 2 when the previous one was a 4. – Peter Taylor Jan 18 '17 at 12:30 • @PeterTaylor Right, forbidding randomness is probably the cleanest solution. Showing whether an RNG-using code solves the problem seems pretty complex. – randomra Jan 18 '17 at 15:13 • So a program that always prints 1234567890 will satisfy this, or am I missing something? – Magic Octopus Urn Jan 18 '17 at 20:33 • @carusocomputing The stream should contain every integer not just every digit. E.g. 1234567891011121314... fulfills this point. – randomra Jan 18 '17 at 23:29 # Where am I? (Some other tags pls help) Your task in this challenge is to output the location of the user. This may be done by means of GeoIP, a builtin GPS device, or any other means. Output should either be in the format (latitude, longitude) accurate to at least one degree, or (City, [optional state/province/etc], Country). Errors due to the GPS device being inaccurate or similar which are not the fault of your code are allowed. Fewest bytes wins. • Accurate to one degree? Holy hell, do you know how much one degree is? google.com/maps/dir/11.00000,+2.000000/10,1/… – Magic Octopus Urn Jan 18 '17 at 20:09 • Also, this is more or less "output the location of the users ISP"... – Magic Octopus Urn Jan 18 '17 at 20:10 • @carusocomputing one degree of Latitude/Longitude. That's just 11, 2. – Pavel Jan 18 '17 at 20:16 • I was just pointing out that if you look at 10,1 compared to 11,2 it's in a different country. If you say closest to the nearest degree the answers will not be constant. – Magic Octopus Urn Jan 18 '17 at 20:31 • @carusocomputing Oh, I misunderstood. I know 1 degree is a lot, but I think it's good enough. It requires actually finding the location rather than relying on other information, which is all that's really needed. This way could cut out some code necessary for formatting which isn't part of the challenge. – Pavel Jan 18 '17 at 20:36 • Ping the router. Ask the router where it is. Done. (No idea if this would work) – SIGSTACKFAULT Jan 22 '17 at 15:49 # Do you accept me? ## Introduction Being accepted is very important to people. But words are also people (right!?). So they also want to be accepted. However most people work non-deterministically and as such it's only fair to transfer that into our decision whether we accept a word. Of course, because a stupid human can't remember much the instructions to decide whether to accept a word must be short... ## Input Your input will be • a list of non-negative integers - the "word" (this is easier than using strings and actual alphabets) • a list of triples of non-negative integers - the transitions, you may also use unordered data structures here • an integer - the starting state • a list of non-negative integers - the accepting states, you may also use unordered data structures here You may use any other object or whatever than integers if it pleases you. ## Output A truthy or a falsey value. ## What to do? Basically implement an NFA. That is, read every single character (ie every number) from left to right and for each one of them look whether there exist a transition from your current state using this character. If so follow it and repeat the process for the next letter. If you face an empty list, your current state must be in the list of accepted states if it is output true and stop examining other paths if it isn't continue examining the other options. If you get stuck (ie the word isn't empty but there's no way to continue), output false. ## Who wins? This is so the shortest answer in bytes wins. ## Examples For the following examples I'm going to use this automaton: which has starting state 10, accepting states [13] and transitions [(10,4,11), (11,4,11), (11,1,12), (12,1,12), (12,3,13), (13,3,13), (11,3,13)]  These three parameters are assumed to be also passed in the examples. Word examples for this automaton are: [1,2,3,4] -> false [4,1,3,4] -> false [4,1,3] -> true [4,1,3,3,3] -> true [2,1,3,4,3,2] -> false [4,1,4] -> false [4,3,1] -> false [4,3,3] -> true  • I'm aware of this other challenge but truly believe that mine is different enough because a) it uses relations instead of a function b) it only asks for NFAs and not for three different automatons c) it asks for truthy / false instead of hard-coded strings d) it's not limited to strings e) it doesn't assume an implicit starting state. – SEJPM Jan 19 '17 at 11:24 # Simulate a vibrating string Vibrations are an integral part of physics. In this challenge, you will be implementing a simulation of a vibrating string. This is actually rather easy to do as a result of the Huygens–Fresnel principle, which allows us to use a simulation process similar to cellular automata. (don't have time to write a full spec right now. Also, I have a 2D version working but figured 1D was enough for a challenge) Below is an example of a string vibrating at its second harmonic, with each row being 1 tick of the simulation.  1.00 2.00 1.00 -1.00 -2.00 -1.00 0.95 1.90 0.95 -0.95 -1.90 -0.95 0.85 1.70 0.85 -0.85 -1.70 -0.85 0.71 1.42 0.71 -0.71 -1.42 -0.71 0.54 1.07 0.54 -0.54 -1.07 -0.54 0.33 0.67 0.33 -0.33 -0.67 -0.33 0.11 0.23 0.11 -0.11 -0.23 -0.11 -0.11 -0.22 -0.11 0.11 0.22 0.11 -0.33 -0.66 -0.33 0.33 0.66 0.33 -0.53 -1.07 -0.53 0.53 1.07 0.53 -0.71 -1.42 -0.71 0.71 1.42 0.71 -0.85 -1.70 -0.85 0.85 1.70 0.85 -0.95 -1.90 -0.95 0.95 1.90 0.95 -1.00 -2.00 -1.00 1.00 2.00 1.00  This challenge is based off the math found on this website. # Task Scheduling code-golf Given as input: • A unix time at which to first run the program • Delay between runs (can be 0) • Number of times to run the program (-1 if infinite) • A program to be run through the console when triggered Run the program under specified conditions. • You can assume your program will always be running • Run the equivalent of nohup <command> &. • What happens if the unix time is before now? What is the delay measured in? What should I do if the delay is 0? What do you mean by "You can assume your program is always running?" Isn't the ability to keep my program running up to my program?. nohup is not a command I'm familiar with, so I'd definitely explain that. – Nathan Merrill Jan 20 '17 at 17:05 • @NathanMerrill 1. undefined behavor, ie do whatever you want 2. seconds 3. undefined behavior 4. if you want to 5. it isn't? – noɥʇʎԀʎzɐɹƆ Jan 20 '17 at 18:17 • All of that needs to be in the in the post. – Nathan Merrill Jan 20 '17 at 18:19 ## The many names of Túrin Tolkien's character Túrin had a multiple personality disorder and consequently needed to change name on a regular basis to be called by something fitting its current mood. He has been known as Turambar, Mormegil, Gorthol, Adanedhel, Dagnir Glaurunga, the Wildman of the Woods, Neithan and some other unofficial nicknames alluding to his tenderness for his sister. This must have been a real headache for the author: not only had he to find the new names but he also had to remember the translation in English1, since every new name is introduced along the lines of "From this day he was known as [Compound_Elvish_word], that is [Word of word]" Your task is to automatize the production of epithets to help Tolkien finish his Unfinished Tales. Given a list of Sindarin2 substantives and their English translations (see list below) as an external file, a list or any reasonable format, randomly take two Sindarin substantives (repetition is possible) and print "From this day he was known as Sindarin1sindarin2, that is English2 of English1" (Note the inversion of words in the translation, and the capitalisation) Input: none Output: A string The list: (names can be capitalized in your own list, but the formatting must be consistent. The order of the couples can also be changed) Sindarin English -------------------- amarth fate ang iron aur morning brethil birch carch fang celeb silver draug wolf galad glittering glor light gwathel sister manadh doom megil sword melethron lover mor darkness naur flame taur forest  Examples: • From this day he was known as Galadaur, that is Morning of Glittering • From this day he was known as Mormelethron, that is Lover of Darkness • From this day he was known as Draugdraug, that is Wolf of Wolf Hobbits played golf and Codë was the Vala of challenges in the Silmarillion, so this is . 1 Sorry, Tolkien specialists, I'm probably massacring Quenya, Sindarin and many other concepts 2 I think • Children do visit this website, so if you consider something unsuitable for them, do not mention it at all, even to hint at avoiding mentioning it. – trichoplax Jan 20 '17 at 15:32 • Changed as asked, the example as well. – drolex Jan 20 '17 at 15:48 • 1. Substantives are far more commonly called nouns in English. 2. This would be a more interesting challenge if the word list had a lot of common substrings to exploit for compression. Maybe it would work better with a fictional language rather than Sindarin? – Peter Taylor Jan 20 '17 at 22:32 # Minimum exchange of bills You're at the supermarket, buying groceries for the week. At the end, the cashier rings up your cart and declares that your total cost is exactly $76. You reach into your wallet, and find a $50, four $20s, and a $1, for a total of six bills. We consider a transaction to be you paying money to the cashier, and the cashier giving you your change (if applicable). Your total for a transaction is the net amount of money you owe the cashier, which is calculated by the amount you pay less the amount of change you get. We can think of a transaction as adding the bills you pay to the cashier, and subtracting the bills you get in return. Thus, the following is a non-exhaustive list of possible transactions in this scenario: $50 + $20 +$20 - $10 -$1 - $1 -$1 - $1 (8 bills)$20 + $20 +$20 + $20 -$1 - $1 -$1 - $1 (8 bills)$20 + $20 +$20 + $20 +$1 - $5 (6 bills)$50 + $20 +$20 + $1 -$10 - $5 (6 bills)  Given a total of$76, and having 1 $50, 4$20s, and 1 $1, the minimum exchange of bills comes out to 6 bills. ## Challenge Given an integer Bill and a list of bills in your wallet [Ones Fives Tens Twenties Fifties Hundreds], calculate the number of bills in a minimum exchange of bills between you and the cashier. ## Rules 1. Your program can accept your input in any reasonable way. You can accept an integer followed by a list of six integers separated by reasonable means. You can accept seven integers separated by any reasonable means. If your language cannot accept input in any reasonable form, you may, at no penalty, hardcode the input into your program. You may only hardcode input if your language cannot reasonably accept meaningful input. 2. Your program must output the number of bills in the minimum exchange transaction. Your program may not print any of the possible transactions themselves. 3. You may assume that you will always have enough money to cover your bill, possibly requiring some change from the cashier. 4. You may assume that the cashier has an unlimited number of all bills at their disposal. 5. You may assume that all inputs are non-negative integers. It is possible that your bill comes out to$0. No integer input will ever be greater than 1000. That's too many bills and quite frankly, too many groceries.
6. This is , so fewest bytes wins.

## Test cases

Input                        Output
[76,1,0,0,4,1,0]              6


I'll come up with and post some more test cases if people think this is a good challenge.

## Possible bonus challenge:

In the United States, a $2 is a rare, but legal, bill issued by the treasury. If you wish, you can have your program accept another integer, between the number of Ones and Fives, representing the number of$2-bills you have in your wallet, which you can use to pay for your groceries. However, since such bills are so uncommon, the cashier will not have any on-hand to give to you as change.

• Never allow arbitrary separators in the input, at least without some length limit; some languages may be able to slip the entire program in there. The easiest method is normally to say that the program takes a list of integers as input via any reasonable means; we have various rulings on Meta about which means are reasonable, and that saves you having to duplicate it in your challenge. I'd recommend against the bonus challenge, by the way; it just makes entries harder to compare. – user62131 Jan 20 '17 at 17:24
• Essentially the making change problem ( codegolf.stackexchange.com/q/70847/194 and probably others) but adding negative value coins (bills). There's a risk it will be closed as dupe; it's borderline enough that I wouldn't cast a supervote. One thing I will suggest, as I have in the past on this type of question, is making the coin (bill) system be input rather than hard-coded. That way you can forget about the bonus challenge and the question feels a bit less culture-specific. – Peter Taylor Jan 20 '17 at 22:26
• I vote no on \$2 bills, that sounds like it doesn't add much. – Magic Octopus Urn Jan 23 '17 at 19:39

# loripsum.net

The purpose of this challenge is to emulate the functionality of the loripsum.net website. This website takes in a "number of paragraphs" and a list of randomized HTML5 stylizations and outputs a pre-formatted HTML5 lorem ipsum text that is REALLY good for placeholders on a prototype website. Your code, however, will focus more on the stylization aspect of this website.

Given a block of lorem ipsum text in the following format:

<segment> := <paragraph> | <paragraph><new-line><segment>

<paragraph> := <sentence> | <sentence><paragraph>

<sentence> := <character_run><sentence_end>

<character_run> := <printable_ascii_without_newline_or_period>|<pawnop><character_run>

<sentence_end> := \n | . | ? | !

Here's an example of a possible input:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quonam, inquit, modo? Progredientibus autem aetatibus sensim tardeve potius quasi nosmet ipsos cognoscimus. Quod non faceret, si in voluptate summum bonum poneret. Duo Reges: constructio interrete.

Tubulo putas dicere? Cum salvum esse flentes sui respondissent, rogavit essentne fusi hostes. Dat enim intervalla et relaxat. Satisne ergo pudori consulat, si quis sine teste libidini pareat? Negare non possum. An hoc usque quaque, aliter in vita? Plane idem, inquit, et maxima quidem, qua fieri nulla maior potest. Quid ei reliquisti, nisi te, quoquo modo loqueretur, intellegere, quid diceret?

Itaque ad tempus ad Pisonem omnes. Universa enim illorum ratione cum tota vestra confligendum puto. Haec dicuntur inconstantissime. Dicimus aliquem hilare vivere; Qui non moveatur et offensione turpitudinis et comprobatione honestatis? Sed quot homines, tot sententiae; Quippe: habes enim a rhetoribus; Omnes enim iucundum motum, quo sensus hilaretur. Tria genera bonorum; Profectus in exilium Tubulus statim nec respondere ausus;

Certe non potest. Dempta enim aeternitate nihilo beatior Iuppiter quam Epicurus; Graece donan, Latine voluptatem vocant. Itaque a sapientia praecipitur se ipsam, si usus sit, sapiens ut relinquat. Quid est igitur, inquit, quod requiras? Atque haec coniunctio confusioque virtutum tamen a philosophis ratione quadam distinguitur. Ego vero volo in virtute vim esse quam maximam;

Verum hoc idem saepe faciamus. Huic mori optimum esse propter desperationem sapientiae, illi propter spem vivere. Si enim ita est, vide ne facinus facias, cum mori suadeas. Indicant pueri, in quibus ut in speculis natura cernitur. Apparet statim, quae sint officia, quae actiones. An est aliquid per se ipsum flagitiosum, etiamsi nulla comitetur infamia? Non autem hoc: igitur ne illud quidem. Res enim se praeclare habebat, et quidem in utraque parte.

Your task, given the input t from above, is to apply one formatting operations at random once per paragraph, defined by the following list of operations:

• Character Run Operations (Should be performed on 1-5 word runs chosen at random. This should NEVER cross sentence boundaries (\n|.|?|!))
• Bold <b></b>
• Italic <i></i>
• Underline <u></u>
• Sentence Operations (Should be performed on 1-2 sentences in the paragraph)
• Block Quote <blockquote></blockquote>
• Preface <pre></pre>
• Heading <h1></h1> ... <h6></h6> (Chosen at random)
• Paragraph Operations (Should turn entire paragraph into this format, separated by sentences if the operation is segmented (like a list)).
• Unordered List <ul><li>Sentence 1</li>...<li>Sentence n</li></ul>
• Ordered List <ol><li>Sentence 1</li>...<li>Sentence n</li></ol>

So, here is one possible random output:

[1:HEADING(h1 chosen),2:BOLD(4 times),3:PREFACE(1 sentence),4:UNORDERED-LIST,5:BLOCKQUOTE(2 sentences)]


Applied to the input from above (t):

# Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Quonam, inquit, modo? Progredientibus autem aetatibus sensim tardeve potius quasi nosmet ipsos cognoscimus. Quod non faceret, si in voluptate summum bonum poneret. Duo Reges: constructio interrete.

Tubulo putas dicere? Cum salvum esse flentes sui respondissent, rogavit essentne fusi hostes. Dat enim intervalla et relaxat. Satisne ergo pudori consulat, si quis sine teste libidini pareat? Negare non possum. An hoc usque quaque, aliter in vita? Plane idem, inquit, et maxima quidem, qua fieri nulla maior potest. Quid ei reliquisti, nisi te, quoquo modo loqueretur, intellegere, quid diceret?

Itaque ad tempus ad Pisonem omnes. Universa enim illorum ratione cum tota vestra confligendum puto. Haec dicuntur inconstantissime. Dicimus aliquem hilare vivere; Qui non moveatur et offensione turpitudinis et comprobatione honestatis?

Sed quot homines, tot sententiae;
Quippe: habes enim a rhetoribus; Omnes enim iucundum motum, quo sensus
hilaretur.
Tria genera bonorum; Profectus in exilium Tubulus statim nec respondere ausus;

• Certe non potest.
• Dempta enim aeternitate nihilo beatior Iuppiter quam Epicurus; Graece donan, Latine voluptatem vocant.
• Itaque a sapientia praecipitur se ipsam, si usus sit, sapiens ut relinquat.
• Quid est igitur, inquit, quod requiras? Atque haec coniunctio confusioque virtutum tamen a philosophis ratione quadam distinguitur.
• Ego vero volo in virtute vim esse quam maximam;

Verum hoc idem saepe faciamus. Huic mori optimum esse propter desperationem sapientiae, illi propter spem vivere.
Si enim ita est, vide ne facinus facias, cum mori suadeas. Indicant pueri, in quibus ut in speculis natura cernitur. Apparet statim, quae sint officia, quae actiones. An est aliquid per se ipsum flagitiosum, etiamsi nulla comitetur infamia? Non autem hoc: igitur ne illud quidem. Res enim se praeclare habebat, et quidem in utraque parte.

Wow! Isn't that much prettier? Here's the code view:

<h1>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</h1> Quonam, inquit, modo? Progredientibus autem aetatibus sensim tardeve potius quasi nosmet ipsos cognoscimus. Quod non faceret, si in voluptate summum bonum poneret. Duo Reges: constructio interrete.

Tubulo <b>putas dicere</b>? Cum salvum esse flentes sui respondissent, rogavit <b>essentne fusi</b> hostes. Dat enim intervalla et relaxat. <b>Satisne ergo pudori consulat, si quis sine</b> teste libidini pareat? Negare non possum. An hoc usque quaque, aliter in <b>vita</b>? Plane idem, inquit, et maxima quidem, qua fieri nulla maior potest. Quid ei reliquisti, nisi te, quoquo modo loqueretur, intellegere, quid diceret?

Itaque ad tempus ad Pisonem omnes. Universa enim illorum ratione cum tota vestra confligendum puto. Haec dicuntur inconstantissime. Dicimus aliquem hilare vivere; Qui non moveatur et offensione turpitudinis et comprobatione honestatis? <pre>Sed quot homines, tot sententiae; Quippe: habes enim a rhetoribus; Omnes enim iucundum motum, quo sensus hilaretur.</pre> Tria genera bonorum; Profectus in exilium Tubulus statim nec respondere ausus;

<ul><li>Certe non potest.</li><li>Dempta enim aeternitate nihilo beatior Iuppiter quam Epicurus; Graece donan, Latine voluptatem vocant.</li><li>Itaque a sapientia praecipitur se ipsam, si usus sit, sapiens ut relinquat.</li><li>Quid est igitur, inquit, quod requiras? Atque haec coniunctio confusioque virtutum tamen a philosophis ratione quadam distinguitur.</li><li>Ego vero volo in virtute vim esse quam maximam;</li></ul>

<blockquote>Verum hoc idem saepe faciamus. Huic mori optimum esse propter desperationem sapientiae, illi propter spem vivere.</blockquote>Si enim ita est, vide ne facinus facias, cum mori suadeas. Indicant pueri, in quibus ut in speculis natura cernitur. Apparet statim, quae sint officia, quae actiones. An est aliquid per se ipsum flagitiosum, etiamsi nulla comitetur infamia? Non autem hoc: igitur ne illud quidem. Res enim se praeclare habebat, et quidem in utraque parte.


Take note specifically of how I split the sentences on the paragraph operators, you delimit by ONLY periods and NEWLINES, nothing else ends a sentence. Also, make not of how the character run operators can span multiple words, BUT NOT MULTIPLE SENTENCES, you must stop before the next sentence begins (EXCLUDING THE ENDING NEWLINE OR PERIOD). As in, it's only applicable to the <character_run> language definition.

This is lowest byte-count will be declared the winner.

• I think you're missing ; from <sentence_end>. I also don't see any sentences ending in \n, but perhaps you were referring to the end of a paragraph? Also, I think the <paragraph> rule should be <sentence> | <sentence><paragraph>. – ETHproductions Jan 20 '17 at 2:27
• @ETHproductions that sentence doesn't end due to the ;, rather it ends due to the newline. – Magic Octopus Urn Jan 20 '17 at 18:20
• Coulda sworn at least one person would like this haha. – Magic Octopus Urn Jan 26 '17 at 14:55
• Are you sure about character runs including any ASCII char except newline or period? I would restrict it to [A-Za-z ], at least for the most part. – ETHproductions Jan 26 '17 at 16:41

## Find square sum products integermath

It's possible to find sets of three numbers whose product including their sum is a square number. Examples:

• (3 + 2 + 1) * 3 * 2 * 1 = 6²
• (3 + 3 + 2) * 3 * 3 * 2 = 12²
• (4 + 4 + 1) * 4 * 4 * 1 = 12²
• (9 + 8 + 1) * 9 * 8 * 1 = 36²
• (8 + 5 + 5) * 8 * 5 * 5 = 60²
• (8 + 7 + 6) * 8 * 7 * 6 = 84²
• (9 + 8 + 8) * 9 * 8 * 8 = 120²

Please write a program or function to find square sum products for me.

Since there are an infinite number of square sum products, even excluding trivial multiples, you should limit your output to depend on a characteristic number N. Your program should always output the same square sum product(s) for a given N, and there should be at least one value of N for each possible square sum product that will cause your program to output that product. However, I will be flexible in what N actually represents, as long as you describe it in your answer. Here are some examples:

• N is one sixth[citation needed] of the square root of the square sum products. For example, an N of 2 would find the second and third of my examples.
• N is the upper bound of the largest summand. For example, an N of 9 would find all of my examples and then some.
• N is the number of square sum products to be found. For example, an N of 12 would find all of my examples and then some.

For the output, I don't actually want the summands or the square root. Instead, please output the pairwise sum of the summands. Please also exclude duplicates (i.e. reorderings) from your answer.

This is , so the shortest program wins!

• You can drop the first [citation needed]: if (a, b, c) is a valid triple, then so is (a*k, b*k, c*k) for k integral. – Sp3000 Jan 21 '17 at 11:43
• @Sp3000 Sure, but that's a trivial case. I'm pretty sure there are infinite nontrivial cases too. – Neil Jan 21 '17 at 11:48
• My point was just that an infinite number do exist, so you can drop the superscript. I'm sure you could come up with something less trivial if you really wanted, like (2*k*k+4*k+2, 2*k*k+4*k+3, 1) – Sp3000 Jan 21 '17 at 12:03
• @Sp3000 Indeed, you can generate a subset by multiplying a triangular number by 4, and taking that number twice with a final 1. – Neil Jan 21 '17 at 13:28
• I find the proposed relationship between input and output too vague, and also open to abuse. For example, I could say that every single N outputs 6^2 unless N is of the form 2^a 3^b 5^c where a,b,c generate a square sum product. Why not just pick a spec, for example, that N is the upper bound of the largest summand? – Greg Martin Jan 26 '17 at 8:36
• @GregMartin I didn't want to be overly restrictive because on other sandbox posts I atttracted comments complaining about what I chose to spec, but I guess some sort of restriction is necessary, sigh... – Neil Jan 27 '17 at 0:33
• I agree that it's not always clear what will make the best challenge...! – Greg Martin Jan 27 '17 at 0:38

# Dual Kimian (Error) and Regular Quine Polyglot code-golfpolyglotquine

Create a program that is

• a non-erroring proper quine in one language...
• ...and a proper quine that produces its own source code through an error in another language

### What is an error quine?

The compiler/interpreter/runtime to produce error output when compiling/running your program which is identical to your program's source code.

• Your program may be specific to a particular version or implementation of your language's compiler/interpreter/runtime environment. If so, please specify the particulars.
• Only standard compiler/interpreter/runtime options are permitted. You cannot pass some weird flag to your compiler to get a specific result.
• The program does not need to be syntactically or semantically valid.
• The program must not produce any output of its own (e.g. by calling print or an output function). All output generated upon attempting to compile/run the program must originate from the compiler/interpreter/runtime.
• The complete output of the compiler/interpreter/runtime must be exactly identical to your program source code.
• The compiler/interpreter/runtime must generate at least one error message when invoked with your program.

(adapted from nneonneo's "Make an error quine!" challenge)

• Polyglots from different versions of the same language or similar languages are allowed
• Related. – user62131 Jan 22 '17 at 2:40
• I fear the spec here isn't clear enough to prevent people using absurd definitions of what counts as an error, like happened in my attempt. (For example, what happens if you throw a string, and the runtime's unhandled-exception handler prints it? Some people consider that to be an error, and it's printed by the runtime, but the text is entirely under user control.) – user62131 Jan 22 '17 at 2:45

# Sandbox Questions

• Is it a good idea to post this as a separate challenge? This one is significantly easier and I fear that posting it would take too much attention away from the original challenge.

Write a program that outputs

NOT CORRUPTED


If any single bit is substituted by the alternate bit the program should output

CORRUPTED

• Isn't this already a question? If so why not just replace it with a link to the question? – user63571 Jan 22 '17 at 17:52

The challenge is dedicated to pseudo-graphical representation of objects, e.g. like by ascii-art. Puzzle is geometrical: to represent bistrings as beads using tiles. The result must be beads-like strings where one is more like a bead and zero is more like a stem (or smaller bead). The solution can result in wide variety of visual concept but there are specific guides, see below.

A simple example of binary beads using single tiles, here standard characters:
Input: 1001, 0101, 0011.
Output:

s--s
-s-s
--ss


or e.g. PETSCII console:

So these are only example form, but now you must "upscale" it, but since you are not in graphical mode, the resulting image must be structure of source units, i.e. it must be a rectangular tiling. In other words. it is not allowed just to draw sprites for each next upscale step. So the whole must be a real console app or code which emulates the console behaviour itself within the guidelines. So you can draw any tiles and use them also. Solution should show some reference to console output, e.g. if using graphical lib, a "print" function should be made which takes the data.

The task is to write an application or function wich draws scalable yet visually consistent beads with efective usage of tiles. Tilesets with least amount of tiles and yet with outstanding rich beads look must win. In other words, one should find good relation between tiles amount and good possibility to present different sizes.

One can present different length strings, but the whole layout must be of adequate size. Multiple words on line is allowed and even welcome especially if shows interesting use case.
Usage of graphical libs is welcome, e.g. to emulate a simple console-like output.
All tiles can be custom, i.e. this should not be necessarily standard characters of console. In real console any characters possible can be used or patched with custom tiles if possible. Any OS can be used.

## Restrictions:

Final image:

• must include at least 2 different types of beads (different sizes), i.e. interesting scalability example
• structures should be good visible from various distance and contiguos as possible
• "zero=stem, ones=bead" rule is not strict, creativity is very welcome but it should be not too far from rule to compare results
• artiscism in forms is always bonus points!

Tiles:

• maximal amount of tiles in the tileset : 16
• are rectangular, e.g 16x8, 8x8 pixels ...
• minimal size: 6x6, maximal size: 24x24 pixels
• only two-color but the whole image can have more colors.

Code:

• Non-cryptic plain code: C, Python, Basic, Fortran and those not too far from it
• hacks (e.g. for old platforms) should be documented somehow and reproducable in theory

# Points given for:

• less unique tiles yet with rich possibilities
• visual consistence by each beads type presented, but two types must not necesserily have same style
• Hint: even within one type, the look of one bead can vary but the whole string easily decodable
• interesting scaling possibilities, e.g. parametric scaling
• fullfill the restrictions
• less operations and minimalistic code
• working application, e.g. interactive counter or a micro-game is welcome

Solution publishing:

• title: amount of tiles used and pixel sizes info
• visual examples easy to follow
• notes about interesting sides of solution
• code and some explanation

Sandbox note: If there are unclear point, free to point to corrections. Please suppose better tags if needed.

• I really like this challenge, though I'd remove the "only monochrome mode is allowed" rule to give the designers more freedom. I'd also include only the first primitive output example, and add a line stating that users are free to format this, since all these examples might push all answers roughly in the same direction. Maybe you can make an answer as well, since the PETSCII example looks great! – Luke Jan 20 '17 at 10:59
• I fear that this question is too broad for a popularity-contest. There are two primary problems: 1. The judgement criterion (which clock is most useful to low-sighted people) does not naturally gather votes. You are far more likely to get upvoted answers that are funny and interesting. 2. The challenge isn't really about programming, but about design. – Nathan Merrill Jan 20 '17 at 17:00
• If you are wanting design help, ux.stackexchange is great for that. If you want people to implement a specific clock, then make objective requirements, and change the challenge type :) – Nathan Merrill Jan 20 '17 at 17:01
• Hi @NathanMerrill, thanks for input. The aim is not for people with low vision, it is just background, I will make that point more clear. And do you mean design challenge is not welcome here? My idea was exactly to challenge different designs with few restrictions. – Mikhail V Jan 20 '17 at 17:50
• Right. Design questions aren't a good fit for this site. – Nathan Merrill Jan 20 '17 at 17:55

## Rainbow Cat Program

Recently, I remembered a program I'd written in C# a while back for fun. It takes a string as input, then outputs that same string, cycling through a rainbow of colours. I now realize that this is basically a cat program, but with the added complexity of the output changing colour every 100ms. So I figured it would make an interesting challenge.

The aim is to make your own "rainbow cat program", taking a string as input, and outputting that same string cycling through the following colours in sequence: red, yellow, green, blue, purple, and pink. Not quite a proper rainbow, but close enough. The colours must change every 100ms (or as close to 100ms as your chosen language will allow).

For reference, here's an extremely badly-golfed version of my original C# program (370 bytes):

using System;using System.Threading;class P{static void Main(){var a=Console.ReadLine();for(;;){L(a,ConsoleColor.Red);L(a,ConsoleColor.Yellow);L(a,ConsoleColor.Green);L(a,ConsoleColor.Blue);L(a,ConsoleColor.DarkMagenta);L(a,ConsoleColor.Magenta);}}static void L(string a,ConsoleColor b){Console.Clear();Console.ForegroundColor=b;Console.WriteLine(a);Thread.Sleep(100);}}


And a gif of it in action!

# Other Rules

• Trailing whitespace/newlines are allowed; printing so many newlines that you push the text off the screen, then writing it again in the next colour, is not allowed. You must physically clear the screen and rewrite the text rather than writing it out over and over.
• Once the cycle starts, it should continue indefinitely without any user input.
• Standard golfing loopholes apply.
• This is , so shortest program wins. Feel free to compete for the shortest program in any given language, though: don't feel put off by the golfing languages!

# Avoiding Averages

Given a non-empty list of positive integers, reorder the list such that for every pair of indices, the average of the values at those indices is not contained in any index between them.

# Rules

• This is so the shortest code wins.

Work in-progress

• Maybe add some sample input->output? – Leo Jan 23 '17 at 15:41
• I like this, but there's also not much here. Maybe add a picture of a kitten or some I/O like Leo said. – Magic Octopus Urn Jan 23 '17 at 19:33
• Can we expect the input to be valid, or if not, what should be done if such an ordering does not exist? (e.g. [1,1,1]). – flawr Jan 23 '17 at 20:22
• @flawr I'm wondering the same thing, should the input always have a possible solution. If multiple solutions exist, return only one or all of them? I'm still ironing out the details. – miles Jan 23 '17 at 20:40
• I'm struggling to think of a set of numbers that doesn't have a possible ordering (where each number occurs once). I think returning only 1 is sufficient. – Nathan Merrill Jan 23 '17 at 21:00

# Compute the CYK-Table!

## Context-Free Grammars

A context-free grammar is a grammar consisting of rules from one variable to a list of variables and symbols. Every string purely consisting of symbols that can be produced using these rules is said to be accepted by the language. For the purpose of this challenge we're only going to consider grammars in CNF which means that on the right side there's either two variables or one symbol (we're gonna ignore the empty language for this challenge).

## The CYK-Algorithm

The CYK-Algorithm is a method to check whether a given word is recognized by a context-free language in CNF. For doing this it iterates over the word and applies all possible rules on all substrings and writes them down in a nice table. This table can then be used to successively find variables generating larger substrings until you (don't) hit the word.

## The Input

• A list of strings representing the word
• A list of triples of strings, representing the rules from one variables (the first in the triple) to two variables
• A list of pairs of strings, representing the rules from one variable to a symbol
• A string, representing the starting variable

You may replace the above input format with your favorite input format, as long as you can encode the same amount of information.

## The output

The output will be three-dimensional: A list of rows consisting of a list of "candidates" which is a list of strings representing a list of variables. An illustration of this is on Wikipedia.

You may replace the above output format with your favorite output format, as long as you can encode the same amount of information.

## Who wins?

This is so the shortest code in bytes to solve the challenge wins!

## Example

Start Symbol: "X"
Word: ["b","a","c","b"]
Rules #1: [("X","X","Y"),("X","Z","Z"),("Y","W","Z"),("Z","X","Y"),("W","Y","W")]
Rules #2: [("X","a"),("Y","a"),("Z","b"),("W","c")]


We're gonna do this step-by-step:

The substrings of length 1 first (this is your first row):

b    , a       , c   , b
["Z"],["X","Y"],["W"],["Z"]


Now for the substrings of length 2 (this is your second row):

[],["W"],["Y"]


(because there's no way to get ZX or ZY, but W -> YW and Y -> WZ)

Now for the substrings of length 3 (this is your third row):

[],["X","Y","Z"]


(because there's no rule to get ZW, but X->XY (1+2), Y->WZ (2+1), Z->XY (1+2) where the sum denotes the lengths of of the used substrings)

Finally for the substrings of length 4 (this is your fourth row):

["X"]


(because X->ZZ(1+3))

So in total your final table for this example is gonna look like this:

[
[["Z"],["X","Y"],["W"],["Z"]],
[[],["W"],["Y"]],
[[],["X","Y","Z"]],
[["X"]]
]


where the first index increases as we go downwards, the second increases as we go to the right an dthe third denotes the variable within the "cell".

# Physical String Length

Given the following information:

• (String) s - A string to be printed.
• (String) f - The font in which it is to be printed.
• (int) pt - The size of the font in which it is to be printed in pts (no decimals).
• Note that the input units are in pt (1/72 inch).
• The output unit should be pixels, rounded to the nearest integer.
• Use 96 PPI in your conversion.

Output:

• The physical length of the string (how many pixels wide the final string is).

Below are a few examples and a piece of code that will let you test arbitrary combinations.

import java.awt.Canvas;
import java.awt.Font;
public class F {
public static void main(String[]args){
System.out.println(physicalStringLength("What?", "Calibri", 12));
System.out.println(physicalStringLength("What?", "Calibri", 24));
System.out.println(physicalStringLength("What?", "Calibri", 36));
System.out.println(physicalStringLength("What?", "Calibri", 72));
System.out.println(physicalStringLength("What?", "Helvetica", 12));
System.out.println(physicalStringLength("What?", "Times New Roman", 12));
System.out.println(physicalStringLength("What?", "Courier New", 12));
}

public static int physicalStringLength(String s, String f, int pt) {
System.out.print(s + "@[" + f + "," + pt + "]=");
return new Canvas().getFontMetrics(new Font(f,0,pt)).stringWidth(s);
}
}


Here's some base-line examples, the output has be created using the above piece of Java code:

What?@[Calibri,12]=35
What?@[Calibri,24]=65
What?@[Calibri,36]=97
What?@[Calibri,72]=193
What?@[Helvetica,12]=35
What?@[Times New Roman,12]=31
What?@[Courier New,12]=35


If you want to see the length of any other strings, use the code provided as a base-line. Using a Java has been banned due to the usage of the example unless you'll be providing a different methodology (kinda sucks, cause Java may be one of the few with a built-in).

This is , lowest byte-count wins.

• The font is an integer? – Poke Jan 24 '17 at 21:25
• Yep, no float font sizes. – Magic Octopus Urn Jan 24 '17 at 21:26
• Sorry, I mean the second parameter "f" – Poke Jan 24 '17 at 21:26
• Nope, that's a typo. – Magic Octopus Urn Jan 24 '17 at 21:26
• It's a little strange to ask for the width in px but input the font size in pt. Pixels are can vary in physical size while points are fixed at 1/72 inches. – Poke Jan 24 '17 at 21:29
• @Poke I guess I could state that Java is using a default PPI is 96. – Magic Octopus Urn Jan 24 '17 at 21:31
• Because I like answering challenges in java I'd be remiss if I didn't suggest adding more to this challenge such as height and other things found here but that's likely not as fun for other languages. I think the challenge does contain enough by itself. – Poke Jan 24 '17 at 21:41
• 1. I don't think this is well defined. Different applications using the same typeface and the same point size will produce strings of slightly different widths because e.g. they don't interpret the hints in the same way. 2. Why ban Java and not e.g. the .Net languages, which have very similar library support? – Peter Taylor Jan 24 '17 at 22:31
• Adding to Peter's point, different rendering engines display fonts differently. The default Windows GDI renderer alone knows 5 different types of anti-aliasing, any of which can be the system standard, not counting fonts rendered by Direct2D, OpenGL or GDI+. It's very easy to just render and measure a string with GDI+, but the length might be different across systems by one or two pixels because of AA. Would that be acceptable? – mınxomaτ Jan 24 '17 at 23:48
• @PeterTaylor Maybe adding in a clause about acceptable standard deviations? – Magic Octopus Urn Jan 25 '17 at 15:28

# Binary Grids

Consider the N-dimensional binary grid, with dimensions {d1,d2,...,dN}. Here are a few examples:

6 (N=1): 100101

3x7 (N=2):

1001001
0110110
1001001


3x3x3 (N=3):

010   001   100
100   011   110
011   110   001


What each of these example grids have in common is: they do not contain any consecutive sequences of the same digit longer than 2.

The Challenge

Write a program or function which, given a list of dimensions, outputs the number of binary grid configurations with the given dimensions that satisfy this condition.

Input

A list of positive integers (>1), either via stdin or passed as an argument. Example: 3 2 6, [3,2,6], etc.

Output

The number of valid configurations, either as a returned value or printed to stdout, or something similar.

Constraints

• While brute-force solutions can work, their time complexity is O(2^N), which is way too long for anything but the smallest grids. Write something which will complete before my computer becomes obsolete, please!
• Standard loopholes are forbidden, not that I think very many of them would apply here anyway.
• This is code-golf, so the shortest code wins, with tiebreakers going to the fastest code.

## Sandbox Questions

1. Is this interesting?
2. Is this doable?
3. What's a better way to word the time complexity restrictions?
4. The only example for which I actually know the answer is for [6]... do I need more? I'd have to solve this myself first...
• 1. I think "consecutive" needs clarification. I'm guessing that it's talking about horizontal and vertical lines but not diagonal ones. 2. Re whether it's doable: in 1D it's oeis.org/A128588 which is easy to calculate. In general it can be done in n-D by calculating all of the acceptable values in some (n-1)-D projection and then taking the power of an incidence graph, but I doubt that scales well beyond 3D. It may be possible with some investigation to get an n-D generating function, but it's hard to tell without spending a couple of hours on the problem. – Peter Taylor Jan 27 '17 at 16:25
• In terms of complexity restrictions, asking the program to run in polynomial time in the number of cells in the grid seems reasonable (because exponential time is enough to brute-force it and it's very rare (impossible?) for a program to have a complexity in between). I don't know whether that's possible, though (although even if there's a chance that it isn't, it may still be worth asking the question). – user62131 Jan 27 '17 at 22:31

# Golf Me a Bubble Sort

Your task is to create a program that performs a bubble sort.
For those who don't know, a bubble sort is a simple sorting algorithm where two adjacent items are taken & swapped if they are in the wrong order until all values are in the correct order.

## Rules

1. You must provide an explanation for how your answer does a bubble sort.
2. You may not use built-in or standard library sorting algorithms. You must make your own code.
3. Your program should take a group of numbers as input and output them in the correct order.
• Input format: 10 5 9 2 . . . (and so on)
• Output can be an array returned by the program when run.
• Output can also be the correctly ordered values separated by whitespace.
4. Speed does not matter as much as of the program functions.

## Test Cases

• 10 5 9 2 1 6 8 3 7 4 (you can format it differently depending on your language)
• 1 2 5 4 3

This is , so the shortest answer in bytes wins.

• It may be a better idea to have entries do only a single iteration of bubble sort; that way it will be easy to verify their correctness. – ETHproductions Jan 29 '17 at 20:52

# Definitions

### Logistic Map

A logistic map is defined as the following equation:

Where the next value in the map (on the left) is determined by a function of the current value (on the right), where the constant lambda represents a set constant between zero and four (non-inclusive, along the reals).

### Stable Point

A "stable point" in relation to a map is a point which is approached repeatedly by iterating the logistic map. They are distinct, and there are one to many for any given lambda.

Write a function or program which, given an input real value n between zero and four (non-inclusive), returns the number of stable points for a map where lambda is n.

# Meta

Main problem: Defining "stable point". Is this definition sufficient?

• The definition is wrong. A fixed point of a map is a point which is mapped to itself. For the logistic map the fixed points are 0 and 1-1/x. – Peter Taylor Jan 31 '17 at 8:45
• If you instead look for points in stable cycles, you need to also specify that the domain is the real numbers, because stable cycles correspond to roots in the polynomial obtained by iterating the map, and over the complex numbers a polynomial always has as many roots as its order. If you specify distinct points in stable cycles of any length, that becomes a real challenge. – Peter Taylor Jan 31 '17 at 8:55
• @PeterTaylor The second one was what I was going for. :P Got my terminology wrong. – Addison Crump Jan 31 '17 at 9:40
• @PeterTaylor Just to verify, I'm looking for the number of distinct stable points for specific values of lambda along this graph. – Addison Crump Jan 31 '17 at 9:49

Language contest

Moving this here from normal question

So, I'm kind of an esolang loony so let me propose the following contest. First of all, we do not care about speed: if two algorithms safe the same problems then they are 'equally good' at least for this challenge. Also, let's think in "special case" terms. Sorting is the problem of well... sorting a list. However, an algorithm that generates permutations of lists with an abort condition equally solves the sorting problem. However, such an algorithm is more generic as the abort condition allows it to do more stuff. In other words: sorting a list is just a special case of generating permutations with an abort condition.

The idea is to concentrate on the most generic version of an algorithm that solves a problem. In other terms: Getting rid of redundant built-ins in esoteric programming languages.

The contest would go as following: The goal is to create an esoteric concatenative language (not necessarily stack based but concatenative) with the fewest built-ins that solve all problems (in some catalog). However, this would be really boring like that because a minimized version of brainfuck would pretty much win. Thus the 'score' function would likely be a function of 'amount of built-ins' and 'average program length'. One other constraint is that you are not allowed to have redundancy in your built-ins. If you have a built-in sortAsc and sortDesc and reverse then sortAsc = reverse . sortDesc thus you are disqualified. This also means that if you have too generic loops as built-ins like uhm for loops you can use these for loops to create a sort function which means you wouldn't be allowed to have a sort function.

What do you guys think?

TL;DR optimize for program length and least amount of builtins required.

• This is an interesting idea, but the rule against redundancy is problematic. It's very difficult (in fact undecidable) to say whether the built-ins of a language are redundant. It's also probable that such limitations can be circumvented with some trick, like having each function take and return a tuple (d, l), where d is some arbitrary data and l is a string that records which functions were used on the data. You might also want to define unambiguously what a "concatenative language" is. – Zgarb Jan 31 '17 at 13:19
• I agree with all of Zgarb's comments. That said, if you enforce a language paradigm, then you could define exactly what "combining commands" means. If you do do that, then I'd highly recommend making this a code-golf challenge, and dropping "least builtins" as a scoring mechanism – Nathan Merrill Jan 31 '17 at 13:34
• If you can formulate any built-in in terms of other built-ins then you have redundancy. Hidden state doesn't really count. But yes, there are likely loopholes nobody has thought about yet. – mroman Jan 31 '17 at 14:06
• @mroman Yeah, that's the definition of redundancy. But given an arbitrary list of built-ins, how can you definitively say "this list is not redundant"? Particularly with the weird stuff esolangs tend to have. – Zgarb Jan 31 '17 at 14:17
• with handwaving probably. – mroman Jan 31 '17 at 15:09
• Hmm, I've thought about this some more, and this is what I'd probably do. Drop the non-redundancy requirement, have a lot of smallish tasks (like 20 or so), and have the scoring function be something like N * 3^B, where N is the total length of the solutions to the tasks and B the number of built-ins. Then implementing a redundant built-in would only be worth it if it cut off 2/3 of your program size across all tasks. I'll have to think about it more to see if there are obvious loopholes that I've missed. – Zgarb Jan 31 '17 at 16:58
• And don't get me wrong, I think this is a superb challenge idea! :) It just needs to be done right to have a positive reception and good answers. – Zgarb Jan 31 '17 at 17:00
• As I commented elsewhere, "First of all, the assumption is that every algorithm that solves the same problem is equally fast" is nonsense, and primes readers with a background in computer science to expect the whole question to be low quality. I suggest rephrasing as "First of all, the assumption is that we don't care about performance". – Peter Taylor Jan 31 '17 at 17:42
• Okay, I think I have found another "loophole". Suppose you have K tasks. Then you can make 3 built-ins and solve each task with a program of length 1 + ceiling(log2(K)) as follows. One built-in does "encoding": it transforms the data into some more restricted format (like multiply every list element by 2 to make them even, if the data is always a list of integers). The other two built-ins work as follows. (contd.) – Zgarb Feb 1 '17 at 9:05
• If the encoded data has been processed by fewer than ceiling(log2(K))-1 functions, they just add a unique marker to the encoding (like by appending 1 or 3 depending on the function). Otherwise, the applied built-ins (counting the current one) form a binary string of length ceiling(log2(K)), which we interpret as a base-2 number encoding the task. Then we just decode the data and solve that task. – Zgarb Feb 1 '17 at 9:05
• @PeterTaylor It just means that for this challenge it doesn't really matter how fast your program is as long as it solves the task in a (meaningful) finite amount of time. – mroman Feb 1 '17 at 14:14
• @Zgarb I can't really follow that. Do you have a more practical/real example of that loophole? – mroman Feb 1 '17 at 14:17
• If that's what it's intended to mean, write that instead, because as it stands it's very easy to interpret it as meaning something different. – Peter Taylor Feb 1 '17 at 14:39
• @mroman Here's an implementation in Python 3. I hope you can follow it. I'm using 8 tasks as an example, which results in length-4 programs. Each program has the form Eabc, where abc is the binary encoding of the task number. – Zgarb Feb 1 '17 at 14:47
• @zgarb yeah I get it now. I guess that's legal to do. – mroman Feb 2 '17 at 7:44