Nonoblock: Difference between revisions

m
Use ternary
m (Handle the case where there is a full line.)
m (Use ternary)
Line 933:
};
 
const permutationsgapPerms = (grpSize, numGaps, minVal = 0) => {
const maxVal = numGaps - grpSize * minVal + minVal;
const sumsToTrg = sumsTo(numGaps);
const hasInnerZero = hasInner(0);
const noInnerZero = compose(inv, hasInnerZero);
return maxVal <= 0 ? [] : (looper(mkArr(grpSize, minVal), maxVal)[1])
? (grpSize === 2 ? [[0]] : [])
.filter(noInnerZero)
: (looper(mkArr(grpSize, minVal), maxVal)[1])
.filter(sumsToTrg);
.filter(noInnerZero)
.filter(sumsToTrg);
}
 
Line 947 ⟶ 949:
const grpSize = blocks.length + 1;
const numGaps = cells - sumArr(blocks);
const fullLine = (numGaps === 0 && grpSize === 2);
const combine = zipArr([...blocks]);
const choices = toBin(choose(0, 1));
const output = compose(console.log, arrJoin(''));
const res = fullLine ? [[0gapPerms(grpSize, cells]]numGaps).map(compose(output, choices, combine));
: permutations(grpSize, numGaps).map(compose(choices, combine));
res.map(output)
};
 
Anonymous user