6 kyu
T.T.T.49: John and Anne's sweet date
245 of 276myjinxin2015
Description:
Story
John and Anne are a pair of lovebirds. They have their own jobs. John works w1
days off for r1
day and Anne works w2
days off for r2
days. Only when they have a rest, they can go out for a sweet date. Please calculate, they can date how many days in a time period? For example:
John works 3 days off for 1 day
Anne works 7 days off for 3 days
In a time period 10 day
John: work work work rest work work work rest work work
|
Anne: work work work work work work work rest rest rest
They have only one sweet date in 10 days
In a time period 1000 day
John: work work work rest work work work rest work work ....
|
Anne: work work work work work work work rest rest rest ....
They will have 100 times sweet date in 1000 days
Task
Complete function sweetDate()
that accepts 5 arguments:
w1
,r1
: The work days and rest days of John
w2
,r2
: The work days and rest days of Anne
timePeriod
: A time period that we need to calculate the sweet date
Return a number that How many times can Anne and John have a sweet date.
Example
w1 | r1 | w2 | r2 | time_period | Result |
---|---|---|---|---|---|
3 | 1 | 7 | 3 | 10 | 1 |
3 | 1 | 7 | 3 | 20 | 2 |
4 | 2 | 7 | 3 | 20 | 1 |
4 | 2 | 7 | 3 | 30 | 3 |
3 | 1 | 7 | 3 | 1000 | 100 |
Puzzles
Games
Similar Kata:
Stats:
Created | Aug 25, 2016 |
Published | Aug 25, 2016 |
Warriors Trained | 586 |
Total Skips | 8 |
Total Code Submissions | 1249 |
Total Times Completed | 276 |
JavaScript Completions | 245 |
CoffeeScript Completions | 8 |
Python Completions | 39 |
Total Stars | 18 |
% of votes with a positive feedback rating | 98% of 64 |
Total "Very Satisfied" Votes | 62 |
Total "Somewhat Satisfied" Votes | 2 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 5 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |