From: Ruby Quiz Date: 2006-01-13T22:41:14+09:00 Subject: [QUIZ] Packing (#62) The three rules of Ruby Quiz: 1. Please do not post any solutions or spoiler discussion for this quiz until 48 hours have passed from the time on this message. 2. Support Ruby Quiz by submitting ideas as often as you can: http://www.rubyquiz.com/ 3. Enjoy! Suggestion: A [QUIZ] in the subject of emails about the problem helps everyone on Ruby Talk follow the discussion. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= by Ilmari Heikkinen You're moving. And that means a whole bunch of boxes need to be moved from the old place to the new one. You've got a pickup truck to do the moving, but it can only hold one vertical level of boxes. The boxes need to be padded with one unit worth of foam on each side that's facing another box. The goal is to minimize the amount of trips you have to do to move all the boxes. The solver program should take two lines of input, first one containing the trunk dimensions (e.g. 10x20), and the second one containing all the box dimensions, separated by spaces (e.g. 1x3 4x8 3x7 9x4 10x14.) The output of the solver should be ascii art of the trunk packings, with each trunkful separated by an empty line. Example: $ ruby solver.rb 10x20 1x3 4x8 3x7 9x4 10x14 **************.***.. **************...... **************.****. **************.****. **************.****. **************.****. **************.****. **************.****. **************.****. **************.****. *********........... *********........... *********........... *********........... .................... *******............. *******............. *******............. .................... ....................