I am trying a competition entry (its old, purely to test myself) and I have come against a problem, this is the description for the competition:
In a word game each letter has a score based on its position in the alphabet, A scoring 1 through to Z scoring 26. The object of the game is to split the letters of a word into two groups so that the total score of the letters in each group is the same. For example, LIONHEAD can be split into LIHAD and ONE, both scoring 34.
and I currently have this code:
import cword running=1 while running==1: poss= print""" do you want to: 1)enter a word? 2)quit? """ menu=int(raw_input('')) if menu==1: word=raw_input("what is the word to check?") if cword.check_word(word):#checks is word is a word for pword in cword.dicta: if len(pword)<len(word): for letter in word: if letter in pword: if cword.val_word(pword)==cword.val_word(word)/2:#gets value of possible and current word, /2 bc new word value will always be half of the original. if pword in poss: continue else: poss.append(pword) print poss elif menu==2: running=0 else: print "that was not a proper command" print "please enter a new one." raw_input()
When running this with 'tiger' as the word, I get these possibles:
['ais', 'aria', 'awe', 'bags', 'beau', 'bind', 'bred', 'cate', 'ceil', 'cepe', 'crag', 'cue', 'dike', 'dip', 'ecu', 'ell', 'ex', 'fard', 'feme', 'fend', 'fer', 'fin', 'gabs', 'gang', 'gape', 'glee', 'glia', 'haik', 'hat', 'held', 'hep', 'it', 'jar', 'kale', 'lake', 'leak', 'lice', 'mig', 'page', 'peag', 'peh', 'pica', 'raia', 'raj', 'ref', 'rib', 'sade', 'see', 'tace', 'ted', 'ti', 'wae'] but how can I go through these words so that only the correct amount of each letter is used?
Many thanks in advance.