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

Stats:

CreatedAug 25, 2016
PublishedAug 25, 2016
Warriors Trained586
Total Skips8
Total Code Submissions1249
Total Times Completed276
JavaScript Completions245
CoffeeScript Completions8
Python Completions39
Total Stars18
% of votes with a positive feedback rating98% of 64
Total "Very Satisfied" Votes62
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes0
Total Rank Assessments5
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • Unnamed Avatar
  • smile67 Avatar
  • kazk Avatar
  • dfhwze Avatar
  • saudiGuy Avatar
Ad