A local computer users' group publishes a quarterly newsletter, and each issue contains a small Turbo Pascal programming problem for members to solve. Members submit their solutions to the editor, and the member who submits the shortest solution wins a prize.
The length of a program is measured in units. The unit count is the total number of occurrences of:
(,[, and+, -, *, /, =, <, >, <=, >=, <>, @, ^, and :=.Comments are ignored, as is every other symbol that does not fall into one of the categories above. The program with the lowest unit count wins; two or more programs with equal unit counts split the prize.
Write a program that reads a series of Turbo Pascal programs and prints the number of units in each.
The input is a series of Turbo Pascal programs. Each program is terminated by a line whose first two columns contain tilde characters (~~), immediately followed by the name of the submitting member. Every program is syntactically correct and uses the standard symbols for comments (braces { }) and subscripts (square brackets [ ]). Input ends at end of file.
For each program, print a single line containing the submitting member's name and the program's unit count, using exactly this format:
Program by NAME contains N units.
Additional notes on Turbo Pascal tokens:
_) or a letter (upper- or lower-case), followed by zero or more underscores, letters, or digits.'). Each string lies entirely on one source line. Two consecutive quotes ('') inside a string represent a single ' character, so a string consisting of one ' character is written ''''. The empty string '' is allowed.10.56E-15: an integral part (one or more digits, always present), an optional decimal part (a . followed by digits), and an optional exponent (an upper- or lower-case E, an optional sign +/-, and digits).\$ followed by one or more hex digits (0–9, a–f, A–F); for example \$a9F.{ }; do not treat (* *) as comments. Comments do not nest.+ and - as operators whenever possible: in x := -3, the - and the 3 are separate tokens.lower..upper; for example 1..10 covers the integers from 1 to 10.