Advertisement
BanyRule

Untitled

Apr 23rd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. fileInput = open('input.txt', 'r')
  2. fileOutput = open('output.txt', 'w')
  3.  
  4. n = int(fileInput.readline())
  5. secretDict = set(fileInput.readline().strip() for _ in range(n))
  6. secretWord = fileInput.readline().strip()
  7. playerSolution = secretWord[0] # игрок знает первую букву загаданного слова
  8.  
  9. PLAYER, BOT = 0, 1
  10. TURN = PLAYER
  11. FAIL = False
  12.  
  13. for line in fileInput:
  14. if TURN == BOT:
  15. ans = line.split()
  16. if ans[0] == 'YES':
  17. pass
  18. elif ans[0] == 'NO':
  19. playerSolution = playerSolution[:-1]
  20. FAIL = True if ans[1] == 'o>-<' else False
  21. if TURN == PLAYER:
  22. playerSolution += line.strip()
  23. TURN = BOT if (TURN == PLAYER) else PLAYER
  24.  
  25. if not FAIL and len(playerSolution) == len(secretWord):
  26. fileOutput.write('WON\n' + set(i for i in secretDict if (sorted([s for s in playerSolution]) == sorted([s for s in i]))).pop() + '\n')
  27. else:
  28. fileOutput.write('LOST\n')
  29.  
  30. fileInput.close()
  31. fileOutput.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement