EDIST - Edit distance

You are given two strings, A and B. Answer, what is the smallest number of operations you need to
transform A to B?

Operations are:

  1. Delete one letter from one of strings
  2. Insert one letter into one of strings
  3. Replace one of letters from one of strings with another letter

Input

T - number of test cases

For each test case:

  • String A
  • String B

Both strings will contain only uppercase characters and they won't be longer than 2000 characters. 

There will be 10 test cases in data set.

Output

For each test case, one line, minimum number of operations.

Example

Input:
1
FOOD
MONEY

Output:
4

Added by:Mislav Balunović
Date:2010-02-28
Time limit:15s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS OBJC PERL6 SQLITE VB.NET
Resource:Internet

hide comments
2012-06-11 12:25:38 Yatindra
1
ALLAHABAD
YATINDRA

8

Last edit: 2012-06-11 12:26:11
2012-06-09 13:01:04 Nikhar Agrawal
Why am I getting seg fault?
2012-06-08 17:59:37 Mukul
Can't u guys give more test cases???
2012-06-01 14:13:18 parag agrawal
Give some test cases
2012-04-04 18:39:47 yajur sharma
why do u guys shy away from giving test cases...!
2012-03-22 02:54:43 laconic
please help me anybody ,i'm getting WA ...
even i,m using algorihm ..
2012-01-25 16:52:25 Vivek Vardhan
can the letter be inserted anywhere???
2011-07-11 14:44:14 cegprakash
can the letter be inserted anywhere?
2011-04-27 16:23:43 Anand
Me too have same doubt yar...
2010-12-28 23:13:08 watashiwa febridesu
Give me more testcase please..
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.