Summer School 14 Assignment 2

download Summer School 14 Assignment 2

of 1

Transcript of Summer School 14 Assignment 2

  • 8/11/2019 Summer School 14 Assignment 2

    1/1

    Second Assignment 25.2.2014

    Due date: August 3, 2014 @ 23:59

    Write a program in C to find the hidden words in a matrix of letters. Words will be created by chainingthe letters. You may start with any letter in the matrix to find the word and proceed in any of 8

    directions (through surrounding 8 characters). You are expected to complete the assignment in twostages.

    In the first stage letters should be searched in straight lines, i.e. once a direction is selected searchshould proceed in the same direction. Words may overlap with each other either partially or totally.Along with the search implementation in the first stage you are expected to implement another searchapproach for the second stage. In this new type of search direction of search may also change at eachletter. Previously used letters cannot be revisited in the same word.

    The maximum size of the matrix is 100x100. The matrix, char wordbox [100][100], is supposed to beinitialized when it is defined in the code. User is expected to enter a string and the program prompts areply. If the word exists, the list of letter chain has to be printed on screen, such as(1,1)(2,2)(3,3)(4,4)(5,5) for APPLE in the below given example. If the word does not exist a messageindicating the state has to be printed on screen. The program terminates when user enters EOF.

    Examples of valid words for the first stage of the assignment

    Diagonals(1,1) APPLE, (4,1) WARD, (4,1) WAR (From upper left to lower right)(7,4) DRAW, (6,5) RAW (Form lower right to upper left)(3,5) PLOT (From upper right to lower left)(8,2) TAPE (From lower left to upper right)

    Straights(4,4) LIER (From left to right)(7,8) STAND (From right to left)(3,5) PIE (from up to down)(4,7) ROOT (from down to up)

    Examples of valid words for the second stage of the assignment

    REALISTIC (4,7)(4,6)(5,6)(6,6)(6,7)(7,8)(7,7)(6,8)(5,8)TESTER (5,1)(4,2)(4,3)(3,2)(2,1)(3,1)

    An example of an invalid word for the second stage

    TESTER (5,1)(4,2)(4,3)(3,2)(4,2)(3,1)

    Note that it is not a valid solution since E (4,2) cannot be revisited

    more than onc e.

    A X S E F V T CE P G Q A D O SR T P J P J O ZW E S L I E R M

    TA O

    LE

    A T CU T R P E L I IK P A D N A T SS T A U R E Y E

    A X S E F V T CE P G Q A D O S

    R T P J P J O ZW E S L I E R MT A O L E A T CU T R P E L I IK P A D N A T SS K A U R E Y E