Advertisement
Guest User

Untitled

a guest
May 11th, 2014
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. from ps3a import *
  2. import time
  3. from perm import *
  4.  
  5.  
  6. #
  7. #
  8. # Problem #6A: Computer chooses a word
  9. #
  10. #
  11. def comp_choose_word(hand, word_list, n):
  12.     high_score = 0
  13.     for length in range(1, n+1):
  14.         print 'Length:',length
  15.         for word in get_perms(hand, length):
  16.             print 'Trying',word
  17.             if get_word_score(word, n) > high_score:
  18.                 print 'Found higher word',word
  19.                 if is_valid_word(word, hand, word_list):
  20.                     print word,'is valid'
  21.                     high_score = get_word_score(word, n)
  22.                     high_word = word
  23.                 else:
  24.                     print word,'is not valid english word'
  25.     print high_word,':',high_score
  26.                
  27. hand = {'a':1,'s':1,'t':2,'w':1,'f':1,'o':1}
  28. #comp_choose_word(deal_hand(7), word_list, 7)
  29. comp_choose_word(hand, word_list, 7)
  30. print 'Fast for',get_word_score('fast', 7),'points'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement