# Sandbox for Proposed Challenges

This "sandbox" is a place where Code Golf users can get feedback on prospective challenges they wish to post to main. 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.

Sandbox FAQ

## Posting

Write your challenge just as you would when actually posting it, though you can optionally add a title at the top. 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, and replace the post here with a link to the challenge and delete the sandbox post.

## Discussion

The purpose of the sandbox is to give and receive feedback on posts. If you want to, feel free to give feedback to any posts you see here. Important things to comment about can include:

• Parts of the challenge you found unclear
• Problems that could make the challenge uninteresting or unfit for the site

You don't need any qualifications to review sandbox posts. The target audience of most of these challenges is code golfers like you, so anything you find unclear will probably be unclear to others.

If you think one of your posts needs more feedback, but it's been ignored, you can ask for feedback in The Nineteenth Byte. It's not only allowed, but highly recommended!

It is recommended to leave your posts in the sandbox for at least several days, and until it receives upvotes and any feedback has been addressed.

## Other

Search the sandbox / Browse your pending proposals

The sandbox works best if you sort posts by active.

To add an inline tag to a proposal use shortcut link syntax with a prefix: [tag:king-of-the-hill]. To search for posts with a certain tag, include the name in quotes: "king-of-the-hill".

Get the Sandbox Viewer to view the sandbox more easily!

# Implement a cleave function

• @Adám You're right. Thanks! – chunes Jun 16 at 7:27
• If my language can directly apply a list of functions to a number, giving me a list of results, does that mean a 0-byte answer, or do I have to wrap the application in no-op code? – Adám Jun 16 at 7:30
• @Adám I have no idea if there's a precedent for 0-byte answers, but if the mere act of writing a list of functions immediately applies them to some object in your programming language, that's interesting and I would want to see it. Would writing a blurb about builtins/builtin behavior being allowed help? Something like "Builtin functionality is allowed but consider adding a less trivial answer as well."? – chunes Jun 16 at 7:37
• Yes, that would help, and asking for non-trivial things is nice. You might also want to ask for people to explain. – Adám Jun 16 at 7:38
• While tagged functional-programming, are we still allowed to submit a full program that prompts for $L$ and $n$? – Adám Jun 16 at 7:44
• @Adám I'm not sure. I took a look at some other higher-order function questions for inspiration, for example https://codegolf.stackexchange.com/questions/223881/implement-an-over-function and it uses the language "You may input and output in the most convenient format for your language, and in any convenient method,..." and that seemed to suffice there. – chunes Jun 16 at 7:56
• Funny thing is that while you call it a conceptual inverse of map, it is just a map, right? E.g. in JS: (L,n)=>L.map(f=>f(n)) – Adám Jun 16 at 8:03
• Indeed, it can be written in terms of map. Does it seem too trivial, you think? Does it need spicing up? – chunes Jun 16 at 8:07
• No, I think it is great. – Adám Jun 16 at 8:07
• How would one apply a list of functions to a number in something like Python, which is not a functional-programming language – StackMeter Jun 16 at 11:07
• @StackMeter lambda l,n:map(lambda f:f(n),l) – Recursive Co. Jun 17 at 5:31
• I see now, thanks @RecursiveCo. – StackMeter Jun 17 at 6:06

# The Great Betting Game

• A few suggestions: perhaps add the date tag, and say something like Output "WEEKDAY" if there are 5 dates, all from Monday-Friday, "WEEKEND" if there are two dates: Saturday and Sunday, and "ALLDAYS" if the input contains seven days all from Monday-Sunday. – Recursive Co. Jun 28 at 12:46

# Generate off-by-one regex for a string

Given an alphanumeric string as input, generate JS-flavored regex in order to match any off-by-one errors for that string. In stricter terms, your resulting regex must match any single deletions, single replacements, or single additions like in the below examples.

#### Examples:

"hi" -> "(h|i|.i|h.|.hi|h.i|hi.)"
"golf" -> "(olf|glf|gof|gol|.olf|g.lf|go.f|gol.|.golf|g.olf|go.lf|gol.f|golf.)"


Here is a program for generating the results.

Note: The order of the regex does not need to matter (ie, "hi" could be "(h|h.|hi.| . . .")) so long as all patterns are in the regex.

This is , so shortest program in bytes wins.

• Which flavor of regex will be used? – user Jul 4 at 16:13
• @user Lets go with JS to make it consistent, it shouldn't really matter though as the regex will share the exact same format as the example cases, with only the order possibly changed. However, i've now updated the post for clarity. – Underslash Jul 4 at 17:23
startup 1 place$L 1 place$ _ left270000 L left270000 _ left269999 L _ ...  Jeez! The output is going to be HUGE! It might be better to treat the BF memory as negative-indexed and reverse all the _L_s and _R_s in 'advance', 'rewind', 'increment', and 'decrement'. Questions: Bonuses for optimizations? If I can implement this myself and provide a complete example output, The bonus could be "subtract the difference between your program's output for the example input with the example output". So eliminating states would be far more valuable than shrinking the code. One could possibly achieve a negative score! Edit: Actually I think this is unreasonable unless the Turing Machine is augmented with non-reading (movement-only or epsilon) transitions. Duplicating every letter of the alphabet just to move over one square is just ridiculously painful. That means this challenge won't link-up nicely with the other one. :( What about, instead of implementing the compiler, just devise a translation scheme (as above) that leads to a smaller output for a trivial sample program (based on calculating, rather than coding)? "Back of the envelope" compiler. • "How much detail on BF do I need to supply? Can I simply reference the BF question?" A link to almost any site that describes the language will do. – dmckee --- ex-moderator kitten Nov 5 '12 at 16:52 • Winning condition? – Peter Taylor Nov 6 '12 at 13:43 • "Longest prefix containing syntactically-correct Malbolge!" :) ... I'd say have none at all. Perhaps the questioner should be required to accept their own example answer? – luser droog Nov 6 '12 at 18:08 • @PeterTaylor Apologies for my last comment. I thought we were on my other answer about the [fun] tag. . . . This one would be a golf: shortest code by character count. But I think a clever system of bonuses could make it interesting. – luser droog Nov 7 '12 at 10:06 • The "Equivalently, you may write a Brainfuck interpreter in TM" option doesn't play very well with being a code golf - how are you going to count the length of the TM? – Peter Taylor Nov 7 '12 at 11:15 • @PeterTaylor Since the TM question specified 5-tuples, I think it's sufficient to count the tuples (== transitions). You can reduce states by increasing the alphabet (or vice versa), but the transitions would remain constant, I think. – luser droog Nov 8 '12 at 5:25 • I'd like to adopt (work on and post) this challenge if you don't want to. Would I be able to? If you do not respond to this message within two weeks, by community guidelines, I am allowed to take it over. – MD XF Aug 18 '17 at 3:23 • Yes, please. If you can do something with it, strike while the iron is hot. – luser droog Aug 18 '17 at 4:19 # Graphical Output -- Esoteric Artifacts -- The Glass Bead Game ## Draw the Cabalistic Tree of Life Simply described, the Tree of Life is an undirected network of nodes representing the conduit between matter and higher forms of spiritual energy. It has an upper face arranged in a hexagon, and a lower fact built from equilateral triangles adjacent to the lower two edges of the upper face. Don't label the paths, paths may overlap however you wish, may be single (thick) lines, even. Code Golf. Bonus -100 for labels on the Sephiroth (nodes); Bonus -150 for Hebrew labels. ## Draw a Mandala for each Natural Number Draw a circle with interesting visual patterns using the input N [ 1 .. \inf ) to determine the number of points around the circle to anchor figures whose shape is also modified by the input N. Actually, 12 seems like a good max: they're pretty much a blur after that no matter what. Eg. http://code.google.com/p/xpost/downloads/detail?name=ve6a.ps //lotsoflines n = 1 ..12 (doesn't need to be this elaborate, This is >600 lines of showing-off.). . . . need good images for these . . . ## Draw the Ptolemeic System of the Universe All the stuff I could find is animated already. Maybe this one's done-to-death. :( Update: Found good stuff on Alchemy. The "Keplar Platonic" model could be fun (3D and all). This one looks good, too. And this. ## Draw the Pythagorean Monochord aka pre-classical nomogram. I misplaced my Pythagoras books, I know I've got a picture somewhere. This is the one I was thinking of. But I think this one's even cooler ## Draw the I-Ching Hexagrams in King Wen Sequence. I suppose I need to implement this first to avoid copyright issues! :) • The I-Ching one would have to be in standard order to be remotely interesting, and then becomes as much about kolmogorov-complexity as graphical-output – Peter Taylor Nov 22 '12 at 21:24 • For the others: images, please! – Peter Taylor Nov 22 '12 at 21:25 • I've emailed the owner of the Alchemy pages asking for permission to use his copyrighted images. Awaiting response. – luser droog Jan 28 '13 at 8:25 ## Polygon prefixes Polygons are named after the number of sides that they have. A pentagon has 5 sides, an octagon has 8 sides. But how are they named? What's the name for a 248-sided polygon? All polygons are suffixed with -gon. There are specific prefixes for each polygon depending on the number of sides. Here are the prefixes for the lower numbers: 3 - tri 4 - tetra 5 - penta 6 - hexa 7 - hepta 8 - octa 9 - nona 10 - deca 11 - undeca 12 - dodeca 13 - triskaideca 14 - tetradeca 15 - pentadeca 16 - hexadeca 17 - heptadeca 18 - octadeca 19 - nonadeca 20 - icosa  Polygons with 21 to 99 sides have a different system. Take the prefix for the tens digit (found on the left column), the ones digit (right column below), and then stick a "kai" between them to get (tens)(ones)gon. 20 - icosi | 1 - hena 30 - triaconta | 2 - di 40 - tetraconta | 3 - tri 50 - pentaconta | 4 - tetra 60 - hexaconta | 5 - penta 70 - heptaconta | 6 - hexa 80 - octaconta | 7 - hepta 90 - nonaconta | 8 - octa | 9 - nona  The 3-digit sided polygons are named in a similar fashion. A 100-sided polygon is called a hectogon. Take the hundreds digit, find it on the column for ones digits, then stick a "hecta" to its right. Now number off the tens and ones like above: (hundreds)hecta(tens)(ones)gon. If the hundreds place digit is a 1, don't put the prefix behind "hecta". So, given an integer (3 <= n <= 999), return the name of an n-sided polygon. n-gon is not a valid answer :P As with all code golf, shortest code wins. Is the description good? Would it be harder if I instead asked for the number of sides, given a name? • What is a 101-sided figure called? "hectahenagon"? Is "hena" from the column for ones digits you mention? If so, then what is a 111-sided figure called? I'd say "hectaundecagon", but then that comes from a column where "hena" is not present. – Gaffi Feb 11 '13 at 11:15 • @Gaffi: Yep, it's hectahenagon, from what Google says. – beary605 Feb 11 '13 at 16:03 • I am going to take this if you allow me or if you don't respond – Christopher May 30 '17 at 1:13 ## Self-Golfing Code? I don't know if I just didn't search hard enough, but I couldn't find any challenge regarding self-golfing code, or rather, any code that can deterministically reduce another set of text code to a much smaller program, yet still compile/run. For example, take this: int main() { std::cout<<"Hello world 1!"<<std::endl; std::cout<<"Hello world 2!"<<std::endl; std::cout<<"Hello world 3!"<<std::endl; std::cout<<"Hello world 4!"<<std::endl; std::cout<<"Hello world 5!"<<std::endl; }  And output this (as one possible solution): #define A std::cout<<"Hello world #define B !"<<std::endl; #define C B A int main() { A 1 C 2 C 3 C 4 C 5 B }  Alternative: Sub MySub() Dim aNumber As Integer Dim someString As String aNumber = 123 someString = "abc" MsgBox aNumber MsgBox someString End Sub  into (again, as one possible solution) Sub m() Dim a As Integer Dim s As String a = 123 s = "abc" MsgBox a MsgBox s End Sub  Do we have a challenge for this? If not, here are some rules I envision: • Golfing code need not be in the same language as code to be golfed. • Since compilers/running of code varies, newly golfed code must still run under same environment. • Possible challenge scoring (multiple options -- thinking code golf): • 1: Shortest golfing code wins (not my favorite, since you can minimally shorten the base code, yet still write the shortest program). • 2: Shortest output of a set of pre-defined code (potentially limiting if participants are unfamiliar with the options available) • 3: Combination of length of golfing code and the output result of the same as input. (Ratio, summation, etc.) -- This I think is my preferred option. • 4: Multi-player Ratio of golfed size of other participants' own code versus their original submission. (Similar limitations to that of point #2.) • Sounds more like an auto-golfer than obfuscation. Seems like it would be very hard to make it a fair contest unless you pick a language to golf, and even then it had better be a simple language (no platform dependency issues or compiler options). – Peter Taylor Feb 13 '13 at 15:15 • @PeterTaylor My examples are golfing, but either would work. Perhaps golfing would be simpler, then? I agree that the options for usable languages makes this a bit messy... Would one challenge per language be acceptable? (i.e. aligned with most challenges that are language-agnostic) – Gaffi Feb 13 '13 at 17:36 • Language-agnostic to mean means that you can write a program to do it in any language. Since the language to be golfed can be different from the submitted program, I don't see any incompatibility between making the problem "Write a program to golf Piet" and being language-agnostic. – Peter Taylor Feb 15 '13 at 0:18 • @PeterTaylor So then you see no problem with one question per language on which to operate? Are there any proposed scoring algorithms you particularly like/dislike? – Gaffi Feb 15 '13 at 12:02 • That depends on what you mean. If you're planning to post 10 questions at once, yes, that would be a problem. But I don't see a problem with posting a well-defined "Auto-golf Piet" and following it up two months later with "Auto-golf Perl 5". – Peter Taylor Feb 16 '13 at 10:19 • Scoring is an issue. The halting problem means that it's impossible to write an optimal solution, so the scoring must take into account how good the solution is. I think option 3 is the best, and you'll want a big test set (maybe a few kB taken from a real-world open source project) with coverage of the language features. – Peter Taylor Feb 16 '13 at 10:22 • Btw, your first example doesn't work. You can't have unmatched quotes in preprocessor directives. Don't know why. – MD XF Jan 13 '18 at 18:03 • I honestly think this would be fine if you did something like solely maco-golfing, making it somewhat language agnostic because of gcc -E. – Adalynn Nov 10 '18 at 14:36 ## DeCSS It is known that the DVD Content Scrambling System can be deciphered with a rather short program (434 bytes of C, 472 bytes of Perl). Can you do better? << Test cases go here >> I don't plan to include a more detailed spec, because it will just wind up duplicating some of the code. The test cases would be in the form of (key, link to data file, md5sum of the deciphered stream). • And the winning criterion is who is the first to get post from the courts? – celtschk Oct 3 '15 at 20:18 • @celtschk, I think that would be unfair. Winning criteria shouldn't really depend on where people live... – Peter Taylor Oct 10 '15 at 20:56 • I think you should at least explain the general concept of the spec. – Rohan Jhunjhunwala Aug 2 '16 at 22:53 • This actually sounds interesting. @PeterTaylor Perhaps you could use (and link to) Charles Hannum's explanation of the algorithm and post this. (It would be fun to have it as a popularity contest for a program that looks like it's nothing DeCSS related, or a program that furthers the gallery's point about the text vs source code arbitrary distinction - but I don't know if popularity contests are popular any more!) – sundar - Remember Monica Jun 25 '18 at 8:25 ## Write a compiler/interpreter for ... Inspired by the lisp challenge here. It is a series of puzzles. I don't like to see a simple eval solution, so: • interpreting the language is fine • translating the language to a different language is fine. I think this is specific for each language. Only the syntax and the basic commands. Also specific. Winning criteria should not be code golf. The goal should be that you can "learn" an other language by looking at the code. Languages that might be good candidates: • Lisp • APL • J • Brainfuck (already posted) • Whitespace • Forth • This only works for languages which are small and well defined. BF fits those criteria. Whitespace does too. The others may not. Lisp and Forth have so many dialects that you would have to specify exactly which dialect to support; Lisp, Forth, APL and J might have too many built-ins to fit in an answer: there are character limits. – Peter Taylor May 12 '13 at 15:16 • You don't have to provide all the built-ins, but that is why it is here. – Johannes Kuhn May 12 '13 at 15:38 • What defines the "basic commands"? – ASCIIThenANSI Aug 31 '15 at 17:54 • I don't know? Maybe that you can do the basic stuff with it like +,-,print,... – Johannes Kuhn Aug 31 '15 at 18:22 • I suggest a programmer can implement the tiniest subset of those languages in order to be Turing-complete, as these are non-trivial subsets that can theoretically simulate the rest of the language... – user85052 Jun 28 '19 at 4:17 • Which human is learning the programming language by looking at the code? – MilkyWay90 Aug 26 '19 at 3:23 # Missile Command I'm making this CW, because it needs lots of help. I've been toying with this idea for a while. Think "battleship" to get in the right mind-frame. But, instead of ships, what you lay down are tiles which represent a Befunge-style program. This program controls the behavior of guided missiles ejected from the spawn tile. The goal is to program a missile which will obliterate an opponent's program block, as well as guard its own control block. Haven't nailed-down the board size. 20x20 seems a little cramped.  1 2 12345678901234567890 ____________________1 4x20 program block ____________________2 ____________________3 _______@____________4 ....................5 12x20 arena ....................6 ....................7 ....................8 ....................9 ....................01 ....................1 ....................2 ....................3 ....................4 ....................5 ....................6 ___________@________7 4x20 program block ____________________8 ____________________9 ____________________02  ## Tiles @ spawn Program control. I'm imagining these to change direction of the code for "boustrophedon" writing. this,then\ txen,siht  haven't thought it all though, yet. / \ Movement. F forward move forward one square B back move back one square L left turn left 90° R right turn right 90° So the submissions would be 4x20 code blocks which compete in a king-of-the-hill style. • If this is deterministic, won't it be "Last person to submit their program wins"? – Peter Taylor Jun 7 '13 at 8:39 • That is a danger, yes. I'm hoping ways around it can be found. There could be a random operator. And proximity detection, or something. – luser droog Jun 7 '13 at 8:46 ## Find all of the Scrabble numbers: A scrabble number is a number n whose scrabble representation can score n points. As an example consider 12: its English spelling twelve has value 12 when it is placed on a stretch of six blank tiles. Since the highest ever reported 1 word scrabble score barely exceeds 2000 points, that will be the upperbound for this challenge. Score and quantities for English: 2 blanks | x1 | x2 | x3 | x4 | x6 | x8 | x9 | x12 | 1 | | | | LSU | NRT | O | AI | E | 2 | | | G | D | | | | | 3 | | BCMP | | | | | | | 4 | | FHVWY| | | | | | | 5 | K | | | | | | | | 8 | JX | | | | | | | | 10 | QZ | | | | | | | |  Considerations for either bonus points to scoring or extra requirements: • Respect the board, only using gaps between double/triple letter and double/triple word scores that occur on a standard scrabble board. • Respect the tile count for each letter. • There are non-English versions of scrabble, maybe it should be 'language-agnostic' (lol, but seriously is there a reason to accept only English submissions?). • Should the 2 blanks be allowed? • What about tiles which were already on the board and so wouldn't score anything? As for language: one approach would be to make it take the names of the tiles (and perhaps the values and counts of the letters) as input; this would also prevent the problem from being effectively one of Kolmogorov complexity. – Peter Taylor Jun 19 '13 at 22:50 • I don't believe that tiles on the board already would pose an issue. If you assume that the board may be prepared with any subset of the tiles beforehand (some may be impossible, but checking that is out of scope) all that is relevant to the problem is which are placed to complete the word. All the tiles points are counted, even the earlier placed, but only the new 7 (or less) tiles may qualify for triple/double-word/letter scores. w.r.t. kolmogorov, If I wanted to make it programming challenge instead of codegolf (so that isn't an issue) then there needs to be a scoring system right? – Kaya Jun 19 '13 at 23:33 • Yes, if it isn't codegolf then it needs a scoring system. I'm not sure what you could use as an alternative scoring criterion, though: it's simple enough logic that pretty much any implementation would be IO-bound, so speed doesn't work; and big-O based tends to be less straightforward than you might think. – Peter Taylor Jun 21 '13 at 11:05 # Sort all lines according to their corresponding Levenshtein Distance to the first line. Shamelessly borrowed from: http://golf.shinh.org/p.rb?Levenshtein+Distance+Sort+FIXED For a definition of the Levenshtein Distance, look here: http://en.wikipedia.org/wiki/Levenshtein_algorithm Rules: Takes input from stdin. Must work for all possible input. Get points for: Smallest character count. Using Languages that are difficult to golf in. I think character count / the average values from here (http://golf.shinh.org/lranking.rb) might suffice? • There are a number of ambiguities in the problem description. What is the correct behaviour if the input is empty? In the general case, should the first line be included in the lines which are sorted and output? Should the sort be by ascending or descending edit distance? How should ties be broken? – Peter Taylor Jun 25 '13 at 20:23 • As for handicapping: are you going to prohibit built-in or library-provided edit distance functions? If not then the averages you link are not especially relevant: PHP handily wins the existing edit distance question by virtue of its built-in function. – Peter Taylor Jun 25 '13 at 20:27 • (That existing question does also raise the possibility of yours being closed for not being sufficiently different). – Peter Taylor Jun 25 '13 at 20:28 # Fastest Code: checking if interval pairs overlap Given an unsorted input of many interval pairs (50+), write the fastest algorithm to determine if they do not overlap. An interval pair is said to overlap if interval x and interval y are overlapping. Example input 1: interval x , interval y 10-25, 50-60 10-15, 25-60  Output: Can be in any true false format. false (They overlap)  reasoning: a.x overlaps b.x a.y overlaps b.y  Example input 2: 10-25, 50-60 20-30, 25-30  Output: true (they do not overlap)  reasoning: a.x overlaps b.x a.y does not overlap b.y  Scoring: [not sure...] brute force gives a worst case n^2 runtime  • It's hard to understand what the program is supposed to do. It's better to give three separate self-contained test cases than to mix them together with extra identifiers which won't be in the actual input. But if I understand correctly, there's nothing difficult here at all. It's just interval overlap testing (two ifs) done twice for no obvious reason. – Peter Taylor Jul 5 '13 at 19:45 • The problem is that there will be a very large input. I'm thinking > 50 lines. – EAKAE Jul 5 '13 at 20:50 • I'm not sure whether or not to score it based on time, or worst case runtime. – EAKAE Jul 5 '13 at 20:59 • Instead of asking for overlap, ask for disjoint: "Check if a family of intervals is disjoint". I also think it would be more interesting if you give intervals in interval notation but I you should at least specify whether or not the endpoints are included. – Justin Dec 21 '13 at 7:41 # Countdown: Federal Holidays in the United States Inspired by this question: Christmas Countdown Write a program or script that will countdown to the nearest U.S. federal holiday, at any given time, and will switch the display to an appropriate greeting during each holiday. The following holidays must be tracked, and announced: Holiday Date Greeting ========================================================================================== New Year's Day Jan. 1 Happy New Year! Martin Luther King, Jr. Day 3rd Mon. in Jan. Happy Martin Luther King, Jr. Day! President's Day 3rd Mon. in Feb. Happy President's Day! Memorial Day Last Mon. in May Happy Memorial Day! Independence Day Jul. 4 Happy Independence Day! Labor Day First Mon. in Sept. Happy Labor Day! Columbus Day 2nd Mon. in Oct. Happy Columbus Day! Veterans Day Nov. 11 Happy Veterans Day! Thanksgiving 4th Thu. in Nov. Happy Thanksgiving! Christmas Dec. 25 Merry Christmas!  The strings listed under "Holiday" and "Greeting" are all free. Shortcuts like "Merry X-mas!" or "Happy 4th of July" will count against you - the full and proper holiday names are free, so there's no good reason not to use them. The following strings are also free, only when used as a label for time units or in advertising the next upcoming holiday: days hours minutes seconds milliseconds until time  On any given non-holiday, the program must show a count-down timer which displays time remaining at least down to the second, and updates the display with an accurate value (according to the system clock) at least once per second. Time remaining until a holiday must be counted as the time until midnight (00:00:00) on that day. How the days, hours, minutes, and seconds (and milliseconds, if you choose) are displayed is up to you, so long as all mandatory items are present and it is clear which numbers represent which value. Again, the strings defining units of time are free so there's no really good reason not to use them. (Though you won't be penalized for not using these strings, so long as it is still unambiguous which time units are which.) The program should also make apparent which holiday is being counted down towards. On any given holiday, the program must cease displaying the countdown timer and instead display the appropriate greeting for that holiday from 00:00:00 until 23:59:59. After a holiday is over, at 00:00:00 the next day, the holiday greeting must go away and be replaced with the countdown timer for the next holiday. Answers must include: • Name of language • Score (length of golfed code, minus free characters) • Golfed code • Total length of golfed code • Total number of free characters used • Un-golfed code, with descriptive comments The program must be capable of running accurately (according to the system clock) at any time, and must be able to run indefinitely. The only limitations to this should be those imposed by the host computer or the nature of the programming language. Are there any additions/deletions/modifications that should be made to these rules? I'm considering changing some of the greetings, but I'm not quite sure what to. • "Happy Martin Luther King, Jr. Day!" is just a mouthful and feels awkward, but shortening it to "Happy MLK Day" feels weird too - any other suggestions? • I'm not quite sure "Memorial Day" should really be preceded by "Happy" - thoughts? • Any others? • I think it would be more interesting if the strings were not free, but you still required exact match. I would like to see the compression scheme used by contestants. – John Dvorak Dec 7 '13 at 12:04 • @JanDvorak This is meant to be code-golf, not kolmogorov-complexity. – Iszi Dec 7 '13 at 22:11 • This challenge proposal has been inactive for over a month. I would like to take ownership of the challenge and make it ready for posting. Please let me know within the next 14 days if you have any objections and would still like to finish and post this challenge yourself. – user10766 Nov 3 '14 at 2:01 # Quine with syntax highlighting I don't really have much of an idea how to properly pose a quine challenge, or what the common syntax highlighting rules are (or aren't) for various languages. So, I figured I'd just toss this concept up here for consideration and let the community flesh it out if they think it's a good idea. • I'm pretty sure some languages don't even have syntax to highlight – John Dvorak Dec 13 '13 at 20:12 • @JanDvorak Perhaps this would not quite be an "all languages" challenge, then - only languages which naturally lend themselves to syntax highlighting would be eligible. – Iszi Dec 13 '13 at 20:19 • You also can't use a language that cannot render any decent GUI. Also, specifying the amount of syntax highlighting the program needs to generate will be hell. – John Dvorak Dec 13 '13 at 20:36 • I don't think this question is feasible, due to the output restrictions and due to the difficulty in defining the minimum required syntax highlighting. – John Dvorak Dec 13 '13 at 21:09 • I like this idea. I think you could specify an adequate level of highlighting with just keywords, strings or characters and numeric literals each having their own color. – Οurous Feb 28 '18 at 21:13 # McDonald's Drive-Thru Changes from original: • Provided some clarification of requirements with regards to impossible ordering quantities. • Added specification to include total cost of order. • Added specification to prefer lowest cost in case of a tie for number of packages. TODO: • Verify package sizes and pricing to be used for this challenge. • Add pricing to output samples. • Edit or remove "not have any limitations" rule. As currently written, it may force otherwise unnecessary bloating of code in some languages. (e.g.: PowerShell can handle numbers as uint64 to work with extremely large quantities, but it defaults to int32.) We want to write a program to help McDonald's Drive-Thru employees assist their customers in ordering Chicken McNuggets. Chicken McNuggets only come in packs of 4, 6, 9, or 20. However, customers may not always be considering this when they pull up to the speaker. For example, a customer might want to order 50 McNuggets but they really don't care what sort of packaging they come in - they just want to make sure they get 50 McNuggets one way or another. We want to help the customers get the best value out of their order - that is, to compose an order large enough to accommodate their needs in as few packages as possible with little to no excess. Users will provide a request for n Chicken McNuggets. Your program's task is to provide the user with the sizes and numbers of McNugget packages needed to fulfill the order exactly. If the exact order cannot be fulfilled, the system must output an order which would meet the customer's needs with as little excess as possible. The system must also provide the total cost of the order. ## Rules • For values of n which can be ordered exactly, output how many of each pack must be ordered to achieve the requested quantity. • For impossible orders (1,2,3,5,7,11), print "[requested quantity] is impossible. Have [nearest valid quantity >n]:" followed by the normal output for the nearest possible quantity >n. • Impossible orders cannot be hard-coded. The program must be able to determine whether fulfilling an order exactly is possible without being explicitly told that 1,2,3,5,7, and 11 are impossible. • Output must exclude any package sizes which do not need to be ordered. • Output must be in descending order of package size. • Output must include the sum total cost of all the packages. (Tax not included.) • Further layout and formatting of the output is up to you, so long as it is unambiguous. • Program must not have any limitations beyond those inherent to the system or programming language. • If there are multiple ways to assemble the order in the least number of packages, output the method which has the lowest total price. Examples: Input: 8 Output: 2x4  Input: 43 Output: 1x20 1x9 1x6 2x4  Input: 11 Output: 11 is impossible. Have 12: 2x6  Relevant Numberphile Link My main concern is that this problem may be too similar to this thread: Work out change Otherwise, are there any changes that should be made to this? • My recommendation is to minimize the total cost of the order, rather than the number of packages. Based on these prices: fastfoodmenuprices.com/mcdonalds-prices, the costs are2.99, $3.89,$4.29, and \$5.00. This website lists the "9 piece" as "10 piece", I think that might be an error. – PhiNotPi Dec 14 '13 at 0:01
• Why the restriction #3? – John Dvorak Dec 14 '13 at 6:12
• I agree that it's too similar to the existing question. In addition, "nearest valid quantity" isn't unique, and you don't give any hint as to how to break ties. – Peter Taylor Dec 14 '13 at 10:17
• @PeterTaylor Tiebreaker is specified as ">n", where "n" is the quantity requested by the user - that is, we want to give the user an option that will have at least as many nuggets as they want to order. – Iszi Dec 14 '13 at 23:37
• @JanDvorak Essentially, to up the difficulty a notch. I figure it's a little trickier to catch the invalid quantities in the process of figuring out the answer if you can't write a simple if statement to match against the known quantities. – Iszi Dec 14 '13 at 23:42
• @PhiNotPi Not sure if that's an error on the site, or a regional difference. The information I posted was based on the linked Numberphile video, which was made in the U.K.. It's also possible they may have changed the menu since then. Presuming that larger packages hold better value in terms of cost-per-nugget than smaller ones, the problem as stated should work itself out to the same goal as you've suggested. However, it might help to differentiate the challenge from the suggested duplicate if we add the total price into the expected output. – Iszi Dec 14 '13 at 23:45
• My question is: how are you going to measure that? How large part of this knowledge are we disallowed from encoding? Can we memorize all but one? Can we special-case 1,2,3? Or, is it that anything goes as long as it either can be generalised to other Frobenius problems, or is inclusive, not exclusive? – John Dvorak Dec 14 '13 at 23:47
• @JanDvorak The program should be able to work out for itself whether or not a given quantity is invalid - that's all there is to it. By its nature, I suppose that means solutions would be able to also handle other Frobenius problems. In fact, I was actually considering a separate "return the largest impossible quantity" problem, where users input several integers and the program outputs the largest quantity that cannot be achieved by adding multiples of those integers. – Iszi Dec 14 '13 at 23:53
• @Iszi Minimizing cost should serve as a tiebreaker for when there are multiple solutions with the minimum packaging. For example, look at N=36. The solution {0*4,0*6,4*9,0*20} works, but {1*4,2*6,0*9,1*20} is cheaper. (I used the costs {{4,2.99},{6,3.89},{9,4.29},{20,5.00}}) – PhiNotPi Dec 15 '13 at 3:07
• @PhiNotPi Ah, I think I misunderstood when Peter said there wasn't a specifier for the tiebreaker. For some reason, I was thinking it was not possible for there to be a tie of that sort. Adding the price aspect definitely helps sort that out, then. Thanks. – Iszi Dec 15 '13 at 3:15
• FWIW, it was my misreading. I failed to see the ">n". – Peter Taylor Dec 21 '13 at 12:01

# .... . .-.. .-.. --- .-- --- .-. .-.. -..

Another Hello World challenge, this time with Morse code!

Taking no input, your program must output HELLO WORLD in audible Morse code, printing each letter as it is played. For the purpose of this challenge, the following Morse code guidelines will be followed:

Duration of sounds:

• Dits are one time-unit long.
• Dahs are three time-units long.
• The gap between elements within the same character is equal to one dit.
• The gap between characters within the same word is equal to one dah.
• The gap between words is seven time units long.
• The length of "one time unit" is up to the programmer, so long as it is consistent throughout the message.

Letters:

• H: ....
• E: .
• L: .-..
• O: ---
• W: .--
• R: .-.
• D: -..

I'm a little iffy on that last bullet regarding duration. Should I set a hard standard, or a minimum? If so, what to?

• Set a hard minimum for timing. Otherwise, a golfed solution might have 1 unit = 1 millisecond. – PhiNotPi Dec 16 '13 at 22:23
• Tasks which take input are normally more interesting. – Peter Taylor Dec 17 '13 at 0:09
• I guess that dahs need to be a continuous tone, not just two dits without a gap? – John Dvorak Dec 17 '13 at 6:32
• @JanDvorak Correct. – Iszi Dec 17 '13 at 6:33
• If you don't plan to post this, I would like to modify it and post it. (If you don't reply to this message within two weeks, by community standards, I am allowed to adopt the challenge.) – MD XF Dec 22 '17 at 2:41
• @MDXF What do you suggest for modifications? – Iszi Jan 2 '18 at 15:18

## Code Golf: counting all colors in an image

The goal of this Code Golf is to create a program that counts all colors in an image.

### The input

The input will be a path to the image file.

### The output

The output should be a number that indicates how much different colors your program found in the image.

### The scoring

It's also important that your program supports much image formats, so I'll calculate the score based on this formula:

(character_count * 3) / (number_of_supported_image_formats * 2)


### Some other rules

• The lowest score wins
• You're not allowed to execute an external program
• No Internet access
• A color doesn't just count if it's present in the palette, there really should be pixels of that color in the image.
• You should also count pixels with 0% opacity.
• #FFFFFF with 100% opacity is not the same color as #FFFFFF with 50% (of course, this is the same for all other colors).
• In vector image formats, if there's a red square (for example) with 50% opacity that overlaps a blue square, then this should count as two colors: red and blue.
• In vector image formats, in case of a gradient, the number of colors depend on which colors are used in the gradient. For example, if there is a red/yellow gradient, then you should count this as two colors: red and yellow.
• A paletted image format is another image format than the non-paletted variant.
• SVG 1.0 is another image format than SVG 1.1 (also count for other image formats).
• What counts as a colour? Does a colour count as present if it's in the palette, even if there aren't any pixels of that colour? What about if it's present, but at 0% opacity? On the subject of opacity, are #ffffff at 100% opacity and #ffffff at 50% opacity the same colour? What about vector image formats: does a red square at 50% opacity partially overlapping a blue square count as two colours (red and blue) or three (red, magenta in the overlap, and blue)? What about gradients: does the number of colours depend on the size of the gradient-coloured object? – Peter Taylor Dec 20 '13 at 15:25
• Also, what counts as an image format? If a program supports paletted PNG but not non-paletted PNG, does that count as 0 formats, 0.5 formats, or 1 format? If a program supports SVG 1.0 and SVG 1.1 does that count as 1 format or 2 formats? Etc. – Peter Taylor Dec 20 '13 at 15:27
• @PeterTaylor: Thanks for your comments! I updated my question. – ProgramFOX Dec 20 '13 at 19:16
• I'm sorry, but I'm afraid the core of this challenge is to be as bold as possible when counting the amount of file formats my language's standard library can handle. – John Dvorak Dec 20 '13 at 19:33
• @JanDvorak: Of course, you should also look whether it's really worth to handle another image format, after you made sure to handle some other. If your score doesn't get lower, then it's not really worth. – ProgramFOX Dec 20 '13 at 19:35

## Implement addition using only division (code golf)

Thought you could implement division using only addition? Well try it the other way around!

Your job is to make a function or equivalent program that accepts 2 numbers and adds them using only division.

## Rules

• No importing libraries
• You can't use anything dealing with mathematics except / and /=, (and their equivalents)
• No bitwise operations
• No string operations except input, output, return, and string concatenation
• Interesting. You might have to close some loopholes, though, as some people will just create a giant lookup table. Also, some people could use string operations use perform addition. Is it going to be code golf? – PhiNotPi Dec 24 '13 at 16:49
• @PhiNotPi I think so, thanks for the tip. – Timtech Dec 24 '13 at 18:42
• Does "no string operations" refer to I/O as well? It's hard to do I/O without string operations of any kind – John Dvorak Dec 24 '13 at 19:21
• @JanDvorak I want to allow I/O - how do I rephrase the question as to allow I/O without allowing math by executing strings? – Timtech Dec 25 '13 at 16:17
• "division using only division" looks like an error... – Peter Taylor Dec 28 '13 at 10:17
• Is this a code golf, code challenge or a popularity contest? – ProgramFOX Dec 28 '13 at 10:56
• @PeterTaylor Thanks :) And @ ProgramFOX, it's code golf. – Timtech Dec 28 '13 at 14:36
• @Timtech Not the number of divisions required? – Johannes Kuhn Dec 28 '13 at 15:03
• @JohannesKuhn What are you talking about? – Timtech Dec 28 '13 at 15:10
• Tried to calculate 0+0 - the only thing I accomplished was a division by zero ;-) – Howard Dec 28 '13 at 16:20
• How do you prevent solutions like Array(a).concat(Array(b)).concat([0,0]).length? – John Dvorak Dec 28 '13 at 19:53
• Is eliminating string concatenation too restrictive? Maybe only allow the built in conversions from strings to numeric types. – Tim Seguine Jan 14 '14 at 11:38
• @Tim I guess so, maybe just disallow eval/expr. – Timtech Jan 14 '14 at 11:50
• and would mod be allowed? – Tim Seguine Jan 14 '14 at 12:07
• @Tim As it currently stands, no. Do you think I should add it? – Timtech Jan 14 '14 at 15:22

## Recognize spoken numbers of .wav file

The goal of this code golf is to create a program or function that recognizes (and outputs) the spoken numbers of a Waveform Audio File (.wav).
The rules are:

1. No network access and you are not allowed to run external programs.
2. The input will be the file path to the WAV file, and the spoken text will only be one of these digits: one, two, three, four or five.
3. The output must be the recognized spoken number of the WAV file.
4. You are not allowed to use third-party libraries.
5. This is a code golf, so the code with the smallest character count wins.
• What do you mean by convert to text? Encode? Recognise spoken text? – Howard Jan 21 '14 at 18:36
• @Howard: Recognize spoken text. I updated my question. – ProgramFOX Jan 21 '14 at 18:38
• That makes it a very subjective challenge. It is quite debatable if a wav file contains recognisable text or not. I can't think of a safe way to put restrictions on the input without making it to a fixed-input kind of puzzle. – Howard Jan 21 '14 at 18:41
• @Howard: You mean, for example, ensuring that the input will only be spoken text without background music? – ProgramFOX Jan 21 '14 at 18:43
• This needs some explicit restrictions on input. I assume that you're assuming that the text will be English, but even then there is a lot of accent variety. Most speech-to-text programs which U.S. companies release can't handle many (if any) British accents in their first version or two. I think that the only way this can be reasonably objective is either to invert a TTS program (in which case it's boring - no errors to account for) or to specify a training text and a test text, where it gets to hear the training text read n times and then tries to interpret the test text. – Peter Taylor Jan 21 '14 at 18:58
• Maybe it is possible if you restrict the challenge to recognise the spoken digits one, two, three and four. Although still difficult to define clearly spoken there may be small enough variation in the input. – Howard Jan 21 '14 at 19:09
• Maybe you can make a youtube video or something similar that contains all the sound that needs to be recognized; the programs just need to cater to those sounds. – Justin Jan 21 '14 at 19:32
• @Howard: That's a good suggestion. I updated my question. – ProgramFOX Jan 22 '14 at 14:14
• What's a "third-party library"? Can C# programs use MS libraries, Obj-C programs use Apple libraries, etc? – Peter Taylor Jan 22 '14 at 16:36
• @PeterTaylor: Yes, they can. – ProgramFOX Jan 22 '14 at 17:29
• Golfing msdn.microsoft.com/en-us/library/… would make for a rather short and boring answer. – Peter Taylor Jan 26 '14 at 15:37
• @PeterTaylor, ProgramFOX: It would make sense to forbid any libraries or programs designed for speech recognition, whether third-party or not. You might want to take a look at my earlier speech synthesis challenge for some ideas on how to word such challenges (and in the comments for some issues I should've thought of in advance). – Ilmari Karonen Feb 9 '14 at 10:08

## Print Lorem ipsum

The goal of this code golf is to write a program that prints EXACTLY this text:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

The rules:

1. No external resources
2. The shortest code in bytes wins.
• Is there any reason to expect the answers to be fundamentally different to those to existing kolmogorov-complexity questions? – Peter Taylor Jan 26 '14 at 15:33
• Won't the winner just post something like cout<<"/*text here*/";? This will probably be pretty boring, as the text needs to be hardcoded in. – user10766 Feb 6 '14 at 1:29
• @user2509848: No, I'd expect the winner to be something that packs the text in base 29 or 32 into a raw byte string and decodes it in GolfScript or some similar language. Or possibly some PHP code that starts with <?=gzinflate(. – Ilmari Karonen Feb 9 '14 at 10:00
• OK, but you will need to specify that in the rules. – user10766 Feb 9 '14 at 15:35