# 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]

# (Pan)consummate Vs

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

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

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

Truthy values:

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

Falsey values:

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

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

We have a lot of base conversion challenges. Surprisingly, aside from one closed challenge, there aren't any where the goal is purely to convert hexadecimal to decimal. This is different from challenges like converting hexadecimal to binary, because many languages have features like hexadecimal literals (0x, , etc.) which can do this in a much shorter or more interesting way. I/O: You should create either a program or function, which takes input and output through one of the allowed methods. The input will be a hexadecimal number, consisting of the characters /[0-9a-f]/ (you may choose the capitalization rules). Scoring: This is code golf, shortest answer per language wins. • Feedback is of course useful. If the downvote is because this is a dupe or is unnecessary, that would be useful to comment on. Otherwise, I can't fix any issues without knowing what they are. – Redwolf Programs Oct 17 at 21:11 # Is it a Pythagorean triple? code-golfdecision-problemgeometrymathnumber-theory Given three numbers, determine whether they form a primitive Pythagorean triple. Here is the definition: • all three numbers are positive integers • they represent the side lengths of a right-angled triangle, that is, $$\a^2 + b^2 = c^2\$$ for any ordering of $$\a\$$, $$\b\$$, and $$\c\$$ • no other primitive Pythagorean triple exists with the same ratio of side lengths, that is, they are coprime. For example, $$\[6, 8, 10]\$$ is not a primitive Pythagorean triple, even though it satisfies the above conditions, because the simper $$\[3, 4, 5]\$$ exists. ## Rules • Unless your language doesn't support them, you must accept floating-point numbers (even though Pythagorean Triples use, by definition, integers) • meta: Is this necessary? Is it too restrictive? • You may be given negative numbers, $$\0\$$, or numbers that cannot form any triangle (right-angled or not, i.e. $$\a + b \le c\$$), in which cases you must return false. • meta: Is this necessary? Does it make it too difficult? • You can return any two distinct individual values, or any typical truthy/falsey values for your language. • Standard I/O and loophole rules apply. • This is , so shortest function or full program in bytes wins. ## Test Cases [0, 3, 3] => false [3, 4, 5] => true [5, 3, 4] => true [3, 4, 6] => false [3, 4, 10] => false [6, 8, 10] => false [3.0, 4.0, 5.0] => true [3.1, 4.0, 5.0] => false [-3, -4, -5] => false [3, 4, -5] => false [4.5, 6, 7.5] => false [91, 60, 109] => true [264, 265, 23] => true [81, 210, 184] => false [140, 221, 83] => false  ## Meta • Are the first two rules necessary, or do they restrict it too much? • Is it clear enough? Are there any additional rules I need to add? Are more test cases needed? • Does this suit the and tags? It's kind of tangential to both areas. • Is this too similar to the existing questions that want you to generate triples? • possible duplicate of this challenge – Razetime Oct 18 at 13:38 • @Razetime that challenge appeared on the front page today and inspired me to make this one. I thought it was different enough because of the coprime requirement and I added the extra rules about invalid values/floats to make it more interesting as well – pxeger Oct 18 at 14:32 • Input validation tends to make for a challenge that is less fun. The coprime requirement is nice, but I'm not sure if it completely changes the challenge. – Razetime Oct 18 at 15:04 • This seems to me to be too much a combination of two separate generic tasks, checking that a^2+b^2=c^2 when sorted, and that a and b are relatively prime. – xnor Oct 19 at 9:40 # Position my geohashes ## The Challenge This is the reverse challenge of Geohash my positions. Given a Geohash string of length 8, convert it to a latitude and a longitude. The conversion is done by the following algorithm, using u09tunqu as an example input. • For each character of the Geohash string, find its 0-indexed position in the map 0123456789bcdefghjkmnpqrstuvwxyz. • u09tunqu becomes 26 0 9 25 26 20 22 26 • Convert each integer into a binary string of length 5. • 26 0 9 25 26 20 22 26 becomes 11010 00000 01001 11001 11010 10100 10110 11010 • Join the binary strings together. • 11010 00000 01001 11001 11010 10100 10110 11010 becomes 1101000000010011100111010101001011011010 • Separate the odd positions in the joined binary string from the even positions. These represent the longitude and latitude, respectively. • 1101000000010011100111010101001011011010 becomes 10000001101000011011 (odd positions: longitude) and 11000101011111001100 (even positions: latitude). • The latitude should be somewhere in the range (-90, 90). Narrow down the range, based on the first character in the latitude binary string. If the first character is 0, the latitude should converge to the lower half of this range, i.e. (-90, 0). If the first character is 1, the latitude should converge to the upper half of this range, i.e. (0, 90). • The 1st character in 11000101011111001100 is 1, so the new range becomes (0, 90). • The remaining characters in the binary string are to be processed in the same way, where 0 represents the lower half of the new range and 1 represents the upper half of the new range. • The 2nd character in 11000101011111001100 is 1, so the new range becomes (45, 90). • The 3rd character in 11000101011111001100 is 0, so the new range becomes (45.0, 67.5). • The 4th character in 11000101011111001100 is 0, so the new range becomes (45.0, 56.25). • The 5th character in 11000101011111001100 is 0, so the new range becomes (45.0, 50.625). • The 6th character in 11000101011111001100 is 1, so the new range becomes (47.8125, 50.625). • ... • The 20th character in 11000101011111001100 is 0, so the final range becomes (48.85826, 48.85843). • The final latitude is the midpoint of the final range. • (48.85826, 48.85843) becomes 48.85835 • Repeat the same process for the longitude, starting from the range (-180, 180) • 10000001101000011011 becomes 2.29460 • Output the final latitude and longitude. • u09tunqu becomes 48.85835, 2.29460 ### Input A string of length 8, consisting only of the characters 0123456789bcdefghjkmnpqrstuvwxyz. ### Output Two signed floats in the ranges (-90.0, 90.0) and (-180.0, 180.0) representing the corresponding latitude and longitude. ## Test cases u09tunqu → (48.85835, 2.2946) dr5r7p62 → (40.68933, -74.04459) stq4s8cf → (29.97525, 31.13783) 75cm2txp → (-22.9519, -43.21043) usdkfsq8 → (71.17089, 25.78302) zzzzzzzz → (89.99991, 179.99983) 00000000 → (-89.99991, -179.99983) ezs42s00 → (42.60507, -5.60286) 7zzzzzzz → (-0.00009, -0.00017)  ## General remarks # AOG Day 4: Party Decorations code-golfquine You've figured out exactly how large your room needs to be. However, they only offer rooms in integer side lengths, so looks like calculating the exact dimensions precisely wasn't so necessary. Whoops! You are planning on decorating your wall with an image. You're hosting this party for a bunch of coders though, so decorating it with some code would be nice. Even better, these all happen to be quine fans, so maybe some self-referential code would be a good talking point. ## Challenge Write a program or function that, given a width and height, outputs or returns a box of that size containing your code repeated as many times as needed with all whitespace removed (bytes [0, 9, 10, 11, 12, 13, 28, 29, 30, 31, 32] in ASCII encoding). If your program uses a different byte set, you may choose to either remove characters that are equivalent to the characters I specified, or to remove characters with the bytes that I specified, but this must be consistent for all values. ## Input Two integers, W and H in any reasonable format (can be taken reversed). ## Output W*H characters of your code, with all whitespace characters removed, repeated until it's long enough, split into H rows of W length. You may output in any reasonable format, such as a grid, list of strings, matrix of characters, etc. ## Testing Program If you wish to test if your program is correct, you can use this program as a reference implementation / official metric for validity. Enter your code into the Code section and the input as space-separated integers into the Input section, and the output will be what your program should output for those inputs. This removes the exact characters; you can change the part in the Footer after if c not in between the triple-quotes if you have a different character set you need to remove. ## Rules and Specifications • Your code must contain at least one non-whitespace character (sorry Whitespace programmers). • You may not read your source code through a file or via any other direct method, as is standard for quine-related challenges. • Standard loopholes apply, as always. • this is a challenge so your score is determined by your code length in bytes with a lower score being better; however, a solution will not be accepted. # Sandbox • is this a duplicate? • is this clear enough? • is there anything else in quine challenges that needs to be well specified to make the challenge properly defined / close loopholes? • I don't really understand what the output is and how it is supposed to be related to the input. What does "repeating" code do? When is "enough"? It seems like you are removing newlines. Are we supposed to be wrapping our code around somehow? Are we filling up the box? I tried to look at your tester, but it is not exactly very readable and seems to crash on some inputs. If so you might want to consider what programs consisting of only whitespace are intended to do. – Wheat Wizard Oct 25 at 16:32 # AOG Day 6: Filtering the Playlist I promise the next one will be better You've sent the invitations for the party (and made the postperson do a whole lot more work than they should have, smh), made the decorations as interesting as possible (who doesn't love a painstakingly written quine) and made sure that the event won't kill anyone (at least, not due to COVID). The next thing that needs to be planned is the music. Now, of course, you could go ahead and create a YouTube playlist by hand, but that's way too tedious and, well, predictable. Instead, you've decided to write a program that randomly chooses songs from the music genre (I know...very efficient isn't it). But of course, there's just one problem with that plan: there's a very small chance that a song selected at random might just ruin the party vibes for everyone (even though people such as myself would consider it a Christmas miracle, others would probably see it as a lame stunt and potentially leave the party). Thankfully, the magic of code allows us to check the html of the YouTube video before hand to tell if it is indeed a rickroll. ## The Challenge Given a YouTube link as input (not shortened, but a full standard link), retrieve the title and description of the video and output whether or not it is a rickroll. In order for a video to be considered a rickroll, it must have either the unbroken phrase Never Gonna Give You Up or Rickroll in the title or description. ## Test Cases Under construction • How about checking the top 5 comments for the unbroken phrase Never Gonna Give You Up or Rickroll as well? Would that make it inconsistent? – Razetime Nov 12 at 13:25 # Coronavirus Spread code-golfarray This question is now on the main site here. # English Stroke Count Alphabet In a Chinese glossary/index for any given book, to find terms that are contained within the book and because Chinese doesn't have an alphabet like in English, they are sorted by stroke count instead. (一畫 = 1 stroke，二畫 = 2 strokes，三畫 = 3 strokes，四畫 = 4 strokes，and so on) An English glossary, having an alphabet, is naturally sorted alphabetically. For this challenge, we flip that idea to the Chinese manner. And we'll follow some Chinese writing rules to help determine stroke order for the alphabet below. Take 口 (kou) for example, a simple square. You'd think it is 4 strokes, but it is actually 3. The 1st being the left vertical line, the 2nd being the top horizontal and right vertical in one fluid stroke, and the 3rd being the lower horizontal line. This pattern, among others, holds relatively true across Chinese characters. For sake of simplicity though, and for some diversity in the English Stroke Count Alphabet, this will be the primary pattern used. First, I need to define stroke count for each letter. For sake of simplicity, and somewhat subjectively, I'll use the characters as they appear below. If there are any arguments why a letter should have a different stroke count, please make your case, but in order to promote diversity in stroke counts, I made some personal judgment calls. These stroke counts could easily change with different fonts. A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 3 3 1 2 4 3 2 3 3 1 3 2 4 3 1 2 2 3 1 2 1 2 4 2 3 3 a b c d e f g h i j k l m n o p q r s t u v w x y z 2 2 1 2 2 2 2 2 3 2 3 2 3 2 1 2 2 2 1 2 2 2 4 2 2 3 Letters with equal stroke counts should retain the original alphabetic order as before. So the English Stroke Order Alphabet is as follows. (If I made an error, please say as much, there are a lot of examples that I might have to adjust) C J O S U D G L P Q T V X A B F H I K N R Y Z E M W c o s a b d e f g h j l n p q r t u v x y i k m z w The Challenge Given a non-empty string input containing a sentence/series of words, or a list of words, organize all words according to this new English Stroke Count alphabet. Output can be either a string, or a list of properly words is a single string of properly organized words, including duplicates should they exist. Note 1: If upper and lowercase for the same letter have the same stroke count, uppercase letters take precedence. • "Cousin" precedes "cousin" • "father" precedes "Father" (because lowercase f is 2 strokes, while the uppercase is 3) • "Stop" precedes "soap" (while the o would precede t in stroke count, uppercase S precedes lowercase s) • KO precedes kO (K precedes k) • kO precedes ko (O precedes o) Note 2: I've intentionally avoided weird words in input. Inputs such as "WeIrD", "COVID-19". Input will never include any numbers, punctuation, or special characters. Input / Output "It was the best of times it was the worst of tImes" / "of of best the the tImes times It it worst was was" ["When", "life", "gives", "you", "lemons", "make", "Lemonade"] / ["gives", "Lemonade", "lemons", "life", "you", "When", "make"] [The, journey, of, a, thousand, miles, begins, with, one, step,] / [of, one, step, The, a, begins, journey, thousand, miles, with] "English Stroke Count Alphabet" / "Count Stroke Alphabet English" "A man a plan a canal panama" / "canal a a panama plan A man" "Carry on my wayward son" / "Carry on son my wayward" "Close our store and begin destroying every flower green house just lose no people quietly rather than using vexing xrays yesterday it killed my zoo wombat" / Same as input (If you can write a better sentence than above, I'd be much appreciated.) ["May", "the", "Force", "be", "with", "you"] / ["be", "the", "you", "Force", "May", "with"] [Im, going, to, make, him, an, offer, he, cant, refuse] / [cant, offer, an, going, he, him, refuse, to, Im, make] "jello Jello JellO JEllo JELlo JELlO JELLO" / "JellO Jello JELLO JELlO JELlo JEllo jello" "We suffer more often In imagination than IN reality" / "often suffer reality than In IN imagination more We" "Code Golf and Coding Challenges" / "Code Coding Challenges Golf and" ["Do", "or", "DO", "not", "there", "is", "no", "try"] / ["or", "DO", "Do", "no", "not", "there", "try", "is"] "Failure the best teacher is" / "best teacher the Failure is" "Can you tell that I am a Star Wars fan" / "Can Star a am fan tell that you I Wars" [enough examples no more words] / [enough examples no more words] • If I is 3, then surely i is 4, no? Similarly for J vs j. – Adám Nov 2 at 21:32 • You should be more lenient about input. E.g. allow a list of words. – Adám Nov 2 at 21:34 • "Uppercase letters take precedence when determining stroke counts, should they be equal." means there's just a single case-sensitive alphabet. It'd be more interesting if uppercase matching lowercase on stroke counts would only be used as a tie breaker. – Adám Nov 2 at 21:37 • @Adám As per point 1, I can see the argument. I can make that change, but it'll likely take a second to get all of the examples in line. Point 2, that input format seems adequate. Point 3, I think I know what you mean. And I'm pretty certain that that's what I was intending, but I had poor wording. – Sumner18 Nov 2 at 21:49 • No rush. I recommend sandboxing for at least one week. – Adám Nov 2 at 21:52 • You should add KD vs kO and kO vs ko to the examples for Note 1. – Adám Nov 2 at 21:53 • I'm not sure what you mean by "that input format seems adequate", but please familiarise yourself with this. – Adám Nov 2 at 21:55 • @Adám I'd like to add one thing about how stroke count works in Mandarin. 口 (kou) in Mandarin appears to be a square, and you'd think it has 4 strokes, but it actually has 3. The 1st stroke is the left vertical line, the 2nd stroke is the top horizontal and right vertical line, and the 3rd and final stroke is the bottom horizontal line. These patterns hold fairly true across Chinese characters. In the case of the letter i, I actually see 3 strokes instead of your suggested 4. The 1st being the slight horizontal tick and vertical line, the 2nd being the bottom line, and the 3rd for the dot. – Sumner18 Nov 2 at 21:57 • I see, but then J should be 1, no? 一丿 – Adám Nov 2 at 21:59 • @Adám Correct, I wasn't necessarily thinking of that when I made the challenge, but I'll add the explanation and make the edit. – Sumner18 Nov 2 at 22:02 # Catch the fruit graphical-output Implement a osu!catch style game. # Introduction osu!catch is a rhythm game where the player moves a "basket" to catch "fruits" falling from the top of the screen to the beat of a song. Think pong, but with timing. It is highly recommended to watch this video before reading the question. Here's a gameplay example from Bubbler: [osu!catch] Hitsuji to Ojisan - XENO [Spec's Overdose] # Input You are required to take the following inputs: • Time: How long your program is supposed to run. • Approach Rate: This is the speed at which the "fruits" are supposed to fall down. • Beatmap: An array of [time, x position, value] triplets where: • Time: you must support time in seconds, at the very least. Higher precision is encouraged. • X position: Where it will fall from. • Value: The size of the "fruit" will decrease with it's value. # Gameplay ## Play area • The canvas must be in a 4:3 aspect ratio. • The score must be displayed at the top of the screen, in the middle. You do not need to align it. • The score starts at 0. • Use a dark background(#222222, preferably). ## The player • The player must be of a rectangular shape, white in color. • Height: 1/50 of canvas height, Width: 1/6 of canvas width. • The player must be at the bottom of the screen, movable using any two keys of your choice. • The player must have a "dash" button. Their speed must increase by a set amount when they hold the dash button. • When the player collects a fruit, it must disappear, and it's value must be added to the score. • When the player misses a fruit, there should be an indicative visual cue where the fruit fell.(a small red square, preferably) ## Fruits • Fruit must be square in shape, and red in color. • Fruits must fall from the top of the screen, outside the viewport(unless unsupported). • Max fruit size is 0.1 × height. Size scales inversely with value. • Fruit speed must be related to the approach rate i.e. Higher approach rate must make the fruits fall faster. You may do this however you like, but please be reasonable. • The lower edge of the fruit must touch the bottom of the screen at it's time value. # Scoring This is . Shortest answer in each language wins. # Meta • Is the specification simple enough? • I am planning on making a separate challenge for this. Is that a better idea? • Is the specfication clear? • Any further feedback? • You most likely already have this in mind, but you can add the game tag. Also, I think you should not leave too many stuff to the golfers, as they could do anything with the oppurtunities (e.g they could just increase the speed by 0 by pressing the dash button). What happens when the player goes outside the canvas? – SunnyMoon Nov 18 at 20:50 # Make a die of given number of faces ## Objective Given an integer $$\n\$$ greater than 3, identify an $$\n\$$-sided die with the "greatest" symmetry, then decompose $$\n\$$ to numbers of faces grouped up to the symmetry, and then output the decomposition. ## Symmetry A die can have one of the following symmetries, from the greatest and with descending order: • $$\I_h\$$, icosahedral symmetry • $$\O_h\$$, octahedral symmetry • $$\T_d\$$, tetrahedral symmetry • $$\D_{ph}\$$, $$\p\$$-fold prismatic symmetry, in ascending order on $$\p\$$, where $$\p\$$ is an odd prime number Note that every other symmetry is redundant. ## Faces A die of each symmetry can have the following faces: • For a die of symmetry $$\I_h\$$: • Optionally $$\12\$$ faces, those from a dodecahedron • Optionally $$\20\$$ faces, those from an icosahedron • Optionally $$\30\$$ faces, those from a rhombic triacontahedron • Optionally $$\60\$$ faces, those from a deltoidal hexecontahedron • Zero or more sets of $$\120\$$ faces, those from a disdyakis triacontahedron • For a die of symmetry $$\O_h\$$: • Optionally $$\6\$$ faces, those from a cube • Optionally $$\8\$$ faces, those from an octahedron • Optionally $$\12\$$ faces, those from a rhombic dodecahedron • Optionally $$\24\$$ faces, those from a deltoidal icositetrahedron • Zero or more sets of $$\48\$$ faces, those from a disdyakis dodecahedron • For a die of symmetry $$\T_d\$$: • Optionally $$\4\$$ faces, those from a tetrahedron • Optionally $$\6\$$ faces, those from a cube • Optionally $$\12\$$ faces, those from a triakis tetrahedron • Zero or more sets of $$\24\$$ faces, those from a tetrakis hexahedron • For a die of symmetry $$\D_{ph}\$$: • Optionally $$\2\$$ faces, those from base faces of a $$\p\$$-gonal prism • Optionally $$\p\$$ faces, those from side faces of a $$\p\$$-gonal prism • Optionally $$\2p\$$ faces, those from a $$\p\$$-gonal bipyramid • Zero of more sets $$\4p\$$ faces, those from a $$\2p\$$-gonal bipyramid Note that faces from the Catalan solids that are not mentioned here are redundant. ## Rules • The input and output format doesn't matter. Possible choices of output format include: • A list, sorted or unsorted • A multiset • Invalid inputs fall in don't care situation. Especially, integers that are 3 or less. ## Examples • For $$\n=4\$$, the die has $$\T_d\$$ symmetry, so $$\n\$$ decomposes to $$\(4)\$$, with the die being a tetrahedron. • For $$\n=5\$$, the die has $$\D_{3h}\$$ symmetry, so $$\n\$$ decomposes to $$\(2,3)\$$, with the die being a triangular prism. • For $$\n=6\$$, the die has $$\O_h\$$ symmetry, so $$\n\$$ decomposes to $$\(6)\$$, with the die being a cube. • For $$\n=7\$$, the die has $$\D_{5h}\$$ symmetry, so $$\n\$$ decomposes to $$\(2,5)\$$, with the die being a pentagonal prism. • For $$\n=8\$$, the die has $$\O_h\$$ symmetry, so $$\n\$$ decomposes to $$\(8)\$$, with the die being an octahedron. • For $$\n=9\$$, the die has $$\D_{3h}\$$ symmetry, so $$\n\$$ decomposes to $$\(3,6)\$$, with the die being a truncated triangular bipyramid. Note that the die won't have $$\D_{7h}\$$ symmetry because $$\D_{3h}\$$ is greater. • For $$\n=10\$$, the die has $$\T_d\$$ symmetry, so $$\n\$$ decomposes to $$\(4,6)\$$, with the die being a chamfered tetrahedron. Note that this is different than the usual d10, which is a pentagonal trapezohedron. • For $$\n=11\$$, the die has $$\D_{3h}\$$ symmetry, so $$\n\$$ decomposes to $$\(2,3,6)\$$. • For $$\n=12\$$, the die has $$\I_h\$$ symmetry, so $$\n\$$ decomposes to $$\(12)\$$, with the die being a dodecahedron. Note that due to the greater symmetry, dodecahedron supersedes rhombic dodecahedron and triakis tetrahedron. • For $$\n=100\$$, the die has $$\T_d\$$ symmetry, so $$\n\$$ decomposes to $$\(4,24,24,24,24)\$$. Note that this is different than usual Zocchihedron, which has prismatic symmtery. Note that, if $$\p\$$ and $$\p+2\$$ are twin primes, $$\p+2\$$ will always decompose to $$\(2,p)\$$. ## Ungolfed solution ### Haskell This implementation mimics the ReadP parser. import Control.Monad type DResult = [([Int], Int)] type DParser = DResult -> DResult returnD :: Int -> DResult returnD n = [([],n)] pfail :: DParser pfail _ = [] get :: Int -> DParser get m results = do (ns, n) <- results guard (m <= n) return (m:ns, n - m) many :: DParser -> DParser many p results = let results2 = p results in case results2 of [] -> results _ -> results ++ many p results2 optional :: DParser -> DParser optional p results = p results ++ results run :: DParser run = filter ((0==) . snd) (<++) :: DParser -> DParser -> DParser (<++) p q results = case p results of [] -> q results results2 -> results2 decomposeDph :: Int -> DParser decomposeDph prismFold = run . optional (get 2) . optional (get prismFold) . optional (get (2*prismFold)) . many (get (4*prismFold)) decomposeTd :: DParser decomposeTd = run . optional (get 4) . optional (get 6) . optional (get 12) . many (get 24) decomposeOh :: DParser decomposeOh = run . optional (get 6) . optional (get 8) . optional (get 12) . optional (get 24) . many (get 48) decomposeIh :: DParser decomposeIh = run . optional (get 12) . optional (get 20) . optional (get 30) . optional (get 60) . many (get 120) decomposeDie :: Int -> [Int] decomposeDie n = fst . head foldr (<++) pfail (decomposeIh : decomposeOh : decomposeTd : map decomposeDph [3,5..]) (returnD n)


