0.2 Hriday and his ribbon dance career
Score: 10pts
Time Limit: 5.00 sec
Hriday the juggler has two magic ribbons A and B, each painted with a sequence of lowercase Latin - or possibly empty (represented by a blank line). The length of the string represents the length of the ribbon.
To amaze his audience, he needs both ribbons to spin in perfect harmony-which means they must be exactly the same length. He can do the following operations on the ribbons in any order, any number of times:-

If |A| > 0, delete the first character of A (one end of ribbon A).
If |A| > 0, delete the last character of A (other end of the ribbon A).
If |B| > 0, delete the first character of B (one end of the ribbon B).
If |B| > 0, delete the last character of B (other end of the ribbon B).
where |A| and |B| represents the length of ribbons.

Compute the minimum number of operations required to make the length of both ribbons same.

Constraints
1 <= t <= 100
0 <= |A| <= 20
0 <= |B| <= 20

Input Format
t - the number of test cases

Then, for each test case:
A - a string of length |A|
B - a string of length |B|

Note: Ribbon of Length 0 will have an input "-"

Output Format
For each test case, output one integer: the minimum number of snips needed so that |A| = |B|.

Example 1
Input:
1
abcd
bc

Output:
2

Explanation:
This example demonstrates a single test case where:
String A = "abcd"
String B = "bc"
By removing one character from the beginning and one character from the end of String A, it transforms into "bc". At this point, the lengths of String A and String B are equal (|A| = |B|). The total number of operations performed is 2.

Log In to solve the Question