Skip to content

Commit 2aa1633

Browse files
committed
Added different solution.
1 parent 0510856 commit 2aa1633

File tree

1 file changed

+30
-0
lines changed
  • [2.2] Fundamentals Exam - Exercises/[1.2] Mid Exam - Retake

1 file changed

+30
-0
lines changed

[2.2] Fundamentals Exam - Exercises/[1.2] Mid Exam - Retake/01_the_lift.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,33 @@
1212
print("The lift has empty spots!")
1313

1414
print(*current_wagons)
15+
16+
# Different solution:
17+
18+
people = int(input())
19+
max_people = 4
20+
current = [int(num) for num in input().split()]
21+
22+
for el in range(len(current)):
23+
if people >= 4:
24+
if current[el] == 0:
25+
current[el] += 4
26+
people -= 4
27+
else:
28+
c_num = max_people - int(current[el])
29+
current[el] += c_num
30+
people -= c_num
31+
else:
32+
current[el] += people
33+
people = 0
34+
35+
check_nums = [int(num) for num in current if num != 4]
36+
37+
if people == 0 and check_nums:
38+
print("The lift has empty spots!")
39+
print(*current, sep=" ")
40+
if people != 0 and not check_nums:
41+
print(f"There isn't enough space! {people} people in a queue!")
42+
print(*current, sep=" ")
43+
if people == 0 and not check_nums:
44+
print(*current, sep=" ")

0 commit comments

Comments
 (0)