As part of the interview for my current developer job I was
asked to produce a perl script that could find all words,
of 3 letters or longer in the unix dictionary that where
hidden in a 20 by 20 word search grid. As normal with these
things the words could be vertical, horizontal or diagonal
and can be either normal or reversed. I had just under 24
hours to complete the script.
This is the test grid I’ve used to
test the scripts
Well at the time this was quite a challenge, but suffice to
say I did get the script sort of working in time and it did
beat the others submitted at the same time. In fact I was
told later that my version was the second fastest version.
This is included the versions written by the development
team at the time!
Since then I've tried porting the the script to other
languages just as a way of getting in to that language.
It's become a more advanced version of the famous 'hello
world' program for me.
So here are the versions I've completed so far.
Perl
This is the version as it was completed for my challenge.
The version I had on my hard drive was quite...er primitive
in style and in any case wasn’t quite finished (the
diagonal line scans weren’t working correctly), so I’ve
taken it and finished it and tweaked it so looks more like
the sort of code I’d normally write now. I’m not going to
say it’s coded neatly or well (at this point it’s been a
year since I’ve coded professionally). In any case it works
so here is the code complete with comments.