~johanvandegriff/BoggleSolver

ref: fde46a1ef766255560499ee9e1d78496a305bb98 BoggleSolver/input.py -rw-r--r-- 596 bytes
fde46a1e — Johan Vandegriff Add files via upload 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python
import sys
import pickle

size = 5
if len(sys.argv) > 1:
  if sys.argv[1].isdigit():
    size = int(sys.argv.pop(1))
  elif len(sys.argv) > 2 and sys.argv[2].isdigit():
    size = int(sys.argv.pop(2))

if size > 5:
  size = 5

print "Size: " + str(size)
#the empty board
board = []

for i in range(size):
  row = []
  for j in range(size): #for each board spot
    letter = raw_input()
    row.append(letter)
  print #write a new row
  board.append(row)

if len(sys.argv) > 1:
  file = []
  file.append(board)
  pickle.dump(file, open(sys.argv[1],'w'))
else:
  print "No file!"