# 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 '19 at 7:51
• @guest271314 You can use this markup to create a tag in a draft: [tag:code-golf] – James Aug 29 '19 at 15:19
• Why no featured anymore? Can't we have it auto-added or something? – S.S. Anne Sep 26 '19 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 '19 at 13:43

# 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 '19 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 '19 at 23:36
• king-of-the-hill needs interaction between submissions. I don't see any here – Jo King Nov 22 '19 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 '19 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.)
• 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.

# 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 Dec 5 '19 at 20:10 • @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 Dec 5 '19 at 20:11 Given a digit as an English word, output its numerical value. For example, given the input one, you should output 1 (optionally with a trailing newline). Your program should cover all the following cases: zero => 0 one => 1 two => 2 three => 3 four => 4 five => 5 six => 6 seven => 7 eight => 8 nine => 9  # Introduction This challenge was inspired by the 24 Game. In the 24 Game, you are given 4 numbers and are asked to make 24 using addition, subtraction, multiplication, division, and parentheses. So... What is the biggest number you can make given 4 numbers using the above operations? # Challenge For four given inputs a, b, c, d, output the biggest number you can get using addition, subtraction, multiplication, division, and parentheses. This is code-golf, so the shortest answer wins. # Example Input and Output  Input --> Output --> Explanation 1,3,2,4 --> 36 --> (1 + 2) × 3 × 4 5,5,5,5 --> 625 --> 5 × 5 × 5 × 5 9,2,3,1 --> 81 --> (1 + 2) × 3 × 9  Please give feedback on this challenge and correct me if my outputs are wrong. Should I change it to the smallest number? • – FlipTack Dec 30 '19 at 23:19 • Also the subtraction and division are surely obsolete for the challenge? – FlipTack Dec 30 '19 at 23:21 • Will positive number divide zero yield Infinity as what IEEE 754 does? – tsh Dec 31 '19 at 3:37 • Shouldn't (1+2)x3x4 greater than 1+2x3x4? – tsh Dec 31 '19 at 3:37 • @FlipTack Probably but maybe not in some circumstances. – Yousername Dec 31 '19 at 22:18 • @tsh No, infinity will not count as the solution. Thank you, that is true that (1+2)x3x4 is greater. – Yousername Dec 31 '19 at 22:19 • Does order matter? From the input it seems the order matters, i.e. we are not supposed to change the order of the input. So, for 1,3,2,4, the answer is 32, rather than 36. – Element118 Jan 1 at 5:25 • @Element118 No, order does not matter, those were just the random numbers that came from my head. – Yousername Jan 4 at 21:11 # How many ACus do I have? Posted to main • I'm not sure this counts as a dupe, but what it seems to be is n=floor(days_between(input, date(1,1,2020)) / 7); return n*(n-1)/2, which doesn't seem terribly interesting to golf. (Also just fyi, the 01 you used in your dates in your script is actually an octal literal i.e. 010 is 8) – FryAmTheEggman Jan 7 at 21:33 • Thanks for the feedback. I have corrected the script. Not sure how the extra 0's managed to slip in! I'll leave the challenge here for a couple more days to see if there are any more comments. – ElPedro Jan 8 at 7:43 • @ElPedro You need to wait longer. At least a month or two, but a few months is really good. – S.S. Anne Jan 11 at 21:25 • I'm sorry and no personal offence intended but I find it a bit strange that a member of 3 months is telling a member of over 4 years with lot's of experience and over 5000 rep how to use the sandbox and the main site. Maybe I am simply getting too old for this community. – ElPedro Jan 11 at 21:36 • And besides which, none of that alters my opinion that downvotes without the downvoter giving a reason are not any help to anyone. If you think differently then please feel free to give me a good reason. I am happy to listen and learn. – ElPedro Jan 11 at 21:40 # Make a Decompiler Bomb Similar to the Make a Compiler Bomb challenge, but backwards. The goal is to create the a 1KiB (1024 bytes) or smaller bytecode file that creates the largest output when decompiled. # Constraints • A binary is either an x86 binary (in the form of an ELF file, PE file (.dll/.exe), or Mach-O binary) or a virtual bytecode file (e.g. Python .pyc, Java .class, .NET CLR, etc.) • The decompiler can be any public (preferably free) decompiler of your choice. (e.g Snowman/Hex-Rays for x86 binarys, CFR/Fernflower/etc. for java, dotPeek for .NET, uncompyle6 for Python, etc.) • A decompiler is any tool that takes a binary and attempts to reconstruct human readable source code from it. • The largest output byte count wins, with the smallest input size as a tie-breaker • The binary must be executable, and print "Hello World!" • The decompiled code must be syntactically correct • I think you probably want to specify what a "decompiler" is, since really any file is "binary" and anything that takes that and produces some valid code probably arguable counts as a decompiler. Further, I think you might be better served by limiting the binary size, like the original challenge, as if someone finds a way that adding $n$ bytes adds more than $n^{2}$ bytes to the output they would achieve an arbitrarily large score. – FryAmTheEggman Jan 17 at 20:06 • @FryAmTheEggman I put in a basic explanation and made the scoring based on largest output rather than a formula. Explaining a decompiler is tricky though, I'll think about that more and maybe edit for it later. – famous1622 Jan 21 at 14:15 • I think the scoring change you made is good, only that kb is a tad ambiguous between being 1000 or 1024, and that it seems a tad large (but neither of those is critical and the second is just my opinion). Thinking about what to do with the problem of defining a decompiler, I realised it was probably a good idea to require that the resulting decompiled code does something. Maybe requiring that the decompiled code is a hello world variant or something will limit some problems like "this program converts to Unary source code". – FryAmTheEggman Jan 21 at 16:27 • @FryAmTheEggman Made it so the decompiled code must have correct syntax, and made the size smaller, was going to post my java example but I just realized I have to make it fit in the new restrictions so... – famous1622 Jan 21 at 16:46 # I delete the input, you delete the source code This is a new twist on the long running series on CGCC. Your task, if you accept it, is to write a program/function that outputs/returns the contents of an input file. The tricky part is that if I delete the input file, your program must delete itself. ## Rules • The source code file and the input file should be in the same directory. • The input file and source file can be named anything at all. I.e. The file names are your choice. • The contents of the input file will be restricted to printable ASCII. • The input file and the source file must be deletable. • This is code-golf, so the shortest (original) code in each language wins! • Default Loopholes apply. ## Example If your program is jspwjxnlow8229 and the input file exists, the program must print the contents of the file. If the file doesn't exist, the program must delete itself. ## Feedback In regards to file manipulation, have I specified the rules enough? • What about languages in which programs don't live in files but rather in binary blobs? Is it enough for the program to delete itself from the binary blob? – Adám Jan 22 at 9:30 • Can the program and/or source file also be named anything at all? – Adám Jan 22 at 9:32 • @Adam, forgive me for not knowing, but what's a binary blob? – Lyxal Jan 22 at 9:32 • It doesn't matter what a binary blob is. I just wanted you to be aware than not all languages use the same model. – Adám Jan 22 at 9:33 • @Adam sure. I'll add a part about that to the challenge – Lyxal Jan 22 at 9:34 • Parts of this feel a bit unclear. Can the submissions know the file names in advance? (If not then the name feels a bit odd, isn't it really write a cat program that deletes itself if the input name doesn't correspond to an existing file? They aren't really tied together in that case) Similarly, why mention the recycling bin? It isn't present on many systems, and behaves differently on those that do have one (most programmatic deletions will require more work to send the file to the temporary "are you sure" location). – FryAmTheEggman Jan 22 at 17:06 # How healthy are my children? As anyone who has twins will know, it can be hard to keep track of which child fed / was changed, and when. That's why I've devised a system using OneNote on my phone. It's quick and easy to use. Each entry (line) uses the following structure (note: I'm not a regex expert and the expression is more permissive than I want - see words for detail): (ddMMyyyy )?HHmm ((1|2|B) (💧|💩|🤱){1,3}){1,3} Or, in words: 1. For the first entry on or after midnight each day only, each line starts with the date. 2. The next component is always the time, hour and minute in 24 hour clock format 3. Next is a child identifier character - 1 or 2; or B if what follows applies to both children. All subsequent emoticons apply to the identified child, until a new child identifier is found or a newline. There is guaranteed to be at least one child identifier in a record. 4. Next comes any or all of the three emoticons (maximum one of each) representing a wet nappy (💧), a dirty nappy (💩) or a feed (🤱) 5. Repeat from step 3. until done. BUT - each emoticon will only appear once per child - so if it appears in B then it won't appear in either 1 or 2; and if it appears in either 1 or 2 it won't appear in B. It won't appear in both 1 and 2 (because then it would be in B instead). The regex doesn't show this subtlety. Some other notes: • Breast-Feeding (feed) emoticon 🤱 is codepoint U+1F931 • Droplet (wet) emoticon 💧 is codepoint U+1F4A7 • Pile of Poo (dirty) emoticon 💩 is codepoint U+1F4A9 • All items in the string are space-separated • I would actually use the initials of my children's names, rather than 1 and 2 - but for the challenge I went with the numbers instead. ## Example 02022020 0005 1 💩 B 💧 🤱 0230 2 💧 🤱 0250 1 💧 💩 🤱 0330 2 🤱 0400 1 🤱 0700 B 💧 🤱 0900 2 🤱 1000 2 💧 🤱 1020 1 💧 🤱 1220 1 🤱 1420 B 💧 1 💩 2 🤱 1440 1 🤱 1600 2 💧 💩 1700 1 💧 1745 B 🤱 2100 B 💧 🤱 1 💩 2350 2 🤱 B 💩 1 💧 03022020 0015 1 🤱 B 💧 0500 1 💧 🤱 0830 1 💧 🤱 0900 2 💧 🤱 1115 B 💧 1 💩 1215 B 🤱 1330 B 🤱 1400 2 💧 💩 # The Challenge Given the raw data, input as a single string or array of entries, containing data such as the above example, output a summary of: • number of feeds, wet and dirty nappies, per baby, over the past 24 hours "The past 24 hours" can be either based on system time, or the current time can be passed as an extra input. The output format is up to you, as long as it: a) is consistent across all runs of the program b) shows the information required some example outputs for the above inputs, with a current time of 14:30 on 3rd of February 2020 (hand-calculated, sorry if they're not right!): Baby 1 had 6 wet nappies, 2 dirty nappies, and fed 8 times Baby 2 had 6 wet nappies, 3 dirty nappies and fed 6 times {{6,6},{2,3},{8,6}} {6,2,8},{6,3,6} etc. This is so lowest bytes wins. Usual exclusions apply. • If a language can't deal with unicode input, should I allow the whole codepoint string substituted in its place? – simonalexander2005 Feb 14 at 11:59 • Should I be more explicit with the output format? – simonalexander2005 Feb 14 at 12:00 • Can someone help me make the regex more tight? – simonalexander2005 Feb 14 at 12:05 # Find the largest deletable prime with no zeros code-challengeprimes Deletable primes (A080608) are primes such that removing some digit leaves either the empty string or another deletable prime. Examples 415673 is a deletable prime because... 4 5673 is a deletable prime because... 4 567 is a deletable prime because... 4 67 is a deletable prime because... 67 is a deletable prime because... 7 is prime 1415673 is not a deletable prime because it is not prime 31513 is not a deletable prime because... 3151 is not prime and... 315 3 is not prime and... 31 13 is not prime and... 3 513 is not prime and... 1513 is not prime  ## Challenge Write a program to find deletable primes with no zeros. The score is the largest deletable prime with no zeros found by your program. # Implement PSL(2,3) Since challenge to implement Galois field already have been many, I'm writing a challenge involving a group of Lie type! ## Objective Implement the multiplication and inversion in $$\\text{PSL}(2,3)\$$. ## The ring $$\\mathbb{Z}_3\$$ The ring $$\\mathbb{Z}_3\$$ is the set $$\\{0,1,2\}\$$ with addition, negation, subtraction, and multiplication defined as modular arithmetic: • Addition is the usual addition with the result moduloed by 3; • Negation, subtraction, and multiplication are also analogously defined. Reciprocal and division is also well-defined, but that's just another detail. ## The group $$\\text{SL}(2,3)\$$ The multiplicative group $$\\text{SL}(2,3)\$$ is the set of 2-by-2 matrices whose entries are members of $$\\mathbb{Z}_3\$$ and the determinant is $$\1\$$. Note that the determinant is calculated using modular arithmetic. Matrix multiplication and matrix inversion is defined as: • Matrix multiplication is the usual matrix multiplication, where addition and multiplication of the entries are modular; • Matrix inversion of $$\\begin{pmatrix} a & b \\ c & d \end{pmatrix}\$$ is $$\\begin{pmatrix} d & -b \\ -c & a \end{pmatrix}\$$. This exploits that the determinant is $$\1\$$. As a consequence, the elements of $$\\text{SL}(2,3)\$$ are: $$\begin{pmatrix} 0 & 1 \\ 2 & 0\end{pmatrix}, \begin{pmatrix} 0 & 1 \\ 2 & 1\end{pmatrix}, \begin{pmatrix} 0 & 1 \\ 2 & 2\end{pmatrix}, \begin{pmatrix} 0 & 2 \\ 1 & 0\end{pmatrix}, \begin{pmatrix} 0 & 2 \\ 1 & 1\end{pmatrix}, \begin{pmatrix} 0 & 2 \\ 1 & 2\end{pmatrix}, \begin{pmatrix} 1 & 0 \\ 0 & 1\end{pmatrix}, \begin{pmatrix} 1 & 0 \\ 1 & 1\end{pmatrix}, \begin{pmatrix} 1 & 0 \\ 2 & 1\end{pmatrix}, \begin{pmatrix} 1 & 1 \\ 0 & 1\end{pmatrix}, \begin{pmatrix} 1 & 1 \\ 1 & 2\end{pmatrix}, \begin{pmatrix} 1 & 1 \\ 2 & 0\end{pmatrix}, \begin{pmatrix} 1 & 2 \\ 0 & 1\end{pmatrix}, \begin{pmatrix} 1 & 2 \\ 1 & 0\end{pmatrix}, \begin{pmatrix} 1 & 2 \\ 2 & 2\end{pmatrix}, \begin{pmatrix} 2 & 0 \\ 0 & 2\end{pmatrix}, \begin{pmatrix} 2 & 0 \\ 1 & 2\end{pmatrix}, \begin{pmatrix} 2 & 0 \\ 2 & 2\end{pmatrix}, \begin{pmatrix} 2 & 1 \\ 0 & 2\end{pmatrix}, \begin{pmatrix} 2 & 1 \\ 1 & 1\end{pmatrix}, \begin{pmatrix} 2 & 1 \\ 2 & 0\end{pmatrix}, \begin{pmatrix} 2 & 2 \\ 0 & 2\end{pmatrix}, \begin{pmatrix} 2 & 2 \\ 1 & 0\end{pmatrix}, \begin{pmatrix} 2 & 2 \\ 2 & 1\end{pmatrix}$$ ## The factor group $$\\text{PSL}(2,3)\$$ $$\\text{PSL}(2,3)\$$ is defined as cosets of $$\\text{SL}(2,3)\$$ by $$\\{\begin{pmatrix} 1 & 0 \\ 0 & 1\end{pmatrix}, \begin{pmatrix} 2 & 0 \\ 0 & 2\end{pmatrix}\}\$$. That is, elementwise multiplications of $$\\{\begin{pmatrix} 1 & 0 \\ 0 & 1\end{pmatrix}, \begin{pmatrix} 2 & 0 \\ 0 & 2\end{pmatrix}\}\$$. They are: $$\{\begin{pmatrix} 0 & 1 \\ 2 & 0\end{pmatrix}, \begin{pmatrix} 0 & 2 \\ 1 & 0\end{pmatrix}\}, \{\begin{pmatrix} 0 & 1 \\ 2 & 1\end{pmatrix}, \begin{pmatrix} 0 & 2 \\ 1 & 2\end{pmatrix}\}, \{\begin{pmatrix} 0 & 1 \\ 2 & 2\end{pmatrix}, \begin{pmatrix} 0 & 2 \\ 1 & 1\end{pmatrix}\}, \{\begin{pmatrix} 1 & 0 \\ 0 & 1\end{pmatrix}, \begin{pmatrix} 2 & 0 \\ 0 & 2\end{pmatrix}\}, \{\begin{pmatrix} 1 & 0 \\ 1 & 1\end{pmatrix}, \begin{pmatrix} 2 & 0 \\ 2 & 2\end{pmatrix}\}, \{\begin{pmatrix} 1 & 0 \\ 2 & 1\end{pmatrix}, \begin{pmatrix} 2 & 0 \\ 1 & 2\end{pmatrix}\}, \{\begin{pmatrix} 1 & 1 \\ 0 & 1\end{pmatrix}, \begin{pmatrix} 2 & 2 \\ 0 & 2\end{pmatrix}\}, \{\begin{pmatrix} 1 & 1 \\ 1 & 2\end{pmatrix}, \begin{pmatrix} 2 & 2 \\ 2 & 1\end{pmatrix}\}, \{\begin{pmatrix} 1 & 1 \\ 2 & 0\end{pmatrix}, \begin{pmatrix} 2 & 2 \\ 1 & 0\end{pmatrix}\}, \{\begin{pmatrix} 1 & 2 \\ 0 & 1\end{pmatrix}, \begin{pmatrix} 2 & 1 \\ 0 & 2\end{pmatrix}\}, \{\begin{pmatrix} 1 & 2 \\ 1 & 0\end{pmatrix}, \begin{pmatrix} 2 & 1 \\ 2 & 0\end{pmatrix}\}, \{\begin{pmatrix} 1 & 2 \\ 2 & 2\end{pmatrix}, \begin{pmatrix} 2 & 1 \\ 1 & 1\end{pmatrix}\},$$ You pick an element of each coset as representives, and don't care about the rest. Multiplication/inversion of such representives is defined as multiplication/inversion in $$\\text{SL}(2,3)\$$, then taking the representive of the coset the multiplication/inversion is in. For example, $$\\begin{pmatrix} 0 & 1 \\ 2 & 0\end{pmatrix}^2 = \begin{pmatrix} 1 & 0 \\ 0 & 1\end{pmatrix}\$$, if $$\\begin{pmatrix} 0 & 1 \\ 2 & 0\end{pmatrix}\$$ and $$\\begin{pmatrix} 1 & 0 \\ 0 & 1\end{pmatrix}\$$ are representives. ## Examples Picking the left elements as representives of the cosets above: $$\begin{pmatrix} 0 & 1 \\ 2 & 0\end{pmatrix}^2 = \begin{pmatrix} 1 & 0 \\ 0 & 1\end{pmatrix}, \begin{pmatrix} 0 & 1 \\ 2 & 1\end{pmatrix}^2 = \begin{pmatrix} 1 & 2 \\ 1 & 0\end{pmatrix}, \begin{pmatrix} 1 & 0 \\ 0 & 1\end{pmatrix}\begin{pmatrix} 1 & 1 \\ 1 & 2\end{pmatrix} = \begin{pmatrix} 1 & 1 \\ 1 & 2\end{pmatrix}, \begin{pmatrix} 1 & 2 \\ 2 & 2\end{pmatrix}\begin{pmatrix} 1 & 1 \\ 1 & 2\end{pmatrix} = \begin{pmatrix} 0 & 1 \\ 2 & 0\end{pmatrix}, \begin{pmatrix} 1 & 2 \\ 2 & 2\end{pmatrix}^{-1} = \begin{pmatrix} 1 & 2 \\ 2 & 2\end{pmatrix}$$ To be more specific about the method of evaluation: $$\begin{pmatrix} 0 & 1 \\ 2 & 1\end{pmatrix}\begin{pmatrix} 0 & 1 \\ 2 & 2\end{pmatrix} ≡ \begin{pmatrix} 2 & 2 \\ 2 & 4\end{pmatrix} ≡ \begin{pmatrix} 2 & 2 \\ 2 & 1\end{pmatrix} ≡ \begin{pmatrix} 1 & 1 \\ 1 & 2\end{pmatrix}, \\ \begin{pmatrix} 1 & 1 \\ 1 & 2\end{pmatrix}^{-1} ≡ \begin{pmatrix} 2 & -1 \\ -1 & 1\end{pmatrix} ≡ \begin{pmatrix} 2 & 2 \\ 2 & 1\end{pmatrix} ≡ \begin{pmatrix} 1 & 1 \\ 1 & 2\end{pmatrix}$$ The steps of this algorithm is: 1. Do usual matrix multiplication/inversion; 2. Modulo the entries by 3; 3. Take the representive of the coset. Though you can make any possible algorithm. ## Rules • Input type and format doesn't matter, but it must be a container of integers. In C, int[2][2] and int[4] are valid examples. This restriction prevents abusing the fact that $$\\text{PSL}(2,3) \cong A_4\$$. • Output type and format doesn't matter either, but it must be the same as the input type and format. • Invalid inputs fall in don't care situation. • Multiplication and inversion may be in separate codes. In this case, the score is the sum of their lengths in bytes. • Since this is a code-golf, the code with least score wins. • This challenge appears to heavily rely on restricted-source and thus to me does not seem too viable. – Jonathan Frech Feb 25 at 0:58 • @JonathanFrech Do you think I should lift the restriction on input type? Otherwise, "You pick an element of each coset as representives, and don't care about the rest" and "Invalid inputs fall in don't care situation" should be enough. – Dannyu NDos Feb 25 at 3:38 # 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 '19 at 13:33 • @ASCIIThenANSI I am also curious – MilkyWay90 Aug 27 '19 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

## The Perfect Keyboard

Back in the 1970s, keyboard designers respected the needs of programmers and languages. For example, see the IBM 2741 keyboard, designed for APL (from Wikipedia):

Today, sadly, most code golfers are forced to struggle with standard keyboards, which are badly suited to the needs of their language. This has to change!

## The challenge

1. Choose a programming language.
2. Design a keyboard, which would best suit the needs of a developer (or specifically a code golfer) in said language.
3. Post the keyboard layout as an answer.
4. Explain how your keyboard enhances the programming experience.
6. Optional - if you are the winner, start a Kickstarter project to build the thing.

This section is, of course, for the sandbox only.

I don't really expect a keyboard design which would actually improve functionality of programs in an actual serious language. I'd expect fun answers, where the keyboard design highlights soemthing fun/interesting/absurd about the language. But my expectations don't matter so much, because it's not me rating the answers, but the other users.

Example (not very good ones):

1. A Brainfuck keyboard with only 4 keys.
2. A Lisp keyboard where half the keys are parentheses.
3. A Piet keyboard - I'm sure someone will come up with something nice.

• I'm note sure if it's a valid challenge since there is no programming actually involved in answering this – Fatalize Sep 3 '15 at 9:28
• @Fatalize, You're right, but it is a programming-related challenge. It requires knowledge of programming languages and people may find it interesting or amusing. I may be pushing the boundaries, I don't know. – ugoren Sep 3 '15 at 9:45
• I would personally be ok with that challenge but I don't know if other, more prominent users would find this challenge off-topic. – Fatalize Sep 3 '15 at 9:48
• Judging from this Meta post, there seems to be a fairly clear consensus that a question must involve programming to be on topic, not merely be programming related. So this question is fairly clearly not valid. – isaacg Sep 3 '15 at 10:08
• You could always include programming the driver or some kind of special interface for the keyboard – Beta Decay Sep 3 '15 at 10:28
• @BetaDecay, This challenge is about crazy creative answers. Requiring a driver implementation seems to me like a way to kill this creativity. – ugoren Sep 3 '15 at 11:01
• @isaacg, trichoplax writes "I judge it by whether the answers to it demonstrate skill and determination, or just aesthetic style" - I think a good answer to this challenge requires undestdanding a language and designing something that relates to its properties. Does it qualify as "skill and determination"? I can't say I'm sure. – ugoren Sep 3 '15 at 11:06
• The art/programming debate was specifically about popcon questions where the answers were programs. There's no doubt whatsoever that a popcon where the answers are just images would be an art question rather than a programming question. On the same basis, this is not a programming question, and does not belong on this site. – Peter Taylor Sep 4 '15 at 13:58
• @PeterTaylor - I don't think it's an art question. The challenge isn't to get a pretty picture of a keyboard, but to design something that suits the language in an interesting way. But I posted it here to get the communities opinion, and it seems quite clear what it is. – ugoren Sep 5 '15 at 19:00
• Since I wrote that meta answer the rules on popularity contests have been tightened up, and I think that is a good thing. I stand by my answer, but I think it is right that popularity contests be judged strictly, to reflect the fact that it is very difficult to write one that is a good fit for the site. – trichoplax Sep 4 '16 at 11:56
• Although it's possible someone will come up with an ingenious approach to designing a keyboard, the challenge itself seems to lean towards "make me laugh" rather than "impress me". This is why I don't think this is a good fit for the site. – trichoplax Sep 4 '16 at 12:03
• I'd love to see what keyboards the community comes up with, but I think it would need to be hosted somewhere other than main. For things which are appealing to the PPCG community, but not quite a fit for main, there's Code Golf Chat. People often post "mini challenges" which aren't well specified enough to be challenges on main, but can end up inspiring people to write a full challenge. – trichoplax Sep 4 '16 at 12:06
• I think it's important to keep testing the boundaries of existing winning criteria, and to try to come up with new ones. The people who put the effort into this will have a long run of rejections, but I really hope these don't come across as "don't try". – trichoplax Sep 4 '16 at 12:19

# Technologic - Now what's THAT command do??

Daft Punk's song "Technologic" is all about actions that a user or computer does when it's working and being used. You goal is to write a program that has one command we will call the Technologic Command. This command will executes all of the actions like "buy it", "lock it", "code it", and "write it" in the order the lyrics are written on 'it'. What 'it' is is up to you, but you gotta let me know.

# Rules

• Any language can be used.
• The song refers to an 'it'. That can be a block a memory, algorithm, function, file, or anything else a computer can manipulate directly or indirectly.
• You must specify what 'it' is you will be performing these actions on. If you don't, you can only earn a maximum of 160 points.
• Points will be deducted otherwise if a command is not used.
• I'm not aware of any 'buy' command, method, function, subroutine or instruction so use a thesaurus and find the closest word you can actually program. I don't expect the program to actually buy or snap anything. Other words like mail and fax are possible, but not recommended.
• If you have to use a synonym, you are not allowed to use that command again
• Encompassing multiple objects into one artifact does not count. For example, taking the command "name it" literally means you won't be able to name an array of bytes, but you can name a file. Creating an object that holds both a file and an array of bytes is not allowed. That would make this too easy to get the maximum amount of points.

# Scoring

• There are 16 commands with a total possible score of 190 points.
• 10 points for executing a command on the specified 'it' of your choosing (160 total)
• 2 points for executing each command consecutively that references your 'it' (30 total)
• 5 points for executing a command on something other than your 'it'
• -3 points for every command skipped.

# Command List

lyrics

Buy it, use it, break it, fix it,
Trash it, change it, mail - upgrade it,
Charge it, point it, zoom it, press it,
Snap it, work it, quick - erase it,
Write it, cut it, paste it, save it,
Load it, check it, quick - rewrite it,
Plug it, play it, burn it, rip it,
Drag and drop it, zip - unzip it,
Lock it, fill it, call it, find it,
View it, code it, jam - unlock it,
Surf it, scroll it, pause it, click it,
Cross it, crack it, switch - update it,
Name it, rate it, tune it, print it,
Scan it, send it, fax - rename it,
Touch it, bring it, pay it, watch it,
Turn it, leave it, start - format it.

• This conversation has been moved to chat. – Dennis Sep 17 '15 at 21:06
• I count way more than 16 commands here. There are 16 lines each with several commands on them. If we cound the hyphenated commands as two, there are 16 x 4 = 64 commands. – Level River St Sep 22 '15 at 22:01
• @steveverrill A slight oversight. haha. I must've counted the lines knowing there were 4 commands on each line and didn't multiply the two together. – Luminous Sep 23 '15 at 12:31

# Just Golf 2016 code-golfkolmogorov-complexity

(Related: A Kingdom Hearts VGM challenge) Sandbox note: potential duplicate?

Just Dance 2016 is coming out soon, and I know I'm definitely excited! However, let's take a quick trip back to 2009, when the original Just Dance was released. There are a lot of great songs, but I don't know who sung half of them!

## The Challenge

Write a program that accepts a Just Dance song name from input and outputs the song's artist (as credited in-game.)

Here is the list of all songs and artists from Just Dance 1:
list pending

## Rules and Assumptions

• You may assume that the song will always be valid.
• The song's title and artist must be properly capitalized.
• You may not read any external files - the song data must be hardcoded.
• If a song is covered (which several have been for various reasons), the program should return the cover artist (as they are credited in the game.)

## Test Cases

Input: Eye of the Tiger
Output: Survivor

Input: Fame
Output: Irene Cara

## Bonuses

• Each game has had one song everyone was really excited about. This year, it's Ievan Polkka by Hatsune Miku. You get a bonus of -50 points if you accept this song as valid input.

• Just Dance is fun, but why should we stop there? If you additionally accept songs fron the rest of the main series (Just Dance 2, 3, Greatest Hits/Best Of, 4, 2014, and 2015, not including DLC and skipping over any duplicates), you get a whopping -2009 points. Here is the full list for those games:
list pending

• Note that this doesn't include Just Dance 2016 songs.
• This can be combined with the other bonus to get a total of -2059 bytes.

## Meta Questions

• Are the bonuses too big? (I'm mainly talking about the -2009 point bonus for including every song.)
• Has anything been left out?
• Is this enough of a challenge?
• This looks like a dupe of codegolf.stackexchange.com/q/53678/194 . – Peter Taylor Sep 24 '15 at 20:24
• @PeterTaylor I would say it isn't, that one asks for input in the form of a game and boss and returns a song, mine asks for a song and returns an artist. That one also has different scoring rules, and mine requires all items to be implemented. – ASCIIThenANSI Sep 25 '15 at 13:51
• They're both "golf this given map / dictionary / associative array". Why would the techniques used be any different? – Peter Taylor Sep 25 '15 at 15:22
• @PeterTaylor According to this meta post, the main qualification for duplicates is "Can answers from one question be copied over to the other with little or no modification and still be competitive?". I looked at the answers for the question you linked, and it doesn't seem like either would do very well if those techniques were used in this challenge. – ASCIIThenANSI Sep 25 '15 at 15:35
• Would this be kolmogorov-complexity? – LegionMammal978 Sep 26 '15 at 17:16
• @LegionMammal978 Yes. – ASCIIThenANSI Sep 27 '15 at 14:48

# Literally just printing the source code

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

## The challenge

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

The rules:

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

# Print a sourcecode

Given 2 inputs(First input is truthy/falsy, second input is program in same language as submission):

1. If the first input is truthy then transform the second input into same program but printing the source code(After modification) first.
2. If the first input is falsy then transform the second input into same program but after the program finished it prints the source code(After modification). If the program doesn't halt, you may or may not modify the program.

It's code-golf, so the shorter answer is the winner.

For example in CJam, I don't write the program to do this. (> means output)

0 q
>{"_~"q}_~
0 0 1{_@+}11*;
>{"_~"0 0 1{_@+}11*;}_~
1 q
> {q](\o"_~"}_~

• Sorry, I'm not quite sure what this question is asking. Would it be okay if you posted examples? – Sp3000 Nov 5 '15 at 14:29
• @Sp3000 Please undo your downvote. The example is fixed. – Akangka Nov 7 '15 at 7:39
• I didn't downvote though... – Sp3000 Nov 7 '15 at 8:13

# Restricted "Hello, World!"

The task is very simple, output Hello, World! to STDOUT. The thing that makes this different are the rules:

• You need to provide a full functioning program, taking no input and outputting via STDOUT.
• The program must not write anything to STDERR
• The maximum amount of bytes you can use is 50
• The program may only contain printable ASCII characters. Programs using CP437 and other encoding systems are not allowed
• If a programming language is already used, you cannot use this same language again.
• You cannot use any character of the prohibited character list. This is the twist:

### Prohibited character list (PCL):

The prohibited character list is a list full of characters, which cannot be used in the following programs. For example:

If the list was: He\., you need to create a program, without the characters H, e, \ and .. These are not case-sensitive.

If you succesfully manage to write a program that doesn't use any characters, you may add new one character to the prohibited character list.

e.g.

If the old PCL was He\., and you managed to write a program that doesn't use any of these characters, you may add a new character to this list. For example (whitespace). The new PCL will be He \. (notice that the whitespace character is added).

### Posting Snippet:

#[Language Name], N bytes

[code]

(explaination etc.)