Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fileInput = open('input.txt', 'r')
- fileOutput = open('output.txt', 'w')
- n = int(fileInput.readline())
- secretDict = set(fileInput.readline().strip() for _ in range(n))
- secretWord = fileInput.readline().strip()
- playerSolution = secretWord[0] # игрок знает первую букву загаданного слова
- PLAYER, BOT = 0, 1
- TURN = PLAYER
- FAIL = False
- for line in fileInput:
- if TURN == BOT:
- ans = line.split()
- if ans[0] == 'YES':
- pass
- elif ans[0] == 'NO':
- playerSolution = playerSolution[:-1]
- FAIL = True if ans[1] == 'o>-<' else False
- if TURN == PLAYER:
- playerSolution += line.strip()
- TURN = BOT if (TURN == PLAYER) else PLAYER
- if not FAIL and len(playerSolution) == len(secretWord):
- 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')
- else:
- fileOutput.write('LOST\n')
- fileInput.close()
- fileOutput.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement