COP3353 - 2013 Spring
Assignment 3 "Solving Anagrams"
Due by 5:00pm Tuesday, April 2
Late assignments (50% grade penalty) can be turned in until April 9

Perl script for solving anagrams

Step 0

Login to linprog{1,2,3,4}.cs.fsu.edu. I recommend going into bash, but it's not really necessary for this assignment, just convenient.

Step 1

Create a directory called assign3/ in your home directory:

Change directory into assign3/:

Create two new Perl scripts, build.pl and search.pl.

(Hint: you may want to also log into linprog{1,2,3,4}.cs.fsu.edu with a second window, if you don't want to use a "shell" buffer inside of emacs for testing your script.)

Your assignment is to have build.pl create a dictionary to help someone solving an anagram.

This dictionary will have entries that look like this:

arst:Arst,arts,astr,astr-,astr.,ATRS,rats,sart,star,stra,tars,TRSA,tsar
aaegln:alange,alnage,Angela,Anlage,anlage,galena,lagena
aaeinrst:antisera,Artesian,artesian,Asterina,asternia,erastian,ratanies,seatrain
aaeinrstt:attainers,reattains,tearstain
aaeinrtz:atrazine,nazarite,triazane
aaeirst:aristae,Artesia,asarite,Astaire,Asteria,asteria,atresia,setaria
aagnor:agroan,Angora,angora,Anogra,Aragon,arango,Argoan,onagra,organa
aagnopr:paragon
abdeirs:abiders,braised,darbies,sea-bird,seabird,side-bar,sidebar

Each entry has a left-hand side that is just the sorted letters of each of the entries on the right-hand side. The two sides are separated by a colon. The entries on the right-hand side are separated by commas.

So, for instance, the key for the word "spot" would be "opst". The key for the word "tops" would also be in "opst", and thus they should both be in an entry like:

opst:opts,OSTP,Post,post,post-,POTS,pots,SPOT,spot,stop,TOPS,tops

Your build.pl script should be run over the file on linprog1 named /usr/share/dict/linux.words:

You can check your resulting dictionary.txt file against this one.

So for instance, the entry for "you'll" should look like:

llouy:you'll

And for the word "a1", it shouldn't appear in your dictionary.txt file.

The entry including "Atlas" should look like:

aalst:Aalst,ATLAS,Atlas,atlas,salat,Salta,salta,Staal,talas

Your other program, search.pl, should take as a single argument a word to be looked up. Your program should take whatever is entered and put it in sorted order, and then search your dictionary.txt file for that entry.

% ./search.pl atlsa
The possible anagrams for "atlsa" are "Aalst,ATLAS,Atlas,atlas,salat,Salta,salta,Staal,talas"

Submission

Like the previous assignments, you should cd back into your home directory and create a tar file, named with the result the uuidgen program:

Please make sure that all three files (dictionary.txt, build.pl, and search.pl) are included in the tar file.

And, as previously, please copy the tar file to the directory ~rlangley/Assignment03/.