1

I've just finished crack of problem set 2. My solution, though, seems quite ugly to me, as it was just some mindless brute force (in which I frankly struggled with strings for a while).

E.g. to iterate through words with 4 letters, I used four nested for-loops. That does not seem nice to me.

Is there any better way of approaching this problem?

2

I have used recursion, wrapped inside one loop for the number of digits. Which I think is the same approach mentioned by User20025. The recursion concept is that a 3 letter password is 1 letter plus a 2 letter password. The whole thing finds the password for Malan (NOPE) in 15 seconds in the IDE50. The max loop (ZZZZ) is done in 25 seconds.

0

I've done the same. It seems that we both have same problem solving mindset xD. Would you like to be my coding partner bro?

2
  • haha sure, why not ^^
    – Kezer
    Aug 28 '17 at 18:13
  • @Kezer so where should I contact you?? Sep 30 '17 at 11:14
0

I had the exact same problem! I found out that you can call a function on itself, which has helped me to shrink the four for-loops into one for-loop increasing in character size.

However, I can't solve it doing this :( really frustrating. My code messes up for some reason.

1
  • Hm, that's interesting, I'm not sure it'd be faster, though. Recursion tends to be quite slow.
    – Kezer
    Sep 9 '17 at 6:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .