![]() |
|
"be consistent" | |
PerlMonks |
Re^9: Need help with Peal!by roboticus (Chancellor) |
on Nov 26, 2012 at 02:50 UTC ( #1005543=note: print w/replies, xml ) | Need Help?? |
No, the hash is just to keep track of the letters in use. You can also use the hash to tell if you're already using a letter when generating a random letter--if you've already used that random letter, try another random letter. If you think about how *you* would do it with dice, paper and pencil, you can tell the computer to do the same thing. For example: You want to generate 8 different letters. How would we do it by hand? Like this:
So for a piece of paper, I'll use a hash (it's much easier to use than individually named variables). So let's convert our manual procedure to code:
Basically, when I code, I break the problem down into smaller problems. Just keep doing that. Eventually, the problems will be simple and you can write the code for it. In your assignment, you've got several steps. You just need to break each of those sections into smaller and smaller parts. But in order to do so, that means that you have to figure out how you would do it by hand. Then you can automate it. ...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|