Click to See Complete Forum and Search --> : Challenge


gomisute
03-06-2008, 10:53 PM
Here is an interesting challenge...
---------------------------------

-You have a 4x4 grid (4 rows, 4 columns).
-in each box in the grid there is a letter from the alphabet (non-repeating)
-write an algorithm to do the following:

>>take all the possible 2, 3 and 4 letter combinations out of the grid ONLY in rows and columns (no diagonals)
>>if any of the combos are words, add them to a list of words

you can use the following helper functions:

getLetterAt($row,$col) // returns the letter at position row (int) and col (int) in the grid

isWord($word) // returns true if string word is a dictionary word

addWordToList($word) // adds string word to the list

----------------

Have fun...
I'm interested to seeing different ways of doing this...

TheRave
03-07-2008, 02:31 AM
Sounds like a piece of coursework to me.

Also something that would make more sense to be written in v, vb or java. Not really a web development thing.

gomisute
03-07-2008, 12:33 PM
I don't know what you mean by "coursework".
---
Anyway, it is possible to do this in php.

Just think of the grid as an array of some sort.

and this type of thing can be a web dev type thing...especially in an online game.

TJ111
03-07-2008, 02:24 PM
The "predefined" functions that you limit "us" to look suspiciously like homework to me.

gomisute
03-07-2008, 06:15 PM
Hahaha! That's so funny.
:)

OK, I guess some people can't take a challenge for what it is...just a challenge. In case you didn't notice, I'm not asking for an answer as I don't need one. I just thought challenging questions bring about positive thought we can all learn from in one way or another.

I'm a 35-year-old developer...I don't have any homework to post here...my only homework is to make money to pay my bills and fulfill my obligations to my family and I am doing that well enough without the help of this forum. I haven't had homework since I left high school 18 years ago and I never went to any school after that, either...nor did I ever take any courses.

---
The functions are part of the challenge...so you can focus on the logic involved rather than the "how-to-check-a-word-against-a-dictionary" type issue. But hey, if you want to attempt it without a helper function, be my guest...no one is "limiting" you to anything.

---
Anyway, anyone who doesn't want to try it, don't try it
...anyone else who wants to make it interesting to read this thread, please add your thoughts on how to solve or how to go about to solving this.

Jeff Mott
03-07-2008, 06:45 PM
gomisute, even if this is a genuine challenge, your post still has all the telltale signs of a student trolling for someone to do their homework.

gomisute
03-07-2008, 07:22 PM
:)
I guess I wouldn't know...I'm not a student nor have I ever been since high school.
anyway...
apparently the talent lacks or no one is interested to try this.

oh, well...
That's the last time I try to make things interesting on this forum.

I'll just stick to my answering questions to help others...which is what I mostly do in js and php forums.