Algorithms and Data Structures/Coding Practices

Kattis Skru op!

brightlightkim 2022. 7. 19. 15:49

Turn It Up!

 

Your volume control is at a comfortable 7 – not too high, not too low. Your friends entirely disagree, and frequently request you turn it up or turn it down, often in a somewhat inappropriate tone of voice.

Ever aiming to please, you try to accomodate their requests and increase or decrease the volume by one step accordingly. There are 11 steps on your volume control: 0, 1, 2, and so on up to 10.

When the volume is set to 0, you can’t turn it further down and can ignore any misguided request to that effect. Similarly, you can’t turn it up to more than 10.

Where is your volume control after n requests?

Input

A single integer n on the first line, the number of requests.

The following n lines contain either “Skru op!” (Danish for “Turn it up!”) or “Skru ned!” (Danish for “Turn it down!”.)

Output

Write a single integer: The position of your volume control after all n requests.

Points

There are three test groups.

Group Points Constraints
1 25 n=1
2 25 1≤n≤3
3 50 1≤n≤100
numOfRequests = int(input())
volumeLevel = 7

for i in range(numOfRequests):
    request = input()
    if (request == "Skru op!"):
        if (volumeLevel != 10):
            volumeLevel += 1
    elif (request == "Skru ned!"):
        if (volumeLevel != 0):
            volumeLevel -= 1

print(volumeLevel)

'Algorithms and Data Structures > Coding Practices' 카테고리의 다른 글

AlgoExpert Smallest Difference  (0) 2022.07.20
Kattis Sort  (0) 2022.07.20
AlgoExpert Three Number Sum  (0) 2022.07.19
AlgoExpert Generate Document  (0) 2022.07.19
AlgoExpert Selection Sort  (0) 2022.07.19