Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- initial_string = input().split()
- move_counter = 0
- while True:
- command = input()
- if command == "end":
- break
- command_split = command.split()
- index_1 = int(command_split[0])
- index_2 = int(command_split[1])
- move_counter += 1
- if 0 <= index_1 < len(initial_string) and 0 <= index_2 < len(initial_string):
- value_1 = initial_string[index_1]
- value_2 = initial_string[index_2]
- if value_1 == value_2:
- print(f"Congrats! You have found matching elements - {value_1}!")
- initial_string.remove(value_1)
- initial_string.remove(value_2)
- else:
- print(f"Try again!")
- else:
- print(f"Invalid input! Adding additional elements to the board")
- middle_point = int(len(initial_string) // 2)
- for el in range(move_counter):
- initial_string.insert(middle_point, f"-{str(move_counter)}a")
- if len(initial_string) == 0:
- print(f"You have won in {move_counter} turns!")
- break
- if len(initial_string) != 0:
- print(f"Sorry you lose :(")
- print(" ".join(initial_string))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement