Question: A computer game to ascend a building with a specified number of floors. You have three different facilities for each floor to reach the top:

A computer game to ascend a building with a specified number of floors. You have three different facilities for each floor to reach the top: the elevator (1), the escalator (2), and walking up the stairs (3).
Each facility has its own scoring rule. Assume the initial score is zero.
Elevator (1): Score increments to the next even number.
Escalator (2): Score increments to the next odd number.
Walk (3): Score increments to the next prime number.
Write an algorithm and python code to display the score to ascend a building. [Difficult]
Example: If number of floors 4 and person chosen 3 for first floor, 2 for second floor, 3 for third floor and 2 for fourth floor. The score is 2(first prime number)+1(first odd number)+3(next prime number)+3(next odd number)=9.
Inputs:
Number of floors (n)
Enter facility number (1 or 2 or 3 n-times)
Output:
Score
Test cases:
Test 1: 1
--- Input ---
5
1
2
3
1
2
--- Expected output (numbers)---
12
Test 2: 2
--- Input ---
10
1
2
3
3
2
1
1
2
3
3
--- Expected output (numbers)---
38
Test 3: 3
--- Input ---
7
3
3
3
3
3
3
3
--- Expected output (numbers)---
58
Test 4: 4
--- Input ---
6
3
2
3
2
3
2
--- Expected output (numbers)---
19

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!