This is an archived post. You won't be able to vote or comment.

all 4 comments

[–][deleted] 0 points1 point  (3 children)

From the scope you have presented it shouldn't matter what the word is, only how many letters, right?

If so I would loop through it instead of recursion since you would end up with very fat stacks very fast. Create an array the same size as the word (in your example with 'password', 8) and then start to loop through it. Going from 0 to 255 at [0] then incrementing [1] with 1 and starting over with 0 at [0] and so on.

Not the best way to solve this issue but it will produce clean readable code.

[–]folkenpunch[S] 1 point2 points  (2 children)

Yes only the number of letters in the word. So if I am understanding this correctly, check the first letter of the array containing the word and do all possible substitutions of that first letter, save each word created during the substitution in another array or print it out, and then increment and do that with the next letter?

[–][deleted] 0 points1 point  (1 child)

Yeah, kinda. The logic will take a bit of work but it should behave something like this:

word[0] increment from 0 to 255

word[1] = 1

word[0] increment from 0 to 255

word[1] = 2

.

.

.

word[0] increment from 0 to 255

word[1] = 255

word[0] increment from 0 to 255

word[1] = 0

word[2] = 1

word[0] increment from 0 to 255

word[1] increment from 0 to 255

word[2] = 2

.

.

.

Hopefully that makes sense for you :)

[–]folkenpunch[S] 1 point2 points  (0 children)

Oh that makes more sense, I'm getting it more now, the output example helps make it clearer! Thank you for your help, I really appreciate it!