# Topologies on Rational Numbers (WIP)

## Objective

Construct a subset $$\P\$$ of $$\\mathbb{Q}\$$ such that:

• $$\P\$$ is neither open nor closed in $$\\mathbb{Q}\$$ as a subspace of $$\\mathbb{R}\$$, and

• $$\P\$$ is open but not closed in $$\\mathbb{Q}\$$ as a subspace of $$\\mathbb{R}_l\$$.

Or, in other words, construct a subset $$\P\$$ of $$\\mathbb{Q}\$$ such that:

• There exists $$\p \in P\$$ such that, there doesn't exist an open interval $$\p \in (a,b) \subset \mathbb{R}\$$ such that, $$\\mathbb{Q} \cap (a,b) \subset P\$$.

• For every $$\p \in P\$$, there exists a half-open interval $$\p \in [a,b) \subset \mathbb{R}\$$ such that, $$\\mathbb{Q} \cap [a,b) \subset P\$$.

• There exists $$\p \in \mathbb{Q} \setminus P\$$ such that, there doesn't exist a half-open interval $$\p \in [a,b) \subset \mathbb{R}\$$ such that, $$\\mathbb{Q} \cap [a,b) \subset \mathbb{Q} \setminus P\$$.

## Notes and Rules

• Note that $$\P\$$ is necessarily infinite, and thus cannot be represented as an associative container. One way of representing $$\P\$$ is to have a function $$\f : \mathbb{Q} → \mathbb{Z}_2\$$ that halts for every input, where $$\\mathbb{Z}_2\$$ is the set of the boolean values. Then $$\p \in P\$$ shall satisfy iff $$\f(p)\$$ is true.

• The representation of $$\\mathbb{Q}\$$ must be exact. Thus you cannot have floating-point values as an input. Though native rational-number arithmetic will be preferred, you may use two arbitrary-length integers as an input. In this case, the fraction is assumed to be irreducible and to have a positive denominator. Otherwise, the fraction falls in don't care situation.

• Invalid inputs fall in don't care situation.

## Example

An example of such $$\P\$$ is:

$$\mathbb{Q} \cap ((0,1) \cup [2,3))$$

Work in progress due to a trivial example.

• Is there a way you can frame this question without topology? At the moment I think participation would be very low due to the high background knowledge demanded. – Sisyphus Nov 10 at 9:58

# English English code-golfstring

You have been hired by the American embassy in the UK to act as a translator. Being a lazy programmer, you decide to write a program to do a bit of the work for you.

You've found out that often just doing the following things can satisfy Word's spellcheck (which has been set to US - English) somewhat, so you don't have to do as much work later when translating written documents:

• All occurrences of "our" can be replaced with "or".
• All occurrences of "ise" and "yse" can be replaced with "ize" and "yze", respectively.
• All occurrences of "ae" and "oe" can be replaced with "e".
• All occurrences of "ll" that have a vowel before them can be replaced with "l".
• The ending "re" can re replaced with "er".

