Perl: the Markov chain saw | |
PerlMonks |
Re: Rectangle packing...by Necos (Friar) |
on Apr 23, 2002 at 15:55 UTC ( [id://161347]=note: print w/replies, xml ) | Need Help?? |
This is an interesting problem. One solution (simplified) is:
I hope this code makes sense. If you make width and height "properties" of the photos, it's just a matter of dividing the canvas into vertical and horizontal components, iterating through the photos, and throwing an exception when you've gotten too much on the canvas (or at least, that's how I've thought about it). This would even work with while/until/etc... loops, but I thought the foreach was the simplest. Hope this helps just a tiny bit. Theodore Charles III Network Administrator Los Angeles Senior High 4650 W. Olympic Blvd. Los Angeles, CA 90019 323-937-3210 ext. 224 email->secon_kun@hotmail.com perl -e "map{print++$_}split//,Mdbnr;"
In Section
Seekers of Perl Wisdom
|
|