6 kyu
A kata is a kata, you can't say it's only a half!
49Voile
Description:
Inspired by, obviously, this
(It's recommended to watch the first 3 minutes of that video first.)
You need to determine how many A presses is required for a segment of a complete run of a certain game.
The A presses for the whole game will be passed in as an array of pairs, e.g: [[10,30],[35,90],[150,151],[250,400]]
, where the two elements in each array represent the beginning and the end of an A press respectively, in arbitrary time unit since the start of the game.
However, counting A presses is not that simple: a segment might begin and/or end during an A press. Thus we count the number of A presses in the following way:
Every actual press of A button is counted as 1 A press.
In addition, if the segment begins while an A press is held, it is counted as 0.5 A presses.
Note that both A presses ranges and segment ranges are inclusive.
e.g An a press represented by [100,200] means that the A button is pressed before time 100 (and after time 99) and released after time 200 (but before time 201).
Example:
howManyAPresses([[10,30],[35,90],[150,151],[250,400]],0,100) => 2
howManyAPresses([[10,30],[35,90],[150,151],[250,400]],20,100) => 1.5
howManyAPresses([[10,30],[35,90],[150,151],[250,400]],20,80) => 1.5
howManyAPresses([[10,30],[35,90],[150,151],[250,400]],300,350) => 0.5
howManyAPresses([[10,30],[35,90],[150,151],[250,400]],150,151) => 0.5
howManyAPresses([[10,30],[35,90],[150,151],[250,400]],90,120) => 0.5
howManyAPresses([[10,30],[35,90],[150,151],[250,400]],120,150) => 1
Fundamentals
Similar Kata:
Stats:
Created | May 12, 2017 |
Published | May 12, 2017 |
Warriors Trained | 302 |
Total Skips | 84 |
Total Code Submissions | 190 |
Total Times Completed | 49 |
JavaScript Completions | 49 |
Total Stars | 13 |
% of votes with a positive feedback rating | 83% of 24 |
Total "Very Satisfied" Votes | 17 |
Total "Somewhat Satisfied" Votes | 6 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 4 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |