~johanvandegriff/BoggleSolver

ref: fde46a1ef766255560499ee9e1d78496a305bb98 BoggleSolver/display.py -rw-r--r-- 750 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
33
34
35
36
#!/usr/bin/python
import sys
import pickle

if len(sys.argv) == 1:
  quit()

file = pickle.load(open(sys.argv[1],'r')) #import the board
board = file[0]

size = len(board)

score = 0;
numwords = 0
if(len(file) > 1):
  words = file[1]
  for word in words:
    length = len(word)
    if length < 7:
      points = length - 3
    elif length == 7:
      points = 5
    else:
      points = 11
    if points < 1:
      points = 1;
    print ("%2d" %(points)), word
    score += points
    numwords += 1
  print "Word Count:  " + str(numwords)
  print "Total Score: " + str(score)

for x in range(size):
  for y in range(size): #for each board spot
    sys.stdout.write("%-2s" %(board[x][y])) #write the letter padded with spaces
  print #write a new row