Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// This modules allows you to run nodeunit tests on all possible combinations of monads, defined in the library
var combinatorics = require('js-combinatorics')
const id = require('../lib/id')
const data = require('../lib/data')
const comp = require('../lib/comp')
const monads = [].concat([data.writer, data.list, data.maybe, id.idMinimal, id.id, id.idWrapped, comp.state, comp.reader])
const stacks = combinatorics.permutation(monads, 3).toArray()
module.exports = (stackFilter, testFunction) => stacks.filter(stackFilter).reduce((obj, stack) => {
obj[stack.map(s => s.name).join('')] = testFunction.apply(null, stack)
return obj
}, {})
const filteredPowers:string[][] = power.filter((i:string[]) => i.length > 0);
const allPowers:string[][] = power.toArray();
const powersCount = power.length;
const nthPower:string[] = power.nth(3);
const limitedCombination = Combinatorics.combination(["a", "b", "c"], 2);
const combination = Combinatorics.combination(["a", "b", "c"]);
const nextCombination:string[] = combination.next();
combination.forEach((i:string[]) => console.log(i));
const combinationsLengths:number[] = combination.map((i:string[]) => i.length);
const filteredCombinations:string[][] = combination.filter((i:string[]) => i.length > 0);
const allCombinations:string[][] = combination.toArray();
const combinationsCount = combination.length;
const limitedPermutation = Combinatorics.permutation(["a", "b", "c"], 2);
const permutation = Combinatorics.permutation(["a", "b", "c"]);
const nextPermutation:string[] = permutation.next();
permutation.forEach((i:string[]) => console.log(i));
const permutationsLengths:number[] = permutation.map((i:string[]) => i.length);
const filteredPermutations:string[][] = permutation.filter((i:string[]) => i.length > 0);
const allPermutations:string[][] = permutation.toArray();
const permutationsCount = permutation.length;
const permutationCombination = Combinatorics.permutationCombination(["a", "b", "c"]);
const nextPermutationCombinations:string[] = permutationCombination.next();
permutationCombination.forEach((i:string[]) => console.log(i));
const permutationCombinationsLengths:number[] = permutationCombination.map((i:string[]) => i.length);
const filteredPermutationCombinationss:string[][] = permutationCombination.filter((i:string[]) => i.length > 0);
const allPermutationCombinationss:string[][] = permutationCombination.toArray();
const permutationCombinationsCount = permutationCombination.length;
const limitedBaseN = Combinatorics.baseN(["a", "b", "c"], 2);
const powersLengths:number[] = power.map((i:string[]) => i.length);
const filteredPowers:string[][] = power.filter((i:string[]) => i.length > 0);
const allPowers:string[][] = power.toArray();
const powersCount = power.length;
const nthPower:string[] = power.nth(3);
const limitedCombination = Combinatorics.combination(["a", "b", "c"], 2);
const combination = Combinatorics.combination(["a", "b", "c"]);
const nextCombination:string[] = combination.next();
combination.forEach((i:string[]) => console.log(i));
const combinationsLengths:number[] = combination.map((i:string[]) => i.length);
const filteredCombinations:string[][] = combination.filter((i:string[]) => i.length > 0);
const allCombinations:string[][] = combination.toArray();
const combinationsCount = combination.length;
const limitedPermutation = Combinatorics.permutation(["a", "b", "c"], 2);
const permutation = Combinatorics.permutation(["a", "b", "c"]);
const nextPermutation:string[] = permutation.next();
permutation.forEach((i:string[]) => console.log(i));
const permutationsLengths:number[] = permutation.map((i:string[]) => i.length);
const filteredPermutations:string[][] = permutation.filter((i:string[]) => i.length > 0);
const allPermutations:string[][] = permutation.toArray();
const permutationsCount = permutation.length;
const permutationCombination = Combinatorics.permutationCombination(["a", "b", "c"]);
const nextPermutationCombinations:string[] = permutationCombination.next();
permutationCombination.forEach((i:string[]) => console.log(i));
const permutationCombinationsLengths:number[] = permutationCombination.map((i:string[]) => i.length);
const filteredPermutationCombinationss:string[][] = permutationCombination.filter((i:string[]) => i.length > 0);
const allPermutationCombinationss:string[][] = permutationCombination.toArray();
const permutationCombinationsCount = permutationCombination.length;
const combinationsLengths:number[] = combination.map((i:string[]) => i.length);
const filteredCombinations:string[][] = combination.filter((i:string[]) => i.length > 0);
const allCombinations:string[][] = combination.toArray();
const combinationsCount = combination.length;
const limitedBigCombination = Combinatorics.bigCombination(["a", "b", "c"], 2);
const bigCombination = Combinatorics.bigCombination(["a", "b", "c"]);
const nextBigCombination:string[] = bigCombination.next();
bigCombination.forEach((i:string[]) => console.log(i));
const bigCombinationsLengths:number[] = bigCombination.map((i:string[]) => i.length);
const filteredBigCombinations:string[][] = bigCombination.filter((i:string[]) => i.length > 0);
const allBigCombinations:string[][] = bigCombination.toArray();
const bigCombinationsCount = bigCombination.length;
const limitedPermutation = Combinatorics.permutation(["a", "b", "c"], 2);
const permutation = Combinatorics.permutation(["a", "b", "c"]);
const nextPermutation:string[] = permutation.next();
permutation.forEach((i:string[]) => console.log(i));
const permutationsLengths:number[] = permutation.map((i:string[]) => i.length);
const filteredPermutations:string[][] = permutation.filter((i:string[]) => i.length > 0);
const allPermutations:string[][] = permutation.toArray();
const permutationsCount = permutation.length;
const permutationCombination = Combinatorics.permutationCombination(["a", "b", "c"]);
const nextPermutationCombinations:string[] = permutationCombination.next();
permutationCombination.forEach((i:string[]) => console.log(i));
const permutationCombinationsLengths:number[] = permutationCombination.map((i:string[]) => i.length);
const filteredPermutationCombinationss:string[][] = permutationCombination.filter((i:string[]) => i.length > 0);
const allPermutationCombinationss:string[][] = permutationCombination.toArray();
const permutationCombinationsCount = permutationCombination.length;
const limitedBaseN = Combinatorics.baseN(["a", "b", "c"], 2);
combination.forEach((i:string[]) => console.log(i));
const combinationsLengths:number[] = combination.map((i:string[]) => i.length);
const filteredCombinations:string[][] = combination.filter((i:string[]) => i.length > 0);
const allCombinations:string[][] = combination.toArray();
const combinationsCount = combination.length;
const limitedBigCombination = Combinatorics.bigCombination(["a", "b", "c"], 2);
const bigCombination = Combinatorics.bigCombination(["a", "b", "c"]);
const nextBigCombination:string[] = bigCombination.next();
bigCombination.forEach((i:string[]) => console.log(i));
const bigCombinationsLengths:number[] = bigCombination.map((i:string[]) => i.length);
const filteredBigCombinations:string[][] = bigCombination.filter((i:string[]) => i.length > 0);
const allBigCombinations:string[][] = bigCombination.toArray();
const bigCombinationsCount = bigCombination.length;
const limitedPermutation = Combinatorics.permutation(["a", "b", "c"], 2);
const permutation = Combinatorics.permutation(["a", "b", "c"]);
const nextPermutation:string[] = permutation.next();
permutation.forEach((i:string[]) => console.log(i));
const permutationsLengths:number[] = permutation.map((i:string[]) => i.length);
const filteredPermutations:string[][] = permutation.filter((i:string[]) => i.length > 0);
const allPermutations:string[][] = permutation.toArray();
const permutationsCount = permutation.length;
const permutationCombination = Combinatorics.permutationCombination(["a", "b", "c"]);
const nextPermutationCombinations:string[] = permutationCombination.next();
permutationCombination.forEach((i:string[]) => console.log(i));
const permutationCombinationsLengths:number[] = permutationCombination.map((i:string[]) => i.length);
const filteredPermutationCombinationss:string[][] = permutationCombination.filter((i:string[]) => i.length > 0);
const allPermutationCombinationss:string[][] = permutationCombination.toArray();
const permutationCombinationsCount = permutationCombination.length;
module.exports = (input, part2 = false) => {
let grid = input
.map(row => row.split``)
let best = Number.POSITIVE_INFINITY
let paths = jsc.permutation(goals).toArray()
paths = _.map(paths, path => {
let nextX = 1
let nextY = 19
let totalSteps = 0
if (part2) path.push('0')
for (let i = 0; i < path.length; i++) {
let key = `${grid[nextY][nextX]},${path[i]}`
if (cache[key]) {
totalSteps += cache[key].steps
nextX = cache[key].x
nextY = cache[key].y
} else {
console.log('calculating', key)
let result = solveOne({
x: nextX,
module.exports = (i, d={}) => {
i = i.map(s => s.match(/^(\w+).+?(\w)\s(\d+).+?(\w+).$/)).reduce((r, v) => {
return (r.k[v[1]] = 1, (r[`${v[1]},${v[4]}`] = +v[3] * {e: -1, n: 1}[v[2]], r))
}, {k: d})
return require('js-combinatorics').permutation(Object.keys(i.k)).map(a =>
a.map((p, k, a) => (i[`${p},${a[k - 1] || a[a.length - 1]}`] || 0) + (i[`${p},${a[k + 1] || a[0]}`] || 0))
.reduce((r, v) => r + v, 0)).reduce((r, v) => r > v ? r : v, 0)
}
module.exports = (i, m='min') => {
var _ = require('lodash'), z = i.map(i => i.match(/(\S+) to (\S+) = (\d+)/)).map(i => ({a: [i[1], i[2]], d: i[3]}))
var x = require('js-combinatorics').permutation(_(z).map('a').flatten().uniq().value())
return _[m](x.map(t => t.reduce((r, v) => ({p: v, d: r.p ? +_.find(z, {a: [r.p, v]}).d + r.d: 0}), {}).d))
}
list.forEach(set => {
if (!set.length) {
return;
}
Combinatorics.permutation(set).forEach(comb => {
results.push(
`vendors${output.chunkDelimiter}${comb.join(output.chunkDelimiter)}`
);
results.push(
`commons${output.chunkDelimiter}${comb.join(output.chunkDelimiter)}`
);
});
});
return results;
module.exports = (input, part2 = false) => {
if (part2) {
const jsc = require('js-combinatorics')
let expected = 'fbgdceah'
let perms = jsc.permutation(expected.split``).toArray()
return perms.find(p => solve(p) === expected).join``
} else {
return solve('abcdefgh'.split``)
}
function solve(initial) {
return input.reduce((value, op) => {
if (op.startsWith('swap p')) {
let [x, y] = op.match(/(\d+)/g).map(i => +i)
let s = value[x]
value[x] = value[y]
value[y] = s
} else if (op.startsWith('swap l')) {
let [, x, y] = op.match(/letter (\w) with letter (\w)/).map(l => value.indexOf(l))
let s = value[x]
value[x] = value[y]