# What is the Sandbox?

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

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

## Get the Sandbox Viewer to view the sandbox more easily

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

• How are tags added to questions? – guest271314 Jan 9 at 7:51
• @guest271314 You can use this markup to create a tag in a draft: [tag:code-golf] – DJMcMayhem Aug 29 at 15:19
• Why no featured anymore? Can't we have it auto-added or something? – JL2210 Sep 26 at 15:57
• @JL2210 We now have a permanent info box that links to the Sandbox, so the featured tag isn't necessary – caird coinheringaahing Sep 29 at 13:43

# What's that frequency?

This is my first code-golf challenge, so apologies if it is a little unclear/already has been done. I gave the past challenges a good look over, but I may have missed something.

Create a function or a full program which accepts a frequency value, and then outputs the closest musical note, and the octave, this frequency corresponds to.

This function/program should support eight full octaves worth of notes, starting from C0 up to and including B8.

Test cases:

440.00 -> A4
466.16 -> A#4
466.20 -> A#4
261.63 -> C4
16.35 -> C0
0.00 -> C0
7902.13 -> B8
10000.00 -> B8


A full list of frequencies and notes they correspond to can be found here: https://pages.mtu.edu/~suits/notefreqs.html

This is a code golf, so shortest code wins!

New contributor
Henry T is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
• Thanks for using the sandbox! :) I found the inverse challenge. I feel as though I've reviewed this version as well, but perhaps it never left the sandbox. In any case, you should include a method by which to classify the frequencies, and what precisely you mean by closeness in the body of your challenge. External links are nice but not enough! – FryAmTheEggman 13 hours ago

# Digits of the sum of the reciprocal exponential factorials

The exponential factorial, $$\n^!\$$, is the extension of the factorial using exponentiation instead multiplication:

$$n^! = \begin{cases} 1, & \text{if }n = 0 \\ n^{(n-1)^!}, & \text{if }n \ge 1 \end{cases}$$

The first few exponential factorials are $$\1, 1, 2, 9, 262144, \dots\$$

The infinite sum of the reciprocals of the exponential factorials tends towards a constant:

\begin{align} \sum_{n=1}^\infty\frac{1}{n^!} & = 1+\frac{1}{2^!}+\frac{1}{3^!}+\frac{1}{4^!} + \cdots \\ & = 1+\frac{1}{2}+\frac{1}{9}+\frac{1}{262144} + \cdots \\ & = 1.611114925808376736\underbrace{111\dots111}_{183213\text{ times}}27224\dots \end{align}

The digits after the decimal point are OEIS A080219

You are to take a positive integer $$\n\$$ as input and output the $$\n\$$th digit after the decimal point of the above constant. Your program must work for an arbitrarily large $$\n\$$, but can fail due to language constraints for reasonably large $$\n\$$. You may choose 0 or 1 indexing. This is so the shortest code in bytes wins

# Meta

• Is this clear?
• Is this a duplicate?
• Tags are , and . Any suggestions?
• Any further feedback?
• The $symbol makes it look like you made a latex-typo :P Maybe you can mention that this is oeis.org/A080219 – flawr 8 hours ago • @flawr Given that it's the symbol used in the Wikipedia article, I think it's best to keep using it. And yes, I will include that OEIS sequence, thanks! – caird coinheringaahing 8 hours ago # A game of putting lines through dots. New contributor Sopel is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. Play snake on a 50*50 grid. The snake will start at length 3, heading (2,0) with body (1,0) and (0,0). It shouldn't bump into wall or itself. There is always one food, which increases the length of snake by 1 when eaten. Smallest amount of steps till there's no space to place food win. Flexible I/O, anyway it doesn't matter. Vote on whether the food placer is transparent and allow food manipulation(Up for yes, down for no) • I think there are already quite a few snake challenges. You need to flesh out some more details here. How do you determine where the food will spawn? Will you be given some sampling of the game state (vision?) on each step? – Beefster Dec 28 '18 at 19:22 • @Beefster If "food placer is transparent and allow food manipulation", you just know how it spawns; If not, you get access to the location of current food – l4m2 Dec 29 '18 at 3:44 • If food manip. is allowed, is the optimal score achievable by finding an Hamiltonian path starts with the snake? – user202729 Dec 29 '18 at 8:55 • @user202729 It depends on how strong the manipulation is – l4m2 Dec 29 '18 at 10:54 • -1 for winning entries must be written in one of the 25 top languages. – Jo King Jan 19 at 9:28 • I'm trying to exclude golfing languages with that - this only seems like an interesting challenge to me if you don't allow languages where it's excessively trivial. Any suggestions for how to do that in a more permissive way or other thoughts about that goal? – lahwran Jan 19 at 22:13 • actually, I think this will be quite difficult in many code golf languages as well, as they usually try to get brevity by cramming things into single letters and numbers. there are of course languages where it'll be excessively trivial, but that's fine, those solutions most likely just won't be upvoted. – lahwran Jan 19 at 22:21 • Most golfing languages won't be able to pull sth. from the interconnected-webs afaik, so there's no real need to invent arbitrary restrictions to ban them. – ბიმო Jan 21 at 16:25 • Also "but that's fine, those solutions most likely just won't be upvoted" is too optimistic, usually it's the other way around :( – ბიმო Jan 21 at 16:26 • dang, good to know. – lahwran Jan 21 at 22:55 # A Quine that Grows! Challenge Create a quine that, when run, outputs itself but copied larger in the next one. The output should be able to be run, and get larger each time the output is run. The output must consist only of characters from the original quine! EX: abc //original abcabc //output  or abc //original aabcc //output  What not to do abc //original abcgef //output abc //original abcoooooooooooo //output  An example I created Try it Online! It replicates pretty fast if I do say so myself! Points This challenge is meant to be a codegolf, but also emphasize on how fast it replicates. So perhaps something like the speed at which it gets bigger divided by the number of bytes. I really don't want loopholes like just repetitively adding characters to a section of the code, making infinite loops, and things of the like. Any input on how to make this a good challenge? I'm open to suggestions!!! • Related, related (probably a dupe) – Jo King Feb 10 at 10:25 • @JoKing What about a polyglot that gets bigger? It runs, making another program that runs and outputs a bigger version of the original, and vice versa. – KrystosTheOverlord Feb 10 at 16:02 • where's the polyglot part come from? otherwise that sounds like the second one – Jo King Feb 10 at 22:04 • @JoKing The output has to be in a different programming language, and then create a larger version of the original, then this larger original makes a larger of second program etc... Also to prevent easy loopholes, no using program languages that are derivatives of eachother – KrystosTheOverlord Feb 10 at 22:32 Just idea. Not sure what to do exactly. # Evolutionary Golf Make simple (not golfed at all at first) code for (some program) with language (something). Now, change a little bit (maximum 3 byte) of code to make it shorter. Altered code must work properly (this is how evolution work). (Maybe here will be starting code). ### Sandbox First. What program would be best? For example, 'Hello World' program is not proper, because it is too short, and can't golf that much. Second. What language would be best? Esolang like BF? Or something like C? • If I understand the challenge idea correctly you will post an ungolfed answer that does something in some (probably verbose) language (i.e. FizzBuzz in C#). And then answers after that should have a Levensteihn distance change $c$ where $1\leq c\leq3$ (at least 1 delete) that does the same thing (in any language). And the shortest answer that's at the end of the answer chain wins if no other answers are posted within 2-3 weeks (which is usually the case with answer-chaining challenges)? Or do you mean that anyone can post an ungolfed program, and others using the same language chain it? – Kevin Cruijssen Jun 26 at 9:04 • @KevinCruijssen I'm thinking of both. This is just brief outline, so everything can be changed. – LegenDUST Jun 26 at 12:10 • this is just game of nim with extra steps – Kenneth Taylor Aug 2 at 17:51 # Print all the commands META Just a rought idea, needs to be worked out. Write a program that prints all the keywords and commands that are available in your langauge when you do not import/add anything ### Details • require full program or standard code-golf? • Understanding that this is a rough idea, what happens in languages without commands corresponding to single tokens e.g. ///? – lirtosiast Jul 18 at 15:49 • It is my opinion that this sort of challenge will likely never be clear. – Wheat Wizard Jul 18 at 16:08 • I'd imagine for /// you'd output all valid non-text characters, so \ /. – bigyihsuan Jul 18 at 17:08 • Another thing is that language version would be specified. For example, Python 2 has print as a keyword, while Python 3 has print() instead. – bigyihsuan Jul 18 at 17:10 • Pretty sure this (or something similar enough to be a dupe) has been done before. Lemme see if I can find it .... – Shaggy Jul 21 at 21:11 • – Shaggy Jul 21 at 21:13 • One way to do this might be to make it language specific? While that isn't usually popular, outputting all of, say, Python's commands in most languages besides python is a dupe of the Rickroll challenge. However, in python itself that isn't the best approach. I can't say how well reveived it'd be, but you could try "output these MATLAB commands in MATLAB" and see what people think. – FryAmTheEggman Jul 23 at 19:45 Here's a challenge I'd like post because I'm curious to see what people will come up with. It's a bit of an anti-code-golf question because the code should look normal. Is it clear what the constraints? Did I miss anything? # Introduction Write a piece of unsuspicious code that does the following: Let's say you've written a parser that parses it's input line by line and somewhere in your code is find_string(line, "[start]", "[end]") // returns string between [start] and [end]  This program, when given it's own source code plain text as input, will match that line (twice actually); but we don't want that. It should still parse what it was designed for but not match any line of it's own source code. # Rules • It's preferred that your code makes it obvious that one of it's intended uses is to parse (and not match) itself. This is so anyone 'refactoring' the code will not accidentally undo the trick that made it work. • Your source code as input will be reduced to a single line. • Your program should be able to handle large input (~10mb) and perform reasonably (for your chosen language). • Your program does not need to parse the input line by line but that just seems like something reasonable code would do. • Points are awarded for code that looks like a normal parser and contains as little assumptions about the input as possible. Bonus points for solutions that contain the start and end delimiters in that order. Easy solutions are to swap the start and end token arguments or to pre-treat the tokens in some way but that would look suspicious. Someone will come along and refactor your code and break the 'trick'. I'm interested in reasonable solutions because this is a reduction of a real life problem. # Example Input and Output • Input lines may or may not contain [start] or [end], only return it in the output when it occurs in a pair. • Input lines will never contain more than one pair of [start] and [end] tokens. • Input lines may contain additional content before [start] or after [end] • Your source code plain text will be inserted at a random line in the input. Input #1: [start]hello[end] <<your source code plain text>> dont output this[start]world[end]  Output #1: hello world  Input #2: lorem[start]i solemnly[end] [start]false start [start]swear[end] ope, sorry just passing through this is not the[end] [start]that i'm up to[end]ipsum [start]no[end]dolor <<your source code plain text>> [start]good[end]  Output #2: i solemnly swear that i'm up to no good  • What is the objective winning criterion? – Unrelated String Aug 9 at 5:16 • This could be a good challenge if it was just 'Write a program that takes a line of input and returns the concatenation of anything between [start] and [end] on each line, otherwise an empty string', with the restriction that if it was fed itself, it wouldn't return anything – Jo King Aug 9 at 6:05 • I'm a little confused about what Bonus points for solutions that contain the start and end delimiters in that order. means, since I thought the point was that we're not allowed to have that? – Jo King Aug 9 at 6:07 • "unsuspicious code" will raise red flags in the minds of a number of old-timers, for historical reasons which I won't explain in detail. What I will say is that unsuspicious is subjective, and we insist on objective criteria. In terms of actual reasonable solutions to the real world problem: don't use magic strings. If "[start]" and "[end]" are both constants and defined on separate lines, the problem is averted, and anyone who refactors to inline them deserves all the bugs that causes. – Peter Taylor Aug 9 at 10:45 # Make it improbable... BUT NOT IMPOSSIBLE You must make a program that outputs truly once in a while. However, making it have output falsy all the time is not acceptable. ## Rules • Standard loopholes are forbidden. • You may use any of accepted I/O formats. • Your program must be possible to output a truly value. • When not outputting a truly value, you may either output a falsy value or not output anything at all. • You may output two or more values, however if it contains a truly value, then the output is considered truly. • The probability of outputting a truly value must be at most 1/2. • Your program must not take/use an input. • Using non-deterministic but non-random(Such as getting the time) is prohibited. However, if date etc. is used in the builtin random function, it is allowed. • The program must theoretically always terminate or stop outputting anything. • You may assume that you have a fast enough computer and large enough memory. • Your program should not be affected by raising the maximum value of a data type. You may still use unaffected constants. • Data types must be following its spec: ie. for an unbounded arbituary precision integer type, you may assume that it can go as high as you want(but you are not allowed to increment until an error as in the rule above), but a double-precision floating-point format still has 22-bit fraction and 8-bit exponent. • Score is calculated as: Pl-1.5l, where P is the probability and l is the byte length. ## Example(s) JavaScript alert(Math.random()<0.1) P=0.1, l=24 => Score=23.534  The lowest score wins! • So is it acceptable for just a program that always outputs truly? You need to define improbable. (I assume this probability must be at least lest than 1/2.) Providing a few examples will be helpful. So is there only output and no input? In addition, you need an objective winning criterion, which is a criterion that posts for this challenge will need to comply in order for it to be a valid answer. (Usually this criterion is making the source code shortest.) – A̲̲ Sep 24 at 13:37 • Sorry, I posted this incomplete. – Naruyoko Sep 24 at 16:14 • I don't think your scoring method works particularly well, unless I'm making an error. For any $l > 1$ your score cannot be less than 1. Achieving a score arbitrarily close to 1 is relatively easy. So the only way to beat that is to have a one or zero byte solution. It is easy to make the probability increase exponentially with linear code additions. It might be necessary to penalise length massively, like $P \times e^{l!}$, to avoid similar problems. – FryAmTheEggman Sep 24 at 18:39 • I see. I guess P^l^k is too penalizing but Pk or Pe^k is too forgiving. Pe^l! looks simple enough but is is the middle so it may work. – Naruyoko Sep 24 at 20:11 • The problem with any of scoring methods for this challenge is that it is possible for any increasing computable function f, a program with length l can have P around 1/f(l). The only non-broken formula could be uncomputable, i.e. P/BB(l), where BB is the busy beaver function. – Naruyoko Sep 24 at 20:15 Title: Transposition ** The challenge ** Given a set of notes (as a string, or a list, or any other reasonable input - but as letters and accidentals, not a numerical equivalent), the key those notes are in, and a target key; output the notes transposed into the new key. Some of the notes may not exist in the scale for the given key (e.g Eb in the key of C). ** Inputs ** The complete set of input notes for this challenge will use the English naming convention, and so are as follows: Ab,G##,A,A#,Bb,B,C,C#,Db,C##,D,D#,Eb,E,F,F#,Gb,F##,G,G# where "b" represents a flattened note (down one semitone per b), and # represents a sharpened note (up one semitone per #). Theoretically all notes can be extended further with more #s and bs; but for the purposes of this program that won't happen beyond what is already given. ** What is transposing? ** Transposing a song involves "moving" the song into a different key, by finding the equivalent note of the scale in that key. We will assume Major scales for the purposes of this challenge. ** Scales ** The scales for this challenge are officially as follows: • C: C, D, E, F, G, A, B, C • C#: C#, D#, E#, F#, G#, A#, B#, C# • Db: Db, Eb, F, Gb, Ab, Bb, C, Db • D: D, E, F#, G, A, B, C#, D • D#: D#, E#, F##, G#, A#, B#, C##, D# • Eb:Eb, F, G, Ab, Bb, C, D, Eb • E: E, F#, G#, A, B, C#, D#, E • F: F, G, A, Bb, C, D, E, F • F#: F#, G#, A#, B, C#, D#, E#, F# • Gb: Gb, Ab, Bb, Cb, Db, Eb, F, Gb • G: G, A, B, C, D, E, F#, G • G#: G#, A#, B#, C#, D#, E#, F##, G# • Ab: Ab, Bb, C, Db, Eb, F, G, Ab • A: A, B, C#, D, E, F#, G#, A • A#: A#, B#, C##, D#, E#, F##, G##, A# • Bb: Bb, C, D, Eb, F, G, A, Bb • B: B, C#, D#, E, F#, G#, A#, B For simplicity, we can assume that both notes in the pairs A#/Bb, C#/Db, D#/Eb, F#/Gb, G#/Ab, C##/D, F##/G, G##/A are enharmonically equivalent (i.e. interchangeable - although they're not, always). For scales with double-sharps, I will accept the enharmonic equivalents as an alternative implementation: • D#: D#, E#, G, G#, A#, B#, D, D# • G#: G#, A#, B#, C#, D#, E#, G, G# • A#: A#, B#, D, D#, E#, G, A, A# but for all other notes in the scale, they must match. If the note isn't in the scale, either can be used. e.g. • F in the key of C should transpose to F# in the key of C#, and not to Gb, because that option in the pair is explicitly in the scale • but D in the key of C# could transpose to either C# or Db in the key of C, because it's an incidental anyway and so there's no easy rule to determine which it should be. BONUS feel-good points *: normally it's # if you're going up, and a b if you're going down - feel free to implement this if you want! For double-sharps (e.g F##) in all cases, It's OK if the program "resolves" these (e.g.to G in that case) even if they are in the scale; but again, some BONUS feel-good points * if you keep the double-sharps in. Examples • CDEFGABC in C to A -> ABC#DEF#G#A • C# in C to A -> A# OR Bb • ABCDEFGBAF#Bb in Bb to Gb -> FGAbBbCDbEbGFDGb • CCGGAAAAGFFEEDDCGGGFFEEEDCGGGFFFFEEED in C to G# -> G#G#D#D#E#E#E#E#D#C#C#B#B#A#A#G#D#D#D#C#C#B#B#B#A#G#D#D#D#C#C#C#C#B#B#B#A# Websites like http://www.logue.net/xp/ can be used to test your answers to other inputs * Bonus feel-good points don't get you anything extra, unless someone can come up with a quantifiable difference that it should make to the score? • This is kind of similar but doesn't use scales and has a different set of chords, so I think this is effectively different? – FryAmTheEggman Sep 24 at 18:47 • Yes, I agree it's similar but doing a different thing to me (they're using chords, and so have the extra text to worry about; but I'm doing notes, like sheet music; and so you have accidentals to worry about) – simonalexander2005 Sep 25 at 8:48 # Interpret Unneccesary (Not quite) Unneccesary is a joke language created by Keymaker. The source is unneccesary, and if given, it will error out. Your task here is similar. If there is input, your program should error out. If the input is empty, your program should do nothing and terminate. • What does it mean to error out? – Beefster Oct 24 at 19:14 • @Beefster throw a runtime error... Or? – HighlyRadioactive Dec 1 at 10:15 • What if I'm using a language that does not have terminal errors such as Bash? – Beefster Dec 2 at 19:34 # Mirror, Mirror, on the wall. Who's the fairest of them all? Well, you know it's Snow White, and the evil Queen is at it again. Will Snow White be saved? Will she fall asleep once again? Will the Prince find her? # Challenge: Given an arbitrary number (>= 2) of possibly duplicated hexadecimal color values (ranging from #000000 to #FFFFFF) and paired strings, calculate the following: • If #FF0800 (Candy apple red) appears in the input, return "Return to Sleeping Death" • If #000000 appears in the input, return "Saved by Grumpy" • If #A98AC7 or #111111 appears in the input, return "Saved by Happy" • If #21E88E or #222222 appears in the input, return "Saved by Sleepy" • If #32DCD5 or #333333 appears in the input, return "Saved by Bashful" • If #43D11C or #444444 appears in the input, return "Saved by Sneezy" • If #54C563 or #555555 appears in the input, return "Saved by Dopey" • If #65B9AA or #666666 appears in the input, return "Saved by Doc" • If #76ADF1 or #777777 appears in the input, return "Saved by the Seven Dwarfs" • If #FFFAFA (Snow) appears in the input, return "Saved by Love's first kiss" • If an F variant appears in the input, return "Press F to pay respects to Snow White" • An F variant is any number that contains at least one F in its hexadecimal form, and is otherwise all 0s (e.g. #0FF0F0, #FFFFFF, #00000F, #F00F00) • If multiple of the preceding occur, return the "fairest" answer. The "fairest" answer is calculated as follows: • For all N occurrences of special color values, choose the (N-1)/2-th (truncating division) occurrence. The associated special output is the "fairest" answer. "Appears in the input" here refers to only the hexadecimal color values, and not to the paired strings. • If none of the preceding occur, return the "fairest" answer. The "fairest" answer is calculated as follows: • Take the hexadecimal color value at the end of input values, write it down, and exclude that single color-string pair from consideration as the "fairest" answer • Show its binary form to the mirror, computing a reflection of only the last 24 (#FFFFFF is the mask) bits. • Choose the hexadecimal color with least Hamming distance from the reflection. If there are multiple (N) such colors, choose the middle ((N-1)/2-th, truncating division) instance of the color. The "fairest" answer is the associated string for the color. # Inputs: A sequence of hexadecimal color values and String values separated by a space. The input may also be read as two separate sequences of hexadecimal color values and String values, or a single sequence of 2-tuples (either (hexValue, stringValue) or (stringValue, hexValue) is permissible, as long as the ordering is consistent across all 2-tuples). Input order matters - for each index, the corresponding element in the supply of color values is "associated" with the corresponding element in the supply of String values, and duplicates can affect the "fairest" answer. The effect is something like Function(List(HexColorValue),List(AssociatedStrings)) -> "fairest" answer. Hexadecimal color values may be represented as either (your choice of) a String "#"+6 digits, or 6 digits alone, as long as the representation is consistent across all color values. Here's an example input: 76ADF1 Return to Sleeping Death 2FE84E Return whence ye came!  Here's another example input: 2FE84E Return to Sender 4FFAFC Return of the Obra Dinn 2FE84E Return to the house immediately, young lady! 2FE84E Return to Sleeping Death 2FE84E Return of the Jedi  Here's the third example input: 2FE84E Return to Sender 4FFAFC Return of the Obra Dinn 2FE84E Return to the house immediately, young lady! 2FE84E Return to Sleeping Death 7217F8 Return of the King  Here's the final sample input: F4A52F Eating hearts and livers F4A52F Eating apples F4A52F Eating porridge F4A52F Eating candy houses F4A52F A Modest Proposal  # Outputs: The "fairest" answer as computed by the specified logic. For example, on the first sample input, the "fairest" answer would be Saved by the Seven Dwarfs, due to the special hex color 76ADF1 appearing within the input. In the second sample, there are no special inputs. First, we take "2FE84E Return of the Jedi", which has value #2FE84E. In binary, this is: 001011111110100001001110  We take the reflection from the mirror, getting: 011100100001011111110100  We compare it against 2FE84E (001011111110100001001110) and 4FFAFC (010011111111101011111100), which have Hamming distances of 18 and 12 from the reflection, respectively. Since #4FFAFC has the uniquely lowest Hamming distance from the reflection, the "fairest" answer is Return of the Obra Dinn. In the third sample input, there are no special inputs. First, we take "7217F8 Return of the King", which has value #7217F8. In binary, this is: 011100100001011111111000  We take the reflection from the mirror, getting: 000111111110100001001110  We compare it against 2FE84E (001011111110100001001110) and 4FFAFC (010011111111101011111100), which have Hamming distances of 2 and 8 from the reflection, respectively. All 3 instances of hexadecimal color value #2FE84E have minimum Hamming distance from the reflection, so we take the (3-1)/2=1th instance (0-indexed) of #2FE84E. Therefore, the "fairest" answer is Return to the house immediately, young lady!. In the last sample input, there are no special inputs. First, we take "F4A52F A Modest Proposal", which has value #F4A52F. In binary, this is: 1111010011001100101111  We take the reflection from the mirror, getting: 1111010011001100101111  We compare it against F4A52F (1111010011001100101111), which has Hamming distance 0 from the reflection. All instances of hexadecimal color value #F4A52F have minimum Hamming distance from the reflection. There are FOUR instances of #F4A52F, because we always exclude the last hexadecimal color instance from evaluation. Therefore, we take the (4-1)/2=1th instance (0-indexed) of #F4A52F, and the "fairest" answer is Eating apples. If you don't exclude the last value from consideration, you actually get the (5-1)/2=2th instance of #F4A52F (Eating porridge), which is wrong. # Rules: • No standard loopholes • Input/output taken via standard input/output methods. • The output must be exactly equal to the "fairest" answer # Scoring: This is code golf, so shortest program wins. Posted~ you can see it here • Going to need tag suggestions :) – Avi Sep 30 at 20:57 • Can each entry be taken as a tuple, i.e. ("#FFFFFF","Return the Slab")? Can the label part also have a hex number in it or are we guaranteed it wont? Rules has the # but the examples do not, is either form fine? Can we get a worked example of a list containing multiple matching entries? – Veskah Oct 1 at 12:33 • @Veskah You can take tuples as input. You can choose whether to keep # in your input hex colors or not, as long as you keep it the same for every single input (no sneaky stuff like putting a # before the correct answer every time). I've added more sample inputs/outputs with explanation. – Avi Oct 1 at 14:28 • -1: This has way too many hardcoded input/output mappings. This challenge is more about encoding those than solving a problem. – Beefster Oct 24 at 19:10 # CMC: Cross-Multiplication Calculator code-golfmatharithmetic In this task you should create a Cross-Multiplication Calculator. Cross-multiplication is a way of factoring an algebraic expression. This is the expression form that this way can solve: $$x^2 + ax + b$$ $$\a\$$ and $$\b\$$ are constants here, and $$\x\$$ is a variable. Anyway, as far as I can tell, this expression form is only solvable in this method. # Anyway, how do I do Cross-Multiplication? (TODO) You first take the number $$\b\$$ and factor this number into integral factors. Okay. We are using the expression $$\x^2 + 8x + 16\$$ as an example. (Although 16 is not a prime) let us assume that 16 only has 2 possible factors: • $$\-1 \times -16\$$ (because $$\-x \times -x = x^2\$$) • $$\1 \times 16\$$ (Obviously this is 16) • And the above 2 with the factors reversed. Now you sum these possible two factors and check this against the number $$\a\$$. • Check 1. So $$\-1 + (-16) = -17\$$. And unfortunately -17 is not 8, we proceed to the next check. • Check 2. So $$\1 + 16 = 17\$$. And unfortunately 17 is not 8, we proceed to the next check. There are no checks left. Did I make a mistake? Of course, I need to change the factors. • $$\-2 \times -8\$$ (because $$\-x \times -x = x^2\$$) • $$\2 \times 8\$$ (Obviously this is 16) • And the above 2 with the factors reversed. We sum those values, and they are -10 and 10 respectively. So I should change the factors to another value: • $$\-4 \times -4\$$ (because $$\-x \times -x = x\$$) • $$\4 \times 4\$$ (Obviously this is 16) • And the above 2 with the factors reversed. Finally! $$\4+4 = 8\$$, and here is the factorization: $$(x+4)(x+4)$$ Now you will probably realize why I desperately need a program to automate this. # Test cases You can assume that the input is always valid. You do not have to specify the variables, only the numbers. Therefore the expression $$x^2 + ax + b$$ is converted into: $$+a \, +b$$ The expected output is not: $$(x+\alpha)(x+\beta)$$ but: $$+\alpha \, +\beta$$ a, b => α, β 8, 16 => 4, 4 -5, -24 => 3, -8  # Scoring This is , so shortest answer in bytes wins. ## Meta • Is this clear enough? • I haven't found a duplicate, but anything? (Although unlikely, I found nothing by searching "Cross Multiplication".) • Tags are code-golf, string and interpreter. Anything else? • Any further feedback? • I've edited your post to use MathJax for the mathematical formula/workings. In addition, I've edited out the rather strict input/output format (leading + etc.) as it's generally recommended to allow the most natural output format. Feel free to revert these changes if you dislike them. Also, your tags bullet point in the Meta section appears to be different to the tags in the title? – caird coinheringaahing Oct 21 at 17:48 • Finally, I'd vote to close this as a duplicate of this or this challenge (as it is a subset of both) – caird coinheringaahing Oct 21 at 17:51 # Parse a regex Grep is a wonderful tool. It can find stuff in files, it can help you spell stuff correctly (grep 'whatever' /usr/share/dict/words or wherever that file is), and it can even test if something is a prime number! However, the first version was implemented back in the golden age, when FORTRAN was respected, Pascal was the language for beginners, and object orientation was just starting out in on its great adventure. One could argue that modern developers have nowhere near that much talent or skill, what with their flashy "IDEs" and "frameworks". If they would be asked to implement something similar, they would just jump at the nearest library or cloud thingimabob and say "Done!". At least, that is what some would say. ## Prove them wrong! Golf grep! Parse a regular expression without calling any built-in functions or operators explicitly meant for this. ## input: Basically the same as a simple grep: a regular expression as a command line parameter, followed by an optional filename or a dash. If the filename is not present, or it is a dash, read for stdin. This is the recommended way to do it, but if you can write an adapter (eg: post stuff to a php form for your program via a shell script), then that is OK as well. The adapter does not contribute to your score. ## output Lines that match the regular expression. ## Notes: The regex dialect is PCRE (perl compatible). Files use unix line terminators if it is relevant. • Closely related, but not quite a duplicate. – AdmBorkBork Nov 18 at 20:42 • Why the downvote? – Mark Gardner Nov 20 at 8:16 • You've likely been downvoted because you "ban built-in functions or operations explicitly meant for this." Consider this post for a lengthy discussion of why this has fallen out of favour. Beyond this being trivial besides parsing regular expressions, it also doesn't actually describe what a regex is or what it means to be PCRE. Challenges need to be self contained! I think your bet is to make a different matching language yourself and ask us to implement grep but with that language instead of regex. – FryAmTheEggman Nov 20 at 19:09 # Predict the state of a Minecraft inventory after click events Minecraft does inventory management over the network by sending packets describing the clicks that a player does. If you're caching these events, it can be non-trivial to predict what state the inventory is in after the clicks ## Challenge Take an inventory of 9 slots, each with an item and a type. Assume all items can stack up to 64 and that if a slot would be "overfilled" that the cursor will continue holding onto the items. Then, take a list of the slot index, button, and mode variables for the clicks to be done (mode and button are defined at https://wiki.vg/Protocol#Click_Window). Output the inventory afterwards. ## Restrictions/Rules You may input and output the inventory in any reasonable format. You may take click input in any reasonable format. You may ignore Mode==2, as the player inventory is not implemented correctly enough for this. You may ignore Mode==3 because this is a survival player You may ignore Mode==5 where Button==8, 9, or 10 for the same reason as Mode 3. Dropping the item is a delete. Your player won't pick it back up or anything silly like that. You may assume that input will have valid counts Don't use standard loopholes ## Examples Input: [["diamond",64],[],[],[],[],[],[],[],[]] [ [0, 0, 0] [0, 0, 1] ]  Output [[],["diamond",64],[],[],[],[],[],[],[]]  Input: [["diamond",64],["dirt", 64],[],[],[],[],[],[],[]] [ [0, 0, 0] [0, 0, 1] [0, 0, 2] ]  Output [[],["diamond",64],["dirt",64],[],[],[],[],[],[]]  Input: [["diamond",64],[],[],[],[],[],[],[],[]] [ [0, 0, 0], [-999, 4, 4], [0, 4, 5], [1, 4, 5], [2, 4, 5], [3, 4, 5], [4, 4, 5], [5, 4, 5], [6, 4, 5], [7, 4, 5], [8, 4, 5], [-999, 4, 6], [8, 0, 0] ]  Output [["diamond",56],["diamond",1],["diamond",1],["diamond",1],["diamond",1],["diamond",1],["diamond",1],["diamond",1],["diamond",1]]  # Meta I have no clue what I'm doing writing a question. Tagged code golf Critique goals: • Improve testcases • Improve description of problem • Determine if the problem is too complex • Challenges are meant to be self-contained. While information where the idea/process comes from can be nice, everything needed to solve the challenge should be in the description. This means you should write down what click does what, for all the people who don't remember what Minecraft clicks do by heart. – AlienAtSystem Nov 22 at 6:43 A very-very old (maybe early 2000s) problem: Print out a decimal number $$\n\$$ such as $$\n^2\$$ ends with $$\n\$$ with maximal length your program can compute in 60 seconds In other words it's needed to find some long enough $$\n\$$ such as $$\10^{\lfloor\log_{10}n\rfloor+1}|(n^2-n)\$$. A hint may be that an $$\n\$$ ending with $$\5\$$ is more easy to compute than an $$\n\$$ ending with $$\6\$$. • How can this be king-of-the-hill? Do you mean code-challenge? And what stops us from hardcoding some extremely large number? – Jo King Nov 21 at 23:36 • king-of-the-hill needs interaction between submissions. I don't see any here – Jo King Nov 22 at 1:43 • @JoKing the problem becomes very simple with modular arithmetic: got 205k digits for free with ~len(n) time for each step imgur.com/ExPdwMb , so there's no need for hardcoding and it's not much interesting. ) – Alexey Burdin Nov 22 at 14:11 # JavaScript: Free for All This is a very experimental idea of mine: given a function which is provided a single function as an argument, try to run that function the most times possible in a browser environment while competing against other bots. ## Bot submissions Each bot consists of a function. This function takes a scoring function as input. Each bot has a state consisting of three values: • score: Number indicating score, winning criterion • locked: Boolean which, when true, prevents further score increases • calls: Number of times scoring function called in last 100ms (?), will set locked to true for the remainder of the round if it exceeds a certain value The scoring function increments score and calls, as long as locked is not true. ## Restrictions If any of these restrictions are violated, a bot will have locked set to true. No bot or bot-defined function may: • Run longer than 5ms • Attempt to modify the window location (location.href, location.assign, etc.) • Attempt to connect to the internet (AJAX, WebSockets, etc.) • Create web workers • Affect hardware (sound, microphone, camera, USB, gamepads, etc.) • Download files • Leave an impact which cannot be fixed by reloading the page ## Notes This is almost certainly a very bad idea on an assortment of levels. If you have any suggestions of restrictions or ways to make the challenge more interesting, be sure to comment. I'm considering some sort of system to determine which bot runs first that adds to the strategy, and interesting attack angles for other bots. To prevent this from becoming a "read the last answer and exactly cancel out its strategy" type thing, I'm open to any suggestions. # Every number is interesting We know that every number is interesting but how? You should write a program or function which: • takes a list of N positive integers (>0 and <2^31) • outputs N lines each of them showing how the corresponding input number is interesting • is not longer than 1024 bytes • uses no more than 1 second per number • doesn't use external sources ## Examples 172: 444 in base6 5776: 76*76 9801: 9 * 1089 (reverse) 68101: no 11 in base2 (10000101000000101) 491033: 317 * 1549 (product of 2 big primes) 467808816: no digit 5 from base6 to base10  ## Inputs You should include the output for the following input in your post: 58 92 120 224 358 490 912 1578 7812 222008 1645060 19796411 550453633  If you care to run your program on a bigger sample and share the result with us use this input data (2500 numbers). (You can upload your output to e.g. pastebin.) This is a popularity-contest so highest voted answer wins. Tags: popularity-contest, number • What sort of criteria are necessary for defining a number as 'interesting'? I see things like square numbers, other bases, etc. But are there any specifics? I'm interested in this challenge (but worried it might be closed as too broad). – ASCIIThenANSI Apr 7 '15 at 13:18 • @ASCIIThenANSI There wasn't a clear definition. That's part of the reason why I abandoned the challenge. – randomra Apr 8 '15 at 1:55 • Would you mind if I tried taking it up? I would have to post as a new answer, because I can't directly edit. – ASCIIThenANSI Apr 8 '15 at 2:00 • @ASCIIThenANSI Not at all. – randomra Apr 8 '15 at 2:01 • @ASCIIThenANSI Where did you post it? – wizzwizz4 Jul 24 at 13:33 • @ASCIIThenANSI I am also curious – MilkyWay90 Aug 27 at 23:41 # Something Else - ASCII Art maker: A text to ASCII art generator maker, the program must input a string and return ASCII art from it. Something like patorjk.com/software/taag/. It has to use the Graffiti font. The winning criteria is the whoever gets the most likes. • Hello! Just a few things to point out: 1) The current spec is very broad. For example, what fonts, how does spacing look, what characters need to be supported... there's a lot more details that need to be included than just "return ASCII art of this text" – Sp3000 Feb 24 '15 at 4:07 • 2) What's the winning criterion? Popularity contest? Code golf? – Sp3000 Feb 24 '15 at 4:08 # Identifying a Sonnet This challenge is about determining if a given file (read-in from stdin) meets the criteria to be a sonnet. You may use any language for this challenge. If your language supports an API to use an online dictionary you may use that API, if your language doesn't then too bad. Additionally, it is preferred if your language is one that can be ran directly from the command line and is a language that has a compiler or interpreter available directly from my distro's repos(Fedora), as I would rather just use a bash script to test the various programs, then test each program manually. # Definition of a Sonnet • Has 14 Lines (lines are denoted as the standard newline on your operating system). • Has a definite rhyme scheme, it will have one of the following rhyme schemes • ABBA ABBA CD CD CD • ABBA ABBA CDE CDE • ABAB ABBA EFEF GG • Iambic Pentameter - consists of alternating stressed, unstressed syllables. This doesn't have to be perfect 100% of the time, just at least 50% of the time. In order for your program to declare a given string a sonnet, it must meet all of the above criteria. ## Additional Notes You do not have to identify the following: • Thought Structure - too intense for a code golf challenge, and too subjective. • Topic - computer lacks context to determine this # Input Input will be read from stdin. This is the string that you will be declaring to be or not to be a sonnet. # Output Your program will output either yes or no for the question: Does this string meet the given requirements to be a sonnet? As this is code golf yes or no can be abbreviated to Y/N. # Winner The solution with fewest number of bytes win that has the highest accuracy ratio for the correct identification of a sonnet. The preference is for higher accuracy rather than brevity of the program. # Test Data and Resources ## What is not a sonnet The following are examples that you program should return false on: • Beowulf • Haiku • Input that doesn't have exactly 14 Lines in it • The text of this question. • The text of just about any other question on StackExchange. • Things that don't have a rhyme scheme. See Below # Not A Sonnet A man got on a boat The boat was leaky and had poor construction For it was made by a one-eyed blind man and his dumb intern As soon as he got out of port at the fort it started to sink eventually, it tanked. And it capsized If only that shipwright wasn't so blind deaf and dumb as microsoft tech support That's not much support at all.  • I think without dictionaries for rhymes and stresses this is probably not a good idea. Of course you can use some sort of accuracy ratio, but then you also need false positives, and you need a lot more examples than the few on the pages you've linked. But if you do this there's no requirement to actually recognise the sonnets by their rhymes and stresses - instead, I'm pretty sure, people will just regex golf the test sets. – Martin Ender Mar 24 '15 at 19:36 • @MartinBüttner I updated the requirements with an accuracy percentage, and added the option to use an API to look up terms from a dictionary. – HSchmale Mar 24 '15 at 19:57 • 1. Test data which only covers one possible output isn't test data. I can write a program which always outputs Y in as little as one byte and it will pass all of the linked "test data", but it comes nowhere near to meeting spec. 2. Unless you specify which rhyme/stress dictionary to use, you can't guarantee that the test data is "correct". – Peter Taylor Mar 24 '15 at 20:20 • @PeterTaylor I added examples of what is not a Sonnet. – HSchmale Mar 24 '15 at 20:32 • I'm not sure how to say this, but it feels as though this task has a lot of individual parts, each of which could be quite tricky. Especiallly detecting rhymes/syllables/stresses, since words can be pronounced/stressed differently based on context. Also if you're using Shakespeare's sonnets I have no idea where to get rhyming and stress dictionaries for Elizabethan English... – Sp3000 Mar 25 '15 at 14:18 • To make this interesting, you'll need some interesting near-misses: non-sonnets that can't be detected by something simple like counting lines or words per line. – xnor Mar 25 '15 at 20:59 • @xnor You mean a file with a that looks like a sonnet but has no rhyme. – HSchmale Mar 25 '15 at 21:04 • Yes, for example. Or, one with rhyme by wrong rhythm. Or, one with nonsense characters that seem to "rhyme". – xnor Mar 25 '15 at 21:06 • @Sp3000 You can just use modern english, or just base it on words that have similar endings. – HSchmale Mar 25 '15 at 21:11 # Create a Drawing Guide for a Polygram Poor old Jim, he's just terrible at drawing polygrams, and he's asked you to create a "drawing guide" for him - an ascii polygram with numbered edges, so he can follow the instructions. ## Challenge Write a program to produce an ascii polygram with P <= 10; each edge of the polygram should be made of a single digit 0-9, showing the order in which the edges should be drawn. ## Input Your program should receive (via STDIN, as function arguments, or some other language-appropriate method): P, the number of edges/vertices of the polygram, and Q, the spacing. In the notation as per the Wikipedia link, you'll be drawing a {p/q} polygram. ## Output Either print to STDOUT or return (or something else language-appropriate) a multiline string showing the drawing guide for the given polygram. The string can be any size you like, as long as it's large enough to display a clear polygram. ## Notes Your code should be able to handle compound regular polygons as well as regular regular polygons, and also inputs of q > p/2 (poor old Jim doesn't realize that the polygram for {p/q} is the same as for {p/p-q}). ## Example Output for {10,3}  5 5 4 4 21 5 888 2 11115 8888 7 2 5111888 4 7 2 888111 4 7 2 888 111 7 8885 4117 8882 4 711 8 2 5 7 111 25 47 9 5 7 0 9 2 74 0 52 7 0 9 2 7 4 5 92 7 04 9 70 4 5 2 7 5 29 7 4 6666 2 9 07 33 666 0 7333 2 696 337 2 9666 333 7 2 9 66633 0 7 2 333 666 7 2 339 666 7 2333 9 0 67 9 0 0  ## Scoring This is code-golf, so shortest in bytes wins. Tiebreaker goes to the most votes. • I have a python solution to this which is ~600 bytes, so it's definitely doable, and it's not easy... – sirpercival Apr 27 '15 at 4:31 • I think the spec needs to be more prescriptive for this to make a good question, especially since the example seems to indicate that you're not currently even prohibiting the lines from having gaps. At a minimum I would say that you should require the lines to be equivalent to those produced by Bresenham's algorithm, and specify how overlaps should be handled; at the extreme, you could tie it down so tightly that it becomes a parameterised kolmogorov-complexity. – Peter Taylor Apr 27 '15 at 9:34 # Pointer to pointers to pointers to pointers You should choose a language supporting pointers like C. And your task is simple: demonstrate a legitimate use of the most level of pointers. You should justify your code by describing an algorithm that: • Has only plain text, number or an array of those as input and output. • You think it will make things easier to write those code as a part of the implementation of this algorithm. • This implementation would have optimum memory usage (only declared variables and parameters, explicitly allocated space, and the return addresses for recursive functions count). Other rules: • They must be pointers to pointers directly, i.e. a pointer to an object containing a pointer doesn't count. It's better if nobody using this code will want to extend some pointer to an object later. • Each pointer must have a different type (if your language can somehow make them the same type). • You should create at least one pointer, and either dereference or compare two non-null pointers once in each level. • Using pointers as arrays is only half as interesting. • Iterators, etc, are considered in essence pointers and allowed in this challenge. But you can't define new types implementing iterators for this purpose. • Could you specify "legitimate"? This sounds a bit like code bowling (and seems to have the same issues). With enough imagination I'm sure I can justify any depth of pointers. – Martin Ender Apr 30 '15 at 17:43 • @MartinBüttner Edited but, basically, it is subjective. – jimmy23013 Apr 30 '15 at 17:57 • @MartinBüttner Added a restriction to have optimum memory usage. I'm not sure whether it works. – jimmy23013 Apr 30 '15 at 18:19 # Winning Tic-Tac-Toe lines For a given tic-tac-toe board of size N**D (for example, a normal tic-tac-toe game is 3**2), the number of winning lines of length N is given by the expression: $$2^{D-1} + \sum_{S=1}^{D-1}2^{S-1}DN^{D-S}$$ (Basically, you are summing the number of lines in each S-dimensional slice of the board.) # The challenge: Given N and D, your answer should output a list of D-dimensional coordinates for each winning line. Input and output are any reasonable format. You can assume that both N and D are positive integers, with N > 1. (Degenerate cases of N=1, D>1 not included.) Since this is , fastest answer wins. Please explain your algorithm! • How do you intend to determine which of two answers is fastest? – Peter Taylor May 12 '15 at 19:37 • yes, @randomra made the same point on chat. i'll edit this in, but i guess... i'll put together some test cases and then time them? i dunno, i was going back and forth between this and code-golf, but i'd prefer interesting and readable algorithms. – sirpercival May 12 '15 at 20:10 • i posted this here because i really want the answer, and i hate coming up with brute force solutions... :D – sirpercival May 12 '15 at 20:16 • Um. Given that you're asking people to enumerate an exponentially large set, in what sense will the answers not be brute force? – Peter Taylor May 12 '15 at 20:28 • well, there's brute force and then there's brute force. but really it's because i don't want to do it myself, haha. – sirpercival May 12 '15 at 20:34 • also, making use of symmetry can severely reduce the computation. – sirpercival May 12 '15 at 20:40 • I imagine that the runtime in any such algorithm will be basically proportional to the number of things you print, so there won't be any good way to improve by algorithm and the speed will be very platform-dependent. – xnor May 12 '15 at 23:40 # Ayn Random number generator Inspired by xkcd 1277: Write a random number generator that takes no input and generates a random integer between 1 and 100. When run less than 200 times, the frequency of all numbers needs to be between 0 and 2, but when it's ran 50 000 times, the number 42 (obviously) should have a frequence that's more than 4 standard deviations higher than the mean. Format is code-golf. Your score is the bytecount of your code. • 1. I think it's difficult to decide objectively whether a PRNG appears to be fair at first sight. 2. The term more often should probably be quantified. – Dennis May 18 '15 at 21:49 • I see lots of C rand()%1000 and the like incoming... – rorlork May 18 '15 at 22:05 • @Ypnypn I have changed the criteria to have much lower numbers so they're easier to verify. – Nzall Jun 6 '15 at 13:04 • @Dennis I have rewritten the question to clarify what "being fair" is and what "more often" actually entails. – Nzall Jun 6 '15 at 13:05 • 1. Are you thinking of a standalone program that you run multiple times or a function that is allowed to keep a state? In the first case, not even a perfect RNG will, with overwhelming probability, satisfy the first condition. 2. Do you mean the mean and standard deviation of a perfect, uniform RNG or the one the code implements? – Dennis Jun 6 '15 at 23:44 • @Dennis I'm thinking of just a function AynRandom() that gets called. The frequency of numbers with a small number of iterations is subject to change, maybe from 0 to 4. The mean and Standard Deviation must be the one the code implements. – Nzall Jun 7 '15 at 9:49 • between 0 and 2 ? so print 42 would be a valid program ? – Falco Jun 11 '15 at 15:32 • @Falco No, because 42 would appear more than 2 times (unless you only run it twice). The problem is that I need a way to indicate that the RNG is fair with a low iteration count, but unfair with higher iteration counts. The only way I can make it work is by stating that with low iteration counts, all numbers should appear about equally often, which is either 0, 1 or 2 times. – Nzall Jun 11 '15 at 15:36 Please nitpick this. If there's anything that wouldn't work or would be inconvenient, however small of an issue it is, tell me about it! Also, suggestions for [adjective] are more than welcome. # Determine how [adjective] a number is (code-golf) A number would be considered [adjective] if 0 is the result of multiplying its digits together, then multiplying the digits of the resulting number, then repeating until a single-digit number is produced. The more steps it takes to reach 0, the more [adjective] the number is; if the resulting number is not 0, though, the number is not [adjective] regardless of how long it took to finish. The formula used to determine [adjective]-ness is 10-10/T where T is however many numbers it took to reach 0 (including 0 and the initial input) Your goal is, as the title says, to write a program or function that determines how [adjective] a number is, and prints every iteration along the way. Here are some example inputs/ouputs: in: 879 out: 879 <- (T=1) 504 <- 8*7*9 (T=2) 0 <- 5*0*4 (T=3) <- optional newline 6.6... <- 10-10/3 (repeating decimals can be expressed in any way you want) in: 2468 out: 2468 <- T=1 96 <- (T=2) 2*4*6*8 54 <- (T=3) 9*6 20 <- (T=4) 5*4 0 <- (T=5) 2*0 8 <- 10-10/5 in: -888 out: -888 -512 <- -8*-8*-8 -10 <- -5*-1*-2 0 <- -1*0 6.6... <- 10-10/3 in: 1344 out: 1344 48 32 6 0 <- did not produce 0, so the prog/func returns 0  Your program must follow these rules: -Takes input from STDIN. -Throws an "error" (printed to STDOUT) and halts immediately after input if the input has one or more 0s in it or if it's less than three digits in length. The error must be a string, and as it's supposed to be printed to stdout, cannot be one generated by the language itself (eg 1/int(min(input())) to check if it's zero). Lastly, the error message has to clearly define what the error is; ERR:0 and ERR:LEN, for example, would suffice. Bonuses/Penalties: -25 if it properly handles decimals. For instance, an input of 99.22 would first turn into 9*9 + 0.(2*2), or 9*9 + 0.4, and so on. This is , so the shortest answer in bytes wins. • I don't like the +15 penalty. Whether strings are used is vague in some languages. The constant amount +15 is too little deterrent for some languages but huge for very concise ones. The fact that you've found a short solution you don't like is sign you should rethink the problem, not try to plug the hole. – xnor Jun 17 '15 at 7:48 • @xnor that's reasonable. I suppose it is a valid way of doing it, anyway, so I removed all mention of strings in that section. Should I also inc/decrease the bonus for decimals? – M. I. Wright Jun 17 '15 at 22:29 • The programming languages I know either don't allow throwing user-defined errors or print them to STDERR. Now, if you just want us to print a message and exit immediately... – Dennis Jun 17 '15 at 23:32 • ...and should be printed to STDOUT. I had a feeling that wasn't clear; I edited it, is it better now? – M. I. Wright Jun 17 '15 at 23:33 • It's the word throw that throws me off (no pun intended). To throw an error usually means something rather specific. Print an error message to STDOUT (or closest alternative) would be less confusing in my opinion. Also, since this is code golf, I think you should require specific error messages. There's no fun in losing a contest because you chose ERR:LEN and somebody else got away with EL. – Dennis Jun 18 '15 at 3:16 • Remove bonuses altogether. It's in the list of things to avoid. – mbomb007 Mar 1 '16 at 21:31 • The error if the input contains a zero seems like a separate challenge. It may be better received if there is only one challenge. There is community support for avoiding Chameleon challenges. – trichoplax Aug 10 '16 at 11:40 # Represent a Number in the Strangest Way You Can Think Of.. while staying under 8 unique characters Your goal is to represent some numbers in the strangest way possible. ### Rules: • The result must be a number that can be used in the programming language like any other ordinary number. For instance, <my expression> + 3 should return 3 more than the value of <my expression>. • The code must be under 20 kilobytes. That's a rather large size for a number so you should be all set. • The expression must have under 8 unique characters! The length of it can be as long you want, just keep it under 8 unique characters. aaaaaaaaaaaaaaaaaa is valid (if it works in the programming language) but abcdefghijklm isn't valid because it uses 8 or more unique characters. ### Guidelines: • The goal here is to represent a number in the strangest and most interesting way possible, so if I ask you to represent the number 35 it would be a good idea to respond with something more interesting than 35 or 12 + 23. • This isn't a ! Feel free to make your code as long as you want, so long as it's under 20 kilobytes. Fancy code can look nice! • The code doesn't need to support decimals (floats) but if it does, it will get 10 extra points (see below). • The code also doesn't need to support negative numbers (for instance -37) but if it does, it will get 10 extra points (see below). • Try to make your post follow the below: ### Post format: # Language Description ### 0 ...  ### 1 ...  ### 30 ...  ### 108 ...  ### 1337 ...  ### 1234567890 ...  ### 3.1415 [10 bonus points if you can get this!] ...  ### -25 [10 bonus points if you can get this!] ...  ## Bonus numbers: ... The points is equivalent to the number of votes on the answer plus 10 if it supports decimals with 10 more points if it supports negative numbers. Whoever has the highest points is considered the current winner. Have fun! This is my first go at making a popularity contest so if you have any tips those would be appreciated.. :) • This is a great challenge... whoever downvoted this has to rethink their concept of code-restriction challenges... – WallyWest Jul 15 '15 at 22:49 • Ah, thank you. :) – Florrie Jul 15 '15 at 23:28 • Updated again with negative numbers added (-25), as well as 1 and 0. – Florrie Jul 15 '15 at 23:33 • @Sp3000 8 unique chars, not 8 total. – isaacg Jul 16 '15 at 10:04 • @isaacg Didn't I state that? – Florrie Jul 16 '15 at 11:11 • @liam_ You did, the person I was responding to who deleted their comment missed it. – isaacg Jul 16 '15 at 11:32 • TBH, I think this is such a poor popcon that it can't be rescued, but if you want to at least make it clear what you're asking then: 1. You talk about representing "a" number, but also about "support[ing] decimals" and "support[ing] negative numbers". What exactly do you want? A function which maps numbers to code? But if so, the "Post format" makes no sense. 2. What is the code which has a 20kB limitation? Total for all the numbers listed in the "Post format"? Each individual number listed in the "Post format"? Something else? 3. Are the 8 distinct characters per number or for all numbers? – Peter Taylor Jul 17 '15 at 16:19 # Wrong tool for the task ### Task Write two full programs in the same programming language that solve the following two tasks: 1. Read two positive integers from STDIN and print their sum to STDOUT. 2. Read two positive integers from STDIN and print their product to STDOUT. Additional details: • Given enough time and memory, your programs has to support arbitrarily large integers. • All integers (input and output) use standard decimal notation, have no leading zeroes and are followed by a single linefeed. ### Scoring The first task is code golf, so your objective is to make your program as short as possible. The second task is code bowling, so your objective is to make your program as long as possible. Your score is defined as follows: The highest score wins! ### Robbing a language There's a catch! Only the submission with the shortest program in a particular language will be considered valid for task 2, so there can only be one valid answer per language. This means that you cannot deliberately write a huge program for task 2; you actually have to pick the "wrong tool" for the task. Additional details: • Task 1 exists merely to provide the proper denominator for the score (and robbers have no moral anyway), so byte-per-byte copies of somebody's program for task 1 are allowed. • If two answers use the same language and have programs of the same length for task 2, the answer that achieved that length first will be considered valid. • If somebody invalidated your answer, you may attempt to golf your answer to revalidate yours and invalidate his. • I suspect this will come down to people writing code in unary and disagreeing on what input/outputs formats are valid for such a language. – xnor Jul 20 '15 at 20:17 • @xnor I'm not sure I understood your comment. The format for I/O is purposedly restrictive, so an answer's validity should be clear-cut. – Dennis Jul 20 '15 at 20:25 • @feersum I think the log scoring does benefits unary. Say (making up numbers) task 1 takes 100 chars of BF and task2 takes 150 chars. Then, those are translated to 300 chars and 450 chars of binary, and so 2^(300) and 2^(450) chars of unary, giving a score of 1.5. In comparison, if the tasks take 20 chars and 50 chars in another language, that's about a score of 1.3. I guess this is surmountable though (20 and 100 gives 1.5). – xnor Jul 20 '15 at 20:33 • Are the inputs decimal numbers? For a language like BF, can the numbers be taken as byte values rather than characters? What separator should be used between the numbers? Are leading zeroes OK in the output? I think you'll have to be pedantic and precise about everything given how much of the character count may depend on details, but it's doable. – xnor Jul 20 '15 at 20:35 • Yeah that's right, it is only for Unary. – feersum Jul 20 '15 at 20:37 • @xnor All integers (input and output) use standard decimal notation, have no leading zeroes and are followed by a single linefeed. – Dennis Jul 20 '15 at 20:42 • @Dennis Wow, you anticipated everything and I missed it. I take it then that input must be as a string of numerical characters? Also, do I understand right that you have to print a newline for output (say, print a+b,"\n" in Python)?. – xnor Jul 20 '15 at 20:45 • @xnor Yes to both. The newline is required and you have to use numerical characters. I'd specify the exact character range, but I don't want to exclude non-ASCII languages.I'll think of a way to make it clearer. – Dennis Jul 20 '15 at 20:51 # GitHub Gist command-line client Create a command-line tool that publishes a list of files as one public GitHub Gist. ## Specification The following bullet points describe the behavior of the program. If a bullet point has "must", you must implement that point. If a bullet point has "can optionally" or "should optionally" you can implement that point on your own volition. 1. It must be a complete command-line program. 2. It must use the GitHub Gists API. 3. It must post an anonymous Gist (that is, not as a GitHub user). 4. Gisted files must use the filename provided on the command-line. 5. The command-line must accept multiple positional arguments. 6. If no arguments are specified, it must print this usage to STDOUT: gist: usage: <file> [file...] verbatim then exit with code 0. 7. If something else goes wrong, it must print this message to STDERR: gist: unable to gist =( verbatim then exit with code 1. 8. If everything is successful it must print the Gist's HTML URL to STDOUT. 9. It can optionally accept a flag for description -d <description. floor(score * .9) 10. It can optionally accept a flag for private gisting -p. floor(score * .9) 11. In the case that a description flag is not used or implemented it must set the description to an empty string. ## Example Input/Output The number before the prompt is the exit code of the previous command. 0$ gist
gist: usage: <file> [file...]
0 $gist no-such-file.txt gist: unable to gist =( 1$ gist hello.txt
https://gist.github.com/anonymous/1e645596ce7bceeb1ec9
0 \$


## Scoring

This is a so shortest answer wins. As stated above, the following multipliers are in effect:

• (9): score = floor(score * .9)
• (10): score = floor(score * .9)
• Both (9) & (10): score = floor(floor(score * .9) *.9)
• What's up with the Example Input/Output code snippet? The editor's preview displays it correctly. – Winny Jul 27 '15 at 20:17
• For the usage, should those literal strings be used regardless of the name and invocation of the program, or should it substitute the correct invocation for the leading gist? I'm thinking particularly of cases like Java, which doesn't support hashbangs. – Peter Taylor Jul 27 '15 at 20:32
• Literal string, I think. – Winny Jul 27 '15 at 20:34
• That's a good point about Java. I think I'll remove the item about shebangs since it's unfair. – Winny Jul 27 '15 at 20:41
• If both bonuses are done, is it floor(score * .9 * .9), or floor(floor(score * .9) * .9)? – Maltysen Jul 27 '15 at 23:48
• Also, if the bonuses are done, do we have to make the usage string reflect that, or just print it verbatim? – Maltysen Jul 27 '15 at 23:50
• Output strings verbatim. And floor(floor(score * .9) * .9) for both. I'll update the question momentarily. – Winny Jul 28 '15 at 2:07
• I'm curious why this challenge is being downvoted. – Winny Jul 28 '15 at 2:28

# Golf these arrays

Gzip base64: (too long, will be added if I'll post this question).

## Rules

• You don't have to output them all. And you can output the arrays in any order. But the order of items in the arrays must be kept as is.
• You can print other arrays, which wouldn't be counted towards your score. The number of arrays you print must be no more than 10,000, and the total number of arrays, subarrays and numbers must be no more than 10,000,000.
• You can use any convenient format to represent the arrays (and the list of outputted arrays).

## Scoring

If your program or function has n bytes, and it printed k distinct arrays from the above list, your score would be n*(128/k)2. Lowest score wins.

### Problems

It looks too boring.

• It also looks too broad. – Peter Taylor Aug 8 '15 at 7:55