Submit an Entry

To enter the challenge, you need to signup or login.

This Challenge's Best Entries [View All]

(View the Overall | Perl | PHP | Python | Ruby leaderboard.)

Rank User Size Language Score [?]
1st ySas 181 Perl 10,000 (v58)
2nd Mark Byers 209 Ruby 8,660 (v113)
3rd flagitious 225 Ruby 8,044 (v23)
4th tybalt89 232 Perl 7,801 (v1)
5th shinh 252 Ruby 7,182 (v43)
6th ksk 264 Ruby 6,856 (v4)
7th kounoike 279 Perl 6,487 (v19)
8th grizzley 286 Perl 6,328 (v4)
9th jojo 291 Perl 6,219 (v19)
10th irori 292 Ruby 6,198 (v26)

See who is active in this challenge →

Crossword

(Challenge added 1509 days ago.)

Only drawing them, not solving them ... yet!

Discuss This Challenge →

The Problem

Today, we'll be drawing some crosswords in ASCII according to the simple rules below.

(Before we get started, Some people may recognise the challenge as being the same as Ruby Quiz #10. A reminder though - Instead of the nice, elegant solutions submitted to Ruby Quiz, we're after the shortest, nastiest ones here!)

The rules are as follows :

  • You will receive a crossword grid on stdin. Your program should draw a larger representation of this grid, complete with numbers for the clues, on stdout.

  • The grid will consist of multiple lines containing capital Xs ("X") and underscores (_). An X denotes a filled-in square, and an _ is a blank square. Any whitespace within each line should be ignored. An example grid would be

    _____X_
    _XX_XX_
    _X_____
  • For each X, you should output

    ######
    ######
    ######
    ######

    and for each blank square, you should output

    ######
    #    #
    #    #
    ######
  • When combining squares, you should collapse the borders together so that the grid

    __
    X_

    would look like

    ###########
    #    #    #
    #    #    #
    ###########
    ######    #
    ######    #
    ###########
  • You should drop any filled-in squares which form the outer age of the crossword.

    So,

    X_X
    ___

    would be rendered as

         ######
         #    #
         #    #
    ################
    #    #    #    #
    #    #    #    #
    ################
  • The final step is to add numbers to indicate where the clues fit into the crossword. A square is numbered if it is the start of a word going either left to right, or from top to bottom. Numbers start at 1, and increase left to right, top to bottom and should be placed so there are no spaces between the number and the border to the left.

    So, the previous diagram with clue numbers included would look like

         ######
         #1   #
         #    #
    ################
    #2   #    #    #
    #    #    #    #
    ################

Other Information

  • Your program will be ran four times with various grids. See below for the grids your code will be given.

Examples

These are the grids that will be given to your program and the expected output for each of the four runs :