# Spring 2003, Weekly Problem 7

This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2002, TopCoder, Inc. All rights reserved.

### Problem Statement

If you want to write a message anonymously, one way to do it is to cut out letters from headlines in a newspaper and paste them onto a blank piece of paper to form the message you want to write. Given several headlines that you have cut out, determine how many messages from a list you can write using the letters from the headlines. You should only consider each message by itself and not in conjunction with the others, see example 2.

Create a class Anonymous which contains the method howMany which takes as parameters a tvector<string> headlines containing the headlines which you have cut out as well as a tvector<string> messages with the messages you may want to write, and returns an int which is the total number of messages you can write.

### Definition

• Class: Anonymous
• Method: howMany
• Parameters: `const tvector<string>&`, `const tvector<string>&`
• Returns: int
• Method signature int howMany(const tvector<string>& headlines, const tvector<string>& messages)
(be sure your method is public)

### Class

#include <string> using namespace std; #include "tvector.h" class Anonymous { public: int howMany(const tvector <string>& headlines, const tvector <string>& messages) { // fill in code here } };

### Notes and Constraints

• All letters that you cut out can be used both as upper or lower case in a message.
• Spaces should be ignored in elements in both headlines and messages.

• headlines will contain between 1 and 50 elements, inclusive.
• messages will contain between 1 and 50 elements, inclusive.
• The length of each element in headlines will be between 1 and 50 characters, inclusive.
• The length of each element in messages will be between 1 and 50 characters, inclusive.
• Each element in headlines will only contain the letters 'A'-'Z', 'a'-'z' and space.
• Each element in messages will only contain the letters 'A'-'Z', 'a'-'z' and space.

### Examples

1. ```headlines =

{"Earthquake in San Francisco",
"Burglary at musuem in Sweden",
"Poverty"}

messages =

{"Give me my money back",
"I am the best coder",
"TOPCODER"}
```
Returns: 2

In the first message we have three 'm's, but there are only two 'm's among the headlines (both in the word "museum"), so this message can't be written.

The second message can be written. Note that the first letter, 'I', only appears as lower case in the headlines, but that's allowed. The last message can also be written, so the method should return 2.

2. ```headlines =

{"Programming is fun"}

messages =

{"program","programmer","gaming","sing","NO FUN"}
```
Returns: 4

The messages "program", "gaming", "sing" and "NO FUN" can all be written but not "programmer" (no 'e's exist). The method should return 4.

3. ```headlines =

{"abcdef","abcdef"}

messages =