Time limit
1s
Memory limit
128 MB
Mastermind is a game about guessing a hidden ordered arrangement of colored pegs. Instead of physical pegs, uppercase letters from A to Z may be used as colors. One player secretly chooses the target arrangement, and another player submits a guess. The player who knows the target must compute the score for the guess.
In this variant, the score is computed in the following order.
Each target letter can be matched at most once, and each guess letter can contribute to at most one score type. First fix the black score, then use the remaining letters to make as many grey matches as possible, and finally use the remaining letters to make as many white matches as possible. For each input line, output the score of the guess.
The input contains several lines. Each line contains a target arrangement and a guess arrangement separated by one space. Each arrangement is a string of length between 2 and 50, inclusive, using uppercase letters from A to Z. On the same line, the target and guess always have the same length.
A line containing only # marks the end of input. Do not process that line.
For each input line containing a target and a guess, output one line. The format is guess: b black, g grey, w white. Here guess is the guess arrangement from the input, and b, g, and w are the black, grey, and white scores.