Skip to content

Instantly share code, notes, and snippets.

@yalovek
yalovek / lucky-ticket.js
Last active March 11, 2019 16:57
Lucky ticket
(function(count){
if (count % 2 !== 0) {
throw Error('Must be even number');
}
const result = {};
const length = count / 2;
const sums = Array.from({length: Math.pow(9, length) / 2});
const nums = Array.from({length: 10});
const go = (l, m, n) => {
@yalovek
yalovek / iterate-arrays.js
Last active March 30, 2019 04:42
Iterate arrays
(function(cb, ...params) {
const last = params.length - 1;
const count = params[last] - 1;
function iterate(c, values) {
params[c].forEach(function(item) {
if (c === count) {
cb(...values, item);
} else {
iterate(c + 1, [...values, item]);