Skip to content

Instantly share code, notes, and snippets.

@antofa
Created August 1, 2018 14:45
Show Gist options
  • Save antofa/eff99f72655a538dc5a3ba928cb827a6 to your computer and use it in GitHub Desktop.
Save antofa/eff99f72655a538dc5a3ba928cb827a6 to your computer and use it in GitHub Desktop.
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