# Sandbox for Proposed Challenges

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

Sandbox FAQ

## Posting

Write your challenge just as you would when actually posting it, though you can optionally add a title at the top. You may also add some notes about specific things you would like to clarify before posting it. Other users will help you improve your challenge by rating and discussing it.

When you think your challenge is ready for the public, go ahead and post it, and replace the post here with a link to the challenge and delete the sandbox post.

## Discussion

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

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

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

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

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

## Other

Search the sandbox / Browse your pending proposals

The sandbox works best if you sort posts by active.

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

Get the Sandbox Viewer to view the sandbox more easily!

# Secretary Problem - Cops and Robbers

The Secretary Problem is a famous problem. In this challenge, it’s a little different:

1. You need a new secretary that asks for the least salary
2. You have a lot of applicants that you can interview one at a time, but don’t know how many applicants there are
3. Each applicant will tell you how much salary they want (they’ll want at least $1 salary, but may all want$5)
4. Applicants do not ever request the same salary for some weird reason (not sure if they’re robots or eavesdroppers)
5. After you interview an applicant, you must give an immediate "yes, I accept you" (truthy) or "no, go away" (falsey)
6. You want the applicant that asks for the lowest salary, so you can stay rich
7. No applicant ever requests more than 1 million dollars (for obvious reasons)

In the maths world, it’s actually that you want the highest leveled applicant, but I put it this way because who doesn’t want to stay rich

Your challenge is to write a program that takes two inputs: the previous applicants’ salaries, the current applicant’s salary, and outputs whether to accept the applicant (truthy) or deny him/her (falsey).

The robbers will attempt to find a list of applicants (and the salaries they demand) that forces your program to accept a person with a high salary demand. You need to attempt to make your program only accept the applicant which asks for the LEAST salary (that way you can stay rich)

The answer that (when answered against by a robbers thread - [link]) accepts the person with the least salary wins/gets accepted (i.e. the answer that accepts a $1, if that doesn’t exist, then the answer that accepts a$2, if THAT doesn’t exist ... and so on)

If your answer does not accept any, (up to the last applicant) you automatically get

Each answer in the cop’s thread is a program that takes two inputs: the previous applicants’ salaries, the current applicant’s salary, and outputs whether to accept the applicant (truthy) or deny him/her (falsey).

Your challenge is to find a program in the cop’ thread (insert link here) and attempt to give it an input such that it accepts a person with a HIGH salary request. Answer that forces an algorithm to accept the highest amount of money gets accepted (i.e. the answer that forces a cop answer to accept a $1000000 salary applicant, if that doesn’t exist, the answer that forces a cop answer to accept a$999999 salary applicant, if THAT doesn’t exist ... and so on)

• Changed - "at least 100 applicants" and "at least one applicant that requests <$100" – W D Oct 27 '21 at 5:27 • The cops can consider only the bound of$100, as at least one robber will be <$100. Oct 27 '21 at 9:03 # Output a random integer in a range that is a multiple of all in one set and not a multiple of any in another set Given an integer range and two sets of integers, generate a random integer inclusive within the range that is a multiple of all the numbers in the first set but is not a multiple of any number in the second set, or specify that such a value does not exist. ## Examples: • Range: 100 - 200 • Divisors: 3, 5 • Non-divisors: 9, 10 Possible values are: 105, 165, 195 (output one at random) ## Rules 1. Mathematically elegant solutions are preferred, but brute force solutions are accepted. 2. If outputting one of multiple values is possible (as shown above), the solution should return a different value with each execution so that, probabilistically, all possible values are eventually output. 3. This is code golf, so lowest byte count wins. NOTE I have a solution for this in C#, but I'm curious of what other solutions there are. I had a heck of a time working out the math for this and thought it would be a good bit of puzzling for this community. • The First Rule is unnecessary. Nov 5 '21 at 18:49 • Why do you say so? If not included, I expect only brute force solutions will be provided. Nov 7 '21 at 19:12 • If the first code is included and others may think is fastest-code tag Nov 9 '21 at 15:32 • I suppose that is one of the end goals. Maybe that's a win condition I need to add. I've never seen that in code golf. I'll have to research that tag for examples. Nov 9 '21 at 19:26 • This needs testcases (pick one at random) and add tag random. Nov 11 '21 at 21:59 # Quantum boolean ## Background Have you ever dream of quantum state? If that's true for you, you are probably weird... Anyway, I came up with an idea: what if we make a quantum in code? ## Task Create a data type, function, or class, anything that can be put in a condition. What should it do: (def your thing here, I'll name it "X" for now) if X: part a else: part b  part a and b should both be executed, although the chance of which being first should be 50/50.  if X: a=5 else: a=10 b=5  a should have 50% chance to be 5, 50% 10, but b will always be 5 x can be different everytime mention, or always the same on parallel universe if X: part a else if X: part b else: part c  Could be: execute a,b,c with a 50% being first execute,b,c 25% each.(second X and first X both being quantum) In this case a will never be the second one executed. possible case: a,b,c a,c,b b,c,a c,b,a   / a True 50% init / b True 25% \ a False \ b False - c 25% First X Second X  Or: X True for a X False for c b will never be executed.  / X True - a init \ X False - c  # Example X as your submit if X: # or X() print(1) else: print(2)  return 1 2  or 2 1  # Extra A whole compiler/transpiler (changing code to fit in quantum state) is allowed, but will compete on it's own(with other compiler style anwser). # Rule • Standard rules. # Goal golf your quantum as smaller as possible! # Meta • Is this clear? • Is this hard? • Is this fun? • This doesn't make a whole lot of sense to me. You seem to be describing a code construct that takes a list of statements and executes them all in random order. By design that isn't how if/else statements work: 'part a and b should both be executed' can't happen no matter how you define X. Nov 18 '21 at 3:30 • @Dingus one of the possible way is to have function X read self source code, you don’t have to run excatly same code on excatly position, you can copy statement and execute it at other file/place, or just rerun program with modifications upon called. – okie Nov 18 '21 at 5:50 # Silly Sentence Generator Your challenge is to input a sentence and find all words enclosed within angle brackets. (< and >) Here is an example: The <adjective> <noun> biked across the bridge.  Next, replace all <noun>s with a random noun, all <verb>s with a random verb, all <adjectives>s with a random adjective, and all <adverb>s with a random adverb. According to the above rule, The <adjective> <noun> biked across the bridge. could become The daring monkey biked across the bridge. Your program will input a list of nouns, verbs, adjectives, and adverbs. Make sure the words follow capitalization. So if the random noun in <noun> <verb>ed is monkey, it should then become Monkey. Another rule is that if a verb (like slide) ends with e, and the bit after the <verb> is ing or s, (e. g <verb>ing) do not keep the final e. (e. g slideing becomes sliding). ## Examples Note that these examples assume the nouns are monkey and ai, the verbs jumped and sliding, the adjective daring, and any list of adverbs (since the examples don't use them.) The <noun> was <verb>ed by the <adjective> <noun>. => The monkey was jumped by the daring ai. <verb>ing <noun>s play together. => Sliding monkeys play together.  Shortest code wins! • I would suggest replacing the "Test cases" section with "Examples" to show some possible outputs. Sep 17 '21 at 17:44 • @AaronMiller Added some test cases and additional rules. Sep 17 '21 at 17:53 • You don't specify in these cases whether you want to be including the propagation of the word lists, etc. into the code golf challenge. If this is a requisite that the population of the lists be included in the bytes, this is going to make every 'golfed' solution pretty huge, even with small word lists you've provided. Sep 17 '21 at 18:15 • @ThomasWard Edited. Sep 17 '21 at 19:00 • I think it would be better to instead take the lists of words as additional inputs Dec 1 '21 at 18:33 • It's still not clear if we're hardcoding the words or not Dec 1 '21 at 18:34 # Output sequence from a name You are given a sequence of numbers(0-9) which you have to convert to its literal form. ## Example Input : 1246 Output : 26666 We interpret the input as one 2 four 6, thus giving the output 2 one time and 6 four times ## Testcase Input Output 1234567809 2444666668888888 2345 335555 ## P.S. 1. Is this descriptive enough? 2. Would it be fun to do? # Can I obtain this Minecraft item? Given a list of items I have access to, determine if I can obtain a certain amount of some other item via crafting, mining, trading, and some other actions. ## Actions This is a list of all actions which may be performed, and what items they involve Crafting: • Log × 1 to Planks × 4 • Planks × 2 to Stick × 4 • Dirt × 2, Gravel × 2 to Coarse Dirt × 4 • Glass × 6 to Glass Pane × 16 Mining: The following require a wood pickaxe, or above: • Stone × 1 to Cobblestone × 1 • Coal Ore × 1 to Coal × 1 The following require an iron pickaxe, or above: • Diamond Ore × 1 to Diamond × 1 • Emerald Ore × 1 to Emerald × 1 The following do not require a tool: • Coarse Dirt × 1 to Dirt × 1 • Gravel × 1 to Flint × 1 Smelting: Smelting requires fuel, see below. These are the items that can be smelted: • Cobblestone × 1 to Stone × 1 • Sand × 1 to Glass × 1 • Coal Ore × 1 to Coal × 1 • Iron Ore × 1 to Iron Ingot × 1 • Diamond Ore × 1 to Diamond × 1 • Emerald Ore × 1 to Emerald × 1 • Kelp × 1 to Dried Kelp × 1 (unfinished) # Popularity Contest: Implementation of a Hash Table Create a class in some OOP language for a hash table that supports getting, setting, and removing values. You can't use the built in hash table/dictionary/map implementation. Highest votes in one week wins. A key is any valid string. A value is any valid string, number, or boolean. Example functionality: hash.set("key","value"); hash.get("key"); // returns "value" hash.set("key", 1234); hash.get("key"); // returns 1234 hash.set("key2",hash.get("key")); hash.get("key2"); // returns 1234 hash.delete("key"); hash.get("key"); // returns null/undefined/none/etc. or throws an error hash.get("key2"); // still returns 1234  Definition of a hash table (from Wikipedia): In computing, a hash table (also hash map) is a data structure used to implement an associative array, a structure that can map keys to values. A hash table uses a hash function to compute an index into an array of buckets or slots, from which the correct value can be found. The hash table cannot be simply an array that is searched in linear time. It must be an actual hash table that uses a hash function to map the keys to the value. • Popularity contest and shortest don't mix. That aside, the spec is too vague. What is a "value"? What assumptions can be made about hashcodes? If the language makes all types nullable, should null be permitted as a key? What should the type be in languages which have co- and contravariance? And for that matter, what qualifies as a "hash table", bearing in mind that people will try to exploit any loophole? Jan 2 '14 at 23:16 • @PeterTaylor Thank you for the feedback! Please see my edits, and let me know what you think. Could you meant about co/contravaraince? I looked at the wikipedia article about it but I'm not really sure how that has anything to do with this question. – hkk Jan 2 '14 at 23:37 • I think it's still vulnerable to the loophole of "I have a hashtable with one bucket" (i.e. it's really a list of (key, value) pairs which I traverse in linear time). The thing about variance is to do with static typing of the elements of the map. E.g. in Java Map<String, Integer>'s get method has signature public Integer get(Object); in C#, a Dictionary<string, int>'s Get method has signature public int Get(string). The edited version makes it clear enough that the hashtable isn't expected to be genericised. Jan 3 '14 at 0:08 # 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). Apr 7 '15 at 13:18 • @ASCIIThenANSI There wasn't a clear definition. That's part of the reason why I abandoned the challenge. 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. Apr 8 '15 at 2:00 • @ASCIIThenANSI Not at all. Apr 8 '15 at 2:01 • @ASCIIThenANSI Where did you post it? Jul 24 '19 at 13:33 • @ASCIIThenANSI I am also curious Aug 27 '19 at 23:41 # 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... 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. 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. Apr 30 '15 at 17:43 • @MartinBüttner Edited but, basically, it is subjective. Apr 30 '15 at 17:57 • @MartinBüttner Added a restriction to have optimum memory usage. I'm not sure whether it works. 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? 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. 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 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? 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. May 12 '15 at 20:34 • also, making use of symmetry can severely reduce the computation. 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. May 18 '15 at 21:49 • I see lots of C rand()%1000 and the like incoming... May 18 '15 at 22:05 • @Ypnypn I have changed the criteria to have much lower numbers so they're easier to verify. Jun 6 '15 at 13:04 • @Dennis I have rewritten the question to clarify what "being fair" is and what "more often" actually entails. 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? 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. Jun 7 '15 at 9:49 • between 0 and 2 ? so print 42 would be a valid program ? 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. 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? – user39326 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... 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? – user39326 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. Jun 18 '15 at 3:16 • Remove bonuses altogether. It's in the list of things to avoid. 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. Aug 10 '16 at 11:40 # 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. 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. 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. 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. 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. 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. Jul 27 '15 at 20:32 • Literal string, I think. 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. Jul 27 '15 at 20:41 • If both bonuses are done, is it floor(score * .9 * .9), or floor(floor(score * .9) * .9)? 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? Jul 27 '15 at 23:50 • Output strings verbatim. And floor(floor(score * .9) * .9) for both. I'll update the question momentarily. Jul 28 '15 at 2:07 • I'm curious why this challenge is being downvoted. Jul 28 '15 at 2:28 # Golf these arrays Your task is to output these 128 arrays: http://pastebin.com/UeBMJfv7 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. 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. 5. Start counting votes for 7 days, until I acceopt the winning answer (the answer with most votes). 6. Optional - if you are the winner, start a Kickstarter project to build the thing. ## Expected Answers 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 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. 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. 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. Sep 3 '15 at 10:08 • You could always include programming the driver or some kind of special interface for the keyboard 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. 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. 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. 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. 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. 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. 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. 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". Sep 4 '16 at 12:19 This and this gave me an idea, but I'm not quite sure if this can be done at all, or if it is trivial. If it is, maybe point out how it could be changed to be interesting. # Anti golfing - Write the longest program not repeating any character Well, it's just what the title says. Finally you're allowed to use as much bytes as possible. ## Conditions • The code of the program or function should not use any character that is used in the code before. • Your program should print some sort of result to stdout, or into a file or return a value. You're not allowed to output or return the empty string or only a newline. • Other than that your program might do anything. Read input, print lots of output, or what you can think of, but you have to explain what it does, of course. • Only characters in the ASCII range [32 .. 126] and newlines are allowed, which limits the maximal code length to 96 bytes. • Variable names are only allowed to consist of a single character • String literals or the like are forbidden. They could be used to hold the unused characters (though they would need two " in most languages anyway). • The same rule applies for similar literal constructs like blocks or what else is there in some languages. • Even if the length of a string literal would be used to generate a number, it is forbidden. • Variables can not just be declared and never be used. They have to be reflected in the output somehow. • If you've read and understood the above rules and still found a loophole and used it, you should go and stand in the corner for a while, thinking about what you've done. So all in all, only use characters for actual code that does something generating the output, might it be calculating a value or formatting. And don't put unused characters somewhere in your code as a literal. Numbers are an exception, but I guess it's no problem to use them anyway. I guess you should have a pretty good idea of what would be considered cheating here. Example in awk BEGIN{gsub(a,9);print$j-13+d^c/4*5678%20}


It prints 15.5, score is 42.

It replaces the empty string a with 9 in $0, which is the empty string in the beginning. So $0 becomes 9.

Then it prints the result of 9-13+1/4*5678%20.

($j is $0 (==9), because j is not defined

d^c ist 1, because c and d are not defined)

Please don't invent languages for this ;)

The longest code in bytes wins.

• Are you sure you want to allow ASCII 127? That's the unprintable<DEL> character. The main problem with this challenge is "only use characters for actual code that does something". This is essentially unenforceable, because there may be arbitrarily complicated no-ops in the code. It's also why most code-bowling challenges fail to be popular/interesting. Sep 14 '15 at 7:32
• Well, I thought about making it a "most votes win" challenge, but I guess that would be unfair for less known users. I don't know what could be done with what you are pointing out. Sep 14 '15 at 7:51
• I don't think this is a good candidate for a popularity contest. Popularity contests shouldn't be used as a cop out if the actual spec is a bit vague. They work best for challenges where the actual scoring criterion can be well specified but is more easily judged by humans than machines (e.g. "visually approximate a given image with these constraints..."). Sep 14 '15 at 7:54
• Yeah, it's hard to formulate the rules for this. But I think it's not always about finding a winner anyway. Thought this might be fun. Resolved the character 127 situation btw.. Sep 14 '15 at 7:57
• How could I change that rule? I'm thinking about "only use code that contributes to the generation of the output" Sep 14 '15 at 8:02
• How do you define "contribute"? E.g. this GolfScript program prints the length of the block in {...} which is a convenient way to stuff all characters except in '"# in there. Do all those random characters actually contribute? In Slashes everything which isn't an unescaped slash is printed to STDOUT, so as long as I put \/ together, I can put any characters I want there and they'll all contribute. Sep 14 '15 at 8:07
• Hmm, I thought this would be covered by forbidding string literals.. might think about extending that rule to blocks. Well, I'm not that fluent at esolangs. Sep 14 '15 at 8:10
• It's trivial to use all possible 96 bytes. Trust me. If you really want to see the program I'm thinking of, I suppose I could write it, but I'm pretty sure it can be done. Sep 16 '15 at 18:34
• Yeah, I guess you're right. i have no idea how it would be done, but alright. Sep 16 '15 at 20:10
• Not to mention this is pretty much a duplicate of codegolf.stackexchange.com/questions/30159/… Aug 6 '17 at 12:52

# 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. 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. 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. 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 . 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. Sep 25 '15 at 13:51
• They're both "golf this given map / dictionary / associative array". Why would the techniques used be any different? 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. Sep 25 '15 at 15:35
• Would this be kolmogorov-complexity? Sep 26 '15 at 17:16
• @LegionMammal978 Yes. 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.
– 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. Nov 2 '15 at 14:39

# 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.)

New PCL: [list + new char]


In the beginning, the PCL is empty. The last person who managed to create a program without a new program made in 2 days, wins!

I'm not really sure if it is flawed or not. If you have any suggestions or comments, feel free to post them below in the comment section :)

• Already exists. Nov 22 '15 at 23:38

# 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. Nov 29 '15 at 1:45
• @VoteToClose so more like 25% as well? Nov 29 '15 at 1:48
• No - I'd go static. Plus, this is really close to being a dupe... Nov 29 '15 at 1:51
• Near dupe of codegolf.stackexchange.com/questions/1003/… 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. 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 Nov 30 '15 at 6:09
• How is MMDDYY a day of the week? 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. Nov 30 '15 at 19:57

# Golf A Wiki

## The Challenge

Golf a wiki. A wiki, for the purposes of this contest, is defined as a website with:

• Content editable by all
• Easy CamelCase (defined as a word with two capitals) linking
• Different pages or articles that are the targets of the links

Your wiki can be a self-contained HTML file (e.g. TiddlyWiki), or a cgi-bin script (e.g. SigWik).

## Scoring

Your score is the size of your program in bytes, divided by the number of extra features implemented plus one.

The possible extra features are:

• Page history
• Syntax for "nowiki", that is, something like <\noscript> in HTML that makes the text inside it not be wiki syntax.
• A page list
• A find page facility
• Delete pages
• Change page titles
• Redirects
• Random page
• Non-HTML formatting that is not just links [Should I remove this? I doubt it will be done.]

Lowest score wins, as this is code golf.

# DISCLAIMER

ANSWERS WILL PROBABLY CONTAIN MAJOR SECURITY FLAWS. ONLY USE ON PRIVATE PORTS, UNLESS YOU WANT YOUR COMPUTER AND VERY POSSIBLY YOUR WHOLE NETWORK TO GET DESTROYED (FIGURATIVELY). [Is this too forceful?]

• I would vote to close this as too broad. Among the problems I see: 1. The two given examples don't seem to be the same thing as each other 2. The complete lack of constraints mean that I could just automatically make every word a link. (This could be fixed by specifying one link syntax: for golfing I quite like the UseModWiki use of CamelCase for links). 3. I think I can get the "text formatting" feature for free by not escaping HTML characters. 4. Needs a big warning "Answers will likely contain major security flaws and should not be used on ports which are publicly visible" Dec 30 '15 at 10:49
• Ok, thanks, I'll edit when I have time today. Dec 30 '15 at 21:27

## Progress 100%

For that I created an event mechanism that reports on the progress of each individual file. It sends me the information on how many bytes B have been downloaded of file T total.

## Input

Integer C between 1 to 100, followed by new line, followed by C progresses separated by new line. Each progress is constructed of two numbers with the maximum size of 64 bits: B T, separated by space.

Input options

The input is a String available from the following options

• file
• stdin
• method parameter

## Output

Floating number between 0 to 1, the average of all the progresses. It must be displayed to 11 decimal places, floored.

## Criterial

Shortest code wins

## Example

Input file:

3
5 10
1024 1024
20 100


Output

0.56666666666


Explanation

((5/10) + (1024/1024) + (20/100)) / 3 = 17/30


## Example2

Input file:

1
2 10


Output

0.2


## Example3

2
Long.MAX_VALUE Long.MAX_VALUE
5 10


Explanation In this example Long.MAX_VALUE represent the maximum 64 bit value, so if you use 64 bit value for storing the sum of the averages it will not work in this case.

Output

0.66666666666

• 1. It's not clear from your specification how the result should be computed. The "total progress" implies to me that I should figure out how many bytes have been downloaded of the total, i.e. sum(B)/sum(T). However, your first example suggests, that we should actually compute the arithmetic mean/average of the individual progresses. If so, please state this clearly. 2. By requiring 11 digits of accuracy, you require 64-bit floats (double precision), because 32-bit floats only have 7.something decimal digits. Is this intentional? (seeing your input is only 32 bits) Apr 1 '15 at 20:39
• @MartinBüttner how about now? I do want the high precision Apr 1 '15 at 21:24
• My first point still stands. It's not clear from the specification how the result should be computed. Apr 1 '15 at 21:27
• @MartinBüttner I expect you to process all the progresses and find the average one, not sure how to say it right. Apr 1 '15 at 21:28
• Just like that, but as far as I can see your challenge currently doesn't mention "average" or "arithmetic mean" anywhere. Apr 1 '15 at 21:32
• @MartinBüttner Anything else? Apr 1 '15 at 21:40
• Why did you remove it again? And what's the purpose of the hint? Apr 1 '15 at 21:43
• @MartinBüttner sorry had 2 windows opened. The hint helps you to understand that you cannot store the sum of all the progresses in 64 bit value. Apr 1 '15 at 21:45
• What does "up to 11 digits of accuracy mean"? That I can supply only 3 digits, but I may not supply 12? And what counts as a "digit of accuracy", anyway: are you talking decimal places or significant figures? And if significant figures, what is the correct output if the average progress is exactly 0? Apr 1 '15 at 22:37
• @PeterTaylor I want an 11 digits after the dot of accuracy in the output. So 3/10 will produce 0.33333333333 and 0/10 will produce 0. Maybe you can suggest a better way of writing it down. Apr 1 '15 at 22:40
• I've edited in some changes. I would suggest also deleting the hint and replacing it with a test case. It would also be good to describe a test case (it will probably be too long to post) which demonstrates that it's not sufficient to use IEEE754 double-precision. Apr 2 '15 at 7:35
• @PeterTaylor is it ready now? Apr 2 '15 at 14:09
• It would also be good to describe a test case (it will probably be too long to post) which demonstrates that it's not sufficient to use IEEE754 double-precision. Apr 2 '15 at 19:28
• @PeterTaylor I don't understand what you are saying, can you please explain it a little bit more Apr 2 '15 at 20:15
• Since you're requiring programs to support averaging 2^31 numbers and you want output to a precision of about 35 bits, a naïve solution with 64-bit floating point will be incorrect, but that might not be obvious to everyone who would attempt an answer. Apr 2 '15 at 20:23

Write a polyglot (a program that works on several languages) that produces the // this is a comment output.

## Example (JS + Plain PHP + Plain HTML) (74 / 3 = 24.66 points)

// this is a comment<?php ob_start();?><!--


## Another Example (CoffeeScript + CJam + brainfuck) ()

e###-[----->+<]>----..+[--->++<]>.---[->++++<]>.------------.+.++++++++++.+[---->+<]>+++.-[--->++<]>-.++++++++++.+[---->+<]>+++.[->+++<]>+.-[->+++ <]>.+[->+++<]>.++++++++++++.--..--------.+++++++++.++++++.
"// this is a comment"
e### alert "// this is a comment"


## Scoring

Your score will be code byte length / num langs

The smallest score wins!

• Is there anything that makes this significantly different than polyglot Hello World? Feb 1 '16 at 14:03
• @Geobits this is more easy, really Feb 1 '16 at 14:37

# Linear Time Sorting

It was another slow day at Initech Inc. when a feature request came in:

New Feature: Ability to sort by cash value in the transaction form. But make it a fast one!


Well it looks simple.. but what do the requester mean by fast one? Let's call Jim, from sales he probably knows what's going on.

Jim: Well you know , our Business Inc. contact is very passionate about

programming and computer science! In fact he had this idea that we should

do sorting in how that was called.. linear time?

You: Well you know that's impossible?

Jim: But it was already approved by their cto and all! You need to do something


You and Jim came up with a plan.. nobody will notice if that big of a list isn't sorted enough, right?

Your task is to write a linear time sorting program. It will be scored on accuracy of the sort as compared to list sorted by regular sorting algorithm but it must work on O(N) time in the worst case, where N is length of the input.

Input will be in the form of list of string-double tuples, e.g:

[("aaaa",2.0) , ("aaba",1.0)]


The program should sort on the number value of the tuple, i.e. in the above case the order should be reversed. There may be multiple inputs with the same double values, but no string value is repeated. In the event that two inputs have the same integer value the perfect solution is to keep the order as it is. The double value may be any floating-point value that fits in 8 byte double precision variable. NaNs should be placed at the end of the list.

The score is calculated as number of "bubble sort operations" (switch an element with the next/previous element) needed to achieve perfect output from the output of your algorithm.

# Sandbox Worries

Well I don't know how clear my explanation of challenge was and if it is interesting to the PPCG crowd.

Obviously there is a need for testing program and test cases.

• How big will the test cases be? If you pick a fixed size, the response will be "n passes of bubble sort where n is the size of the largest test". Bam, linear with perfect score. Apr 11 '16 at 10:12
• @JanDvorak I rephrased the scoring sentence to more reflect what I meant. In that case the score wouldn't be perfect as after just n switches the list wouldn't be the most ordered. EDIT: I think I understood it now. Well I think you can somehow exclude answers like that with some caveats in the rules, like "Your algorithm cannot make any assumtions about length of the input" Apr 11 '16 at 10:17
• I don't make any assumptions. It sorts every array up until the largest test case correctly and all other arrays partially. Apr 11 '16 at 10:28
• An algorithm that fares better than n-pass bubble sort is to do a level-n mergesort. If the length exceeds 2^n, sort each [k::len/2^n] subarray separately. Apr 11 '16 at 10:32
• But then you're making assumptions based on the size of the test cases - if somehow the test cases were changed (but still fitting the rules) to test cases which are much longer (for example you prepared for max 10 element list and you get 100000 element list) your program isn't linear. Apr 11 '16 at 10:41
• The problem with a spec is that it cannot change once you've posted the challenge, and you can't define "making assumptions based on the size of the test cases". You can't even ban all magic numbers - I can simply use functions merge1 .. merge20 Apr 11 '16 at 10:47
• It isn't the spec - the way the test cases used to grade the result are constructed is described but do I have to post the test cases (but those used to score) themselves? Apr 11 '16 at 10:50
• You need to define the test cases, and you can't change them based on the answers (if only because updating the score of every answer would be a nuisance). Maybe you could ask for asymptotic behavior, but that can be surprisingly hard to measure. Apr 11 '16 at 10:53
• Hidden test cases are a problem as well, because then we can't test the submissions after you're gone. Apr 11 '16 at 10:55
• The idea was to pregenerate some test cases (undisclosed) and some test cases that are disclosed (for testing purposes during the coding) and then do a cutoff time for the challenge where all the solutions are tested against the undisclosed challenges. Also obviously after the cutoff time the test cases would be disclosed. Apr 11 '16 at 10:56
• 1. Most real-life data types can be sorted in linear time, so the premise of the question seems badly flawed. 2. "Input will be in the form of list of string-double tuples ... There may be multiple inputs with the same integer values" Huh? Where do the integer values come from? 3. "The double value may be any floating-point value" Where do NaNs sort? Apr 11 '16 at 16:00
• 1. The idea is that the data may be the worst case for any algorithm that can achieve linear sorting time 2. It was a typo 3. At the end - I will put it into the question Apr 11 '16 at 18:36
• Why does the input being worst case make any difference? The solution will still be perfect, so you'll need a tie-breaker to separate every single answer. Apr 11 '16 at 21:27

# Make a quine without using string literals popularity-contest

A quine is a computer program that prints out it's own source code to stdout. Your task is to make one that doesn't use string literals.

You cannot:

• Have any empty program
• Read your source code directly or indirectly (i.e. form a file)
• Use error messages to print out the source code
• Rely on language features to print out the source
• Relying on a REPL environment

A string literal is a:

• String type (obvious)
• Number used to store the character (sorry BF!)
• Other predefined constant

You are encouraged to compute your own source code.

• This hits two of the "things to avoid when writing challenges": do X without Y and popcons. (I assume it's an attempt to finesse a third: generalised quines). It also has some fairly bad phrasing: what language can print anything without using "language features"? In what way does BF use literals? How many languages can compute anything without using at least one constant? Apr 12 '16 at 7:27

## Cops and robbers : Programmers/Hackers

• This challenge is quite different from my previous challenges. This challenge is an endless competition between robbers and cops, which are respectively hackers and programmers. One of them will ever win!!!

• This will evolve to code de/obfuscating when it gets to the higher stages: a skillful programmer who is struggling to save his program from a sourcecode-mangling attempted by a cunning "robber" who tries to impose his existence by patching his name instead of the name of the "programmer" in the output console without changing anything else in the code. The story begins this way:

• Programmer is at the point of executing his recently made C code, so he included this trivial line to show off:

C (1)

    printf("[Programmer's username]")


After executing this program programmer saw this on the screen:

[Robber's username]


which indicates the presence of some evil code at the compiler level that compromises his code, which follows:

Matlab (2)/parser

      a=findstr(code,'printf(''[Programmer's username]'')'); if a code(a:20)='printf(''[Robber's username]'')';end


The programmer cannot modify the counter-program in the compiler, so he must rather change the program content to escape the twiddling:

PHP (3)

      $a='[programmer's username]';echo$a;


The score is now 3, which is the number of steps from the beginning. The current user would win only if the hacker did not figure out something like:

PHP/Regex(pcre flavor) (4)

      $code=ereg_replace("(\$\w)\='programmer';(.*?);echo\s\1","\1\='robber';\2;echo\s\1",$code)  Since the solution above does not satisfy the rules (see the bottom of this question), the score stays unchanged, and the programmer can make a counter example, and take out the score from last submitter with a penalty on his score equivalent of how much he earned in the earlier level, where the counter example can be something as: PHP (4) $a='programmer';$b=$a;$a='unrelated';echo$a;


Or he can adjust his program in higher scale to escape all the regex-trapping in a superior range, So the cycle goes on until no post can be added and the last submitter before the end of June is declared a potential winner meanwhile.

The hacker can also fix his regex and regain his score, so the recent scoring will be abrogated from programmer.

Perl/dynamic-regex (4)

local @a=('');

sub check{
if (grep {$_ eq @_[1]} @a) {push @a,@_[0]; } elsif (grep {$_ eq @_[0]} @a)   {
my @del_indexes = grep { @a[$_] eq @_[0] } 0..$#a;
foreach $item (@del_indexes) { splice (@a,$item,1);
}
}
return 1;
}

sub actor{
if (grep {$_ eq @_[0]} @a) {return "print robber";} else {return "print ".@_[0];} } sub initiate{ push(@a,@_[0]); return 1; }$code =~ s/(((\w+)\="programmer"(??{initiate($3);}))|(print\s(\w+))|((\w+)\=(\w+)(?{check(($7),($8));})(?1)))/print($2);actor(\$5)/pegmx;


As you can see this Perl program prints b in the first case because the variable b is compromised after the first assignment, but in the second case the regex modifies the output because d receives the target-string transitively. Let's just stop here and not mess the fun (of course, if there will be some).

## Scoring and rules

How is the score counted ?

• Any hacker/programmer is scored for his code as the actual level L the game is on.
• A partial dynamic regex within the core of the program is scored L + (2^L)/log(length of program + length of characters which do not belong to the regex)), where the log is base 2. For the second example of level (4) the length of the compacted program is 480, and the length of regex is 136, so the score is 4+2^4/log2(480+480-136) ~= 4+16/9.6
• A fully functional regex as in the first example level (4) is scored L + (2^L)/log(length of regex), where the log is base 2, in that case S = 4 + 2^4 / log(91) ~= 4+16/6.5
• Scores are added progressively to submitters, and when a level is surpassed with no regex, it is still open for scores, while the actual winner remains unchanged.
• A penalty on a certain-leveled score when the regex/parser is revealed out of rules and the game is regressed to this stage until the issue is fixed, rules are cited below:

Rules:

• The main rule: the hacker-program must compromise an output to the console, which is the username of the programmer. Any other behavior is unaccepted simply because a string variable of [programmer's username] can be used in other order rather than printing, a counter-example is easy, converting the string to integer then use it for arithmetic calculations that harms the main program once intentionally modified.
• Also one of the following factors declared by any counter-example bans the targeted flawed regex/parser as non rule-complying:
• The regex/parser prints anything other than a chosen string preferably set as the username of the robber.
• The regex/parser generates a program which does not compile.
• The regex/parser does not print anything, or compromises a segment of code that is needed for tasks other than printing .
• The variable which stores the program is named code by default, also you may assume that is one-liner, and any non-significant spaces are omitted, and that it is fully working by default.
• The regex/parser deals with one variant of one code proportion in a comprehensive way, i.e. if a print function is used, that encompasses all printing functions in all languages puts,disp,..etc. Also, code separators can be unified to one characterL either , or ; or a significant space needlessly of enumerating all keywords/syntaxes, this is not a contest about a working code in a specific programming language.
• To prevent endless program/regex loops let's just not making a jokey sequence as a='programmer';print a / /(\w)\='programmer';print\s\1/ / a='programmer';b=a;print b / /(\w)\='programmer';(\w)\=\1;print\s\2/ because the first person who makes a regex/parser which palliates to a same replicated idea will take out all attributed scores to this idea from their owners, so any anaphoric sequences like this in addition that they are set to same level, they are unneeded.
• Any language that uses pointers/addresses/classes like C++ are welcome, as long as they help to evade the hacker.
• Please, for the love of god, spell things correctly. In the first bit alone I spotted a ton of spelling mistakes without even looking for them. Also, that whole first list is... basically impossible to understand, at least for me. Maybe use full sentences?
– Nic
May 10 '16 at 21:29
• Have you seen our cops-and-robbers challenges? It sounds like that is what you are trying to do here. That said, there are a couple of problems with the spec: Defining what parts of the language counts as a "partial regex" or "full regex" is really tough, especially when we get into esoteric languages. May 10 '16 at 21:36
• Could you add a short summary to the post? I don't understand what the actual task here is. Is this a cops-and-robbers or answer-chaining challenge, or something entirely different? May 10 '16 at 21:36
• i will see what cops and robbers is May 10 '16 at 21:39
• @NathanMerrill this is not a code golf so i dont see the point of introducing esolangs here May 10 '16 at 22:28
• @Agawa001 Esoteric languages are still useful outside of golfing. You can use them to make it tough for regexes to match. May 10 '16 at 23:06
• The introduction is very long and after reading it I have no idea what the task is. I would have to vote to close this as "Unclear what you're asking" in its current state. May 11 '16 at 7:45
• So what's the core mechanic? Is this an answer-chaining question where answers must alternate programmer and hacker? But if the programmer can change language at will, how can the hacker hope to win? May 12 '16 at 12:06
• @PeterTaylor yes it is answer chaining but the last submitter can post two consecutive answers and be the robber and cop themselves, the programmer change his code, hacker changes his regex taken consideration of all last regex/parsers. May 12 '16 at 16:13
• I have no idea what this challenge is supposed to be. The very little explanation of the concept is muddled by spelling and grammar issues. Please, learn English spelling and grammar before trying to write a challenge.
– user45941
May 13 '16 at 5:18
• @PeterTaylor refer at the 4th rule, procedures which accomplishes a specific task in different languages are dealt as one thing, this is not a challenge about checking language-syntaxes, when a programmer changes language, consider all previous regex/parsers changed to trap same functionnalities of previous code on the new language. May 28 '16 at 11:37

## Challenge

Write a program that takes an numerical input n and outputs the nth number that is not a perfect square.

## Rules

This is , so least bytes wins.

• What's the maximum expected input? Does it expect 0? How do we handle 0? Is there a requirement on the efficiency for large inputs? Also give some example inputs and outputs. Jun 17 '16 at 20:19
• Here's some test cases I just generated: 1->2,2->3,3->5,4->6,5->7,6->8,7->10,8->11,9->12,10->13,11->14,12->15,13->17,14->18,15->19,16->20,17->21,18->22,19->23,20->24,21->26,22->27,23->28,24->29,25->30,26->31,27->32,28->33,29->34,30->35,31->37,32->38,33->39,34->40,35->41,36->42,37->43,38->44,39->45,40->46,41->47,42->48,43->50,44->51,45->52,46->53,47->54,48->55,49->56,50->57,51->58,52->59,53->60,54->61,55->62,56->63,57->65,58->66,59->67,60->68,61->69,62->70,63->71,64->72,65->73,66->74,67->75,68->76,69->77,70->78,71->79,72->80 Is this the function you expect? Jun 17 '16 at 20:41
• Yes, yes it is. Jun 17 '16 at 20:42
• Can you address my other questions please? Namely, the largest expected input and how to handle input of 0. Jun 17 '16 at 20:43