Shortest Code : Waiting for a Bus
Description:
Shortest Code: Waiting for a Bus
(Code length limit: 160 chars)
This is the challenge version of coding 3min series. If you feel difficult, please complete the simple version
Task
John is Waiting for a Bus.
The Bus Station first bus starting at 06:00, Every 15 minutes a bus departure, the last bus departure time is 20:00. the bus average speed is 30 km/h.
You are given two arguments:
time
:a string, the time when John start waiting. time format:hh:mm
(24 hour time format)km
: a integer number, the distance between the location of John and the bus station
Please calculate when John can get on the bus. return a string with time format: hh:mm
Example
time='06:00',km=1 sc('06:00',1)='06:02'
John start waiting at 06:00, a Bus start at 06:00
Bus travel 1 km with 2 minutes, so John take on the Bus at 06:02
time='06:00',km=10 sc('06:00',10)='06:20'
John start waiting at 06:00, a Bus start at 06:00
Bus travel 10 km with 20 minutes, so John take on the Bus at 06:20
time='07:00',km=10 sc('07:00',10)='07:05'
John start waiting at 07:00, a Bus start at 06:45
Bus travel 10 km with 20 minutes, so John take on the Bus at 07:05
time='10:00',km=100 sc('10:00',100)='10:05'
John start waiting at 10:00, a Bus start at 06:45
Bus travel 100 km with 3 hours 20 minutes, so John take on the Bus at 10:05
time='09:00',km=100 sc('09:00',100)='09:20'
John start waiting at 10:00, a Bus start at 06:00
Bus travel 100 km with 3 hours 20 minutes, so John take on the Bus at 09:20
some edge case:
time='05:00',km=1 sc('05:00',1)='06:02'
John start waiting at 05:00, a Bus start at 06:00
(John gets up too early, so he should waiting a long times)
Bus travel 1 km with 2 minutes, so John take on the Bus at 06:02
time='20:00',km=1 sc('20:00',1)='20:02'
John start waiting at 20:00, a Bus start at 20:00
(John caught up with the last bus)
Bus travel 1 km with 2 minutes, so John take on the Bus at 20:02
time='20:10',km=1 sc('20:10',1)='06:02'
John start waiting at 20:00, a Bus start at next day 06:00
(John didn't catch the last bus, he should waiting to next day)
Bus travel 1 km with 2 minutes, so John take on the Bus at 06:02
Code length calculation
In javascript, we can't get the user's real code, we can only get the system compiled code. Code length calculation is based the compiled code.
For example:
If you typed sc=x=>x+1
after compile, it will be:sc=function(x){return x+1;}
Series
- Bug in Apple
- Father and Son
- Jumping Dutch act
- Planting Trees
- Reading a Book
- Eat watermelon
- Special factor
- Symmetric Sort
- Are they symmetrical?
- Guess the Hat
- Find the murderer
- Give me the equation
- Balance Attraction
- Max Value
- Regular expression compression
- Remove screws I
- Remove screws II
- Collatz Array(Split or merge)
- Trypophobia
- Virus in Apple
- Waiting for a Bus
- Tidy up the room
Similar Kata:
Stats:
Created | Apr 7, 2016 |
Published | Apr 8, 2016 |
Warriors Trained | 213 |
Total Skips | 4 |
Total Code Submissions | 653 |
Total Times Completed | 39 |
JavaScript Completions | 39 |
Total Stars | 3 |
% of votes with a positive feedback rating | 86% of 21 |
Total "Very Satisfied" Votes | 15 |
Total "Somewhat Satisfied" Votes | 6 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 3 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 6 kyu |