Skip to content

Instantly share code, notes, and snippets.

@yosiat
Created June 27, 2015 09:04
Show Gist options
  • Save yosiat/f48aa564ca6bd3c2d422 to your computer and use it in GitHub Desktop.
Save yosiat/f48aa564ca6bd3c2d422 to your computer and use it in GitHub Desktop.
every
# 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