Sorry i deleted the other post by mistake, was trying to edit it.
No clue how to do this. Hints would be very appreciated.
Sorry i deleted the other post by mistake, was trying to edit it.
No clue how to do this. Hints would be very appreciated.
One way that might help is trying to imagine, how this could be done by hand on piece of paper.
says the function has three parameters, does that mean you call the function with three parameters? I find this project to be too much of a jump in difficulty. I don’t think anyone in the forum can solve this.
If you look at the tests it shows the function is called with only one argument:
4. permuteString("fcc") should return [ "fcc", "cfc", "ccf" ].
However, internally perhaps the function EDIT: calls itself with 3 arguments?
Yes, maybe there is two functions
do you think you can solve this? Curious
I will solve it, but I’m on deck and you’re at bat.
I’m cheering you on for a home run and here if you need support.
Hey Thanks!! If you solve it I will be super impressed.
You’re going to solve it too.
Frankly I would avoid recursion at all costs because it still confuses me. I get it but it’s just so hard to really visualize.
We’ll get this though, it’s not rocket science.
Additional (optional) parameters are to help with implementing recursive solution. User stories are making fairly good job with hinting how everything should work internally.
with respect, you think you can solve this? I dont think you can, Its harder than you think. What do you do with the removed characters and how do you get different combinations that are not duplicated
I’m not sure what you’re trying to achieve with these comments? Try to focus on your own work.
Need guidance? Share your code here.
you use it to build the permutations as the prefix
user story 2
The prefix value would accumulate characters to form a permutation.
Hey that message was for Sanity.
" User stories are making fairly good job with hinting how everything should work internally". I was asking for hints/help and that was Sanity’s response.
I dont understand what that means. Wait…i may have an idea.
I know, it doesn’t really make a difference, does it? It’s not productive and I’m not sure what you’re trying to get at exactly.
It kind of reminds me of an attempt at “reverse psychology” where you are trying to goad someone into solving this for you by saying they can’t do it.
They were trying to provide good advice saying that you should read over the User Stories more carefully.
In any case it’s almost impossible to determine what you understand or not or what guidance to give based on anything you’ve said.
Try it out, share some code, or ask more specific questions.
I honestly dont think many people will be able to solve it in this forum. Its too tricky of a problem so I was just voicing my opinion. I was a little irritated Freecodecamp included it as one of the labs as it seems way too much of jump in difficulty. Not intentionallly trying to use reverse psychology. I dont think people will be able to solve it. Sanity made it sound like it was easy, that the hints for the outline of project were enough.
This just doesn’t matter, focus on your own work.
Recursion is the 2nd most difficult thing in programming after naming things. I’m not surprised it’s hard.
function permuteString(str){
let results = ['']
let prefix
if(str.length === 0){
results.push(str)
return
}
str.split("").forEach((item, index) => {
permuteString(item.slice(0,index - 1) + item.slice(index))
})
}
console.log(permuteString('hi'))
Hey. This is what i have so far. Im going to swap out the forEach() for a for loop
function permuteString(str){
let results = ['']
let prefix
if(str.length === 0){
results.push(str)
return
} else {
results.push(str)
for(let i = 0; i < str.length; i++){
let remainingStr = str.slice(0, i-1) + str.slice(i)
let removedChar = str.slice(i-1, i)
permuteString(remainingStr)
}
}
}
console.log(permuteString('hi'))
Im getting a stack overflow. Dont understand how to use the prefix variable