Skip to content

Commit abb03ba

Browse files
committed
Update: TicTacToe2 solution
1 parent 1d60192 commit abb03ba

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

kattis/TicTacToe2/tictactoe2.vn.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,16 @@
5252
# Anything else is impossible
5353
else:
5454
print("no")
55-
56-
# wins[X] -> A, wins[O] -> B, grid.count(X)-grid.count(O)==i -> Ci
55+
56+
# A = wins[X]
57+
# B = wins[O]
58+
# C0 = grid.count(X) - grid.count(O) == 0
59+
# C1 = grid.count(X) - grid.count(O) == 1
60+
# (original form, then simplified with sympy.simplify_logic)
61+
62+
# yes = (C0 | C1) & (C0 | ~B) & (C1 | ~A) & (~A | ~B)
63+
# valid turn count (0 or 1)
64+
# winner must match turn count (2 expressions)
65+
# X and O cannot both win
5766

58-
# yes = (A.¬B.C1)+(¬A.B.C0)+(¬A.¬B.(C0+C1))
59-
# Fun fact: We could try to simplify this.
60-
# We'll probably find a simpler equation for no.
67+
# Well, that was fun.

0 commit comments

Comments
 (0)