Hacker News new | ask | show | jobs
by jonahx 2077 days ago
> The solution is only about ~100 lines.

    wins=. 9 3 $ 0 1 2  3 4 5  6 7 8  0 3 6  1 4 7  2 5 8  0 4 8  2 4 6
    winner=. # e. 3 + wins #@-.~"1 ]
    isover=. [: +./ ] winner/.~ 2 | #\
    fullgame=. {.~ 1 + 1 i.~ isover\
    all=. (i.!9) A. i.9
    echo # ~. fullgame"1 all

https://tio.run/##NU3LDsFAFN3PVxxqQRq3Rh9UIuE7tItGBiOjTTRYkP...

Or the 1-liner:

    # ~. ({.~ 1 + 1 i.~ ([: +./ ] (# e. 3 + w #@-.~"1 ])/.~ 2 | #\)\)"1 (i.!9) A. i.9
which surely could be golfed even further.
1 comments

What's the language on the one-liner? I know nothing about J, but it doesn't seem to run. Sorry; just a bit fascinated.