1. Time measurement using song duration
Consider that Alice is cycling from point A to point B. During the cycling, Alice is listening to songs in her music player.
Given the following inputs:
1. The distance between A and B in metres
2. The speed at which Alice is traveling in metres per second
3. Duration of each song in her playlist in the
following format: mm:ss
the program should:
• Print the number of the song that Alice is listening when the cycling is completed from A to B
· Print Invalid input if any of the constraints mentioned in the constraints section is violated
Example 1
Consider the following inputs:
2000
5
Now consider the following list of songs:
05:30
02:04
dis = int(input())
speed = int(input())
time = dis / speed
cnt = 0
bar = 0
l = list(map(str, input().split()))
ll = []
for i in l:
foo = int(i[:2])*60+int(i[3:])
ll.append(foo)
for i in ll:
cnt += i
bar +=1
if cnt >= time:
print(bar)
break
Comments
Leave a comment