From 61b575d34f0778895e4f6cd986350496af8c7eb2 Mon Sep 17 00:00:00 2001 From: Jethro Stapelbroek Date: Tue, 25 Jul 2023 12:40:12 +0200 Subject: [PATCH] 1-D Frogger (Easy) --- 1dfroggereasy.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 1dfroggereasy.py diff --git a/1dfroggereasy.py b/1dfroggereasy.py new file mode 100644 index 0000000..4ffaf88 --- /dev/null +++ b/1dfroggereasy.py @@ -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