Round 1B 2013


  Submissions
Osmos
10pt
Not attempted
4627/7207 users correct (64%)
12pt
Not attempted
3501/4538 users correct (77%)
Falling Diamonds
14pt
Not attempted
935/1857 users correct (50%)
28pt
Not attempted
522/714 users correct (73%)
Garbled Email
12pt
Not attempted
444/894 users correct (50%)
24pt
Not attempted
255/345 users correct (74%)
  Top Scores
dolphinigle100
K.A.D.R100
blmarket100
rng..58100
Seyaua100
bmerry100
jcn100
chokudai100
IvanRomanov100
neal.wu100
Practice Mode

Problem C. Garbled Email

This contest is open for practice. You can try every problem as many times as you like, though we won't keep track of which problems you solve. Read the Quick-Start Guide to get started.
Small input
12 points
Large input
24 points

Problem

Gagan just got an email from her friend Jorge. The email contains important information, but unfortunately it was corrupted when it was sent: all of the spaces are missing, and after the removal of the spaces, some of the letters have been changed to other letters! All Gagan has now is a string S of lower-case characters.

You know that the email was originally made out of words from the dictionary described below. You also know the letters were changed after the spaces were removed, and that the difference between the indices of any two letter changes is not less than 5. So for example, the string "code jam" could have become "codejam", "dodejbm", "zodejan" or "cidejab", but not "kodezam" (because the distance between the indices of the "k" change and the "z" change is only 4).

What is the minimum number of letters that could have been changed?

Dictionary

In order to solve this problem, you'll need an extra file: a special dictionary that you can find at https://code.google.com/codejam/contest/static/garbled_email_dictionary.txt. It is not a dictionary from any natural language, though it does contain some English words. Each line of the dictionary contains one word. The dictionary file should be 3844492 bytes in size, contain 521196 words, start with the word "a", and end with the word "zymuznh".

When you're submitting the code you used to solve this problem, you shouldn't include the dictionary. As usual, however, you must submit all code you used to solve the problem.

Note that if you are using Windows and want to look at the dictionary file, you should avoid Notepad, and instead use WordPad or another piece of software, or else all the words might appear on the same line.

Input

The first line of the input gives the number of test cases, T. T test cases follow. Each test case consists of a single line containing a string S, consisting of lower-case characters a-z.

Output

For each test case, output one line containing "Case #x: y", where x is the case number (starting from 1) and y is the minimum number of letters that could have been changed in order to make S.

Limits

S is valid: it is possible to make it using the method described above.

Small dataset

1 ≤ T ≤ 20.
1 ≤ length of S ≤ 50.

Large dataset

1 ≤ T ≤ 4.
1 ≤ length of S ≤ 4000.

Sample


Input
 

Output
 
4
codejam
cxdejax
cooperationaabea
jobsinproduction

Case #1: 0
Case #2: 2
Case #3: 1
Case #4: 1

Explanation

"code" and "jam" both appear in the dictionary. Although "cooperation" is an English word, it doesn't appear in the dictionary; "aabea" does.

Overview  |  Problem A  |  Problem B  |  Problem C

Round 1B attracted nearly 5000 participants fighting for the 1000 spots that gave qualification to Round 2. The first problem our contestants faced was game-based Osmos with a greedy solution; over 3500 contestants managed to figure it out. This was followed by Falling Diamonds, where you had to calculate the probability of getting a diamond; a significant number of contestants had a hard time with getting the small input right. See the analysis of the problem for our ideas on how to solve it!

The final problem of this round was Garbled Email, which was much more accessible than Round 1A's Good Luck, with over 200 successful submissions for the large. This required some insightful string manipulation to handle a huge dictionary we provided.

119 contestants managed to get a full score from this round, led by Indonesia's dolphinigle, who finished all the problems in a bit over an hour. To advance to Round 2 you needed either the large of one of the two more difficult problems, large of Osmos and the small of Falling Diamonds, or large of Osmos, small of Garbled Email, and a really impressive speed!

Congratulations to the top 1000, and we hope you enjoyed the problems in this round!


Cast

Problem A. Osmos written by Bartholomew Furrow. Prepared by Zhen Wang and Bartholomew Furrow.

Problem B. Falling Diamonds written by Onufry Wojtaszczyk. Prepared by Alex Fetisov and Tomek Czajka.

Problem C. Garbled Email written by Bartholomew Furrow. Prepared by Jonathan Wills and Bartholomew Furrow.

Contest analysis presented by Onufry Wojtaszczyk and Bartholomew Furrow. Solutions and other problem preparation by Igor Naverniouk, Ahmed Aly, Tomek Kulczynski, Hackson Leung, Karim Nosseir, Hao Pan, Md. Arifuzzaman Arif, Sean Henderson and John Dethridge.

You cannot ask questions at this time. Please email us at codejam@google.com.
You have 0 submissions.