I know why it is failing the test; the values exceed the max set size. I also tried with an array. I also tried with a numeric count that increments in the if statement, but since it still relies on the set mutation, it produces the same failure for test 4.
Yeah, that’s what I meant, there needs to be a way to count only unique permutations, and it seems storing it in an array or set or something is the way to access only unique permutations. If I use only an incremental count, it will count all permutations, including those that appeared before — for “racecar”, the incremental count exceeds 5000. The issue is not the set, it’s the call, but I don’t know how to resolve it…
“freeCodeCamp” does indeed trigger an infinite loop because as I mentioned from beginning, the size exceeds the set—it probably exceeds max call stack size