17
\$\begingroup\$

Let's take a grid of 16x16 printable ASCII characters (code points 0x20 to 0x7E). There are 30-choose-15 paths from the top left to the bottom right corner, making only orthogonal moves, like the following example:

##..............
.#..............
.######.........
......##........
.......##.......
........#.......
........#.......
........#.......
........###.....
..........###...
............#...
............####
...............#
...............#
...............#

Each such path consists of exactly 31 characters. Note that each of those characters is on a different of the 31 anti-diagonals:

0123456789ABCDEF
123456789ABCDEFG
23456789ABCDEFGH
3456789ABCDEFGHI
456789ABCDEFGHIJ
56789ABCDEFGHIJK
6789ABCDEFGHIJKL
789ABCDEFGHIJKLM
89ABCDEFGHIJKLMN
9ABCDEFGHIJKLMNO
ABCDEFGHIJKLMNOP
BCDEFGHIJKLMNOPQ
CDEFGHIJKLMNOPQR
DEFGHIJKLMNOPQRS
EFGHIJKLMNOPQRST
FGHIJKLMNOPQRSTU

This is not an example grid. This is a visualisation of the 31 anti-diagonals.

We'll call a grid diagonally unique if no anti-diagonal contains the same character twice. If the grid has this property, no two paths will contain the same string. (Just to clarify, the visualisation itself is basically the opposite of diagonally unique.)

The Challenge

Design a diagonally unique 16x16 grid, such that as many paths as possible are valid code which prints Jabberwocky to STDOUT (with optional trailing line break) in as many languages as possible. Each code may either be a full program, or the body of a parameterless function without return statement (this is in order not to discourage languages that need to have their code in some boilerplate function/class/namespace).

Note: For simplicity you can use some reserved character for unused cells like Ypnypn did.

For each valid path, please clearly state one programming language it is valid in.

The winner is the submission with the largest number of languages covered by the above list. (Alternatively, for each language you want to count, show one path which is valid in that language, but make sure not to count any path for two languages.)

In the event of a tie, count the grid cells which are not covered by any valid path. Fewer unused cells win. If there is still a tie, I'll accept the answer with the most (net) votes.

Validation Script

I just quickly put together a little CJam snippet you can use to validate that a grid is diagonally unique.

  1. Go to the online CJam interpreter.
  2. Paste the following code

    l:A;
    qN/W%A16**33/z{A-__|=}%:*"D""Not d"?"iagonally unique"
    
  3. In the input field, put you reserved character on the first line (use an unused character if you don't make sue of a reserved character), and then your grid in line 2 to 17. E.g., for Ypnypn's answer:

    ~
     pr~~~~~~~~~~~~~
     tin~~~~~~~~~~~~
    ~ypt(~~~~~~~~~~~
    ~~ef(~~~~~~~~~~~
    ~~  "J~~~~~~~~~~
    ~~~~~ab~~~~~~~~~
    ~~~~~~be~~~~~~~~
    ~~~~~~~rwo~~~~~~
    ~~~~~~~~~ck~~~~~
    ~~~~~~~~~~y~~~~~
    ~~~~~~~~~~\n~~~~
    ~~~~~~~~~~~")) ~
    ~~~~~~~~~~~  ;  
    ~~~~~~~~~~~~~~~ 
    ~~~~~~~~~~~~~~~ 
    ~~~~~~~~~~~~~~~ 
    
  4. Run.

Let me know if you think it has a bug.

\$\endgroup\$
  • 6
    \$\begingroup\$ 'Twas brillig, and the slithey toves did gyre and gimble in the wabe... (yes, I have that memorized) ;) \$\endgroup\$ – Doorknob Oct 28 '14 at 0:08
  • \$\begingroup\$ This sounds like one of Calvin's Hobbies' questions, which is a fantastic achievement. I still have not been able to understand how it's done. \$\endgroup\$ – Soham Chowdhury Oct 29 '14 at 17:39
21
\$\begingroup\$

30 33 35 Languages

Reserved character: ~

 println!~~~~~~~
 puts    (1,~~~~
    echo   '~~~~
"cWprintfn"Ja~~~
Eork~~~;'Jabbe~~
\ui)K00~~~~~br~~
]tteL~0~~~~~ew~~
]<~ln(0~~~~~ro~~
`<~~~ 0~~~~~wc~~
m"~~~ "~~~~~ok~~
rJ~~~'J~~~~~cy~~
j"<< "a~~~~~k'..
^~~~~~bberwoy");
f~~~~~~~~~~c'  ;
t~~~~~~~~~~ky"  
XX"););  5f+'); 

Languages:

01. Rust        | println! (  "Jabberwocky") ;  |
02. Groovy      | println     "Jabberwocky"     |
03. E           | println  (  "Jabberwocky")    |
04. Swift       | println  (  "Jabberwocky") ;  |
05. Julia       | println  (  "Jabberwocky");;  |
06. Processing  | println  (  "Jabberwocky")  ; |
07. Falcon      | printl   (  "Jabberwocky")    |
08. ALGOL 68    | print    (  "Jabberwocky")    |
09. Vala        | print    (  "Jabberwocky") ;  |
10. Pawn        | print    (  "Jabberwocky");;  |
11. Batsh       | print    (  "Jabberwocky")  ; |
12. freeBASIC   | print       "Jabberwocky"     |
13. Rebol       | print       "Jabberwocky"  ;  |
14. Red         | print       "Jabberwocky"   ; |
15. AWK         | print       'Jabberwocky'     |
16. Perl        | print       'Jabberwocky'  ;  |
17. bc          | print       'Jabberwocky'   ; |
18. Euphoria    |  puts    (1,"Jabberwocky")    |
19. C           |  puts    (  "Jabberwocky") ;  |
20. Tcl         |  puts       "Jabberwocky"     |
21. Ruby        |  puts       'Jabberwocky'     |
22. Zsh         |      echo   "Jabberwocky"     |
23. Bash        |      echo   "Jabberwocky"  ;  |
24. tcsh        |      echo   "Jabberwocky"   ; |
25. PHP         |      echo   'Jabberwocky'     |
26. Fish        |      echo   'Jabberwocky'  ;  |
27. Dash        |      echo   'Jabberwocky'   ; |
28. F#          |      printfn"Jabberwocky"   ; |
29. C++         |    cout<<"J"<< "abberwocky" ; |
30. D           |     Writeln(  'Jabberwocky'); |
31. Pascal      |     WriteLn(  'Jabberwocky'); |
32. Delphi      |     Writeln(  "Jabberwocky"); |
33. GolfScript  |      print;'Jabberwocky'..;;  |
34. CJam        |   "E\]]`mrj^ftXX"););  5f+'); |
35. Pyth        |      pk)K00000"Jabberwocky"   |

(Pyth and CJam thanks to user23013)

\$\endgroup\$
  • \$\begingroup\$ Actually, the haskell code prints the string with quotation marks. To print it without them you would need putStr[ln].... Also, haskell doesn't have ;;. I believe you mixed it with Ocaml. \$\endgroup\$ – proud haskeller Oct 29 '14 at 21:40
  • \$\begingroup\$ Even Ocaml doesn't have that. (The online interpreter gives error if I put ;;). Anyways, replaced Haskell with something else. \$\endgroup\$ – Optimizer Oct 29 '14 at 22:05
  • \$\begingroup\$ Pyth would be easy to add - | p b"Jabberwocky" | works, for instance \$\endgroup\$ – isaacg Oct 30 '14 at 16:45
  • \$\begingroup\$ @isaacg Thanks! I was going to look into Pyth too. This saves me time :) \$\endgroup\$ – Optimizer Oct 30 '14 at 16:50
  • \$\begingroup\$ @isaacg BTW, where is such path ? \$\endgroup\$ – Optimizer Oct 30 '14 at 16:51
15
\$\begingroup\$

17 languages

Here's the grid, with . as the reserved character:

 prin...........
 utstln!........
       (1,......
<?echo    ".....
.........'Jab...
............b...
............e...
............r...
............w...
............o...
............c...
............k...
............y"..
............' ).
.............  ;
..............  

And here are the languages and their paths (ignore the vertical bars):

01. Rust        | println!(   "Jabberwocky" ) ; |
02. Swift       | println (   "Jabberwocky" ) ; |
03. Scala       | println (   "Jabberwocky" )   |
04. Falcon      | printl  (   "Jabberwocky" )   |
05. Vala        | print   (   "Jabberwocky" ) ; |
06. Lua         | print   (   'Jabberwocky' ) ; |
07. ALGOL 68    | print   (   "Jabberwocky" )   |
08. Dart        | print   (   'Jabberwocky' )   |
09. Rebol       | print       "Jabberwocky"   ; |
10. Perl        | print       'Jabberwocky'   ; |
11. AWK         | print       "Jabberwocky"     |
12. Euphoria    | puts    (1, "Jabberwocky" )   |
13. C           | puts    (   "Jabberwocky" ) ; |
14. Tcl         | puts        "Jabberwocky"     |
15. Ruby        | puts        'Jabberwocky'     |
16. Bash        |     echo    "Jabberwocky"     |
17. PHP         |     echo    "Jabberwocky"   ; |

I haven't been able to test all of them, so let me know if something doesn't work.

\$\endgroup\$
  • \$\begingroup\$ I think you cannot use the same path for more than one language and add it to your score. \$\endgroup\$ – Optimizer Oct 28 '14 at 10:58
  • 1
    \$\begingroup\$ @Optimizer I don't think there are any paths used twice. Admittedly, the differences are pretty small. \$\endgroup\$ – grc Oct 28 '14 at 11:00
  • 1
    \$\begingroup\$ Ugh, you sneaky guy! :P \$\endgroup\$ – Optimizer Oct 28 '14 at 11:24
  • \$\begingroup\$ For PHP, after removing boilerplate, ` echo "foobar" ` (more than 1 space each time) prints just fine. Without any white spaces. Try it here \$\endgroup\$ – Optimizer Oct 28 '14 at 19:30
  • 2
    \$\begingroup\$ Its okay to remove boilerplate from the code, which is <? here \$\endgroup\$ – Optimizer Oct 28 '14 at 19:41
3
\$\begingroup\$

18 languages and more

Reserved character: ~.

         "~~~~~~
12345678 "~~~~~~
12345678 "~~~~~~
12345678 "~~~~~~
1234567: ea~~~~~
1234567: c;~~~~~
1234567: hL~~~~~
1234567: o'~~~~~
1234567:  Jab~~~
1234567:?""""~~~
~~~~~~~~~Jabberw
~~~~~~~~~~~~~~~o
~~~~~~~~~~~~~~~c
~~~~~~~~~~~~~~~k
~~~~~~~~~~~~~~~y
~~~~~~~~~~~~~~~"

Languages:

CJam                             |             ea;L'J"abberwocky"|
GolfScript                       |              cho "Jabberwocky"|
Bc                               |                  "Jabberwocky"|
Bash                             |         """"echo J"abberwocky"|
Zsh                              |           ""echo J"abberwocky"|
Fish                             |             echo J"abberwocky"|
Tcsh                             |         """"echo Ja"bberwocky"|
Dash                             |           ""echo Ja"bberwocky"|
Ksh                              |             echo Ja"bberwocky"|
Mksh                             |         """"echo Jab"berwocky"|
Yash                             |           ""echo Jab"berwocky"|
Sash                             |             echo Jab"berwocky"|
Posh                             |         """"echo "Jabberwocky"|
Csh                              |           ""echo "Jabberwocky"|
PHP                              |             echo "Jabberwocky"|

and...

FreeBasic                        |                 ?"Jabberwocky"|
QBasic                           | 12345678        ?"Jabberwocky"|
QB64                             | 123456788       ?"Jabberwocky"|

There should be many more Basic dialects that works. But I don't have time to test all of them yet.

\$\endgroup\$
  • \$\begingroup\$ Remember that you cannot use the same path for more than 1 language. So not all BASIC dialects will fit in. \$\endgroup\$ – Optimizer Dec 23 '14 at 8:50
  • 2
    \$\begingroup\$ @Optimizer At least those dialects which have line numbers and doesn't check overflow (and have ? for print) should work... Just select a different line number. \$\endgroup\$ – jimmy23013 Dec 23 '14 at 8:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.