Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

find words puzzle game in prolog

Options
  • 01-08-2010 11:04am
    #1
    Closed Accounts Posts: 1


    hi i'm new in prolog and i'd get program assignmet to write a "find words puzzle game":

    Given an nxn letter matrix and a list of words, the program should find all the appearances of the words in the matrix and their location. They could appear up-down, right-left and diagonally (over all - 8 directions). A word can appear any number of times (including zero) and they can overlap (like the words bad, and adult) and even be a subset of one another (like the words bad and ad).
    i'm hopeless can anybody help me???
    i don't know how to start!!!


Comments

  • Registered Users Posts: 19,025 ✭✭✭✭murphaph


    A matrix is just a multidimensional array (an array with other arrays as elements inside it). If you look at it that way (draw it on a piece of paper, and start thinking about how you search through arrays), you can see you will need some loop to look for the first letter, then if it find it, to look for the next and so on (inside the first loop). If it doesn't find it, the loop will need to break out to start looking for the desired letter in the next location, or if all "directions" have been checked, to start looking for the first letter of the next word until all words have been searched for.

    I imagine you will have nested loops to do the searching. I presume this is a college project, so it's not much use to your education for someone to just write the code for you. I'm new to programming to, you will learn by solving the details of the problem yourself.

    Arrays (as I am finding out in work) are always going to be at the core of data manipulation or thereabouts, so it's good to work with them and learn how to handle them. If the more experienced programmers here feel I'm way off, please correct. PS: I don't know anything about prolog, but the method of searching through arrays is common to almost all programming languages.


Advertisement