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.grayproductions.net/ruby_quiz/ 3. Enjoy! -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= For this, the tenth Ruby Quiz, let's tackle a classic problem. I've seen it just about everywhere in some form or another, but I believe Donald E. Knuth may have first made it a popular challenge. This week's quiz is to layout crossword puzzles. A puzzle layout will be provided in a file, who's name will be passed as a command-line argument. Those layouts will be formatted as such: X _ _ _ _ X X _ _ X _ _ _ _ _ _ _ _ X _ _ _ X _ _ X X X _ _ _ X _ _ _ X _ _ _ _ _ X Xs denote filled in squares and _s are where a puzzle worker would enter letters. Each row of the puzzle is on a new line. The spaces are a readability tool and should be ignored by your program. In the final layout, these squares should look like this: ###### Filled in square ###### ###### ###### ###### Letter square # # # # ###### Now, when we combine these squares, we don't want to double up on borders, so: _ _ X _ should become: ########### # # # # # # ########### ###### # ###### # ########### As a style point, many crosswords drop filled squares on the outer edges. We wouldn't want our Ruby generated crosswords to be unfashionable so we better do that too. X _ X _ _ _ Would render as: ###### # # # # ################ # # # # # # # # ################ The final step of laying out a crossword puzzle is to number the squares for word placement. A square is numbered if it is the first square in a word going left to right or top to bottom. Numbers start at 1 and count up left to right, row by row going down. Putting all that together, here is a sample layout. (This was generated from the layout format at the top of this quiz.) ##################### #1 # #2 #3 # # # # # # #################################### #4 # ######5 # #6 #7 # # # ###### # # # # #################################### #8 # #9 # # #10 # # # # # # # # # # ##################### ########### # ######11 # # # ###### # # #################################### #12 #13 # ######14 #15 # # # # # ###### # # # #################################### #16 # # # # # # # # # # # ########################## Solutions should output (only) the finished crossword to STDOUT.