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...


Computer Engineering lab


Question} Using python solve the below problem:<br>How to measure the difference between two strings? This is a midnight<br>question of biological scientists. The number of pairs of different characters in<br>the same position may be a good indicator. However, it will not work well in<br>the case when two strings have different lengths. The longest common<br>subsequence will also fail when strings are too long.<br>Recently, Professor of Math L.P.C. has invented the special method to deal<br>with this problem. His invention has been known as a simple but creative<br>solution: the difference is based on the number of substrings (a non-empty<br>group of consecutive characters) of one string that are not substrings of the<br>other string.<br>Let's learn about his invention. Call the first string as A and the second string as<br>B. Let Ş be the set of all different substrings of A, and T be the set of all<br>different substrings of B. We then define another set P which consists of all the<br>strings that belongs to S or T, but not both. According to the Professor L.P.C.<br>method, the size of P is a good indicator to measure the difference between A<br>and B<br>For example, let A = aacd and B = cdaa. We can see that:<br>%3D<br>S= {a, aa, aac, aacd, ac, acd, c, cd, d},<br>T= {c, cd, cda, cdaa, d, da, daa, a, aa},<br>P = {aac, aacd, ac, acd, cda, cdaa, da, daa}.<br>Size of P is 8 and we can say the level of difference between A and B is 8.<br>Your task is to find this indicator. Find a pythonic approach for the solution and<br>develop an optimized python code. Sample inputs outputs are listed below:<br>Input:<br>aacd<br>cdaa<br>Output:<br>8<br>

Extracted 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
Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here