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


To post to the sandbox, scroll to the bottom of this page and click "Answer This Question". Click "OK" when it asks if you really want to add another answer.

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.


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
  • Comments addressing specific points mentioned in the proposal
  • 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.


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!


3624 Answers 3624

83 84
86 87

I Got All Night


  • Is this interesting?
  • Has this already been submitted?
  • Issues/loopholes in the rules?
  • Suitable tags?

The goal

Make a program that takes as much time as possible to complete. That's it.


  • It must not be infinite. while(1){} will not be accepted.
  • You must be able to show how long it will take. Either through calculating it or by measuring it.
  • It must be doing something non-trivial. for(var x=0; x<1000000000000; x++){y++;} will not be accepted.


Your score is the time it takes to complete in milliseconds divided by the size of the program in bytes. Round to the nearest point if needed.

For example, if your program is 95 bytes long and takes 3 hours to complete, your score is (3*60*60*1000)/95 = 113,684 (rounded)

  • \$\begingroup\$ busy beaver tag? \$\endgroup\$ Jun 15 '17 at 2:29
  • \$\begingroup\$ also nontrivial is a bad requirement \$\endgroup\$ Jun 15 '17 at 2:29
  • 1
    \$\begingroup\$ The main issue here is that time taken isn't objectively measurable on regular computers. Further, "trivial" is also not objective. Any computable task is largely equivalent to the for loop you have, besides some "minor" details. \$\endgroup\$ Jun 15 '17 at 2:29
  • \$\begingroup\$ also be prepared for answers that would go past the heat death of the universe \$\endgroup\$ Jun 15 '17 at 2:29
  • 2
    \$\begingroup\$ @DestructibleLemon Please don't post so many short comments, this isn't a chat room. Take time to think through what you want to say, and say it all at once. You can edit your comments for a couple minutes to add more details you realised that you omitted. \$\endgroup\$ Jun 15 '17 at 2:32
  • \$\begingroup\$ @FryAmTheEggman The wording I was going to use was "useful" instead of "non-trivial", but I figured that was even less descript. Do you have any suggestions for that? Also, what if I write a python script that measures computer speed (i.e. spinning around in a loop for 10 seconds, incrementing a variable) to normalize for different computer speeds? \$\endgroup\$
    – Daffy
    Jun 15 '17 at 2:37
  • \$\begingroup\$ @DestructibleLemon That's what I meant by Either through calculating it or by measuring it. If you can calculate that your program will take 15 billion years, then it's completely usable. Converting 15 billion years to milliseconds might be a hassle though ;) \$\endgroup\$
    – Daffy
    Jun 15 '17 at 2:38
  • 2
    \$\begingroup\$ You would have to run all the submissions yourself then, however the problem will then be answers that take too long to verify. Calculations would be very difficult to say, for example, what if my program will only run on some ancient computer, will I be able to use that clock time? Also what about context switches/interrupts/etc? Generally I don't think this kind of challenge works, it's sort of like why world records for "shortest concert" don't exist anymore: programs that take forever are not really programs. \$\endgroup\$ Jun 15 '17 at 2:46
  • \$\begingroup\$ I think this ground has been well-covered by existing challenges to make large numbers and this would add anything new. \$\endgroup\$
    – xnor
    Jun 15 '17 at 3:29

Help me play Battleship!

Battleship is a two-player guessing game in which each player guesses the placement of the opponent's ships, placed on a grid.

Each column is labeled with a letter, and each row with a number. The label starts from top left (A and 1), and descends as you move right/down.

Each player is given two grids, one for placing ships, and one for guessing the enemy's ship placement. Each player places 5 ships -- one ship of length 5, one ship of length 4, two ships of length 3, and one ship of length 2 -- on her grid, either horizontally or vertically. The players should not share their ship placements.

After placing all ships, each player takes turn guessing the opponent's ship placements. The guessing player guesses one position, and the defending player must announce "hit" or "miss," depending on whether she (the defending player) had a ship there. When all positions of a ship is hit, it is "sunk."

The player who sinks all of the opponent's ships win.

This is an example of a battleship board (taken from Wikipedia):

enter image description here


Given the list of guesses a player has made, construct a 10x10 array that represents the board.


  • The input can take any reasonable format, as long as it is explained. Some examples are [[position, result], [position, result], ...] and [[hit positions], [miss positions]].
  • The output array can have any characters, as long as empty, "hit," and "miss" squares are distinguishable from one another. (e.g. unknown = 0, hit = 1, miss = 2)
  • You may not take the list of unknown grid positions in the input.

Test Cases

Pastebin link


  • Is this challenge interesting?
  • Are there any dupes? (I couldn't find one)
  • Did I include too much detail in the introduction? (If so, what should I remove?)
  • Are my test cases sufficient?

Star Trekkin'

Just an idea at this stage; wanted to get it down lest I forget it. I'll come back to it in a few days to work out the details.


Generate an ASCII art representation of the USS Enterprise with an animated, randomised ASCII starfield behind it.


Programming Challenge: Winning criterion is the shortest byte program which can tell me (x, y) which number "x" was doubled in the list, and which number "y" was removed from the list of 1000 numbers from 1 to 1000.

Given a list of 1000 positive integers in random order, find the integer that is repeated more than once, the integers that are not present in the range [1,1000] and output the count of the repeated integer present in the list.

The format of the list is a space deliminated text file such as this:

779 990 5 814 353
627 173 797 714 619
802 719 895 966 325
275 158 322 215 271
631 232 175 10 397
892 124 26 287 878
757 754 508 871 255
363 159 482 400 247
223 857 862 18 434
919 335 586 65 579
828 943 366 874 999
238 289 362 600 321
193 863 613 930 143
107 879 530 284 110
437 426 981 546 924
701 441 941 43 614
542 727 694 351 643
794 563 476 834 624
804 634 776 672 57
597 338 748 908 156
297 234 444 598 891
925 163 229 791 326
944 182 262 987 734
582 910 567 132 28
645 962 994 6 917
617 64 106 304 404
88 93 849 882 677
749 254 12 399 897
329 988 31 379 654
25 646 134 445 327
577 848 673 551 408
405 806 244 40 601
497 177 972 526 545
796 755 630 663 423
428 562 610 1 686
548 281 101 154 747
763 32 236 368 956
639 522 507 792 771
693 147 728 203 845
615 889 931 440 299
348 707 235 320 295
803 513 703 940 717
205 150 702 189 183
296 875 575 454 492
194 425 126 657 976
570 809 945 825 168
890 217 656 29 550
684 188 78 221 446
523 952 676 900 583
484 933 268 608 708
665 17 963 212 253
432 964 858 909 316
155 120 114 210 477
319 647 822 409 388
818 308 77 102 373
929 113 402 841 213
470 877 648 968 135
309 824 690 844 463
323 240 706 391 653
372 985 346 788 510
991 554 494 44 915
758 756 989 759 659
534 142 939 675 378
974 345 462 54 942
681 1000 7 716 415
42 264 996 438 464
386 350 197 141 84
123 127 811 853 516
60 49 277 70 986
98 733 905 978 103
390 230 501 449 731
34 370 541 958 466
251 71 108 846 260
576 830 100 140 529
869 333 303 664 589
856 777 427 187 184
305 766 829 136 456
786 401 737 961 475
412 887 178 91 698
448 433 62 519 832
314 957 861 898 683
983 515 893 220 817
979 149 267 3 63
458 473 139 970 835
666 119 967 695 343
242 947 41 47 623
973 53 354 74 816
121 471 151 246 369
499 45 593 691 376
111 46 226 83 431
274 606 506 265 753
79 387 451 883 525
479 744 162 949 8
292 95 97 324 823
315 152 394 671 718
347 836 50 195 360
812 566 725 612 923
537 911 620 51 328
243 19 556 592 288
334 298 873 655 443
705 66 767 604 285
760 896 474 406 73
918 688 667 914 730
729 826 959 774 543
594 192 27 948 912
491 419 341 518 55
146 787 495 904 172
469 761 840 626 637
144 616 465 712 660
785 365 250 636 384
208 2 174 864 839
741 410 621 342 442
245 568 998 485 216
960 224 239 782 855
291 355 860 807 936
920 56 669 561 697
112 270 715 913 938
364 851 467 751 468
450 995 609 490 72
674 713 640 185 801
361 742 38 784 167
225 743 692 790 907
859 762 569 115 521
116 200 580 632 997
85 82 249 207 486
218 196 14 932 867
429 258 125 793 69
865 385 902 222 531
611 658 318 935 980
808 23 105 722 300
520 30 420 286 662
227 581 745 585 928
330 638 358 587 16
452 635 736 489 252
89 951 137 591 721
880 555 204 535 769
9 820 605 854 148
128 934 396 480 307
161 711 750 704 651
696 133 813 789 517
263 775 553 75 992
293 190 916 273 602
461 11 977 202 764
483 76 52 773 723
870 872 498 359 868
67 544 504 279 833
599 48 171 687 80
547 336 417 642 181
558 906 256 219 81
866 810 709 186 668
572 145 209 739 682
847 752 720 332 393
770 965 574 629 176
746 306 138 798 15
528 778 392 457 726
337 39 86 380 160
493 211 436 180 241
795 94 955 837 214
584 954 117 549 59
340 805 367 927 633
946 738 819 487 557
768 4 37 827 596
511 628 381 68 679
838 179 603 680 13
231 650 35 700 735
975 595 502 301 424
527 678 950 280 532
649 685 710 539 903
248 276 571 500 435
560 109 926 588 278
414 509 237 169 740
885 118 430 382 689
481 311 199 993 821
261 447 540 357 92
129 131 953 375 377
852 61 191 228 937
122 418 439 573 198
331 302 505 644 283
421 416 36 894 884
831 22 24 104 876
371 272 622 312 578
459 395 455 536 374
969 403 565 269 389
552 90 164 922 781
503 460 524 206 356
130 259 533 294 157
901 422 290 514 982
641 661 478 559 496
282 512 266 257 538
765 564 96 783 724
843 317 411 799 652
488 310 349 313 413
453 886 58 971 20
921 618 815 850 99
339 87 21 472 699
33 607 800 352 899
233 166 780 407 625
670 201 170 383 772
344 376 881 984 590
165 732 153 398 842  

For example in this list 376 is repeated twice, and 888 is removed once. In this challenge a number "x" can only be repeated "once", so the number "888" can only be removed once, so an acceptable output for a programmed answer is this "(x, y)" where "x" is the number repeated twice, and "y" is the number removed.

I attempted to make this programming question, but because I included a bonus for web-scraping, and the format of the output for an answer was not clear it didn't receive positive reviews.

So I would like suggestions I how I can make this challenge clearer. Thank you.

Here is my challenge and the comments I received.

Programming Challenge: Tell me which number I repeated, how many times, and which one I skipped?

  • 1
    \$\begingroup\$ I have gone through and made the challenge clearer here: hastebin.com/ucesohawok.md Feel free to use or disregard this. However, one of my suggestions is to loosen the I/O formats (meaning stating input and output can be in any reasonable format). This would mean that the list could be taken as a list/array instead of a string. Same thing for output. This is ultimately up to you, but note that it is discouraged to restrict I/O formats as you have done. \$\endgroup\$
    – GamrCorps
    Jun 15 '17 at 20:26
  • \$\begingroup\$ Thank you very much. \$\endgroup\$
    – xyz123
    Jun 15 '17 at 20:47
  • \$\begingroup\$ My first reaction was that this is too straightforward to golf, but thinking more led to some interesting tricks. I think this is a nice challenge. \$\endgroup\$
    – xnor
    Jun 16 '17 at 0:14
  • \$\begingroup\$ I suggest relaxing the input format and also allow a list or array of numbers. \$\endgroup\$
    – Laikoni
    Jun 17 '17 at 7:00

Working For The Weekend

Option 1

Taking no input, output true if today is Saturday or Sunday or false otherwise.

Option 2

Taking no input, output how many days, from today, until the weekend.

Sunday:    0
Monday:    5
Tuesday:   4
Wednesday: 3
Thursday:  2
Friday:    1
Saturday:  0


  • Which option do you prefer?
  • Too trivial?
  • Dupe?
  • Allow local times to be used or require UTC? (I wanna say UTC)
  • true & false or truthy & falsey? (if option 1)
  • Working or Livin' For The Weekend?
  • 1
    \$\begingroup\$ 1) option 2 is less trivial and so Peter Taylor may not downvote / 2) Local times, not UTC / 3) truthy & falsey if you choose option 1 / 4) Working For The Weekend \$\endgroup\$ Jun 16 '17 at 14:28
  • 2
    \$\begingroup\$ In my opinion this is far too trivial to be interesting. I feel in general time based questions are pretty boring. I don't feel it provides anything that hasn't been covered extensively by other date/time questions. \$\endgroup\$
    – Wheat Wizard Mod
    Jun 16 '17 at 14:32

What could I add to improve this post? I have some questions that are inside of brackets.


A farmer needs help calculating the least time it will take him to pick his fruit each day.


  • This farmer has X orchards.
  • Each orchard has Y [is Y the correct variable to use here? does it matter?] fruits in it. If the orchard has no fruits, then it will contain the string "none".
  • The farmer has a list, this list contains the fruit he must pick.
  • The farmer will only go down the list in order
  • You must calculate how long it will take the farmer to pick his fruit on each day.

More on the orchards

  • All of the orchards are in a line.
  • Each orchard is exactly 1 unit [should I say unit or kilometer?] away from the next and previous one.
  • The farmer can go up and down the line, but may not jump from one orchard to another

Input and Output

You will receive an input in the following format:

*string* *string* *string* *string*
*string* *string*
*string* *string*
*string* *string*
*string* *string*

X is the number of orchards

  • Everything after X and before Y is an orchard containing a/some string(s), each string is a different fruit in that orchard.

Y is the number of days that the farmer must gather fruit.

  • Each day consists of two strings that are different fruits.
  • You must find what orchard these strings are in and calculate the difference.

Input Rules:

  1. Each fruit name string will be one word with no spaces
  2. [Should I add more here? if so, what should I add?]

Real Example

Still confused? Maybe this will clear it up:





orange pear pear


orange lemon pumpkin

pumpkin lettuce flowers peas


peas lettuce 

apple orange 

apple pumpkin 

flowers orange 

output: [ 0, 1, 3, 1 ]



  • 6 the number of orchards
  • A set of 6 orchards containing fruit, each orchard on a new line.
  • 4 the number of days on the farmers list.
  • A set of 4 fruits to compare, each pair of fruits is on a new line.


  • Output an array of the differences between each set of fruits.
  • The difference between peas and lettuce is 0, because they are in the same orchard.
  • The difference between apples and oranges is 1 because they are one orchard apart.
  • The difference between apples and pumpkins is 3 Because they are three orchards apart.
  • The difference between flowers and oranges is 1 because they are one orchard apart.

Annotated input/output

6 orchards 

a none

b apple

c orange pear pear

d none

e orange lemon pumpkin

f pumpkin lettuce flowers peas


4 fruits

peas lettuce 0

apple orange 1

apple pumpkin 3

flower orange 1


output: [ 0, 1, 3, 1 ]
  • \$\begingroup\$ I would only use the name y one time, as using it for two different things makes this a little confusing. \$\endgroup\$
    – Gryphon
    Jun 21 '17 at 20:07

Studio 54

Studio 54 was a famous nightclub in Manhattan. The club is referenced in the Futurama episode Rebirth in which the crew visits a nightclub called Studio 122133. The mathematical expression 122133 evaluates to (1 x 1) x (2) x (3 x 3 x 3) = 1 x 2 x 27 = 54.


Determine whether a positive integer is a "studio number." We define a studio number to be a number n that can be expressed as the product of a set of distinct positive integers that does not include n, each of which is raised to the power of one of the numbers in the set. Or, more mathematically:

Studio Numbers

You should have a consistent output value for "is a studio number" and "is not a studio number," and nothing else.

Test cases

These are inexhaustive lists and are just meant for basic ad-hoc testing.

Studio numbers:


Not studio numbers:


Computed by this script.


I'm going off of this for the two consistent outputs, but I'm not really sold either way. I could also change the requirements to be to output the "studio" representation of the number.

Does the math-y bit help? Could I make the studio number definition clearer?

I've been unable to find any "nice" properties of these numbers that allow for methods besides brute force. Would this still be interesting enough to golf? I could also add a "reasonable time" limit that would enforce some non-naive code to reject bad attempts, but I'm not sure that's much better.

The studio numbers do not appear to be a sequence recorded on the OEIS.

  • \$\begingroup\$ You say "does include n", but I think you mean, "does not include n". \$\endgroup\$ Jun 17 '17 at 22:32
  • \$\begingroup\$ @Challenger5 Uhhh, whooops... Thanks :) \$\endgroup\$ Jun 17 '17 at 22:37

Only HeLlO WoRLd is allowed.

We are all familiar that "Hello World" is the 1st introductory program that most people learn when they first start to program. Then programmers go on to greater and better programs. But who says they have to go on to greater and better programs? What if all other programs were censored?

Your Task:

Write a computer program that takes in standard input. If the standard input is any case-insensitive version of HeLlO WoRLd, do nothing. If the Standard input is anything other than a case insensitive HeLlO WoRLd, print an infinite loop of a HELLO WORLD matrix to the standard output.

To print an infinite HELLO-WORLD-Matrix, randomly sort the letters of "HELLO" and the letters of "WORLD", join the two words with a space as if you were saying HELLO WORLD, although you are probably saying "HELLO DWROL", " OELLH LWODR" gibberish with an occasional "HELLO WORLD". Then just keep printing all this gibberish to the standard output.
























There is actually only one "HELLO WORLD" amid all this gibberish

Winning criterion: shortest program in bytes.

  • \$\begingroup\$ What is an infinite loop of a HELLO WORLD matrix? \$\endgroup\$
    – user42649
    Jun 18 '17 at 16:08
  • \$\begingroup\$ Actually, I think I would like to up the challenge and request that HELLO WORLDS be printed to the standard output in a tab deliminated string with the letters randomly sorted, so occassionally the standard output would get HELLO WORLD HELLO WORLD ... But it would mostly get "EHLLO DWORL HEOW LLROD ... etc. \$\endgroup\$
    – xyz123
    Jun 18 '17 at 16:11
  • \$\begingroup\$ I updated my HELLO WORLD INFINITE matrix problem and made it more difficult. You should check it out. Is there anyway that I can have the tab separation show up on the problem the same way it shows up on the edit tab? \$\endgroup\$
    – xyz123
    Jun 18 '17 at 17:01
  • \$\begingroup\$ You may want to say "anagram of..." instead of "randomly sort the letters of..." \$\endgroup\$
    – Mr. Xcoder
    Jun 18 '17 at 17:29
  • \$\begingroup\$ Are there rules about the horizontal and vertical spacing of your matrix, and the number of helloworldoids per line? This needs to be explicitly specified or else explicitly left flexible. \$\endgroup\$
    – user62131
    Jun 19 '17 at 18:54
  • \$\begingroup\$ What do you think would make the challenge the most fun? \$\endgroup\$
    – xyz123
    Jun 20 '17 at 3:54

Golfing a Busy Turing Machine

For the sandbox

This question is really hard, and the solution is restricted to one "language" – a 1-tape, 2-symbol Turing Machine. So I'm not sure if it belongs on PPCG. I've written up a basic description below, but can go into more detail if anyone is interested.


I recently came across a paper that explicitly presents a 7910-state 1-tape, 2-symbol Turing machine that cannot be proven to run forever in ZFC, assuming ZFC is consistent. It also cites codegolf.stackexchange.com!

The existence of this Turing machine proves that calculating BB(7910) is independent of ZFC.

So, we know that we can calculate up to at least BB(4), and definitely can't calculate BB(7910) and above.

Can you create a Turing Machine with under 7910 states that cannot be proven to run forever in ZFC?

The author designed two custom-purpose programming languages (Laconic and TMD) to create this Turing Machine. In order to improve upon his work, I imagine you could go one of three ways:

  1. Optimize his algorithm in Laconic such that it encodes the interpreter or Friedman's mathematical statement (section 3.1) more tersely.

  2. Optimize TMD so individual instructions are translated to fewer states.

  3. Find a simpler statement whose truth implies the consistency of ZFC, and encode that instead of Friedman's statement.

  4. Go another direction entirely!

Winning criteria

The Turing Machine with the fewest number of states that cannot be proven to run forever in ZFC, wins. The length of the code you used to generate this Turing Machine is irrelevant.

You don't win if you compute BB(5), but you do get eternal fame.

  • \$\begingroup\$ There's currently a huge loophole in the question: you can just present a Turing machine that trivially halts, without violating any of the rules. Defining this unambiguously is going to be hard; the problem is that the submitter has to prove that the Turing machine always halts, but also prove that the Turing machine can't be proven to always halt, which is almost a contradiction (and only works because the first "prove" is subjective but the last objective; but how do you enforce a subjective criterion?). That said, I like the question and it'd be nice if it could be made to work. \$\endgroup\$
    – user62131
    Jun 19 '17 at 19:24
  • \$\begingroup\$ It's also worth noting that the vast majority of PPCG users won't understand the question no matter how precisely you try to word it. That probably isn't a problem for the people who are interested in or are willing to learn computability theory, but expect a large number of wrong answers that misunderstand the question and have to be deleted. \$\endgroup\$
    – user62131
    Jun 19 '17 at 19:25
  • \$\begingroup\$ @ais523 "Cannot be proven to run forever" is a subtle point – it's not that it doesn't run forever but that it's impossible to prove whether or not it does. If the submitter can prove that the Turing machine always halts, then it would not be a valid submission. Or if it were, would solve the halting problem. I should clarify to say "cannot be proven either to halt or to run forever." My big concern is your second comment, though. In any case, this post explains the main points in the paper, and is very accessible and worth reading independent of PPCG! scottaaronson.com/blog/?p=2725 \$\endgroup\$ Jun 19 '17 at 19:33
  • \$\begingroup\$ Right, I think the correct framing of this problem is "produce a Turing machine that cannot be proven to halt and cannot be proven not to halt". (Of course, we know it won't halt in practice, because if it did, you could prove it halts by running it, but that should be left out of the framing of the question.) That makes it clearer what's going on to people who haven't seen the problem in question beforehand. I wonder if opening this up to other languages might not be interesting too: brainfuck, for example, is a good fit for this challenge. Things like Jelly probably aren't though. \$\endgroup\$
    – user62131
    Jun 19 '17 at 19:36
  • \$\begingroup\$ @ais523 The way to construct a program like this is usually to say "this machine halts iff conjecture A is true" where conjecture A's truth implies the consistency of ZFC. \$\endgroup\$ Jun 19 '17 at 19:37
  • \$\begingroup\$ Opening up to other languages seems reasonable enough, especially as I imagine it wouldn't be too hard to write a brainfuck to 1-tape turing machine transpiler \$\endgroup\$ Jun 19 '17 at 19:38
  • \$\begingroup\$ I can tell you haven't read the discussion about this in the comments of two blog posts in Aaronson's blog, because Stefan O'Rear one-upped with a search for a contradiction in ZFC in about 1900 states. See github.com/sorear/metamath-turing-machines . NB codegolf.stackexchange.com/q/79620/194 was also inspired by that discussion, although in a slightly different direction. See cheddarmonk.org/papers/laver.pdf for a 64-state machine which is not known to halt in ZFC, but is proven to halt assuming a rank-into-rank cardinal. \$\endgroup\$ Jun 19 '17 at 22:17
  • \$\begingroup\$ @PeterTaylor very cool, thanks! I generally try to steer clear of comment-reading on blogs, but I should probably make an exception for academic ones. \$\endgroup\$ Jun 19 '17 at 22:20
  • \$\begingroup\$ @PeterTaylor I just noticed that the Laver paper is yours. Super impressive. I'd love to know if/when you ever end up publishing it \$\endgroup\$ Jun 19 '17 at 22:31
  • \$\begingroup\$ Any answer to this is also an answer to Write a program whose nontermination is independent of Peano arithmetic. Turing machine answers are welcome. (Though I’m not sure how we score those in bytes… perhaps the entropy measure (2n lg (4n + 1))/8?) Also (conjecturally) related: Laver table computations and an algorithm that is not known to terminate in ZFC. \$\endgroup\$ Jun 23 '17 at 20:44

Grouped Keyboard Scores

color board

In the above graphic, one can see 12 distinct color groups, which roughly correspond to columns on a keyboard. The following is a plaintext representation of which characters occur in each group.

Group 1:  ~` \n\t
Group 2:  !1QqAaZz
Group 3:  @2WwSsXx
Group 4:  #3EeDdCc
Group 5:  $4RrFfVv
Group 6:  %5TtGgBb
Group 7:  ^6YyHhNn
Group 8:  &7UuJjMm
Group 9:  *8IiKk<,
Group 10: (9OoLl>.
Group 11: )0Pp:;?/
Group 12: _-{["'+=}]|\

Challenge: Sort characters in the input according to their position in the aforementioned table. For input "Hello, World!", the output would be " !WedrH,llool". The relative order of characters within the same group does not matter, so the output " !WderH,llloo" is just as acceptable.

Scoring: Let P be the product of the number of characters in each non-empty section. Let S be the number of sections your program uses. Then, your score is P × S.

For example, the program QAZ would have a score of 3, and QWERTY would have a score of 6. 12321 would have a score of 12. The lowest such score wins.

Here is a code snippet for scoring your submission:

var sections = [
    "`~\t\n ",

function getSection(chr){
    for(var i = 0; i < sections.length; i++){
        if(sections[i].indexOf(chr) >= 0){
            return i;
    return -1;

function score(program){
    // group by sections
    var sectionHolder = [];
    var foundSections = [];
    for(var i = 0; i < program.length; i++){
        var chr = program[i];
        var index = getSection(chr);
        if(index < 0)
            return "n/a\nInvalid character: " + chr;
            sectionHolder[index] = [];
        if(foundSections.indexOf(index) < 0)
    var S = foundSections.length;
    var P = foundSections.map(function(e){
        return sectionHolder[e].length;
    }).reduce(function(a, c){
        return a * c;
    }, 1);;
    return S * P;
var output, code;
window.addEventListener("load", function(){
    output = document.getElementById("output");
    code = document.getElementById("code");
function update(){
    output.innerHTML = "";
        "Score = " + score(code.value)
* { font-family: Consolas, monospace; }
#output { white-space: pre; }
<textarea id="code" oninput="update();"></textarea>

<div id="output"></div>

Test cases

Note: represents a tab and represents a newline.

 "input" => "output"

 "Hello, World!" => " !WedrH,llool"
 "Grouped Keyboard Scoring" => "  aSededcrrrGbgynuKiooop"
 "QWERTYUIOPqwertyuiop" => "QqWwEeRrTtYyUuIiOoPp"
 "2017 + 42 = something" => "    122se4tghn7mio0+="
 "Tab␉ulator" => "␉aarTbtulo"
 "Hello␤World" => "␤WedrHllool"
  • \$\begingroup\$ Should group one be: ~` \n\t? \$\endgroup\$ Jun 19 '17 at 14:33
  • \$\begingroup\$ @carusocomputing Yes, indeed \$\endgroup\$ Jun 19 '17 at 16:16

Call a library function

Given a single int32, a path to a Dynamic Link Library (.dll) or Shared Library (.so), and the name of a function, return the single int32 result of calling the function on the single int32.


On 64 bit Linux: 0 /usr/lib64/libm-2.24.so fesetround0

On 64 bit Linux: 1 /usr/lib64/libm-2.24.so fesetround1

On 32 bit Linux: 1023 /usr/lib/libm-2.24.so fesetround1

On 32 bit Linux: 1024 /usr/lib/libm-2.24.so fesetround0

On 64 bit Windows: inp please\edit\filename.dll fnameout

On 64 bit Windows: inp please\edit\filename.dll fnameout

  • \$\begingroup\$ Please help me find a suitable DLL! \$\endgroup\$
    – Adám
    Jun 19 '17 at 19:53
  • \$\begingroup\$ This needs to specify that the function takes a single int32 as argument and returns a single int32. \$\endgroup\$
    – user62131
    Jun 19 '17 at 19:58
  • \$\begingroup\$ @ais523 Thanks, done. \$\endgroup\$
    – Adám
    Jun 19 '17 at 20:03
  • \$\begingroup\$ Where's the int32 in the Windows examples? \$\endgroup\$ Jun 19 '17 at 20:36
  • \$\begingroup\$ @PeterTaylor I need help with a dll that's commonly found on Windows. \$\endgroup\$
    – Adám
    Jun 19 '17 at 20:38
  • \$\begingroup\$ It's worth noting in the testcases that although libm is very commonly seen on Linux, the exact file path tends to vary from distribution to distribution. (For example, it's different on Fedora and Ubuntu.) \$\endgroup\$
    – user62131
    Jun 19 '17 at 21:59
  • \$\begingroup\$ @ais523 Can you edit the Linux samples to replace "Linux" with "Fedora" and "Ubuntu" and give the correct paths? \$\endgroup\$
    – Adám
    Jun 19 '17 at 22:00
  • \$\begingroup\$ @Adám: Not easily, they frequently change as a result of the system being updated, and it depends on processor architecture (not just bit depth) and sometimes even configuration. Just tell people to find the path to their own libm library for the appropriate architecture. (Note that the situation on Windows is much worse, because it doesn't ship even standard DLLs like libm by default.) \$\endgroup\$
    – user62131
    Jun 19 '17 at 22:02
  • \$\begingroup\$ @ais523 Just as plausible example, I mean. \$\endgroup\$
    – Adám
    Jun 19 '17 at 22:03

What is the maximum number of backslashes (escape characters) required to mean one backslash?

If you want to use a regex to look for a backslash, you have to escape that backslash, so that the character after it isn't escaped instead. But if you then have to store this regex in a string (in a c-style language, for instance), you need to double the number of backslashes, so that a regex string to match \stuff\ would need to be "\\\\stu(f+)\\\\" (and I had to further double the backslashes to post it in StackOverflow, but that isn't executable so doesn't count).

In your answer, explain the language and the (reasonable) situation, from either real or made-up business needs, and the answer with the most backslashes (per final, output backslash) will get upvoted (permanently) and accepted (until a better one comes along). If using AutoHotKey or another language that has a different escape character (for instance, `), then instances of that character will count instead of backslashes.

This question is not how many backslashes could you use in some esoteric code-golfing language to eventually calculate to a backslash, otherwise I don't think there would be an upper limit. This instead is about feasible scenarios that force you to use a lot of backslashes.

  • \$\begingroup\$ I feel as though this simply devolves into finding as many languages as possible that have something like eval. You can't enforce "reasonableness" as it isn't objective. Sorry, but I don't think this kind of challenge is a good fit for our site. But thank you for using the sandbox! \$\endgroup\$ Jun 19 '17 at 20:35

Write an interpreter for XKCD's broken language


  • Is this a good idea?
  • Is the point system good?
    • If so, are the point values good? I based them off of how difficult I imaged each part to be.


Randall Munroe, author of the webcomic XKCD, posted a comic a while back about a joke programming language and how it gets types confused.

Here's the comic in question

Your job is to write an interpreter for a slightly modified version of this language.


  • If your language supports it, it must be a live interpreter where all input lines start with [#]> (where # is the line number) and all outputs must start with =>.
    • If your language does not support it, you may substitute this with reading all the lines on the input and printing out each output on its own line, still starting with =>. Remember to keep track of line numbers.
  • All commands must be usable in any order and with any parameters (within reason)
  • Each command you implement correctly is worth the listed point value. See scoring to find your final score.

Integers plus numeric strings (1 point)

Given an int and a string containing a number (in that order) calculate the numeric sum of them, then return the result as a string with quotes surrounding it.

[1]> 2 + "2"
=> "4"
[2]> 6 + "13"
=> "19"

Numeric strings plus lists (1 point)

Given a numeric string and a list, append the numeric value to the list and return the list as a string.

[1]> "3" + []
=> "[3]"
[2]> "7" + [1,4]
=> "[1,4,7]"

Dividing by zero (1 point)

Any number divided by zero returns a NaN object. This does not have quotes around it.

[1]> 1/0
=> NaN

NaN plus integer (2 points)

Given a NaN object and an integer, pretend it's a string and increment the leading character, carrying over if needed. The result does not have quotes.

[1]> (5/0)+2
=> NaP
[2]> NaN+256
=> NbN

You do not need to use ASCII for this, any character set works, as long as it includes at minimum the 52 uppercase and lowercase letters.

You will never have to add a result from this to another integer. (For example, NaP+4 is invalid)

String plus string (1 point)

Given two strings, remove swap the first and last quotes with single quotes and return the result.

[1]> ""+""
=> '"+"'
[2]> "Hello"+"world"
=> 'Hello"+"world'

List of integers plus integer (3 points)

Given a list of integers (or an empty list) and another integer, return True or False based on whether the new integer matches the linear pattern.

It will follow this rule:

If the list has 0 or 1 items, return True regardless (everything matches).
Determine the pattern of the list by subtracting every item by the item right before it. If the pattern is inconsistent, return False regardless (nothing matches).
Otherwise, check if the new integer matches the pattern. If it does, return True. If it doesn't, return False.

[1]> [1, 2, 3, 4] + 5
=> True
[2]> [5, 7, 9, 11] + 13
=> True
[3]> [6, 5, 4, 3] + 2
=> True
[4]> [2, 4, 6, 8] + 9
=> False
[5]> [1, 2, 1, 4] + 5
=> False

Range(a, b) (1 point)

With the Range function given two numbers, return a list of numbers from a to b.

[1]> Range(1, 5)
=> [1, 2, 3, 4, 5]
[2]> Range(3, 6)
=> [3, 4, 5, 6]
[3]> Range(6, 4)
=> [6, 5, 4]

Plus integer (1 point)

Given simply "+" and an integer, return the line number plus the integer.

[1]> +2
=> 3
[2]> +2
=> 4
[3]> +1
=> 4

Single digit plus single digit (2 points)

Given two single digit integers a and b, replace all future instances of a in the output with (a+b)%10 (where % means modulo, essentially wrap around if the result is more than 1 digit). Return Done. This effect is superficial and has no effect on math. This only affects output, not input.

[1]> 3+2
=> Done
[2]> Range(1, 6)
=> [1, 2, 5, 4, 5, 6]
[5]> 1+2
=> Done
[4]> Range(1, 6)
=> [3, 2, 5, 4, 5, 6]

Floor (1 point)

Draw an ascii art floor with the number at the bottom. The specifications are 3 lines of only pipes, then a line with a pipe, 3 underscores, the number, and 3 underscores.

[1]> Floor(4.7)
=> |
=> |
=> |
=> |___4.7___
[2]> Floor(105.3)
=> |
=> |
=> |
=> |___105.3___


Add up the points you've earned. Your score is now calculated as (15-points) * bytecount. Lower is better.


  • You do not have to account for mixing functions. For example, Range(Floor(2.3)) is invalid.
  • Whitespace may be added or removed as is convenient.
  • Double quotes or single quotes may be used as convenient (as long as you use the opposite for "String plus string")
  • Any brackets may be used for lists, as long as it's consistent.
  • A few commands were omitted from the original comic because I couldn't figure out a way to make it well specified.
  • 2
    \$\begingroup\$ Scoring is broken: it goes up when you implement more features, but down when you golf bytes off the program. Those should probably both aim in the same direction. Also, even if you change "multiply" to "divide", you're still only scoring on the average number of bytes per feature (which incentivizes only implementing one feature, the shortest). The normal fix is to divide the byte count by the square of the points from features, lower is better. \$\endgroup\$
    – user62131
    Jun 19 '17 at 7:52
  • 2
    \$\begingroup\$ If your language supports this, do that. If not, do this is not a very good idea. Also, reading multiple lines and the => prefix seems like it's just extra code for no good reason. \$\endgroup\$
    – Okx
    Jun 19 '17 at 7:56
  • \$\begingroup\$ @ais523 Ah thanks for catching that. What I meant was, you take your point score and calculate (15-points)*bytes. If you get all of them, your score is simply your byte count. If you get a few of them, your score is larger accordingly. Lower is better. \$\endgroup\$
    – Daffy
    Jun 19 '17 at 18:29
  • \$\begingroup\$ @Okx The => prefix is to keep with the style of the comic. And reading multiple lines is important because some of the commands affect things in the future, which you wouldn't see if you can't input multiple lines. I see what you mean though about if this, that, if not, this. Do you think the interactive approach is better or the non-interactive one? \$\endgroup\$
    – Daffy
    Jun 19 '17 at 18:31
  • \$\begingroup\$ Dupe? codegolf.stackexchange.com/q/52953/8478 \$\endgroup\$ Jun 20 '17 at 9:15
  • \$\begingroup\$ @MartinEnder I would argue that is not a dupe. That question hopes to simulate the comic's output, without making it general. Return values to functions can be hardcoded. Mine has stricter specifications. \$\endgroup\$
    – Daffy
    Jun 21 '17 at 6:10

Counting from 0 - 100

I posted this question, but it was not taken very well, so I wanted to put it through the sandbox and get some feedback/help before re-posting.


Output all numbers from 0-100. Without using any of your languages built in loops.

Loops that are not allowed

This list contains, but is not limited to

  • For loops
  • While loops
  • Do While loops
  • Goto Statment
  • In Range


  • \$\begingroup\$ I really don't think this is a good idea for a challenge. It would either be builtins, like this in Jelly, or printing literal strings, with maybe some clever compression. \$\endgroup\$
    – scatter
    Jun 20 '17 at 14:37
  • \$\begingroup\$ Ok, I will leave it here in the sandbox incase anyone else thinks that they have a way to make it better. But I will not post it. \$\endgroup\$
    – zoecarver
    Jun 20 '17 at 14:38
  • \$\begingroup\$ @Christian Definitely golfable too. \$\endgroup\$ Jun 20 '17 at 14:49
  • \$\begingroup\$ Also the Python answer \$\endgroup\$ Jun 20 '17 at 15:04
  • \$\begingroup\$ "but is not limited to" - I think you're going to need to be more explicit than that. Does array mapping count as a loop, for example? \$\endgroup\$
    – Shaggy
    Jun 20 '17 at 15:42
  • \$\begingroup\$ @EriktheOutgolfer I actually had that ready to post when this challenge was posted in PPCG, but it was deleted before I had the chance to. I was just too lazy to look up the atom list when commenting on this post :P \$\endgroup\$
    – scatter
    Jun 20 '17 at 16:33
  • 1
    \$\begingroup\$ "Without loops in your code" is a non-observable requirement. I don't think there is a good way to do what you want at all, since there are so many ways to "loop" that you can't possibly define them all. Take this for example. \$\endgroup\$ Jun 21 '17 at 1:20
  • \$\begingroup\$ This is what Fry is referring to with "non-observable requirement". In general imposing restrictions on which features answers can use is highly problematic. a) There are many many languages that don't have to constructs you explicitly disallow, but which may have similar constructs which aren't in the spirit of the restriction either. But b) "not limited to" doesn't fly because who is to decide whether any given construct is a loop or not? There are even languages where you can write loops without any specific syntax element for them. \$\endgroup\$ Jun 21 '17 at 8:58
  • 1
    \$\begingroup\$ In general, if you find yourself having to impose explicit restrictions on the allowed approaches to a challenge, it's often a sign that it's not a great idea in the first place. I assume this is why the challenge wasn't received well in the first place. \$\endgroup\$ Jun 21 '17 at 8:59


In this challenge you will attempt to write a program to perform OCR in the fewest bytes possible. The tests are linked below, the only data that your program receives is the contents of the image, you may not rely on file name, timestamp, or other metadata, additionally you may not query any external source such as the internet or dispatch an independent program to outsource the task of OCR.


Given a hand written word in in image of 80px in height. Output the word. words will consist of lowercase latin letters:



Given the test cases, your score is a percent of the words you have gotten correct. No partial credit.

Tests cases:


  • \$\begingroup\$ The scoring doesn't seem to be affected by the length of the code. Should the specification in the fewest bytes possible be there? \$\endgroup\$ Jun 21 '17 at 3:16
  • \$\begingroup\$ Closely related. I think this gives a good example of how to do an OCR question well, but it also demonstrates that they're not a good fit for the site. It uses a standard database rather than home-made test cases, and tries to model the standard approach of training set and test set to prevent overfitting, but that standard approach isn't really compatible with our definition of objective scoring, because only the OP knows what the test set is. \$\endgroup\$ Jun 21 '17 at 8:35

Data exfiltration

Frenzy in the frequency domain.

Summary of the challenge

You must find a way to broadcast a ten-character password through a lossy communication channel and recover the password on the other side. To achieve this you must write two programs. The first program will receive the password as input and encode it as output data for the channel, the second program has to decode the output of the channel back to the password.

Some background

In signal processing theory, many problems are usually dealt with by converting a signal from the time domain to the so-called frequency domain, a trick that relies on the fact that any function can be written as an infinite series of sine waves. Signals can be converted into this domain using a Fourier transform. This transform is lossless, and the resulting signal can be converted back into the time domain using the inverse Fourier transform. The frequency domain has some interesting properties, as the actual values of the signal in it represent the amplitude and phase of different frequencies in the original signal.

A special case exists for when the signal exists out of equally spaced sampled points, called the discrete-time Fourier transform. To perform this transform the fast fourier transform algorithm is commonly used. Given a signal of N samples spaced with dt spacing, it will convert it into a signal containing N frequency bins which are each 1/(N*dt) apart.

Channel definition

The communication channel requires 256 unsigned bytes data as input, and returns 256 unsigned bytes data as output. If the input values are centered around zero and interpreted as data samples on regular intervals, then the output values represent the amplitude of the signal in the frequency domain scaled to use the range 0 to 255, calculated using a discrete fourier transform. The channel is lossy as it only transfers the amplitude of each frequency, not the phase.

It can be simulated using the following python 3 script:

import cmath
def channel():
    # amount of input and output values
    # read the input values from standard input as newline separated integers and center them around zero
    n=list(map(lambda: min(255, max(0, int(raw_input())))-127.5, range(l)))
    # perform a discrete fourier transform
    v=[sum(v*cmath.exp(-2.0j*cmath.pi*t*k/l)for t,v in enumerate(n))/l for k in range(l)]
    # remove artifacts due to the Nyquist limit
    v[1:128]=map(lambda n:n*2,v[1:128])
    # return the scaled magnitude of each frequency bin
    for i in v:print(int(round(abs(i)*cmath.pi/2)))


The password is randomly generated using only using visible ASCII characters (0x20 up to and including 0x7E) and is 10 characters long.

Inputting the password to the encoder, communicating it to the channel, receiving data from the channel and communicating the decoded password should all follow the default input/output rules. The password must be decoded only from data received from the channel, no side-channels are allowed.


This is , where the score is calculated by adding the length of both the encoder and decoder program. For each language, the shortest entry in bytes wins.


  • Is the challenge clear
  • Is the difficulty okay
  • Anything else?


  • \$\begingroup\$ I feel like the background could use some work. I don't think someone unfamiliar with the FFT would know things like how it is periodic in time and in frequency, or that you could use and inverse DFT formula, barring calculation inaccuracies. Your description of the channel largely requires that people are already familiar with this, or that they understand python well. The penalties are largely pointless, it only really serves to make people not want to answer your question. The question is not too hard, but I think as it is it isn't accessible to people who haven't learned this already. \$\endgroup\$ Jun 21 '17 at 1:09
  • \$\begingroup\$ "Must output to standard output" is the sort of restriction which 90% of languages don't care about and the other 10% will require crazy amounts of boilerplate to accomplish, rather detracting from the rest of the challenge. I recommend that you link to this post to define legal forms of input and output, unless you have a good reason not to. Additionally, penalising builtins with character penalties doesn't really work because the size of the penalty differs from language to language (and those penalties are prohibitively large in most). \$\endgroup\$
    – user62131
    Jun 21 '17 at 1:35
  • \$\begingroup\$ I've changed the input/output rules and removed the penalties in accordance with your comments. However I'm not sure how to improve the background, as explaining all the interesting tricks you can do with frequency domain manipulation would require significantly more explanation than possible (or interesting for most people) in a challenge. If people really want to learn about the details of it, the background section offers a few links that explain it much better than I could myself. \$\endgroup\$ Jun 21 '17 at 12:37

List My Factors!


Given an algebraic expression as input, list all the factors of it. A factor of an algebraic expression is any algebraic expression (or simply a numerical expression, sometimes) that evenly divides it. A factor can only be an integer or an algebraic expression consisting of integers and variables.


  • The algebraic expression will contain * to denote multiplication.

  • The algebraic expression will only contain integer constants and coefficients.

  • The algebraic expression will contain ^ to denote exponentiation.

  • The algebraic expression will only contain positive constants, coefficients and variables.

  • Your program should output only the positive factors.

  • The algebraic expression will not contain negative exponents.

  • You must not use any built-in to accomplish this.

  • Standard Loopholes apply.


The algebraic expression 5*x^2 has the following factors:

  1. 5
  2. x
  3. x^2
  4. 5*x^2
  5. 5*x
  6. 1

The algebraic expression 10*(x-y)^2 has the following factors:

  1. 10
  2. 5
  3. 2
  4. 1
  5. (x-y)
  6. (x-y)^2 or x^2 + y^2 - 2*x*y
  7. 2*(x-y)^2 or 2*(x^2 + y^2 - 2*x*y) or 2*x^2 + 2*y^2 - 4*x*y
  8. 5*(x-y)^2 or 5*(x^2 + y^2 - 2*x*y) or 5*x^2 + 5*y^2 - 10*x*y
  9. 10*(x-y)^2 or 10*(x^2 + y^2 - 2*x*y) or 10*x^2 + 10*y^2 - 20*x*y.
  10. 10*(x-y) or 10*x - 10*y
  11. 2*(x-y) or 2*x - 2*y
  12. 5*(x-y) or 5*x - 5*y

The algebraic expression x^2 - y^2 has the following factors:

  1. 1
  2. x-y
  3. x+y
  4. x^2 - y^2


Your program may take the input in any way except assuming it to be present in a predefined variable. Reading from file, input box, modal window, command line etc. is allowed. Taking input as function argument is allowed as well.


Your program should output a list of factors of the given input as a collection data type (such as array) or as a separator-separated String.

Your program may output in any way except writing the output to a variable. Writing to file, screen, modal window, command line etc. is allowed. Outputting using function return is allowed as well.

Test Cases

Input               Output

5*x^2               [5*x^2, 5, 1, 5*x, x, x^2]
10*x^2              [10*x^2, 10, 5, 2, 1, 10*x, 5*x, 2*x, x, 5*x^2, 2*x^2, x^2]
10*(x-y)^2          [10*(x-y)^2, 10, 2, 5, 1, 10*(x-y), 5*(x-y), 2*(x-y), (x-y), (x-y)^2, 2*(x-y)^2, 5*(x-y)^2]
x^2 - y^2           [x^2 - y^2, x+y, x-y, 1]

Winning Criterion

This is , so the shortest code in bytes wins!


  1. Should I allow negative constants and coefficients? Answer : No
  2. Should I allow variable exponents?
  3. Is there any mistake in Examples and Test Cases?
  4. How long should I let this challenge be here?
  5. Any problem with the Input/Output Rules?
  6. Should I allow built-in to accomplish the task?
  7. Any other suggestion?
  • \$\begingroup\$ Would x^2-y^2 be a valid input? \$\endgroup\$
    – Leaky Nun
    Jun 22 '17 at 9:56
  • \$\begingroup\$ @LeakyNun Yes . \$\endgroup\$
    – Arjun
    Jun 22 '17 at 9:57
  • \$\begingroup\$ What would the expected output be? \$\endgroup\$
    – Leaky Nun
    Jun 22 '17 at 9:57
  • \$\begingroup\$ The rules should mention that addition and subtraction are allowed; they currently don't. I'm wondering whether this challenge would be more interesting if you had to find the decomposition into "prime" (i.e. irreducible) factors, rather than just all factors, though; the two are similar tasks but the latter is more interesting and easier to read the results of. As for question 4, just leave the challenge up indefinitely; time limits on challenges are a bad idea if they're at all avoidable, as many people enjoy solving older challenges. \$\endgroup\$
    – user62131
    Jun 22 '17 at 10:01
  • \$\begingroup\$ @LeakyNun 1, x-y, x+y, x^2-y^2 \$\endgroup\$
    – Arjun
    Jun 22 '17 at 10:07
  • \$\begingroup\$ It seems this challenge is more about parsing/pretty printing than about factoring. (The integers allow for brute forcing.) I'd recommend allowing for more flexible input and output, otherwise this is going to be trivial to write a competitive submission for some languanges with CAS but almost impossible for other languages. \$\endgroup\$
    – flawr
    Jun 22 '17 at 10:09
  • \$\begingroup\$ @ais523 I've added what LeakyNun asked to the challenge. Better? \$\endgroup\$
    – Arjun
    Jun 22 '17 at 10:13
  • \$\begingroup\$ @flawr I don't understand what you mean with your first comment. To your second point : Good point, I'll edit \$\endgroup\$
    – Arjun
    Jun 22 '17 at 10:14
  • \$\begingroup\$ @flawr Edited . \$\endgroup\$
    – Arjun
    Jun 22 '17 at 10:22
  • 1
    \$\begingroup\$ 1. The examples now contradict the spec's limitations on input. 2. What is a positive factor? Is it a factor with only positive coefficients? 3. What are the factors of x^x? 4. If this is fundamentally "factor a multivariate polynomial", I think there may be one or two questions along those lines already in the sandbox. The univariate case has been done on main. \$\endgroup\$ Jun 22 '17 at 11:52
  • \$\begingroup\$ Before I forget, a nice (or nasty) illustration of the relevance of my question 2: x^3 + x^2 + 2x + 8 = (x + 2)(x^2 - x + 4). \$\endgroup\$ Jun 22 '17 at 16:19

Rotational Anagrams

Given, for lack of a better word, an anagram cube c with n rings and a word w, output whether or not you can rotate the individual sections to make w appear across the middle.


  • The letters that can appear are all printable ASCII characters EXCEPT for newlines.
    • All three characters that make up the rings can appear (|-+).
  • Your program should work for cubes of any size, though the maximum I expect you to test is my biggest case (this means that if your code won't finish for n=22 on TIO, I don't care).
  • Your only input should be the ASCII-art c and the word w.
  • Your only output is one of two distinct values for true/false, which are arbitrary.
  • You can assume the input is well-formed, and output anything for bad input.


Example cube with n=3 and w='AXMOZC':

| +--Y--+ |
| | +N+ | |
| | +P+ | |
| +--W--+ |

Rotate the outer wheel once coutner clockwise:

| +--Y--+ |
| | +N+ | |
| | +P+ | |
| +--W--+ |

Ding-ding! A match, so we can output truthy for this, but for AXMOYC there is no rotation that allows that combination, so it would return falsy. (X and Y are not adjacent on the ring, which means they can't appear at the same time.

Here's a small cube of n=2:

| +P+ |
| +C+ |

For an input w=PPCG|GPCP|PCPG|GCPP this returns true, everything else is false. So you can start to see that the possible keyspace of answers is always n**2, so... hint hint.

Here's the big honkin' example that took me a minute to piece up.

| +--------O--------+ |
| | +------5------+ | |
| | | +----E----+ | | |
| | | | +-----+ | | | |
| | | | | +G+ | | | | |
C 3 D E - B O L L I 4 G
| | | | | +O+ | | | | |
| | | | +--W--+ | | | |
| | | +----F----+ | | |
| | +------6------+ | |
| +--------N--------+ |

And, amongst many other strings, for w=CODE-GOLFING|CODE-BOWLING you should return true.

This is , if you're on my front lawn the third Tuesday of next month in a batman costume doing unspeakable things to my sprinkler system, you've won.

  • \$\begingroup\$ Is this meant to be a challenge about parsing the input format? If so (and it seems to be), you probably want parsing. Also, is there a need to verify the format, or can programs assume it's correct? \$\endgroup\$
    – user62131
    Jun 22 '17 at 10:52
  • \$\begingroup\$ @ais523 I feel like there's enoguh challenge in the parsing, and that will allow some unique interesting choices to extrapolate out the wanted symbols. You don't have to handle invalid input. \$\endgroup\$ Jun 22 '17 at 13:39

Home on the Range


Given a range [0,n) that has been shuffled, return the index of each element of the range.


[1, 2, 0] -> [2, 0, 1]

This is the range [0, 3) after being shuffled. The element at index 0 in the result is 2 because, in the input, 0 is at index 2. Likewise, the 0 in the output is the index of the 1 in the input, and the 1 is the index of 2.

[1, 0, 2] -> [1, 0, 2]
[0, 1, 2, 3] -> [0, 1, 2, 3]
[0, 2, 1, 3] -> [0, 2, 1, 3]
[2, 0, 1, 3] -> [1, 2, 0, 3]
[3, 2, 0, 1] -> [2, 3, 1, 0]
[4, 3, 2, 0, 1] -> [3, 4, 2, 1, 0]
[1, 2, 4, 0, 3] -> [3, 0, 1, 4, 2]
[2, 4, 0, 3, 1] -> [2, 4, 0, 3, 1]


I will award a +100 bounty to the first person to design and explain an algorithm that solves this problem using O(n) time and O(1) space.


  • I think my explanation was rather poor. How can I make this more clear?
  • Is this a dupe?
  • Is the bonus a good idea? (I really want to hear the answer because I don't know if this is even possible!)
  • \$\begingroup\$ Why [4, 3, 2, 0, 1] -> [3, 4, 1, 2, 0] not -> [3, 4, 2, 1, 0]? \$\endgroup\$
    – Leaky Nun
    Jun 22 '17 at 14:25
  • \$\begingroup\$ Oh, and do realize that this is what /: in J does, which makes this a 2-byte solution. \$\endgroup\$
    – Leaky Nun
    Jun 22 '17 at 14:25
  • 1
    \$\begingroup\$ @LeakyNun Oh, well that sucks /: \$\endgroup\$
    – hyper-neutrino Mod
    Jun 22 '17 at 14:27
  • \$\begingroup\$ @LeakyNun Typo. Thanks! I've never used J so I didn't realize there would be a builtin for it /: maybe I could convert this into a "best-algorithm" question? \$\endgroup\$ Jun 22 '17 at 14:30
  • \$\begingroup\$ Essentially codegolf.stackexchange.com/q/95838/194 ? \$\endgroup\$ Jun 22 '17 at 14:48
  • \$\begingroup\$ @PeterTaylor Yes, essentially. And I think it's a one-byte solution in Jelly: . \$\endgroup\$ Jun 22 '17 at 15:09
  • \$\begingroup\$ @musicman523 And it is a one-byter in Dyalog APL as well \$\endgroup\$
    – user41805
    Jun 22 '17 at 15:38
  • \$\begingroup\$ I could do one of three things: post it anyway to allow non-golfing languages to compete, make it a best-algorithm question instead, or delete it entirely. What do you all think? \$\endgroup\$ Jun 22 '17 at 16:10
  • 1
    \$\begingroup\$ I think that a) there's very little point in posting something which will be closed as a dupe; b) best-algorithm is hard to judge when built-ins do the job for you but their implementation might be closed or vary between versions; c) the bonus is pretty trivial provided that you specify that the code should modify the supplied array, and impossible otherwise. \$\endgroup\$ Jun 22 '17 at 16:17
  • \$\begingroup\$ @PeterTaylor how can you do it, modifying the original array? \$\endgroup\$ Jun 22 '17 at 17:35
  • \$\begingroup\$ Cycle by cycle, using ~ (bitwise not) as a flag to indicate which cycles have already been visited. \$\endgroup\$ Jun 22 '17 at 17:55
  • \$\begingroup\$ What happens if the entire array is a cycle? How do you process it with O(1) memory? \$\endgroup\$ Jun 22 '17 at 18:09
  • \$\begingroup\$ Bounty for O(n) time and O(1) space? But... but it's code golf. \$\endgroup\$
    – Neil A.
    Jun 22 '17 at 21:54
  • \$\begingroup\$ @NeilA. don't worry this isn't going to be posted, at least not as-is \$\endgroup\$ Jun 22 '17 at 22:37

Find the maximum number of coprimes in a set

Inspired by a recent question on Math.stackexchange.com, which I can't find anymore.

The challenge

Exactly what it says on the tin. You are given a set of integers and you have to create a program (according to the default definitions on meta) that outputs the size of the biggest subset that shares no divisors except for 1.


A set of nonzero positive integers of length >= 2. You can take this input as per the defaults in meta.


Output, print or return the size of the subset of the input that does not share any divisors except for one.


1 2 3 4 5 6 7 8 9 10 11 12 13 14

1 3

2 3 5 7 9

2 3 5 7 11 13
  • \$\begingroup\$ 1. The second test case is wrong: it should give 2. 2. What does it mean for a subset to share a divisor? Perhaps "the biggest subset such that no two of its elements share a divisor greater than 1". 3. In all of the test cases, it suffices to count the elements which are either 1 or prime. The question needs test cases for which that isn't sufficient. It might be nice to encode some classic graphs like Petersen's. \$\endgroup\$ Jun 22 '17 at 22:08

Golf a program whose behavior is independent from Peano arithmetic

Your task is to write a program that doesn't take any input, and whose termination cannot be proved or disproved inside Peano arithmetic. This is , so the shortest byte count wins!


  • Standard loopholes apply
  • Shortest by count wins
  • You can assume that your program runs in a machine with an unlimited amount of memory.


Questions for meta

  • Is this a good challenge?
  • Is it a duplicate?
  • I think the same question with a behavior independent of ZF set theory might be interesting as well (see this link for instance), but will attract very different answers; should I post it as a separate challenge?
  • What can be improved? Are the tags ok?
  • \$\begingroup\$ Current sandbox post that's fairly close to this one. There might be two challenges in this space, but maybe just one; perhaps you could give feedback on the other post? \$\endgroup\$
    – user62131
    Jun 23 '17 at 2:45
  • \$\begingroup\$ It seems like the other sandbox post is pretty limited to Turing machines only, whereas this one allows any programming language, so I think the two will attract quite different answers. Secondly, I believe restricting to Peano arithmetic instead of ZF will make solutions that are simpler, so I believe the two challenges are still quite different (but I'd like input from others on this as well). \$\endgroup\$
    – nore
    Jun 23 '17 at 3:06
  • 2
    \$\begingroup\$ Is this the same as this challenge? \$\endgroup\$
    – xnor
    Jun 23 '17 at 7:10
  • \$\begingroup\$ @xnor it is the same indeed, so I guess I should instead go for independent of ZF. This makes it closer to the other sandbox proposal, but I still think allowing any programming language makes the challenge quite different from a Turing machine-only one. \$\endgroup\$
    – nore
    Jun 23 '17 at 13:25
  • \$\begingroup\$ See also: codegolf.stackexchange.com/search?q=aaronson \$\endgroup\$ Jun 23 '17 at 21:33
  • \$\begingroup\$ If a program’s behavior is independent of ZF or ZFC, it’s also independent of PA, so I’d be happy to see such programs posted on the existing challenge, unless it starts getting so many answers that they get drowned out (current trends suggest that’s unlikely ☹). \$\endgroup\$ Jun 24 '17 at 6:49
  • \$\begingroup\$ @AndersKaseorg true, it looks like people are not that interested in this kind of challenges :( The point for having two separate challenges was because ZF/ZFC-independent answers might be a lot more complicated than PA ones. \$\endgroup\$
    – nore
    Jun 24 '17 at 14:28
  • \$\begingroup\$ @nore Do you know of any simple answers to the PA challenge? I don’t think my PA answer is notably simpler than a ZFC version would be. \$\endgroup\$ Jun 24 '17 at 20:52
  • \$\begingroup\$ @AndersKaseorg I tried to find statements that are easy to check and that are independent of PA, but the simplest I have been able to find is still the ZF-independent one used in the busy beaver paper. \$\endgroup\$
    – nore
    Jun 25 '17 at 2:18

Iterate over all sets

(This question needs fixing so that the output size is not too large)

Consider all possible pairs of sets of integers (can have positive, negative and zero values) A and B such that |A| = |B| = 7. Define the set T_{A,B} = {a * b | a in A, B in B}.

The challenge is to iterate over all pairs of sets A and B so that |T_{A,B}| < 19 and the largest absolute value of an integer in A or B is at most 128. As an example of one such pair of sets, A = B = {2^i | for i in {1,...,7}}.

What should my code output?

Your code should output the pairs of sets A, B along with |T_{A,B}|.

For example:

A = {2,4,8,16,32,64,128}, B = {2,4,8,16,32,64,128}, |T_{A,B}| = 13.

Running time

I don't care how long your code takes to run except you must run your answer to completion before posting an answer.


Code golf the Fast growing hierarchy (fgh)

if your not familiar with the fgh you migth want to check out this explantion: Large Numbers, Part 3: Functions and Ordinals

and these value aproximations: Fast growing hierarchy Approximations

the goal this code golf is to golf the following functions:

  • the exact value of fω(x) this means you can't golf the ackermann function

  • the growth rate of fω2(x)

  • the growth rate of fω2(x)

In any language of your chose.

This is a code golf so the smallest program that defines each of these functions wins (Note:the functions are allowed to call each other).

It is also allowed to ask for an input x and output the 3 function values in any order.



Sandbox notes

I'm not sure on which functions should be the target but these functions seem challenging yet golf-able in less than 150 bytes.

Upon closer inspection I realized that fω2(x) is probably to easy since it can be golfed with something like:

f(x,a...) {
    for i in range(a.length) {
        if(a[i] != 0) { //first non zero
            Arrays.fill(a, 0, i, x); //replace 0's with x
            a[i]--; //decrement a[i]
            return f^x(x,a);
    //all zeros
    return x+1;

f(x,n) > fn(x)

f(x,0,n) > fωn(x)

f(x,0,0,n) > fω^n(x)

so f(x,0,...,0,x) (x zeros) ~= fε0(x)

Any other tags? Suggestions? Does this interest you?

  • \$\begingroup\$ Having three winners doesn't really work. But having three separate questions is probably not the right solution either: they're close enough to be borderline dupes of each other. Perhaps the best way would be to score for the total length of the three functions, allowing the faster ones to call the slower ones but at the cost of having to name them. That might make for some interesting tradeoffs between using the functions directly vs having one function for f_{w^2 a + wb} which the others call with different values of a and b. \$\endgroup\$ Jun 23 '17 at 21:23
  • \$\begingroup\$ @PeterTaylor good suggestion, I changed the win condition. But I realized those a probably not the right functions since w² can be golfed really easily. \$\endgroup\$
    – fejfo
    Jun 24 '17 at 7:47
  • \$\begingroup\$ Why not do exact values? \$\endgroup\$ Nov 24 '17 at 20:51
  • \$\begingroup\$ Your solution for f_{ω^2} is very sub-optimal. See my answer. \$\endgroup\$ Nov 24 '17 at 20:53

Monopoly KoTH

This is going to take me a while to finish and may never be fully done. Don't expect this to be posted anytime soon. However, this will be an ongoing project under development.

Who hasn't heard of Monopoly? If not, don't worry, as I will explain the rules! If you already know the rules, read on, for they may be different in this rendition.

The Rules of Monopoly

Monopoly is played on a board, with 36 different squares, that looks somewhat like this

monopoly board

For this version, we'll use the original British version, because I'm British and proud of it!

Squares are split into 3 categories:

  • Property. These are the ones with a coloured bar at the top, such as Old Kent Road or Whitehall. They also include the 4 stations in the middle of each side, and the utilities (Electric Company and Water Works)
  • Bonus Cards. These are the squares marked Community Chest or Chance. These allow for a player to either receive or lose money, depending on a random card choice.
  • Special Squares. These are the 6 other squares in the board, the 4 corner squares and the taxes (boo!)

Let's look at these categories in a bit more detail.


Properties are grouped, depending on the colour of said property. Each property has a rent value that contains the amount that a player must pay to the owner of the property, when they land on that property. If one player owns all of the properties in one colour, the rent for each is doubled.

Players can also buy properties, which is how they own them. Each property also has a price, which is then deducted from the buyer's cash and given to the Bank, in exchange for the property. Stations cost £100 each and all other properties available to buy have their cost written below their square.

Stations' rent increases the more stations that someone owns. In the following progression

  • 1 Station: Rent = £25
  • 2 Stations: Rent = £50
  • 3 Stations: Rent = £100
  • 4 Stations: Rent = £200

Utilities' rent depends on the dice roll. If a player owns 1 utility, multiply the roll by 4 and that is the rent. If the player owns both, multiply the roll by 10 to get the rent due.

Properties can be built on. That means that a player builds houses and hotels on them, in order to increase that properties rent. A player can build houses and hotels on a property if

  • it has a coloured bar at the top
  • the player owns all of the properties in the group
  • they have enough money. Each house costs £50 and each hotel costs £100.

Each property can have a maximum of 4 houses. After that, the player must build a hotel. A property can only have 1 hotel on it. Houses and hotels drastically increase the rent of a property, for example £4 (no buildings) to £450 (one hotel).

Bonus Cards

The name of these are a bit of a misnomer. These are denoted on the board by ? symbols and chests on squares and can either give or take money from you. For this game, we will ignore Get Out of Jail Free cards and the Goto cards. The cards can result in a random integer between -1000 and 1000 added to your score. If this results in bankruptcy (we'll see this later), so be it.

Special Squares

  • Go. If you land on Go, you get given a £400 reward. If you simply go past it (Mayfair -> Old Kent Road), you get £200. It's also where the pieces begin.
  • Jail. If you roll and land on this square, don't worry, as you don't go to jail. You are "Just Visiting"
  • Free Parking. This is where the taxes go! If you have to pay taxes, either because of the Tax squares or because of a Bonus Card, that money goes to Free Parking. If a player lands on it, they get all the money there!1
  • Go to Jail. This does what it says on the tin. You go straight to Jail. But this time, you're in Jail, not just visiting. You stay in Jail until you roll a double.1 After which, game continues as normal. You cannot collect rent while in Jail.
  • Taxes. Super Tax and Income Tax are two squares which charge you £100 and £200, respectively. However, you can regain that money as it goes straight to Free Parking!


In Monopoly, if you run out of money, you are bankrupt. Here, you have two options. You can either mortgage your properties or, if you don't have any, you are out of the game! The last one with any money wins the game and the KoTH!

When you lose, all your properties go to the player who bankrupted you. If that's the Bank by virtue of Bonus Cards, then all your properties are available to be bought again.


You can mortgage properties in order to get more money if you're in a pinch. Unfortunately, this "deactivates" the property, meaning that you don't get any rent when people land on it. If you have enough money, you can unmortgage a property for 110% of its mortgage value. (£100 -> £110)


If you land on an unbought property and don't buy it, either because you don't have enough or you just don't want to, the property goes on auction. This means that all players can bid on the property. Bidding starts at £1, which means that a player can, theoretically, get the property for a much lower or higher price than its original price.


I am hoping to be able to include trading but this does depend on my ability as a coder. In an ideal world, I will be able to get it working but, unfortunately, this may not happen :(

1: I am aware that this changes depending on who you're playing with, but this is how we'll do it in this version.

Rules of the KoTH

I have written (still finishing) a Player class in Python which contains all of the things that a Monopoly player can do. Your task is to rewrite 2 of the functions that can change your player's behaviour.

While thinking about how to make this KoTH, I listed out the complete process that gives you a chance to change what you do. Let's go over that process! This flowchart shows the process for each turn. Green items show the choices that you have to make.

This is the text version:

1. Roll dice and move
2. Is the property owned by the Bank?
    1. Yes. Nothing happens.
    2. No. Pay the due rent.
3. Choice of:
    1. Buy
    2. Auction
4. Choice of:
    1. Trade
    2. Build
    3. Mortgage
    4. Unmortgage
    5. Move On
5. Repeat until bankrupt


1. Choice of:
    1. Play the auction
    2. Don't play the auction
2. Are you playing the auction?
    1. Yes.
        1. Choice of:
            1. Bid new max
            2. Skip one round
            3. Skip all rounds
            4. 'All in'
        2. Repeat until 1 player left bidding
    2. No. Don't do anything.


1. Choose a player to trade with
2. Offer properties and/or money
3. Does the other player agree with the trade options?
    1. No. They counter offer. Do you like their options?
        1. No. Do you want to continue negotiating?
             1. Yes. Go to point 2 above
             2. No. The trade is over.
        2. Yes. You trade the agreed upon items.
    2. Yes. You trade the agreed upon items

But, for you coders out there, I'll explain using a bit of code.

Your submission should contain a single class that inherits from Player. You may add in as many extra attributes as you want, but in order to be used, your code must refer to them. I'm not editing the controller just for your bot to work.

However, each class must look like this

class NameOfPlayer(Player):
    def turn(self, square, roll):
        (code that determines your actions per turn)
    def auction_action(self, price, bidders):
        (code that determines your auction actions)
    def trade_actions(self, players, last_offer):
        (code that determines your trading actions)

    (any other functions you want)

Your turn function will return 3 numbers as a list e.g. [1,2,3] which are the results of the choices above. The first item should be either 1 or 2 (Buy or Auction), the second should be one of 1,2,3, 4 or 5 (of the 4. Choice of: options) and the third should be either 1 (play the auction) or 0 (don't play the auction) such as [1,5,0] would buy the property, move on to the next player and not play the auction on this turn (doesn't matter as there wasn't an auction).

Your auction_action function will return either a number (your bid) or one of a (all in), s (skip this round) or q (quit auction), which determines what you will do on that round of the bidding. This continues until either you quit the auction of you are the only one left.

Your trade_actions function will return a list every time it is called. The list consists of [agree with previous offer (as a bool), properties to trade (as a list), cash to trade (as an int)]. When a trade has just begun, the first item in the list will be ignored and the last_offer parameter will be ignored. The last_offer parameter contains the second 2 items returned by the person you are negotiating with, so that you can decide whether you want to continue trading or not.

If you lose all your money, your program with be taken out of the active players and placed into the results table. The last one standing wins!

  • \$\begingroup\$ I call dibs on the Go submission that always go to jail. \$\endgroup\$
    – Uriel
    Jun 25 '17 at 16:35
  • \$\begingroup\$ While you are allowed to use the monopoly rules, I'm not sure about using the picture of the board? \$\endgroup\$ Jun 26 '17 at 4:44
  • \$\begingroup\$ @DestructibleLemon what do you mean? \$\endgroup\$ Jun 26 '17 at 5:59
  • \$\begingroup\$ If I'm reading this correctly, this is a variant which doesn't allow trading properties, and that's the most interesting part of the game. The rules stated also fail to state what happens to the properties of a player who goes bankrupt. (Correct answer: they must mortgage all of them and then forfeit them to the player to whom they owe rent. I'm not sure offhand what happens if they're going bankrupt due to taxes, but presumably the properties revert to the bank and when someone lands on them they buy or auction). \$\endgroup\$ Jun 26 '17 at 9:23
  • \$\begingroup\$ @PeterTaylor I'm currently writing the controller and a base class, which will determine what I can and can't allow in the game. Once that's finished and all issues with the controller are sorted out, I will update the rules here to fit with it's capabilities. Also, the version I've played allows for a player to mortgage their properties to avoid bankruptcy (as in you mortgage and if you're still bankrupt, you lose) \$\endgroup\$ Jun 26 '17 at 13:54
  • 1
    \$\begingroup\$ My point is that unless it's a two-player game, you lose is not a sufficient description because the game needs to continue until there's only one winner. The comment about mortgaging is because if I owe you more money than I can get by mortgaging all my properties, I have to mortgage them and give you the money obtained and the mortgaged properties, and so you have to pay to unmortgage them before you can benefit from them. \$\endgroup\$ Jun 26 '17 at 14:05
  • \$\begingroup\$ What stops this from going into an infinite loop without a winner \$\endgroup\$ Jul 27 '17 at 16:12
  • \$\begingroup\$ Feedback copied from TNB: I think this would be way more interesting if the Goto cards were included, and the random amount given/taken was less significant (£1000 is a lot). The Goto cards add a bit of strategy in which properties to buy. Also, my version has the income tax be either £200 or 10% of the player's net worth. Is that different in yours, or is it just removed for simplicity? \$\endgroup\$ Feb 23 '21 at 5:01

Just One More Time


Write a program or function that will run without error once, but will crash when run for the second time.

If you are writing a function, you may assume the function will be run twice within the same interpreter session or program.

If you are writing a program, you may assume the machine will not be rebooted between runs.


This is , so the shortest answer in each language wins.

  • \$\begingroup\$ I feel like the function version is much easier than the program version so I don't think you will see many programs in languages that could do both. Take C: i=1;f(){return 1/i--;}. I don't think you could reasonably ban "global" values to prevent this, but it's up to you if you even think this is a bad thing. \$\endgroup\$ Jun 27 '17 at 1:10
  • \$\begingroup\$ Will it run a third time? \$\endgroup\$
    – Okx
    Jun 27 '17 at 10:16
  • \$\begingroup\$ @FryAmTheEggman The answer you gave is exactly the type I would be looking for \$\endgroup\$ Jun 27 '17 at 15:01
  • \$\begingroup\$ @Okx It would not be run a third time. For functions, the assumption is that the crash would kill the interpreter session/program. For programs, I just won't run it a third time. \$\endgroup\$ Jun 27 '17 at 15:02

What Tiles did I have?

Everyone should be aware of the scoring system in a classic board game: Scrabble. I remember going back into my old scrabble box and finding some old post-it notes containing old scores. I always wonder what the heck was played for some of the more insane point scores. That gave me the idea for this challenge...

English-language editions of Scrabble contain 100 letter tiles, in the following distribution:

  • 0 points: * x 2 (These are the blank tiles)
  • 1 point: E ×12, A ×9, I ×9, O ×8, N ×6, R ×6, T ×6, L ×4, S ×4, U ×4
  • 2 points: D ×4, G ×3
  • 3 points: B ×2, C ×2, M ×2, P ×2
  • 4 points: F ×2, H ×2, V ×2, W ×2, Y ×2
  • 5 points: K ×1
  • 8 points: J ×1, X ×1
  • 10 points: Q ×1, Z ×1

Your challenge is, given a single integer input between 0 and 185, output a corresponding sequence of scrabble tiles that sum to that score with a length between 2 and 100 characters in length.

The Specifics

  • The letters don't have to spell anything, they just have to sum to that score.
  • You can only use a tile the number of times it exists (E.G. E can be used 12 times).
  • The shortest word is 2 characters long, for an input of 0 you get **.
  • Outputs will not match between answers, as there are many solutions.

Inputs and Outputs

  • Input should be a single integer, anything else is wrong.
  • Output should be a single string, with no spaces, order of letters is arbitrary.

Example (Potential Solution)

0   | **
1   | *E
2   | EE
[... Pattern Omitted ...]
[... Pattern Omitted ...]
[... Arbitrary Ordering Omitted ...]

This is ,: Whomever contacts Cthulhu using the dark arts first wins.

  • \$\begingroup\$ Whomever contacts Cthulhu using the dark arts first wins. that's bait \$\endgroup\$
    – Stephen
    Jun 27 '17 at 20:25
  • \$\begingroup\$ @StephenS wellp, if you want more bait check out 20 of my other random ass winning criterion for my sandboxies. \$\endgroup\$ Jun 27 '17 at 20:27
  • \$\begingroup\$ Sorry Sandbox sucks :/ can output be a list of one-char strings? and integer includes negatives, dunno if that's on purpose or not \$\endgroup\$
    – Stephen
    Jun 27 '17 at 20:29
  • \$\begingroup\$ @StephenS nono! That wasn't a diss on you or sandbox! That was just me stating that last 20 submission I've made to the sandbox I've put random winning criterion like "Winner buys dennis a subway footlong, or his countries' equivalent". \$\endgroup\$ Jun 27 '17 at 20:35
  • \$\begingroup\$ Also, it says an integer between 0 and 185. Also I mentioned words must be at least 2-chars. I feel like either my challenge's wording blows or you misread it a little. Probably more likely the challenge is worded poorly, I've had 2 already. \$\endgroup\$ Jun 27 '17 at 20:35
  • \$\begingroup\$ I made it a diss on Sandbox, that no one noticed them xD and I was looking in the #Input section for all the input specifics - I should have looked at the whole challenge, my bad. I just read Input should be a single integer, anything else is wrong. so that's what I assumed the whole rule for Input was (reading is hard) \$\endgroup\$
    – Stephen
    Jun 27 '17 at 20:37
  • \$\begingroup\$ @StephenS to be honest, reading isn't hard, it's contextual. I always have noticed in my career that I 100% understand anything that I create. Then, when explaining it to others, it may make literally 0 sense but be 100% viable in my head. Then like 10/12 people come forth saying "What the heck did you even try to write man?" And I realize, "what the hell did I even try to write?" Hahaha. The way I explain things to others can be horrifically inadequate by my own experience. \$\endgroup\$ Jun 27 '17 at 20:48
  • \$\begingroup\$ Related. It's a borderline dupe, in that the only real difference is a suitable wrapping loop. \$\endgroup\$ Jun 27 '17 at 21:42
  • \$\begingroup\$ A standard Scrabble board is 15 x 15, and even a "Super Scrabble" board is only 21 x 21. Should the maximum word length be limited to 15 (instead of 100)? \$\endgroup\$
    – Jasper
    Jun 29 '17 at 5:50

Display the Undisplayable

I have sometimes seen answers to challenges, written in binary machine code. The users who post them usually display them in hexadecimal representation. This representation makes the code extremely long, and does not do them justice!

Thus, we should give them help, and I don't care if they don't need it. Your task will to write a program/function/eldritch incantation to turn their beautifully golfed binary code into the shortest possible string of printable characters.


A sequence of random binary data of random length. Use any of the standard IO methods (note to self: find the link to the Meta post).


A sequence of printable characters. Use any of the standard IO methods.

  • If encoding is relevant, you are free to choose any encoding, provided you clearly indicate which one you used in your answer. What is relevant is the number of characters anyway.

  • Whitespaces (regular space, new line, non-breaking space, form feed, etc.) are considered not printable. They can be added if you wish, but their presence or absence must not impact the decoding of the output.


  • There must exist a program, that can take any possible output of your program, and turn it back into the input (providing it is not needed, but will be smiley'd at).

  • If your program is run twice, with 2 inputs of same size, the 2 resulting outputs must have the same size.

  • Standard loopholes apply.


The score is calcaulated as the number of bytes in the input, divided by the number of characters in the output. The higher the better.

If the score varies depending on the length of the input, take its average over input sizes from 1 to 1024 bytes included (I don't think we'll have answer 1 kb long here).

Giving an answer in a binary language (machine code, LLVM bitcode, etc.) and adding the output when run with its own binary source will be smiley'd at (but no bonus, unless it can also summon Cthulhu).

Don't forget to explain how your code works!


  • Do you think it's a good idea? Is there already a challenge like this one?
  • Is there any blatant loophole/possible imporvements?
  • What tag(s) do you recommend for this challenge? (please edit the answer)
  • \$\begingroup\$ @Mr.Xcoder Sorry ^^ \$\endgroup\$ Jun 28 '17 at 12:43
  • \$\begingroup\$ it's spelled Cthulhu \$\endgroup\$
    – Mayube
    Jun 28 '17 at 13:10
  • \$\begingroup\$ @Mayube That was what Mr.Xcoder's deleted comment was about... At first I didn't want to make a trivial edit, but since spelling of culture reference is such an important matter... Fixed! Now maybe I'll get more reactions about the challenge itself ^^ \$\endgroup\$ Jun 28 '17 at 13:14
  • 2
    \$\begingroup\$ I think this needs a precise definition of printable character. Unicode doesn't define the term. But once that's provided this is just a base conversion with an awkward base and every answer should get the optimum score, so the scoring system doesn't work. \$\endgroup\$ Jun 28 '17 at 13:51
  • \$\begingroup\$ I just wanted to say thank you for using the sandbox! I hope things go well with your challenges :) That said, I have to agree with Peter Taylor, it seems like every answer will get the optimal score. I think requiring the optimal score and changing to code-golf will work better, but there are many other ways you could fix it. Good luck! \$\endgroup\$ Jun 28 '17 at 14:03
  • \$\begingroup\$ Worth noting that encoding is always gunna be relevant given non-printables don't count, as bytes 0x00-0x20 are non-printables by your definition, meaning if the given binary contains any of those bytes, ASCII can't be used. \$\endgroup\$
    – Mayube
    Jun 28 '17 at 14:06
  • \$\begingroup\$ @FryAmTheEggman I thought about something like that - maybe not the optimal score, but greater than a given value. And it seems I was right to use the sandbox, since there are already 2 potential loopholes detected! \$\endgroup\$ Jun 28 '17 at 14:08

Every Nth Line in Source Outputs N

Heavily inspired by Hello, World! (Every other character)

Related to my other Sandbox post Every Nth Char in Source Outputs N; is it a dupe?

Write a program that outputs 1. When the first, third, fifth, etc. lines are removed, it outputs 2. When all lines where their (1-based) index in the source, mod N, are not 0, are removed, it should output N.

This is . The winner is the program that works with the largest N, while working for all n < N (obviously, to run up to N, it has to be at least N lines long). If there is a tie, the winner is the shortest answer that reaches the largest N. Your program must at least work up to N=2, since I don't think any languages will struggle with simply printing 1.


Examples are based off of this sample program:

let's dance

For the program to work for N=1, the original program should output 1.

For the program to work for N=2, the following should output 2:

let's dance

For the program to work for N=3, the following should output 3:


For the program to work for N=4, the following should output 4:

let's dance

For the program to work for N=5, the following should output 5:



The highest N this program could work for is its line length, 8.


Sandboxing this mostly so I don't forget about it (as I don't want to initiate this so soon after v3). Unlikely to need any serious revision, but comments are appreciated none the less.

Prisoner's Dilemma v4: The Amnesiac Gentlemen.

This is similar to v3 Petri Dilemma, except with one significant change: no one knows what round it is. The same setup, submission format, and scoring will be used. For sandbox brevity, I'm only noting the differences from v3.

Bots will receive input at the beginning of its turn in the format:

current points, enemies points, your previous moves, enemy's previous moves

The format of the move list (both yours and the enemy's) will be a string of characters, "c" for cooperation "d" for defection, in order from first round to last. However this list will contain only the first seven moves of the game as well as the most recent 7 moves (as everyone knows, you can only hold seven items in working memory). A String 14 characters or fewer would indicate a round at the beginning of the game where 14 total moves haven't yet been performed. Later rounds would be indeterminate.

Additionally, as the current round number is not being passed in, bots will be unaware of when the end of the game comes (games will still be 200 rounds). This should prevent "Ah ha, last round, I backstab!" "Ah ha, but I backstab you first, one round earlier!" strategies, which is what dominated a large swath of the v3 strategic playspace (I did tests where all backstab-early bots were coded to all backstab on the same round and there were only two that performed sub-optimally as a result, both of which were set to backstab "before all n-Tit-for-Tat strategies", moving them back 1 rounds re-elevated them above n-Tit-for-Tat again, as well as which one backstabbed the other first determining the winner between them). While several bots from v3 would be valid submissions in v4, all of the winning bots utilize more data than v4 will let them have, opening up the playing field for new techniques.

Here are four sample strategies that will be entered to start with:

Tit for Tat

def titfortatfunc(mypoints, enpoints, mylist, enlist):
    if not enlist or enlist[counter-1] == "c":
        return "c"
        return "d"


from random import choice
def randompickfunc(mypoints, enpoints, mylist, enlist):
    return choice(["d", "c"])


def cooperatorfunc(mypoints, enpoints, mylist, enlist):
    return "c"


def defectorfunc(mypoints, enpoints, mylist, enlist):
    return "d"

(Code Golf) How Many Notes Are There?


Most music games (MUG) describes the "instructions" that the player must follow as "notes". When the charts (set of notes) are first available, MUG players usually record the chart as a video and upload them to video sites. However, unless playing a full combo (able to pick up all notes) that the combo count directly shows the number of notes, it is usually not practical to count the number of notes one by one directly (since there are usually hundreds of notes), so they calculate that from the scores that may show on those videos if the score formula is known.

One of those examples is jubeat, which is somehow like a MUG version of "Whack-a-Mole". Although officially "instructions" are called "chips", players have the consensus to call them "notes". (For those who don't know what jubeat is please check it out here: jubeat - RemyWiki)


What you have to do, is to:

  • Write a program or function,
  • Which accepts a list of integers as the only input,
  • That calculates the numbers of notes which is possible for all the given "basic scores".


  • The input can be an array of integers or a string containing those integers (Please indicate the input format).
  • The integers in the input are guaranteed to be in the range of [0, 900000] inclusive.
  • A case (NOTES in the formula) is possible means that, for each integer in the input, there exists a variable ACH, when substituted into the formula below, the formula evaluates to that integer. (See The Formula and Test Cases for details)
  • All possible cases within the range [1, 1100] inclusive must be included in the output.
  • The output can be an array of integers or a string containing the results (Please indicate the output format).
  • If there is no case fulfilling the requirements, the program or function should either return an empty array, an empty string, null, or any objects indicating absence of results.
  • NO RUNTIME EXCEPTIONS shall be thrown in any circumstances.

The Formula

The max score is 1000000, but here we only consider BASIC_SCORE, whose maximum is 900000.

The BASIC_SCORE is calculated by BASIC_SCORE = floor(floor(ACH * 100000 / NOTES) * 0.9), where ACH is an integer in the range [0, NOTES*10] inclusive except NOTES*10-1 and NOTES*10-2.

As a concrete example, take ACH=6850, NOTES=900, we have BASIC_SCORE = floor(floor(6850 * 100000 / 900) * 0.9) = 684999.

As a result, NOTES=900 is a possible case for the basic score 684999.

Test cases

 Input                                    | Output
 896757, 846353, 844486                   | 916
 891000, 893999                           | (all multiples of 30 within [1, 1100])
 899736                                   | 1024, 1025, 1026, 1027
                                          | (342, 683, 684 are false positives because  
                                          |  in these cases ACH = NOTES*10-1 or 
                                          |  ACH = NOTES*10-2)
 873540, 802468                           | (none: no case fits all inputs.
                                          |  some cases do fit some inputs but not all)
 0, 900000                                | (all values within [1..1100])
 800000                                   | (none)

Rules and Winning Criteria

This is a , so the source code with the shortest length (in terms of bytes) wins. Standard loopholes apply.

83 84
86 87

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .