You shall write a C++ program that:
- Reads an arbitrary number of whitespace-delimited tokens from standard input.
- Determines and prints (to standard output) two decimal integer values:
- The number of input tokens that are valid Scrabble words (case-insensitive), i.e. those that can be found in
/srv/datasets/scrabble-hybrid
. - The total number of points that all those words would be worth in Scrabble, according to the letter values in
/srv/datasets/scrabble-letter-values
.
- The number of input tokens that are valid Scrabble words (case-insensitive), i.e. those that can be found in
Specific Requirements
- You may assume that the number of valid words and the total number of points will not exceed the range of an unsigned 64-bit integer.
- Open and read the contents of each relevant data file exactly once.
- Make sure to use STL components that will avoid any gross inefficiencies (excessive computation and/or storage) in your program. Your program should at least be able to process each of the example inputs below in no more than 5 seconds, on our server.
- Print the two integer values in the order specified above, and make sure your output contains no other numeric decimal values. Otherwise, the format of output is up to you.
Sample Executable and Expected Output
A sample executable named cs19_scrabble_total
is available on the server, which demonstrates expected behavior of your program, e.g.:
$ cs19_scrabble_total <<< 'spinnaker'
1 word worth 15 points
$ cs19_scrabble_total < /srv/datasets/many-english-words.txt
519135 words worth 7566688 points
$ cs19_scrabble_total < /srv/datasets/shakespeare-othello.txt
17531 words worth 105915 points
$ cs19_scrabble_total < /srv/datasets/king-james.txt
650865 words worth 4305807 points