Results 1 to 10 of 13

Thread: Beginners Programming Challenge no.19

Threaded View

  1. #1
    Join Date
    Aug 2005
    Location
    Sweden
    Beans
    407

    Beginners Programming Challenge no.19

    Beginners Programming Challenge no.19
    Since I won the 18th challenge I have tried to come up with the next one,
    hoping it will be challenging without being insurmountable:

    Crossword creator helper
    Description
    Creating crosswords (crossword example in post 3) is a difficult task, and a program to help out can speed up the process. It is your task to write the program following the specifications:

    The program will read data from a file with the following format:

    • One line with one number denoting the width in cells of the crossword
    • One line with one number denoting the height in cells of the crossword
    • Multiple lines containing X,Y,D,W where
      • X and Y are numbers signifying the position where the 'question cell' responsible for the word is placed (0,0 is the upper left corner)
      • D is the direction of the word--signified by one letter, either h (horizontal) or v (vertical)
      • W is a word (containing only lowercaze a-z)

    So the input 0,0,h,foobar means that #foobar is placed in the upper left corner of the crossword, where # is the little question box hinting at the word foobar.

    Constraints
    • A cell may contain a single letter or a '#' signifying that it is used by a question box, or be unused '.'
    • A question cell (#) may be overlapped by another question cell (eg for a word in a different direction)
    • The resulting crossword should be printed
    • Upon discovering an impossible word placement the input parsing should stop and the crossword so far should be printed. The impossible word cells should be marked with '$' and the word and position should be printed. (see example 2)
    • If the placement coordinate of the word is outside the crossword this should be printed (see example 3) but no dollar signs are needed,
    • If the placement coordinate is inside the crossword, but the word would stick out, this should be printed, but the parts inside should be marked with $ (see example 4)


    Example Input/Output
    1) Valid
    Input:
    Code:
    8
    6
    1,2,h,car
    3,0,v,bar
    4,1,v,rose
    2,3,h,robot
    1,2,v,dog
    Output:
    Code:
    ...#....
    ...b#...
    .#car...
    .d#robot
    .o..s...
    .g..e...
    2) Invalid word
    Input:
    Code:
    8
    6
    1,2,h,car
    3,0,v,bar
    4,1,v,rose
    2,3,h,fruit
    1,2,v,dog
    Output:
    Code:
    ...#....
    ...b#...
    .#car...
    .#$ro$$.
    ....s...
    ....e...
    Horizontal word 'fruit' can not start from cell 3,2 (letter mismatch)
    3) Invalid word placement
    Input:
    Code:
    8
    6
    1,2,h,car
    3,0,v,bar
    4,100,v,rose
    2,3,h,fruit
    1,2,v,dog
    Output:
    Code:
    ...#....
    ...b....
    .#car...
    ...r....
    ........
    ........
    Vertical word 'rose' can not start from cell 4,100 (out of bounds)
    4) Invalid word size
    Input:
    Code:
    8
    6
    1,2,h,car
    3,0,v,bar
    4,1,v,rosebud
    2,3,h,robot
    1,2,v,dog
    Output:
    Code:
    ...#....
    ...b#...
    .#car...
    ...r$...
    ....$...
    ....$...
    Vertical word 'rosebud' can not start from 4,1 (size mismatch)
    Judgement criteria
    The judgement criteria pretty standard, the program has to work,
    code should be readable, it has to be your code, etc. etc...

    Entries accepted until and including 2011-04-24

    Best of luck.
    Last edited by red_Marvin; March 24th, 2011 at 03:06 AM.
    Don't peach linux. Melon it!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •