Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

No dependencies package to calculate and list permutation and combination.

License

NotificationsYou must be signed in to change notification settings

kota-yata/Percom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm versionBuild StatusLicense: MIT

NPM

npm package listing and calculating combination and permutation

Usage

$ npm i percom

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

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

Example

constarray=["A","B","C"];constresult1=percom.com(array,2);//result1 = [ [ "A", "B" ], [ "A, "C ], [ "B", "C" ] ]constresult2=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

constarray=["A","B","C"];constresult1=percom.per(array,2);//result1 = [ [ 'A', 'B' ], [ 'A', 'C' ], [ 'B', 'A' ], [ 'B', 'C' ], [ 'C', 'A' ], [ 'C', 'B' ] ]constresult2=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 underMIT license

Development

yarninstall// before create PRyarnmocha

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

Developer

Kota Yatagai (https://kota_yata.com)

About

No dependencies package to calculate and list permutation and combination.

Topics

Resources

License

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp