Skip to content

Commit

Permalink
Updated to add parenthesis for print
Browse files Browse the repository at this point in the history
makes compatible with Python 3 and above
  • Loading branch information
mrailton committed Sep 17, 2024
1 parent c53c95a commit f17fe09
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions boggle.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
from random import choice
from string import ascii_uppercase
import logging
import time


def timeit(method):
"""Calculates time taken to run a function when called"""
def timed(*args, **kw):
t1 = time.time()
result = method(*args, **kw)
print '%r %2.2f sec' % (method.__name__, time.time() -t1)
return result

return timed


def get_grid():
"""Return a dictionary of grid positions to random letters"""
Expand Down Expand Up @@ -109,7 +97,7 @@ def print_grid(grid):
for x in range(X):
s += grid[x, y] + ' '
s += '\n'
print s
print (s)

def word_score(word):
"""Returns the boggle score for a given word"""
Expand Down Expand Up @@ -137,9 +125,9 @@ def word_score(word):
wordset = set(words)
totalwords = len(wordset)

print "Found "+str(totalwords) + " words:"
print " Word\tPoints"
print "--------------"
print ("Found "+str(totalwords) + " words:")
print (" Word\tPoints")
print ("--------------")
for item in sorted(wordset):
print item+"\t"+str(word_score(item))
print (item+"\t"+str(word_score(item)))

0 comments on commit f17fe09

Please sign in to comment.