DWITE Online Computer Programming Contest
February 2009
Problem 1
Baby Diff

While diff is a useful text-processing utility that finds the differences between the 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 file DATA1.txt will contain 5 sets of input, two lines each. Each line will be a non-empty string less than 255 characters long.

The output file OUT1.txt will contain 5 lines of output, integers 0 <= i <= 255 -- the number of leading characters that are the same between the two lines, up to the first difference.

Note that the two lines could be of different lengths. 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