#K38802. Taco: Minimum Operations to Transform Strings
Taco: Minimum Operations to Transform Strings
Taco: Minimum Operations to Transform Strings
Given two strings A and B of equal length, your task is to determine the minimum number of operations required to transform A into B by changing one character at a time. In other words, you are to compute the Hamming distance between the two strings.
The transformation is defined as follows:
For two strings of length n, the minimum number of operations is given by:
$$ \text{Operations} = \sum_{i=0}^{n-1} \mathbf{1}(A[i] \neq B[i]) $$
where \(\mathbf{1}(\cdot)\) is the indicator function that returns 1 if the condition is true and 0 otherwise.
You need to implement the solution such that it reads input from stdin
and writes the answer to stdout
.
inputFormat
The input consists of a single line containing two non-empty strings A and B separated by whitespace. Both strings are guaranteed to be of the same length.
For example:
abc def
outputFormat
Output a single integer representing the minimum number of operations required to transform A into B. This is equivalent to the number of character positions at which the two strings differ.
For example, given the input above, the output should be:
3
Note: The answer is printed to stdout
.
abc abc
0