Git Product home page Git Product logo

permutations's Introduction

Combinations and permutations

This is a simple and naive approach to find all possible permutations in all available combinations of a given string.
The rule is simple - each letter of a given string should be used in all available places with all available combinations.

A B C D = 64
--------
4*3*2*1 = 24
4*3*2   = 24
4*3     = 12
4       = 4

We have two versions a.js and b.js. They should be run via cli passing your input string.

a.js

$ node a.js 'abcd'
This goes throught all available iterations and outputs everything it generates in to output.txt file. This apporach is not fast and it has limitations like JavaScript heap out of memory when string is longer than 13 characters. In the end it takes some time to write everything to the file.

b.js

$ node b.js 'abcd' 3
This one has wordlist intergated. It stops imidiatly if available permutation was found in the word list. This also takes aditional parameter - desired word length.
It is much slower than a.js since on each iteration it is checking wordlist if it is a real word.
This is an example of non recommended solution from performance wise.

permutations's People

Contributors

denistimofijuk avatar

Watchers

 avatar

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.