eolymp
bolt
Try our new interface for solving problems
Problems

Anagrammatic Distance

Anagrammatic Distance

Two words are said to be \textit{\textbf{anagrams of each other }}if the letters from one word can be rearranged to form the other word. For example, \textit{occurs }is an anagram of \textit{succor}; however, \textit{dear }is not an anagram of \textit{dared }(because the \textit{d }appears twice in \textit{dared}, but only once in \textit{dear}). The most famous anagram pair (in English) is \textit{dog }and \textit{god}. The \textit{\textbf{anagrammatic distance }}between any two words is the minimum number of letters which must be removed so that the remaining portions of the two words become anagrams. For example, given the words \textit{sleep }and \textit{leap}, we need to remove a minimum of three letters - two from \textit{sleep }and one from \textit{leap }- before what's left are anagrams of each other (in each case, \textit{lep}). With words such as \textit{dog }and \textit{cat}, where the two have absolutely no letters in common, the anagrammatic distance is an extreme (explicitly \textbf{6}) since all the letters need to be removed. (Here, a word is always an anagram of itself.) You must write a program to calculate the anagrammatic distance between any two given words. \InputFile The first line of the input will contain a positive integer value \textit{N }(less than \textbf{60,000}) indicating the number of cases. Each case will consist of two words, possibly empty, each given on a single line (for a total of \textbf{2N}\textit{ }additional lines). Although they may have zero length, the words are simple - the letter are all lowercase and are taken from the usual twenty-six letter English alphabet (\textit{abcdefghijklmnopqrstuvwxyz}). The longest word is \textit{pneumonoultramicroscopicsilicovolcanoconiosis}. \OutputFile The output should consist of the case number and the anagrammatic distance, formatted as shown.
Time limit 1 second
Memory limit 64 MiB
Input example #1
4
crocus
succor
dares
seared
empty

smell
lemon
Output example #1
Case #1:  0
Case #2:  1
Case #3:  5
Case #4:  4