aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2022-10-14 11:07:26 -0400
committerAnthony Wang2022-10-14 11:07:26 -0400
commitf0a38e712f0c92ac2930a1091bf014756a43e0fd (patch)
treec76974e7e4cbee04dd5ede45a4706e06b06fabf7
Initial commit
-rwxr-xr-xflipper.py22
-rw-r--r--test.f4
2 files changed, 26 insertions, 0 deletions
diff --git a/flipper.py b/flipper.py
new file mode 100755
index 0000000..f8e5b14
--- /dev/null
+++ b/flipper.py
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+
+from sys import argv
+
+mem = [{}, {}]
+
+def flip(x, y):
+ if y not in mem[x]:
+ mem[x][y] = 1
+ else:
+ mem[x][y] = 1 - mem[x][y]
+ return mem[x][y]
+
+with open(argv[1]) as f:
+ for line in f.readlines():
+ l = list(map(int, line.split()))
+ if len(l) < 2:
+ continue
+ x = l[0]
+ for i in range(1, len(l)):
+ x = flip(x, l[i])
+ print(x)
diff --git a/test.f b/test.f
new file mode 100644
index 0000000..70dbd19
--- /dev/null
+++ b/test.f
@@ -0,0 +1,4 @@
+0 0
+0 0
+0 0
+0 0