• Write a program or function that takes a string or list of characters as input, performs the replacements mentioned above, and outputs the modified string or list of characters.

## Rules

• A sequence of alphabetical characters is considered a word. Words may be delimited by spaces, commas, periods, or other punctuation characters.
• This is , so shortest code wins.
• No inputs with conflicts, e.g. a word ending with "oure", will be given.

## Test cases

We would like you to analyse something.   | We would like you to analyze something.
An archaeologist has made a discovery.    | An archeologist has made a discovery.
The centre of their research is armour.   | The center of their research is armor.
Back when dinosaurs travelled the Earth,  | Back when dinosaurs traveled the Earth,
We must analyse this further.             | We must analyze this further.
ouroullisaeisere                          | orouliseizeer


## Questions for Meta:

• Are there any more replacements I should add?
• What are some test cases I should add? Are the test cases I have added enough (and are they appropriate)?
• If a replacement ends up in another replaceable word ("isae" -> "ise", as FryAmTheEggman mentioned), should I make answers repeatedly substitute and turn "isae" into "ize", or leave it "ise", or just say that those sort of inputs will never be given?
• Probably a good idea to include a definition of a word. – Giuseppe Nov 12 at 17:38
• You say no inputs with conflicts, but what about replacements that create replaceable strings? Consider isae, do we get ise or ize or is this invalid? – FryAmTheEggman Nov 12 at 19:40
• @FryAmTheEggman That's a good point. I'd prefer to make answer repeatedly substitute the patterns, but do you think that might make it too cumbersome? – user Nov 12 at 19:46
• It basically amounts to wrapping the substitutions in a loop - so I'm not sure it matters terribly much. I think for a challenge on this site it is probably better to say it won't happen, but that's just an opinion (and not a terribly strong one at that). – FryAmTheEggman Nov 12 at 19:48

