
Dhapu and Hamming Distance
|
All submissions for this problem are available.
Problem description.
Dhapu has been reading about communication systems which interests her a lot. There she noticed a peculiar way to measure distance/error between 2 signals called the Hamming Distance. Till now she only knew of Euclidean Distance between 2 points. On searching online, she read the following on Wikipedia:-
In information theory, the Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. In another way, it measures the minimum number of substitutions required to change one string into the other, or the minimum number of errors that could have transformed one string into the other.
If the length of strings differ, we consider that the Hamming Distance cannot be found out.
She wants to see if she has understood the concept clearly. So, she decides to write a program that will find the Hamming Distance between 2 signals. Can you help her?
Input
First line of the input contains the number of test cases T. T test cases follow.
Each test case consists of the 2 strings, each on a separate line.
Output
For every test case, print the Hamming Distance between the 2 strings. If it doesn't exist, print -1.
Constraints
1 <= T <= 1000
1 <= Length of Signals <= 1000
Strings will consist of only alphabets and numerical digits.
Note:- A signal can be represented as a string of characters. Upper case and Lower Case alphabets represent different characters.
Author: | sidthekidder |
Tags | sidthekidder |
Date Added: | 6-01-2015 |
Time Limit: | 1 sec |
Source Limit: | 50000 Bytes |
Languages: | C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, ERL, TCL, PERL6, TEXT, CLOJ, FS |
Comments
- Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
