Permalink
Browse files

update

  • Loading branch information...
1 parent 4d3913c commit e5a820817b866267763fefc273b4c2cb54dd27be nokuno committed Sep 11, 2011
Showing with 32 additions and 6 deletions.
  1. +29 −6 python/google/devquiz2011/slide.py
  2. +3 −0 python/google/devquiz2011/test.txt
@@ -1,25 +1,48 @@
#!/usr/bin/env python
+from copy import deepcopy
+
+def brute_force(board):
+ pass
+
+def correct(board):
+ result = deepcopy(board)
+ num = 1
+ for i in len(result):
+ for j in len(result[0]):
+ if result[i][j] != None:
+ result[i][j] = num
+ num += 1
+ return result
def show(board):
result = ""
for row in board:
- result += "".join(row) + "\n"
+ result += str(row) + "\n"
return result
+def char2int(c):
+ if c == "=":
+ return -1
+ if ord(c) >= ord("0") and ord(c) <= ord("9"):
+ return ord(c) - ord("0")
+ return ord(c) - ord("A")
+
if __name__ == "__main__":
import sys
if len(sys.argv) < 2:
file = "data/problems.txt"
else:
- file = argv[0]
+ file = sys.argv[1]
with open(file) as fp:
- lx, rx, ux, dx = [int(i) for i in fp.readline().strip().split(" ", 4)]
+ lx, rx, ux, dx = [i for i in fp.readline().strip().split(" ", 3)]
n = int(fp.readline())
for line in fp:
w, h, b = line.strip().split(",",2)
w, h = int(w), int(h)
- board = [[b[i*w+j] for j in range(w)] for i in range(h)]
- print w, h
- print show(board)
+ board = [[char2int(b[i*w+j]) for j in range(w)] for i in range(h)]
+ if w == 3 and h == 3:
+ print show(board)
+ print brute_force(board)
+
@@ -0,0 +1,3 @@
+100 100 100 100
+1
+3,3,40=215=86

0 comments on commit e5a8208

Please sign in to comment.