Heavily based on this closed challenge.

# Length of a Sumac Sequence code-golf

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

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

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

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

# Challenge

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

If there is a negative number in the input, remove everything after it, and compute the length.

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

# Test Cases

Taken from the original question.

    t1   t2      length
120  71      5
101  42      3
500  499     4
387  1       3
3   -128     1
-2    3       0

• "No negative integers should be present in the sequence." That make the last testcase invalid. – Shaggy Oct 19 at 14:15
• ah. I'll remove that. – Razetime Oct 19 at 14:16

# Write a program that mimics the output of the command env (with no arguments).

The program should print (to standard output, or closest equivalent) a list of all current environment variables, with each variable on it's own line. The name and content of a variable should be separated by an equal sign.

Here's a grammar:

line ::= name "=" contents
output ::= (line "\n")*


No using the env command.

shortest code wins.

• Can we use built-ins the get environment variables? – Adám Nov 15 at 15:50
• @Adám If you mean "Can we use built-ins to get the environment variables", yes, I don't see a reason you couldn't, and otherwise it might be impossible to get them in some languages. – binarycat Nov 15 at 15:54
• And I assume (ba|k|c|…)sh cannot participate? – Adám Nov 15 at 15:56
• @Adám If they can find a way to get a list of environment variables without using env, I guess they could, unless I'm missing some other command that produces the same output. There's a lot of languages that can't complete the challenge (mostly esoteric ones), but they aren't technically banned. – binarycat Nov 15 at 23:28
• How about set on Windows/DOS? – Adám Nov 16 at 8:07

# Find the longest streak of Fibonacci numbers on the Ulam spiral

## Fibonacci numbers

Fibonacci numbers are a sequence where each element is the sum of the previous two elements. In the original Fibonacci sequence, the first two number are 1. So the sequence goes: 1, 1, 2, 3, 5, 8, 13, 21, .... For the challenge, we will accept any two numbers as the two starting numbers of the series.

## Ulam spiral

The Ulam spiral is an arrangement of natural numbers. The spiral goes counter-clockwise and starts with the numbers 1, 2, where the 2 is right of the 1. For this exercise, only the shape of the spiral is relevant.

Find the length of the longest streak of generalised Fibonacci numbers (with any two starting numbers) following the Ulam spiral in a given array of integer numbers.

## Example

The following 5x5 array has two generalised Fibonacci sequences: one of length 4 (in blue + yellow: 138, 81, 219, 300) and one of length 8 (in green + blue: 24, 57, 81, 138, 219, 357, 576, 933). The answer is thus 8.

## Rules

• Your program should at least support arrays up to 65535 * 65535 in size and array elements with values up to 4,294,967,295.
• Invalid input (non-square arrays, float or negative elements, non-arrays, etc.) may lead to unpredicted output, errors or (un)defined behaviour.
• Default I/O rules apply and default loopholes are forbidden.

on question 1; see comments below

• This is , so the shortest answer in bytes wins.

on question 2; see comments below

• This is , so the fastest answer wins.
• Fastest code is measured in average user time over 5 different, undisclosed input matrices of sizes 100, 1000 and 10,000, each run 3 times on my late 2013 MacBook Pro with 2,3 GHz quadcore Intel i7 CPU and 16 GB of RAM.

## Review questions

• I plan on publishing this question twice: one time as a codegolf and one time as a fastest-code. See the last section of my question. I think this challenge has interesting but very different optimization strategies for speed and size. Is this be something that would be frowned upon by the CGSE community?
• Is the challenge clear enough as stated?
• Should I add more/larger test cases? Or a test case generating Python script?

# Fix the dates  string

Your company has preferred ISO date format to fill in the database entries. But, some of your clients have been sloppy when they enter the date, they usually skip off the leading zeroes in days/months (no issues in year). Write a program to correct the date string, if needed.

# Test cases

# extended format: yyyy-mm-dd

2016-12-17 -> no issues, return 2016-12-17
2008-10-5 -> issue in day, return 2008-10-05
2000-1-1 -> holy crap! return 2000-01-01
2020-2-27 -> issue in month, return 2000-02-27

# basic format: yyyymmdd

2016730 -> 20160730
# it may be "2016-7-30" or "2016-73-0", but only "2016-7-30" is valid
2020131 -> 20200131
201911 -> 20190101 (holy crap!)
# remember, dates are valid and non-empty
4040404 -> 40400404


# Rules

• It is guaranteed that the given date is valid, and the year has no issues!
• Further, in the simple format of date, there would be no ambiguities like 2020111, 202011, etc. This would make challenge ambiguous rather than hard x_x
• Input can be either a date string, or an array of them.
• This is a , so fewest bytes will win!

## Meta

• Is the challenge's text clear enough?
• Should I ask this as two separate challenges (extended, simple)?
(this would be appropriate, I think and as said by anatylog)
• Is this a duplicate?
• Any suggestions/improvements?
• Any edge test case?
• You should definitely choose only one input format! If you want both, make it two separate challenges, not two separate parts. If you choose the one without delimiters, you must specify what to do with ambiguities (e.g. 2222101 - should convert to 2222-01-01, 2222-10-01, or doesn't matter). – anatolyg Nov 18 at 16:06
• @anatolyg - well, I meant to say seperate challenges, actually. Never mind, I'll do that. Secondly, about the ambiguities, I'll never ask them. This will be mentioned too! – vrintle Nov 18 at 16:57

# Sociable sequences

Sociable numbers are a generalisation of both perfect and amicable numbers. They are numbers whose proper divisor sums form cycles beginning and ending at the same number. A number is $$\n\$$-sociable if the cycle it forms has $$\n\$$ unique elements. For example, perfect numbers are $$\1\$$-sociable ($$\6\to6\to\cdots\$$) and amicable numbers are $$\2\$$-sociable ($$\220\to284\to220\to\cdots\$$).

The proper divisor sum of an integer $$\x\$$ is the sum of the positive integers that divide $$\x\$$, not including $$\x\$$ itself. For example, the proper divisor sum of $$\24\$$ is $$\1 + 2 + 3 + 4 + 6 + 8 + 12 = 36\$$

There are currently $$\51\$$ known $$\1\$$-sociable numbers, $$\1225736919\$$ known $$\2\$$-sociable pairs, no known $$\3\$$-sociable sequences, $$\5398\$$ known $$\4\$$-sociable sequences etc.

You may choose whether to:

• Take a positive integer $$\n\$$, and a positive integer $$\m\$$ and output the $$\m\$$th $$\n\$$-sociable sequence
• Take a positive integer $$\n\$$, and a positive integer $$\m\$$ and output the first $$\m\$$ $$\n\$$-sociable sequences
• Take a positive integer $$\n\$$ and output all $$\n\$$-sociable sequences

If you choose either of the last 2, each sequence must have internal separators (e.g. 220, 284 for $$\n = 2\$$) and distinct, external separators between sequences (e.g. [220, 284], [1184, 1210] for $$\n = 2\$$)

You can choose whether to include "duplicate" sequences, i.e. the sequences that are the same as others, just beginning with a different number, such as including both 220, 284 and 284, 220. Please state in your answer if you do this.

This is so the shortest code in bytes wins

• You probably need to describe what a proper divisor is. Separately, I'm not sure how great requiring infinite output is. I'd probably consider allowing another optional argument that limits how many sequences to output? – FryAmTheEggman Nov 12 at 19:47

# Isomorphic Modular Arithmetic

For this question, we define $$\U(n)\$$ as the group consisting of a number below $$\n\$$ that is coprime to n (1 included but 0 doesn't) and multiplication as group operator.

Your task is to print every integer (so it's an infinite loop, but there should be output during looping) and group it into lines so that:

1. The line consists of a sequence of sorted number so that the $$\U\$$ group based on each number is isomorphic
2. The output itself has to be sorted based on the first number on each line
3. Every number have to be eventually outputted given enough time.

A pair of groups $$\(X,\times_A)\$$ and $$\(X,\times_B)\$$ is called isomorphic if there is a pair of functions $$\f : X\to X\$$ and $$\g:X\to X\$$ so that:

$$\ f(g(x)) = x = g(f(x)) \text{ (i.e. they are inverses)} \$$

$$\ f(x) \times_B f(y) = f(x \times_A y) \$$

$$\ g(x) \times_A g(y) = g(x \times_B y) \$$

The shortest code wins.

• Your opening sentence doesn't quite define a group. Do you mean a group generated by the coprime and multiplication? It seems like the most logical choice. – Wheat Wizard 18 hours ago
• I am starting to doubt that since the result is always isomorphic to the integers under addition, and completely ignores n. Do you maybe mean the group generated by the coprime and multiplication on the cyclic group of order n? This makes more sense, but not a whole ton of sense. I think if you explained the output requirements more directly it would be easier. As it stands I do not understand them at all. – Wheat Wizard 17 hours ago

# 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. – user45941 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. – Xwtek Nov 7 '15 at 7:39
• I didn't downvote though... – Sp3000 Nov 7 '15 at 8:13

# What day of the week is Christmas?

Christmas is coming quickly, which leads to the question, what day of the week is Christmas this year? But what day of the week is Christmas for any year? Write a program that can do this. This is code golf, so the shortest code wins!

However, there is a major twist. No builtin functions to do this task is allowed!

Bonuses:

1. If the program can handle B.C. years as negative numbers, then -25%
2. If the program prints "The first Christmas!" for an input of -4 (4 B.C. is assumed to be when Jesus Christ was born), then -30 bytes
3. If, for some reason, you really like builtins, +90%! So try NOT to use it!
• The bonus for printing extra should be steeper, or no esolangs are going to go for it. – Addison Crump Nov 29 '15 at 1:45
• @VoteToClose so more like 25% as well? – TanMath Nov 29 '15 at 1:48
• No - I'd go static. Plus, this is really close to being a dupe... – Addison Crump Nov 29 '15 at 1:51
• Near dupe of codegolf.stackexchange.com/questions/1003/… – Calvin's Hobbies Nov 29 '15 at 1:52
• It's unspecified what format we should output in or what calendar we should use, and whether -4 should mean 4 BC or 5 BC. – lirtosiast Nov 30 '15 at 5:57
• @ThomasKwa it should be obvious from the sentence that 4 B.C. is -4. Use the Gregorian calendar, output can be in MMDDYY – TanMath Nov 30 '15 at 6:09
• How is MMDDYY a day of the week? – lirtosiast Nov 30 '15 at 16:32
• @ThomasKwa sorry, it was pretty late when I wrote that so I mistakenly wrote MMDDYY. Just printing the day of the week is fine i.e. print "Sunday", "Monday", "Tuesday", etc. – TanMath Nov 30 '15 at 19:57

# Broken FizzBuzz - Greg Is Confused underhandedcode-golfpopularity-contest

(FizzBuzz suggested by quartata in chat)

Meet Greg. Greg is the new debugger at your company, and he deals with checking programs to see if they work. If they don't, he tries to find out why and fix them.

Greg is rather new to programming and understands the basics, but still gets tripped up by some advanced things. Sometimes, programs don't work and he doesn't know why.

You don't really like Greg, so you decide to play a game. You create two nearly-identical FizzBuzz-style programs - one which works, and one which doesn't.

For example:

n = input()
if (n % 3 == 0) {
print "Fizz"
}
if (n % 5 == 0) {
print "Buzz"
}


works, but

n = input()
if (n % 3 = 0) {
print "Fizz"
}
if (n % 5 == 0) {
print "Buzz"
}


doesn't. Greg is confused (but not by something as simple as this).

And because Greg has a desk only a few feet away from you, your code must be as small as possible, so he doesn't catch on.

## Rules

• Your correct program must accept an integer as input and return output as specified below, and your incorrect program must do something else (such as throwing an error or giving invalid output).
• The valid program's output must print "Fizz" if the number is divisible by 3, "Buzz" if it divisible by 5, "FizzBuzz" if it divisible by both 3 and 5, and nothing if it isn't divisible by 3 or 5.
• The invalid program's output may do anything else.
• Greg knows all programming languages to date, including super-obscure ones. Therefore, your answer may be in any language you choose (providing it was created before this challenge was posted.)
• You MUST have the two programs be nearly identical, except for one small change. The more concealed or insignificant-looking, the better.
• Greg uses PPCG and has participated in underhanded challenges before, so he knows about the C trigraph (??/). You can't trick him with it.
• Greg has also seen replacing ASCII characters with nearly-identical Unicode or abusing fonts, meaning that won't work either. Therefore, your program's change must work with all fonts, any may not exploit visual similarity between characters with different code-points.
• Changing an a to an A is allowed, as long as it's not obvious that that's what broke the program. However, changing a to <unicode character that looks exactly the same> is forbidden.
• Both programs must be written in the same language with the same version.
• The language both programs are written in
• Two programs: one FizzBuzz program, and another that is broken
• How to run both of them (the commands must be identical with identical arguments)
• Why one doesn't work (in spoilertext)
• The output of the broken one
• Your programs must have a Levenshtein distance of no more than 10 from one-another. (Meaning that you may add, delete, or change up to 10 characters in the broken code from the correct one.)
• Your score is the total bytecount of both of your programs.
• The winner is the post with the smallest score over 20 votes.

Meta Questions

• Is 10 too small a maximum Levenshtein distance? I was also considering 15.
• Are any of my rules already forbidden by the standard loopholes? I'd like to remove them if possible to make the post shorter.
• Similarly, should I remove or change any of my rules?
• This is a code-golf version of this previous edit. Should I keep it as code-golf or change it back?
• "replacing ASCII characters with nearly-identical Unicode" doesn't really express what that old chestnut does. "Exploiting visual similarity between characters with different code-points" is more accurate. Although it's arguable whether that covers e.g. switching space for non-breaking space, and I don't think it covers using non-whitespace non-printable characters (which with the right font are invisible). – Peter Taylor Dec 16 '15 at 16:44
• I think there is something interesting here in making seemingly equivalent programs behave very differently. But I'm generally sceptical of underhanded pop-cons, because they're usually way too broad and this one doesn't seem to be an exception. The primary cause is probably that there's no actual task that the program should accomplish. That means you can literally write any code that leads to failure from a small change (which is probably most code although the failure will not be surprising for most of those changes). I'd recommend giving a task for at least one of the two programs. – Martin Ender Dec 16 '15 at 16:49
• @PeterTaylor Maybe something like "Your program's change must work with all fonts, any may not exploit visual similarity between characters with different code-points"? – ASCIIThenANSI Dec 16 '15 at 16:53
• @MartinBüttner I've changed it to two programs that should print "Hello, world!" (only the correct program will work). How does this look? – ASCIIThenANSI Dec 16 '15 at 16:57
• There are some very closely related underhanded challenges: codegolf.stackexchange.com/q/31647/8478 codegolf.stackexchange.com/questions/23250/what-no-error codegolf.stackexchange.com/questions/19379/… – Martin Ender Dec 18 '15 at 16:37
• @MartinBüttner I've added them in. Do you think they're close enough to be duplicates? – ASCIIThenANSI Dec 18 '15 at 16:42
• @ASCIIThenANSI I can't predict how the community will vote, but I wouldn't mod hammer it. – Martin Ender Dec 18 '15 at 16:45

# There's an App SE Site for that

Oftentimes, when searching through StackExchange, I find myself seeking to post a question about something or another, but not knowing where to post it. That's where you come in.

## The Challenge

Write a full-functioning program that does the following:

1. Takes an input string
2. Attempts to find suitable SE sites relevant to the input string (this is very flexible, but should not be returning English.SE for questions about Coffee, for example)
3. Attempts to find 3 questions on each suitable site that may relate to the input string (should match the list of questions if I searched in the search bar of each site, sorted by number of votes)
4. "Output" is a folder tree written to disk with the following qualities:
• The highest folder of the tree should be named the input string.
• The second-highest layer should consist of folders named the same as the sites on which the input string was found suitable.
• The third layer should be <=3 .md files that are named the same as the questions found when searching through the suitable sites, the contents of which are the question's markup content.

# Rules

• You MUST query for this information. I don't want 50EB solutions.
• "Suitable sites" are defined as the keyword appearing in the site description.
• Run time should be <5 minutes for >3 MB internet speed.

# Bonuses

There are no bonuses.

Remember - SE is a big place now, and, as of such, we must compensate with short code. This is , everybody, so the shortest solution wins!

• "Whatever defines "suitable" for your code is up to you" is too broad IMO. – Peter Taylor Jan 25 '16 at 14:35
• @PeterTaylor Refined. Please see edit. – Addison Crump Jan 29 '16 at 17:50
• @RikerW I don't know what you're saying. – Addison Crump Jan 29 '16 at 17:57
• Me neither. lol – Rɪᴋᴇʀ Jan 29 '16 at 17:58
• What's the yardstick for whether two words are synonyms? If that's up to answers to decide, no-one will waste any bytes on it, so you should simplify the question by removing the mention of synonyms. Otherwise you need to add a source (and risk the question being largely a kolmogorov-complexity for that list). – Peter Taylor Jan 29 '16 at 19:48
• @PeterTaylor Fixed. – Addison Crump Jan 29 '16 at 20:45

Are bug hunts like this allowed?

# Bug Hunt - Make a change in a Git repo that Git cannot detect

Challenge: In the working directory of a Git repo, make a change that Git cannot detect.

• Changes can be on any file in the working directory or subdirectories that is tracked by Git.
• You may use any tool to make the change, or script your own program to do so.
• For tools, state the tool used and the steps to reproduce.
• For script or program, produce the code (please use GitHub Gist if it's too long). State the language and compiler version, if any.
• You can also do the change manually. In this case, outline the steps.
• State the version and platform of the Git binary used.
• Show a comparison between an actual clean working directory and the modified one to show the change Git can't detect.
• Show that git status says "nothing to commit, working directory clean".

Winning Criterion:

• The extend of the undetected change - the bigger the change, the better.
• Reasonably latest Git version.
• Easy to reproduce.
• [Optional] Short code or simple steps. It's OK if it's not, as long as you do something exceptional.
• Most upvotes (for tiebreaker reasons).
• [Optional] You located an actual unfixed bug in the Git source code, and not just a quirk in something else.

Restrictions:

• Obviously, using .gitignore is not allowed. It's a bug hunt. Changes that Git is designed to ignore are not allowed. We should reasonably expect Git to see and report the change, but find that Git doesn't.
• Use latest Git version you can get. Some old version with some bug that's already fixed doesn't count.

Please let me know if this is OK, so I can go ahead to post it on the main site.

I could only find . A suggested tag would have been the best.

• Currently bug hunts aren't allowed. Because no one proposed them, you can propose bug hunts by asking a question on meta. – user48538 Mar 20 '16 at 12:28
• I have a strong feeling that this won't be allowed. We don't allow code that exploits bugs or harms computers. – Nathan Merrill Mar 20 '16 at 12:31
• @NathanMerrill source? – ADTC Mar 21 '16 at 0:17
• meta.codegolf.stackexchange.com/q/4829/20198 – Nathan Merrill Mar 21 '16 at 2:21
• Is this essentially asking for an AES collision? – Peter Taylor Mar 21 '16 at 11:14
• @PeterTaylor now that wouldn't be a bug, would it? But yes, I guess that's also a valid scenario. Can you create one? – ADTC Mar 23 '16 at 6:06
• This sandbox post has had little activity in a while and little positive reception from the community. Please improve / edit it or delete it to help us clean up the sandbox. – programmer5000 Jun 9 '17 at 14:11

## Calculate the number of consecutive 0's at the end of n!

Simply put, write a program or function that takes n and returns the number of consecutive 0's at the end of n!

Examples

Input: 12
Output: 2


Input: 12345
Output: 3082


Input: 100000
Output: 24999

• I think this might be a dupe. – Rɪᴋᴇʀ Apr 2 '16 at 21:45
• @EasterlyIrk Do you have a link to the duplicate problem? – MrPublic Apr 4 '16 at 11:38
• This is extremely similar. – FryAmTheEggman Apr 4 '16 at 17:20
• This proposal would be similar to finding the position of the last nonzero digit, but it's not similar to the linked challenge, which finds the value of the last nonzero digit – Luis Mendo Apr 6 '16 at 11:14

## Self-identification before golfing

Since golfed code is harder to read, answers often contain an less golfed version. There are a number of potential golfing transformations depending on the language, so you may be able to score more highly using a more traditional language. Some examples of golfing transformations:

• Removal of spaces, tabs and/or newlines
• Removal of disambiguating parentheses
• Removal of braces around single controlled statements
• Conversion from statements to comma operator
• Removal of explicit return statements
• Renaming identifiers

Your challenge is to write a program or function that can identify an ungolfed version of itself. Scoring is based on the number of golfing transformations that can be recognised. The submission must be capable of identifying all "original" code that is itself capable of self-identification (at least one such code must exist). Each supported transformation scores 1 point, but there are also bonus points available:

• 1 bonus point if the transformation can be repeated multiple times
• 1 bonus point of the program rejects at least one invalid transformation of itself (e.g. white space added inside a keyword)
• 1 bonus point if the program only accepts valid transformations of itself
• 1 bonus point if the transformation shortened the code (so if you only supported renaming a 1-letter variable to another letter, you would not qualify)
• 1 bonus bonus point if in addition the transformed program recognises the original program as a transformation of itself

Example: A submission accepts the name of another program as a command-line parameter. It opens itself using its own name hard-coded into itself. It recognises the following transformations:

• A change to the hard-coded file name (3 points, as there is only one file)
• A change to the amount of space between words (5 points, as there are no invalid transformations to reject)
• A change to the names of its variables (4 points, as it doesn't check whether the variables are renamed consistently or to keywords)

Total score: 12 points.

In the event of a tie on score, shortest code wins.

Tags: code-golf, quine

• This is hopelessly subjective. – feersum Apr 5 '16 at 13:35

# Random Wikipedia Browsing

Here's a short one for you. Create a program or function prints or returns the title of a random Wikipedia page (similar to Alt + x functionality)

Rules:

• Program or function will take no input
• Program or function will print to STDOUT (or nearest equivalent) or return only the page name. I don't care about trailing spaces or newlines. Preceding spaces or new lines are disallowed
• Program or function may not access a list of Wikipedia page names stored within a local file.
• There is no requirement to use English language Wikipedia (en.wikipedia.org)
• Page must be chosen (psuedo) randomly

For reference, here is a link to the Wikipedia API. Shortest program or function in bytes wins.

• Bash: xdg-open http://bit.ly/19UDVJs (I think it's open). That Bitly link points to the Random Page link, which redirects to a random page. Wouldn't be hard to find a shorter URL, either. – Fund Monica's Lawsuit Apr 14 '16 at 17:10
• Aww man, I had no idea that existed, guess it makes this pretty trivial – wnnmaw Apr 14 '16 at 17:11
• Yep. Though if the language's builtins don't support automatic handling of redirects, it might be more challenging. – Fund Monica's Lawsuit Apr 14 '16 at 17:11
• Could I disallow using that link? – wnnmaw Apr 14 '16 at 17:12
• I dunno, to be honest. I'm not very good at writing challenges. – Fund Monica's Lawsuit Apr 14 '16 at 17:13
• Relevant chat discussion, this challenge is trival – wnnmaw Apr 14 '16 at 17:21
• @wnnmaw the Random Page is often used for wiki-racing. It's pretty fun. You can do either shortest distance (pages traversed), or fastest time. Maybe you could make this into a King of the Hill challenge to write a bot that wiki-races against other bots? – mbomb007 Apr 21 '16 at 18:15

# What can I build? code-golf

## The Rules

Today I have decided to make geometric shapes out of toothpicks and gumdrops! However, I have a limited supply, so you have to figure out what I can build. I will give you an input in the format m n, where m is toothpicks (edges) and n is gumdrops (vertices.) Your output should be, in any output format of your choice, all 3D geometric shapes such that the amount of edges=m and the amount of vertices=n. The list of 3D geometric shapes you will use is this: Gist

• You may NOT access the Internet.
• No builtins relating to geometry or solids
• This is code golf, so shortest code wins.
• For no solids and invalid input, output nothing

# Examples

In: 3 2 Out: <empty>
In: CodeGolf123 Out: <empty>
In: 12 6 Out (Bonus): {regular tetrahedron,unit equilateral square pyramid,unit equilateral triangular dipyramid,unit equilateral triangular prism,unit equilateral pentagonal pyramid,regular octahedron} Out (Regular): {regular octahedron} 

• The first 3 rules can be deleted, as they're ppcg defaults – Bálint May 22 '16 at 20:03
• Not the first... – user46167 May 22 '16 at 20:04
• I think this would work better with 1 solid with exactly n and m edges and sides. – Rɪᴋᴇʀ May 22 '16 at 20:29
• How about doing that, but having this as a bonus? – user46167 May 22 '16 at 20:37
• 1. KISS. Ditch the stuff about the external file: the overhead to load it and the overhead generated by requiring it to be UTF-8 mean that no-one would want to use it anyway. 2. "No builtins" literally bans people from using any language. Specify what built-ins are banned. 3. Make the data available in a usable format: i.e. a text file hosted on gist.github.com or pastebin. 4. The bonus is a no-brainer: a 10% saving for changing two == to <=. Either make it compulsory or remove it entirely, because as it stands it's just complication. – Peter Taylor May 22 '16 at 22:38
• @petertaylor: I am currently on a phone so I can't put a gist... – user46167 May 23 '16 at 10:42
• There are a lot of shapes in that gist. Some of them are specified in different formats. If they're all to be supported it would be nice to have a standard format to represent them. Also some of these shapes specify different edge lengths. Will the challenge assume all edges are length 1 or will you potentially need to break toothpicks and keep track of the remaining pieces? – Poke May 26 '16 at 21:02
• @Poke 1. Will fix 2. Irrelevant-- you have all sorts of toothpicks, some miniscule and others huge. – user46167 May 26 '16 at 23:43

# Golf a golf-scoring program! code-golf

Given a space delimited array of integers, find the smallest number. It's that simple.

[Meta] This may in fact be a duplicate. Please tell me if so.

• This is basically a dupe of any regular sorting question, isn't it? Particularly something like Sign that word. – FryAmTheEggman Jun 9 '16 at 12:52

Write a program that, when executed, returns the markdown file to your answer.

So, something like this:

#Python: 123 bytes

{insert code here}


# Required things:

• Header must be one hash (#`)
• The "code part" must be indented with four spaces (or surrounded with backticks if it's a one-liner).
• The code part must be the actual code used to run the program.
• There must be a separation of a newline between the header and the code.
• The program's display bytecount MUST equal the program's actual bytecount.

# Meta:

• Most importantly: is it even possible, at all?
• Do I need more clarifications?
• Has this been done already?
• "Most importantly: is it even possible, at all?" Definitely possible and in most languages no more difficult than a standard quine. The points in this answer probably apply as well. Also the third-to-last paragraph in this answer since languages with longer names will have a disadvantage. And finally, there's this related challenge (same thing without the quine part). – Martin Ender Jul 27 '16 at 7:25
• Actually, it's just too easy. Just use a normal quine with stuff before. – Erik the Outgolfer Aug 3 '16 at 17:50