Giter VIP home page Giter VIP logo

percom's Introduction

Percom

npm version Build Status License: MIT

NPM

npm package listing and calculating combination and permutation

Usage

$ npm i percom

1. Listing every possible combinatioins (組み合わせ)

  import percom from "percom";

  percom.com(array,num); 
  //array => Target array (対象の配列)
  //num => Number of elements in a combination (組み合わせの数)

Example

  const array = ["A","B","C"];
  
  const result1 = percom.com(array, 2);
  //result1 = [ [ "A", "B" ], [ "A, "C ], [ "B", "C" ] ]
  
  const result2 = percom.com(array, 1);
  //result2 = [ [ "A" ], [ "B" ], [ "C" ] ]

Count the number of possible combination (組み合わせの数を数える)

  percom.countCom(n, r);
  //n => Number of elements in an array (要素数)
  //r => Number of elements in a combination (選ぶ要素の数)

Example

  percom.countCom(8, 3);
  // => 56

2. Listing every possible permutaiton (順列)

  percom.per(array,num);
  //array => Target array (対象の配列)
  //num => Number of elements in a permutation (一つ一つの順列の要素数)

Example

  const array = ["A","B","C"];
  
  const result1 = percom.per(array, 2);
  //result1 = [ [ 'A', 'B' ], [ 'A', 'C' ], [ 'B', 'A' ], [ 'B', 'C' ], [ 'C', 'A' ], [ 'C', 'B' ] ]
  
  const result2 = percom.per(array, 1);
  //result2 = [ [ "A" ], [ "B" ], [ "C" ] ]

Count the number of possible permutation (順列の数を数える)

  percom.countPer(n, r);
  //n => Number of elements in an array (要素数)
  //r => Number of elements in a permutation (一つ一つの順列の要素数)

Example

  percom.countPer(8, 3);
  // => 336

License

percom is under MIT license

Development

yarn install

// before create PR
yarn mocha

Since lint-staged and husky are set up, your code will be formatted before commit.

Developer

Kota Yatagai (https://kota_yata.com)

percom's People

Contributors

codacy-badger avatar dependabot[bot] avatar hands-on-sample avatar kota-yata avatar pubkey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

pubkey

percom's Issues

Debugging for browser usage

Currently, this package is only available on node.js. Since there will be some needs on browser, I'm going to make third party CDN of this package usable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.