From 2acf4c1c012807d11a2467a902f9d7e8d770fb2f Mon Sep 17 00:00:00 2001 From: Rubin Bhandari Date: Sun, 4 Oct 2020 20:35:09 +0545 Subject: [PATCH 1/4] Create CreatePurmutations.js --- String/CreatePurmutations.js | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 String/CreatePurmutations.js diff --git a/String/CreatePurmutations.js b/String/CreatePurmutations.js new file mode 100644 index 000000000..28392ceb2 --- /dev/null +++ b/String/CreatePurmutations.js @@ -0,0 +1,37 @@ +function permutations(str){ + +// convert string to array +let arr = str.split(''), + +// get array length + len = arr.length, +// this will hold all the permutations + perms = [], + rest, + picked, + restPerms, + next; + +// if len is zero, return the same string + if (len === 0) + return [str]; +// loop to the length to get all permutations + for (let i=0; i Date: Sun, 4 Oct 2020 20:45:18 +0545 Subject: [PATCH 2/4] ran standard --- String/CreatePurmutations.js | 54 ++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/String/CreatePurmutations.js b/String/CreatePurmutations.js index 28392ceb2..3df7a6d94 100644 --- a/String/CreatePurmutations.js +++ b/String/CreatePurmutations.js @@ -1,37 +1,31 @@ -function permutations(str){ - +const createPermutations = (str) => { // convert string to array -let arr = str.split(''), + const arr = str.split('') -// get array length - len = arr.length, -// this will hold all the permutations - perms = [], - rest, - picked, - restPerms, - next; - -// if len is zero, return the same string - if (len === 0) - return [str]; -// loop to the length to get all permutations - for (let i=0; i Date: Thu, 15 Oct 2020 16:38:32 +0545 Subject: [PATCH 3/4] Update and rename CreatePurmutations.js to createPurmutations.js --- String/{CreatePurmutations.js => createPurmutations.js} | 6 ++++++ 1 file changed, 6 insertions(+) rename String/{CreatePurmutations.js => createPurmutations.js} (70%) diff --git a/String/CreatePurmutations.js b/String/createPurmutations.js similarity index 70% rename from String/CreatePurmutations.js rename to String/createPurmutations.js index 3df7a6d94..8f3bc708b 100644 --- a/String/CreatePurmutations.js +++ b/String/createPurmutations.js @@ -1,3 +1,9 @@ +/* +a permutation of a set is, loosely speaking, an arrangement of its members into a sequence or linear order, or if the set is already ordered, a rearrangement of its elements. +The word "permutation" also refers to the act or process of changing the linear order of an ordered set +More at : https://en.wikipedia.org/wiki/Permutation +/* + const createPermutations = (str) => { // convert string to array const arr = str.split('') From 90c4900ccad085cf0f83dbfcdced88fe57253b74 Mon Sep 17 00:00:00 2001 From: Rubin Bhandari Date: Thu, 15 Oct 2020 16:39:00 +0545 Subject: [PATCH 4/4] Update createPurmutations.js --- String/createPurmutations.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/String/createPurmutations.js b/String/createPurmutations.js index 8f3bc708b..1b3cbb06a 100644 --- a/String/createPurmutations.js +++ b/String/createPurmutations.js @@ -2,7 +2,7 @@ a permutation of a set is, loosely speaking, an arrangement of its members into a sequence or linear order, or if the set is already ordered, a rearrangement of its elements. The word "permutation" also refers to the act or process of changing the linear order of an ordered set More at : https://en.wikipedia.org/wiki/Permutation -/* +*/ const createPermutations = (str) => { // convert string to array