#K64422. Minimum Changes for Spell Correction
Minimum Changes for Spell Correction
Minimum Changes for Spell Correction
You are given two spells represented as strings. The first string is the original spell and the second string is the copied spell. Each spell is composed of words separated by spaces. Your task is to determine the minimum number of word changes required to make the copied spell identical to the original spell.
Let the original spell be represented as an ordered sequence of words \(O = (o_1, o_2, \ldots, o_n)\) and the copied spell as \(C = (c_1, c_2, \ldots, c_n)\). The number of changes required is given by the formula:
[ \text{changes} = \sum_{i=1}^{n} \mathbf{1}(o_i \neq c_i), ]
where \(\mathbf{1}(\cdot)\) is the indicator function that evaluates to 1 if the condition is true and 0 otherwise. Note that if the two spells do not have the same number of words, the input is considered invalid.
inputFormat
The input consists of exactly two lines:
- The first line contains the original spell, a string of words separated by spaces.
- The second line contains the copied spell, a string of words separated by spaces.
It is guaranteed that both lines have the same number of words.
outputFormat
Output a single integer that represents the minimum number of word changes required to transform the copied spell into the original spell.
## sampleabra cadabra alakazam
abra kadabra alakazam
1