Hacker News new | ask | show | jobs
by fzxu22 1610 days ago
Thanks for the reply! I really appreciate your feedback on this. I wasn't giving much thought about coding style and naming etc. when I worked on this, just wanted to get it running asap. I'll definitely take a better look at your suggestion (I'm not very familiar with perl) and see if I find any time to improve this thing. cheers.
1 comments

My cheat script will not help with refactoring your code, but note that with a helper data structure, you do not need multiple passes over the guess to mark each letter in one of three states. Write down the process in human language first, then write the code to do the thing instead of immediately diving into the code and rearranging it until it produces the desired result.

These exercises are great at improving your intuition and aptitude for refactoring code in a way that makes it more maintainable, easier to read and reason about.