in reply to Challenge: Predictive Texting

A quick (in the sense of not much time spent on it) first cut version before I head off on holiday. :)

Using an early version of the OP's text as the message text I get the following result:

844 strokes to send a 901 character message containing 170 words.

Note that the 2of12.txt file is expected to reside in the current directory.

Updated to count '+' as strokes and part of message text - they effectively turn into spaces

Updated to take advantage of "knowing" the word frequency in the test text up front. Strokes reduce to 540! This version prints the strokes used for each word.

Set LEARN true to have the code learn the word frequency as the text is supplied. In this case the stroke count increases to 810 (there's a slight algorithm improvement on the first version too;) ).


DWIM is Perl's answer to Gödel