Skip to content

Instantly share code, notes, and snippets.

@MM-coder
Created November 9, 2019 11:40
Show Gist options
  • Save MM-coder/f53948e47b46942e7510be10e70377ff to your computer and use it in GitHub Desktop.
Save MM-coder/f53948e47b46942e7510be10e70377ff to your computer and use it in GitHub Desktop.
treasure_numb = 0 # Start tresures on 0
info = input()
info_list = info.split(" ")
numb_chests = int(info_list[0])
init_pos = int(info_list[1])
instruction_numb = int(info_list[2])
locations = str(input())
locations_list = []
for i in locations:
locations_list.append(i)
current_pos = init_pos - 1
if locations_list[current_pos] == 'T':
treasure_numb += 1
else:
pass
for i in range(instruction_numb):
command = input()
command_vals = command.split(" ")
if command_vals[0].upper() == 'D': # Right
command_index = current_pos + int(command_vals[1])
current_pos = command_index
if locations_list[command_index] == 'T':
treasure_numb += 1
locations_list[command_index] = 'V'
else:
pass
if command_vals[0].upper() == 'E': # Left
command_index = current_pos - int(command_vals[1])
current_pos = command_index
if locations_list[command_index] == 'T':
treasure_numb += 1
locations_list[command_index] = 'V'
else:
pass
if command_vals[0].upper() == 'V': # Seen
pass
print(treasure_numb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment