Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on May 11th, 2014  |  syntax: Python  |  size: 0.91 KB  |  views: 1  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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'
clone this paste RAW Paste Data