Created
June 27, 2015 09:04
-
-
Save yosiat/f48aa564ca6bd3c2d422 to your computer and use it in GitHub Desktop.
every
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Every | |
Write a function that accepts two arguments: | |
1. duration in milliseconds | |
2. array of objects that looks like this - { time: Date, value: int } | |
That returns an array of array of objects -> Array<Array<object>> whom partitioned by duration. | |
## Example | |
Given the next input: | |
* time: 15:00 value: 2 | |
* time: 15:01 value: 3 | |
* time: 15:10 value: 4 | |
* time: 15:12 value: 5 | |
* time: 15:56 value: 6 | |
With the duration of 15 minutes. | |
The output must be: | |
* [time: 15:00 value: 2,time: 15:01 value: 3] | |
* [time: 15:10 value: 4,time: 15:12 value: 5] | |
* [time: 15:56 value: 6] | |
# Rules | |
* You must do this the functional way - composition, small functions in the stl (clojure/lodash) | |
* It should be fast, or proposing a way for doing this faster for larger dataset. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment