DWITE '08 R5 #1 - Baby Diff

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Problem type
DWITE Online Computer Programming Contest, February 2009, Problem 1

While diff is a useful text processing utility that finds the differences between contents of files, this baby diff will start out as a simplistic check, counting how many of the leading characters of two lines of text are the same. The hopes and dreams of this program is to grow up into a full-fledged utility, but for now, it starts small.

The input will contain 5 sets of input, two lines each. Each line will be a non-empty string, less than 255 characters long.

The output will contain 5 lines of output, integers 0 \le i \le 255 – number of leading characters that are the same between the two lines, up to the first difference.

Note: the two lines could be of different length. The counter stops before the first character that doesn't match, so two strings that start differently would have a result of 0. Make sure not to count the linebreak characters such as \n, \r, or a combination thereof.

Sample Input

tony
tony
dan
tony
one two three
one two four
a
b
abcd
abcde

Sample Output

4
0
8
0
4

Problem Resource: DWITE

Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported

Comments

There are no comments at the moment.