コード例 #1
0
    def testVocabularySolver(self):
        t = TrieVocabulary()
        t.addWord("spam")
        t.addWord("ham")
        t.addWord("eggs")
        
        solver = VocabularySolver(t)
        assert solver.solve("smaph").__contains__("ham")
        assert solver.solve("smaph").__contains__("spam")
        assert not solver.solve("smaph").__contains__("eggs")
        assert len(solver.solve("smaph")) == 2
        
        pass


#if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testSolver']
    #unittest.main()
コード例 #2
0
ファイル: runner.py プロジェクト: exorbit/alphabear-wizard-py
'''
Created on Nov 10, 2015

@author: st.becker
'''
from alphabear_wizard.vocabulary import fillVocabulary
from alphabear_wizard.solver import VocabularySolver
from alphabear_wizard.scorer import Scorer
from alphabear_wizard.boardSetup import Tokens
from __builtin__ import str
    
if __name__ == '__main__':
    pass
# intitialization
vocabulary = fillVocabulary()
solver = VocabularySolver(vocabulary)
scorer = Scorer()

# create board
board = Tokens()
while True:
    while True:
        cInput = raw_input("Add Value\t:")
        if len(cInput) < 1:
            break
        try:
            value = int(cInput)
            if value >= 1 and value <= 10 : 
                pass
            else :
                print 'Invalid number'