0

#1

Hey there, I’m trying to wrap my brain around this challenge but so far the “Aha” moment haven’t occurred. I want to solve it by understanding the concept behind Heap’s algorithm and translating it into JS and without using someone else’s code. So far I’ve read the Wikipedia entry about it and the pseudo code on the Hint page but it didn’t click for me. What I don’t understand (and please try to explain it without code ) is how to determine whether to push the string into a result array, or to permutate it, and according to what principle or measure to permutate it.

Thanks!

#2

Well if you were not coding a solution how would you do it?

aaab -> 4 perms that I can think of [ aaab ; aaba ; abaa ; baaa ]
abcd -> many more! Which given time I can come up with.
Let’s see [ abcd ; abdc; bacd; badc ; acbd; acdb ; bcad; bcda; dcab; dcba; dabc; dbac; cdab; cdba; cabd; cadb;]
So in my head I was swapping pairs of letters and moving them in different places, all along checking back whether I have found the pair before.
Not sure whether this helps but I think the trick sometimes is to try to understand how you work things out in your head.

#3

Not Really helped.
I’m actually interested in writing a recursive Heap’s algorithem by myself, because I rather solve this challenge (once I manage to write Heap’s) mathematically.
I managed to recurse and push the first string, and now struggling with the timing of calling the swapping and writing the right conditions for it.
Quite of a challenge!