Skip to content

Commit 0872ade

Browse files
committed
Python Fundamentals - Mid exam.
Problem: n°6.
1 parent 20d7fc6 commit 0872ade

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
def jump_neighborhood(length_delivery):
2+
global jump_position
3+
4+
jump_position += length_delivery
5+
if jump_position >= len(neighborhood):
6+
jump_position = 0
7+
8+
if neighborhood[jump_position] == 0:
9+
print(f"Place {jump_position} already had Valentine's day.")
10+
11+
else:
12+
neighborhood[jump_position] -= 2
13+
if neighborhood[jump_position] == 0:
14+
print(f"Place {jump_position} has Valentine's day.")
15+
16+
17+
neighborhood = [int(n) for n in input().split("@")]
18+
19+
jump_command = input()
20+
jump_position = 0
21+
22+
23+
while jump_command != "Love!":
24+
jump_command = jump_command.split()
25+
jump_neighborhood(int(jump_command[1]))
26+
27+
jump_command = input()
28+
29+
print(f"Cupid's last position was {jump_position}.")
30+
31+
if sum(neighborhood) == 0:
32+
print("Mission was successful.")
33+
else:
34+
fail_count = neighborhood.count(0)
35+
print(f"Cupid has failed {len(neighborhood) - fail_count} places.")

0 commit comments

Comments
 (0)