How to measure the difference between two strings? This is a midnight question of biological scientists. The number of pairs of different characters in the same position may be a good indicator. However, it will not work well in the case when two strings have different lengths. The longest common subsequence will also fail when strings are too long.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%
Question} Using python solve the below problem:
How to measure the difference between two strings? This is a midnight
question of biological scientists. The number of pairs of different characters in
the same position may be a good indicator. However, it will not work well in
the case when two strings have different lengths. The longest common
subsequence will also fail when strings are too long.
Recently, Professor of Math L.P.C. has invented the special method to deal
with this problem. His invention has been known as a simple but creative
solution: the difference is based on the number of substrings (a non-empty
group of consecutive characters) of one string that are not substrings of the
other string.
Let's learn about his invention. Call the first string as A and the second string as
B. Let Ş be the set of all different substrings of A, and T be the set of all
different substrings of B. We then define another set P which consists of all the
strings that belongs to S or T, but not both. According to the Professor L.P.C.
method, the size of P is a good indicator to measure the difference between A
and B
For example, let A = aacd and B = cdaa. We can see that:
%3D
S= {a, aa, aac, aacd, ac, acd, c, cd, d},
T= {c, cd, cda, cdaa, d, da, daa, a, aa},
P = {aac, aacd, ac, acd, cda, cdaa, da, daa}.
Size of P is 8 and we can say the level of difference between A and B is 8.
Your task is to find this indicator. Find a pythonic approach for the solution and
develop an optimized python code. Sample inputs outputs are listed below:
Input:
aacd
cdaa
Output:
8
Transcribed Image Text:Question} Using python solve the below problem: How to measure the difference between two strings? This is a midnight question of biological scientists. The number of pairs of different characters in the same position may be a good indicator. However, it will not work well in the case when two strings have different lengths. The longest common subsequence will also fail when strings are too long. Recently, Professor of Math L.P.C. has invented the special method to deal with this problem. His invention has been known as a simple but creative solution: the difference is based on the number of substrings (a non-empty group of consecutive characters) of one string that are not substrings of the other string. Let's learn about his invention. Call the first string as A and the second string as B. Let Ş be the set of all different substrings of A, and T be the set of all different substrings of B. We then define another set P which consists of all the strings that belongs to S or T, but not both. According to the Professor L.P.C. method, the size of P is a good indicator to measure the difference between A and B For example, let A = aacd and B = cdaa. We can see that: %3D S= {a, aa, aac, aacd, ac, acd, c, cd, d}, T= {c, cd, cda, cdaa, d, da, daa, a, aa}, P = {aac, aacd, ac, acd, cda, cdaa, da, daa}. Size of P is 8 and we can say the level of difference between A and B is 8. Your task is to find this indicator. Find a pythonic approach for the solution and develop an optimized python code. Sample inputs outputs are listed below: Input: aacd cdaa Output: 8
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY