There are 40 ways a directed Hamiltonian path can be arranged on a 3×3 grid:
This graphic (thanks Sp3000!) shows only the 20 undirected paths. Traverse each colored line in both directions for the 40 directed paths.
Challenge
Using only printable ASCII, write a 3×3 grid of characters, such as:
ABC
DEF
GHI
When each of the 40 directed paths are read from this grid as 40 single-line, 9-character programs, the goal is to have each program output a unique integer from 1 to 40. Doing this for all 40 paths seems difficult and unlikely, so you only need to make it work for as many paths as you can.
The submission whose 40 path-programs output the most distinct numbers from 1 to 40 will be the winner. Tiebreaker goes to the earlier submission.
Path-programs that error or do not output an integer from 1 to 40 or output an integer that another path-program already covered are not counted. Specifically:
- Programs that error while compiling, running, or exiting are not counted. Warnings are ok.
- Programs that don't output an integer from 1 to 40 or output something slightly malformed such as
-35
or35 36
are not counted. - Programs that require user input to produce the output are not counted.
- Programs that never end are not counted.
- From now on, programs that aren't deterministic aren't counted.
- Otherwise valid programs that output an integer from 1 to 40 that another valid program has already output are not counted. (The first program is counted.)
- Only programs that output integer representations of numbers from 1 to 40 (inclusive) are counted towards your total. The numbers are expected to be in the usual
1
,2
, ...,39
,40
format, unless that is not the norm for your language. (A trailing newline in the output is fine.) - Which numbers your programs output and what order they are in does not matter. Only the number of distinct integers from valid programs matters.
All path-programs must be run in the same language. However, the "programs" may in fact be functions (with no required arguments) or REPL commands, as well as full programs, that print or return their target integer. You may mix and match between functions, REPL commands, and full programs.
Your 9 printable ASCII characters do not need to be distinct.
Example
If your 3×3 grid were
ABC
DEF
GHI
and your 40 programs and outputs looked like this
ABCFEDGHI -> 26
ABCFIHEDG -> 90
ABCFIHGDE -> 2
ABEDGHIFC -> syntax error
ADEBCFIHG -> prints 40 but then errors
ADGHEBCFI -> 6
ADGHIFCBE -> 6
ADGHIFEBC -> 6
CBADEFIHG -> runtime error
CBADGHEFI -> 3
CBADGHIFE -> 4
CFEBADGHI -> -32
CFIHEBADG -> 38.0
CFIHGDABE -> "36"
EDABCFIHG -> 33
EFCBADGHI -> no output
EHGDABCFI -> compilation error
EHIFCBADG -> 8
GDABCFEHI -> 22
GHEDABCFI -> 41
IHGDEFCBA -> 0
GDEHIFCBA -> '9'
EDGHIFCBA -> +10
CFIHGDEBA -> 11
GHIFCBEDA -> error
IFCBEHGDA -> error
EBCFIHGDA -> prints 23 but then loops infinitely
CBEFIHGDA -> randomly prints either 24 or 44
GHIFEDABC -> error
IFEHGDABC -> 30
EFIHGDABC -> 39
IHGDABEFC -> 7
GDABEHIFC -> 29
EBADGHIFC -> -1
GHIFCBADE -> 26
IHGDABCFE -> 1
IFCBADGHE -> error
GDABCFIHE -> no output
IHEFCBADG -> no output
IFCBADEHG -> "quack"
your score would be 14, because there are 14 distinct integers from 1 to 40 validly output, namely 26 2 6 3 4 33 8 22 11 30 39 7 29 1
.
123654789
\$\endgroup\$