+ 1

Why doesn't this work? (Code coach: Land Ho!)

I don't want to write everything down, look for the puzzle to find the info for i in range(100): peeps = i + 1 if peeps % 20 == 0: boats = peeps/20 elif peeps % 20 < 5: boats = round((peeps/20) + 0.5) else: boats = round((peeps/20)) if boats == 1: print(10) else: print((boats - 1) * 20 + 10) 10 10 10 10 -10 -10 -10 -10 -10 -10 10 10 10 10 10 10 10 10 10 10 30 30 30 30 10 10 10 10 10 30 30 30 30 30 30 30 30 30 30 30.0 50 50 50 50 30 30 30 30 30 30 50 50 50 50 50 50 50 50 50 50.0 70 70 70 70 50 50 50 50 50 70 70 70 70 70 70 70 70 70 70 70.0 90 90 90 90 70 70 70 70 70 70 90 90 90 90 90 90 90 90 90 90.0 That's my code and the outputs. I'm pretty sure I know why some of them have .0 on the end, I fixed that but whatever their 3rd value they input is (which they don't show you) doesn't work with the fixed version. The reason for the .0 should be that I didn't bother to make my first if an integer

18th Nov 2023, 3:03 AM
MM081
MM081 - avatar
1 Respuesta
+ 8
MM081 look at the problem as worded You are on a large ship and you put down anchor near a beautiful beach. There is a small boat ferrying passengers back and forth, and you get in line for it. How long will you have to wait to get to the beach? You know that 20 people can fit on the boat and each trip to shore takes 10 minutes each way. Task: Determine your wait time if you know the total number of people ahead of you in line. Input Format: An integer that represents the total number of people ahead of you in line. Output Format: An integer that represents the number of minutes that you will have to wait until you are standing on the beach. Sample Input: 15 Sample Output: 10 Explanation: You can get on the boat right away if you are the 16th person in line, it takes 10 minutes on the boat to get to the beach. > Think about how many people are ahead of you plus > how many minutes from one shore line to the other takes > how many passengers per boat 20 on 20 off in each cycle
18th Nov 2023, 3:50 AM
BroFar
BroFar - avatar