How to use the js-combinatorics.power function in js-combinatorics

To help you get started, we’ve selected a few js-combinatorics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mattapperson / patronus / lib / internalUse.js View on Github external
optional = optional.concat(params.filter(function (param) {

                    // tag the param type so we know what we are looking at later
                    // We must do this becuase to get a truly random combo we must
                    // have a flat array of all param types
                    param.paramType = validation;

                    // Filter for just the optional param combos
                    return !param.flags || !param.flags.required;
                }));

            }
        });

        // OK, now we get all the mix and matched combos, and append required params to each combo
        combos = combinatorics.power(optional).map(function (combo) {

            if (combo.length < 1) {
                combo.push({});
            }
            // add the required params to each combo
            return combo.concat(required);
        });

        // Transform the flat array into an array of objects, where there is a key for each type
        returnedCombos = combos.map(function (combo) {
            var object = {};
            var paramType;

            combo.forEach(function (param) {

                paramType = param.paramType;
github DefinitelyTyped / DefinitelyTyped / types / js-combinatorics / js-combinatorics-tests.ts View on Github external
import * as Combinatorics from "js-combinatorics";

const p:number = Combinatorics.P(1, 2);
const c:number = Combinatorics.C(1, 2);
const factorial:number = Combinatorics.factorial(5);
const factoradic:number[] = Combinatorics.factoradic(5);

const power = Combinatorics.power(["a", "b", "c"]);
const nextPower:string[] = power.next();
power.forEach((i:string[]) => console.log(i));
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;
github DefinitelyTyped / DefinitelyTyped / js-combinatorics / js-combinatorics-tests.ts View on Github external
import * as Combinatorics from "js-combinatorics";

const p:number = Combinatorics.P(1, 2);
const c:number = Combinatorics.C(1, 2);
const factorial:number = Combinatorics.factorial(5);
const factoradic:number[] = Combinatorics.factoradic(5);

const power = Combinatorics.power(["a", "b", "c"]);
const nextPower:string[] = power.next();
power.forEach((i:string[]) => console.log(i));
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;
github chiefsmurph / robinhood-playground / realtime / strategies / rsi.js View on Github external
).toArray().reduce((acc, arr) => {
    
            return {
              ...acc,
              ...Combinatorics.power(arr)
                .toArray()
                .filter(s => s && s.length)
                .reduce((inner, combo) => ({
                  ...inner,
                  [combo.join('-')]: combo
                }), {})
            }
    
          }, {}),
github chiefsmurph / robinhood-playground / realtime / RealtimeRunner.js View on Github external
).toArray().reduce((acc, arr) => {

        return {
          ...acc,
          ...Combinatorics.power(arr)
            .toArray()
            .filter(s => s && s.length)
            .reduce((inner, combo) => {

              combo = [
                'overnight-drops',
                ...combo
              ];
              return {
                ...inner,
                [combo.join('-')]: combo
              };
              
            }, {})
        }
github chiefsmurph / robinhood-playground / realtime / strategies / multi-hits.js View on Github external
).toArray().reduce((acc, arr) => {

      return {
        ...acc,
        ...Combinatorics.power(arr)
          .toArray()
          .filter(s => s && s.length)
          .reduce((inner, combo) => ({
            ...inner,
            [combo.join('-')]: combo
          }), {})
      }

    }, {}),
github chiefsmurph / robinhood-playground / realtime / strategies / macd.js View on Github external
).toArray().reduce((acc, arr) => {

            return {
                ...acc,
                ...Combinatorics.power(arr)
                .toArray()
                .filter(s => s && s.length)
                .reduce((inner, combo) => ({
                    ...inner,
                    [combo.join('-')]: combo
                }), {})
            }

        }, {}),
github NiXXeD / adventofcode / 2015 / day17 / part1.js View on Github external
module.exports = input => require('js-combinatorics').power(input)
    .filter(a => a.reduce((r, v) => r + +v, 0) === 150).length
github chiefsmurph / robinhood-playground / realtime / strategies / golden-cross.js View on Github external
).toArray().reduce((acc, arr) => {

      return {
        ...acc,
        ...Combinatorics.power(arr)
          .toArray()
          .filter(s => s && s.length)
          .reduce((inner, combo) => ({
            ...inner,
            [combo.join('-')]: combo
          }), {})
      }

    }, {}),
  }
github chiefsmurph / robinhood-playground / realtime / strategies / ask-droppers.js View on Github external
).toArray().reduce((acc, arr) => {

        return {
          ...acc,
          ...Combinatorics.power(arr)
            .toArray()
            .filter(s => s && s.length)
            .reduce((inner, combo) => ({
              ...inner,
              [combo.join('-')]: combo
            }), {})
        }

      }, {})