Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sequence = input().split()
- command = input()
- count_moves = 1
- while command != 'end':
- tokens = command.split()
- idx_one = int(tokens[0])
- idx_two = int(tokens[1])
- if idx_one != idx_two and 0 <= idx_one < len(sequence) and 0 <= idx_two < len(sequence):
- if sequence[idx_one] == sequence[idx_two]:
- print(f"Congrats! You have found matching elements - {sequence[idx_one]}!")
- indices = {idx_one, idx_two}
- sequence = [v for i, v in enumerate(sequence) if i not in indices]
- else:
- print(f"Try again!")
- else:
- print(f"Invalid input! Adding additional elements to the board")
- mid_point = len(sequence) // 2
- if idx_one < 0 or idx_two < 0:
- sequence = sequence[0:mid_point] + [('-' + str(count_moves) + 'a')] + [('-' + str(count_moves) + 'a')] + sequence[mid_point:]
- else:
- sequence = sequence[0:mid_point] + [(str(count_moves) + 'a') * 2] + [(str(count_moves) + 'a') * 2] + sequence[mid_point:]
- if len(sequence) == 0:
- break
- count_moves += 1
- command = input()
- if len(sequence) > 0:
- print(f'Sorry you lose :(')
- print(' '.join(sequence))
- else:
- print(f"You have won in {count_moves} turns!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement