4 ms·
Ok, took me 20 minutes, and I forgot to count the draws–I only counted the games when there is a winner. But I think his math doesn't work out. The solution is
by tictac-toe 6y ago
Ok, took me 20 minutes, and I forgot to count the draws–I only counted the games when there is a winner.
But I think his math doesn't work out. The solution is only about ~100 lines. If typing speed was the bottleneck, it would only take 2 or 3 minutes from start to finish.
> The most talented candidates will think about it for a few seconds, then write the program as fast as they can type (and they'll type fast). You can almost sense their frustration because they think way faster than the keyboard allows them to interface with the computer. Typing speed is their bottleneck. (...) The whole process will take about 10 minutes from start to finish.
- abecedarius 6y agoShorter than that. https://gist.github.com/darius/8caf6b8ba3419350d533960dba5638ff https://gist.github.com/darius/8caf6b8ba3419350d533960dba563... Saying typing speed is the bottleneck may be a bit of an exaggeration, but if you look at the leaderboard for Advent of Code, the leaders are incredibly fast. (My result: 5 minutes, but I'm normally a lot slower than those leaders. I'd just already written a tictactoe program and only needed the count-games function.)
- username90 6y agoCoding while talking is significantly slower than just coding though.
- jonahx 6y 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/##NU3LDsFAFN3PVxxqQRq3Rh9UIuE7tItGBiOjTTRYkP76ONVY3XPP8@r9y9btVpAjxgQLaCxBmCAFMqywBsmYkErCn3I6kEl/ljyZYkdt7mwJYITuEH0rgt1curFGqWzbPH@GwwahRCgxRCLpWPFBUKjTw7lzdTM0vclqlmhYoiFbqMo5alMro3yGvVDLlTleGo52gn@cczR6/wU 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.
- jl2718 6y agoWhat's the language on the one-liner? I know nothing about J, but it doesn't seem to run. Sorry; just a bit fascinated.
- jonahx 6y agoIt's J also. Link which will run: https://tio.run/##JYyxDoJAEER7v@LpWdzl4iJwoJiY6HcIlSERG0sKDb9@jrHYzOyb2X3mPJ@Njpote0oqZBMNtBw4IljLKknaFTd/mH5SSdrVeH@8cCyGf9uiZtRMcv52IlrBgHeMpkeRGXfZ2bIpGUKhTsUH14c@iPjJ1l3garrucv4C https://tio.run/##JYyxDoJAEER7v@LpWdzl4iJwoJiY6HcIlSERG0sKDb...