1-D Frogger (Easy)

This commit is contained in:
2023-07-25 12:40:12 +02:00
parent 30941abe2d
commit 61b575d34f

30
1dfroggereasy.py Normal file
View File

@@ -0,0 +1,30 @@
n, s, m = map(int, input().split())
s -= 1
board = list(map(int, input().split()))
shadow_board = [0] * n
def print_ending(ending, hops):
print(ending)
print(hops)
exit()
hops = 0
while True:
if shadow_board[s] == 1:
print_ending("cycle", hops)
shadow_board[s] = 1
if board[s] == m:
print_ending("magic", hops)
if s + board[s] < 0:
print_ending("left", hops + 1)
if n <= s + board[s]:
print_ending("right", hops + 1)
s += board[s]
hops += 1