Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • \$\begingroup\$ If you move the return statement where T=1;break currently is, you don't need any breaks or T, which saves a few bytes. And chained comparisons can probably save a few bytes as well \$\endgroup\$ Commented Sep 5, 2021 at 12:40
  • \$\begingroup\$ @ovs thanks for the first tip! Not sure where I could use the chained comparisons though. \$\endgroup\$ Commented Sep 5, 2021 at 13:05
  • \$\begingroup\$ s[i]!=0and len(p)>1and p[-2]==p[-1] -> s[i]!=0<1<len(p)!=p[-2]==p[-1]. And in the last if you might be able to replace O==sorted(p)and all(...) with (O==sorted(p)*all(...). \$\endgroup\$ Commented Sep 5, 2021 at 13:10
  • \$\begingroup\$ I'm glad you liked it, is this one of your first challenges? Anyway, yes, a state of the game includes the current player, as you can se in the example 2) lines 28, 42 have the same piles configuration but the game doesn't end up in a loop. Unfortunately in that example the outcome is the same as would be in a simulation that wrongly detects a loop. If you want you can help me find a test case that differentiates it \$\endgroup\$ Commented Sep 5, 2021 at 15:58
  • \$\begingroup\$ @Domenico You can just write a comment next to it saying "was seen before, but different player's turn" or something similar. \$\endgroup\$ Commented Sep 5, 2021 at 16:04