fave77 / Mathball

A JavaScript library for Competitive Programming
https://fave77.github.io/Mathball-Docs/
MIT License
100 stars 49 forks source link

All permutations of a string #84

Closed nilshah98 closed 5 years ago

nilshah98 commented 5 years ago

Do the checklist before filing the issue:

NOTE: Provide a clear and concise description of the feature that needs to be added! Or if its a bug, then provide the necessary steps to reproduce it along with screenshots.

Given a string, return all possible permutations of the string. Edit - Should return all permutations, even for the lesser number of characters

M.getAllPerm("abc")        // ["abc","acb","bac","bca","cab","cba","ac","ab","ca","cb","ba","bc","a","b","c"]
M.getAllPerm("123")        // ["123","132","213","231","312","321","12","13","21","23","31","32","1","2","3"]

// validation tests-
// argument passed should always be a string.
M.getAllPerm(123)           // TypeError
M.getAllPerm(["a","b","c"]) // TypeError

Also, try to implemenet this in an interative manner, to avoid stack overflow for larger strings.

Links - Permutations Iterative GeeksForGeeks Permutation Iterative in JavaScript Permutation Recursive in JavaScript

Category: Mathematical Utilities

sweezy793 commented 5 years ago

I would like to work on this issue.

fave77 commented 5 years ago

@sweezy793 you're assigned!

fave77 commented 5 years ago

@sweezy793 are you participating in GirlScript Summer of Code?

sweezy793 commented 5 years ago

@sweezy793 are you participating in GirlScript Summer of Code?

Yes

fave77 commented 5 years ago

Okay!

fave77 commented 5 years ago

@sweezy793 make a different PR which doesn't modify package-lock.json! One thing you can do is pull all the latest changes and replace your package-lock.json with mine by just copy and pasting its contents before switching to your working branch