CMPS-3350 Lab 6

Programming With Style

Work with your group to complete the challenges below. You should divide up the work among your group members. All the problems may be discussed among group members, but each program will be written by an individual student.

Write your own program in your Odin directory 3350/6/

Name your program lab6n.cpp where n is 1, 2, 3, 4, 5, 6, etc.

Please include a Makefile that builds your program.

Rules:
Your program must have...
   . at least one function other than main.
   . one or more conditional statements.
   . one or more loop structures.

Code should follow the Linux Kernel coding style guide.
K&R bracing, spacing, and indenting.

Each program will have a comment block at the top indicating:
    . who wrote the program
    . the assignment and challenge number or letter
    . other relevant information
    . your own name will be at the very top

All of the challenges require the processing of the following file on Odin...

/usr/share/dict/cracklib-small

1. Do not copy this file to your local folder.
2. Do not copy any parts of the file into your source code.
3. Do not localize the path to work only from your directory.

Run your program on an 80-character wide terminal.

Your program output should be similar to the example below.
$ ./lab6x 10000

3350 Lab-6 Challenge #x

File successfully opened.

Words found:

this
that
and
the
other

Total letters in all words: 19

File closed.
End of program.


Challenge 1
Using standard hexadecimal digit-to-letter conversions:

a=10  b=11  c=12  d=13  e=14  f=15

1. Look at each word with 6 letters or less.
2. Remove all letters except a,b,c,d,e,f.
3. Calculate the hexadecimal value of the remaining word.
4. Add the value to a running total.
5. Stop when your total is equal or greater than the command-line value.

$ ./lab61 10000

3350 Lab-6 Challenge #1

File successfully opened.

word: 2nd      val: 13       tot: 13
word: 3rd      val: 13       tot: 26
word: a        val: 10       tot: 36
word: aaa      val: 2730     tot: 2766
word: aaas     val: 2730     tot: 5496
word: aarhus   val: 170      tot: 5666
word: aaron    val: 170      tot: 5836
word: aau      val: 170      tot: 6006
word: aba      val: 2746     tot: 8752
word: ababa    val: 703162   tot: 711914

File closed.
Running total reached goal at word: ababa
End of program.
Try the number 236000646 and tell Gordon which word it stops on. Also try 92648000 and report the results.


Challenge 2
List the 20 longest words in the dictionary with no duplicate letters.

Neatly display the words without any scrolling of the terminal.


Challenge 3
Find all words that are spelled the same forward and backwards.

Look at words that are at least 4-letters long.

Neatly display the words without any scrolling of the terminal.

At the end...
Indicate how many words were found.
Indicate the second-most common letter in all the words combined.


Challenge 4
How many words are made up of exactly 3 different letters.

Look only at words that are at least 4-letters long.

Neatly display the words without any wrapping or scrolling of the terminal.



Challenge 5
How many words have just 1-letter that's not a vowel?

Look at words that are at least 2-letters long.

Neatly display the words without any wrapping or scrolling of the terminal.



Challenge 6
Sort the letters of each individual word in the dictionary lexicographically.

Look at just the new words created.

There will now be some duplicate words.

How many new words occur more than once?

What are the 5 most repeated words?  <--- extra effort required



Challenge 7
How many words, when spelled backwards, match another word in the dictionary?

The words cannot be a palendrome.

Neatly display the words without any wrapping or scrolling of the terminal.



Challenge 8
How many words have all the same letters as another word in the dictionary?

Each word will have the same letters, but no additional letters.

Letters may be repeated in a word.

Look at words that are at least 5-letters long.
Look only at words that are 17-letters long.

Neatly display the words without any wrapping or scrolling of the terminal.



Challenge 9
How many words have letters which are already ordered lexicographically? 

Look at words that are at least 3-letters long.

Neatly display the words without any wrapping or scrolling of the terminal.



What to turn in?
Gordon will find your program on Odin at 3350/6/
Don't forget your Makefile
Programs will be collected when lab ends at 12:30pm.