Created
August 1, 2018 14:45
-
-
Save antofa/eff99f72655a538dc5a3ba928cb827a6 to your computer and use it in GitHub Desktop.
This file contains 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
import { range, uniq } from 'lodash'; | |
function f(a, n) { | |
let b = []; | |
range(n).forEach(i => b.push(Math.ceil(i * a.length / n))); | |
return uniq(b); | |
} | |
console.log(f(range(10), 4)); | |
// [ 0, 3, 5, 8 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment