User Profile
Collapse
-
My mind is blown. Thank you sir~ I think I understand it now :) -
Ok thanks, I think I am getting somewhere, but what exactly happens after the function exits and the string ABC is made?
At first I thought after the function exits:
It rolls back to the pause state of AB from the last recursive call, and C is increased to 1.
Then it rolls back to the second last recursive call with A, and B isn't available since it was incremented after this recursive call. But C is now 1 since the incrementation...Leave a comment:
-
Problems understanding working recursive combinations code
...Code:def wordFunc(myDict, currentWord, n): if n==0: #Base case print(currentWord) else: for char in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ": if myDict[char] <= 0 : continue elif myDict[char] > 0: #Decrease current dictionary's character value by 1 then call function myDict[char] -=1 wordFunc(myDict,currentWord+char,n-1) #Increase
No activity results to display
Show More
Leave a comment: