Algorithms
Easy
2937
3207
Make Three Strings Equal
make-three-strings-equal
"""
You are given three strings s1, s2, and s3. You have to perform the following operation on these three strings as many times as you want.
In one operation you can choose one of these three strings such that its length is at least 2 and delete the rightmost character of it.
Return the minimum number of operations you need to perform to make the three strings equal if there is a way to make them equal, otherwise, return -1.

Example 1:

Input: s1 = "abc", s2 = "abb", s3 = "ab"
Output: 2
Explanation: Performing operations on s1 and s2 once will lead to three equal strings.
It can be shown that there is no way to make them equal with less than two operations.
Example 2:

Input: s1 = "dac", s2 = "bac", s3 = "cac"
Output: -1
Explanation: Because the leftmost letters of s1 and s2 are not equal, they could not be equal after any number of operations. So the answer is -1.


Constraints:

1 <= s1.length, s2.length, s3.length <= 100
s1, s2 and s3 consist only of lowercase English letters.
"""
class Solution:
    def findMinimumOperations(self, s1: str, s2: str, s3: str) -> int:
        
You are given three strings s1, s2, and s3. You have to perform the following operation on these three strings as many times as you want.
In one operation you can choose one of these three strings such that its length is at least 2 and delete the rightmost character of it.
Return the minimum number of operations you need to perform to make the three strings equal if there is a way to make them equal, otherwise, return -1.

Example 1:

Input: s1 = "abc", s2 = "abb", s3 = "ab"
Output: 2
Explanation: Performing operations on s1 and s2 once will lead to three equal strings.
It can be shown that there is no way to make them equal with less than two operations.
Example 2:

Input: s1 = "dac", s2 = "bac", s3 = "cac"
Output: -1
Explanation: Because the leftmost letters of s1 and s2 are not equal, they could not be equal after any number of operations. So the answer is -1.


Constraints:

1 <= s1.length, s2.length, s3.length <= 100
s1, s2 and s3 consist only of lowercase English letters.


Please complete the code below to solve above prblem:
```python
class Solution:
    def findMinimumOperations(self, s1: str, s2: str, s3: str) -> int:
        
```

my_solution = Solution()

test_input = { "s1": "abc", "s2": "abb", "s3": "ab" }
assert my_solution.findMinimumOperations(**test_input) == 2

test_input = { "s1": "dac", "s2": "bac", "s3": "cac" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "a", "s2": "a", "s3": "a" }
assert my_solution.findMinimumOperations(**test_input) == 0

test_input = { "s1": "kui", "s2": "m", "s3": "v" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "a", "s2": "aabc", "s3": "a" }
assert my_solution.findMinimumOperations(**test_input) == 3

test_input = { "s1": "cc", "s2": "cccb", "s3": "c" }
assert my_solution.findMinimumOperations(**test_input) == 4

test_input = { "s1": "luso", "s2": "lu", "s3": "lu" }
assert my_solution.findMinimumOperations(**test_input) == 2

test_input = { "s1": "xx", "s2": "phe", "s3": "xie" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "gzd", "s2": "bcju", "s3": "db" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "cbba", "s2": "cbaa", "s3": "c" }
assert my_solution.findMinimumOperations(**test_input) == 6

test_input = { "s1": "k", "s2": "kfb", "s3": "krcnf" }
assert my_solution.findMinimumOperations(**test_input) == 6

test_input = { "s1": "oby", "s2": "obz", "s3": "obf" }
assert my_solution.findMinimumOperations(**test_input) == 3

test_input = { "s1": "b", "s2": "aba", "s3": "aaccaa" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "a", "s2": "accabb", "s3": "aaa" }
assert my_solution.findMinimumOperations(**test_input) == 7

test_input = { "s1": "b", "s2": "bccaaba", "s3": "ba" }
assert my_solution.findMinimumOperations(**test_input) == 7

test_input = { "s1": "b", "s2": "bacccab", "s3": "cc" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "ca", "s2": "cccabb", "s3": "cb" }
assert my_solution.findMinimumOperations(**test_input) == 7

test_input = { "s1": "ccb", "s2": "ccba", "s3": "ccb" }
assert my_solution.findMinimumOperations(**test_input) == 1

test_input = { "s1": "mbooi", "s2": "pdq", "s3": "br" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "xxfzj", "s2": "faho", "s3": "c" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "acbc", "s2": "acba", "s3": "acb" }
assert my_solution.findMinimumOperations(**test_input) == 2

test_input = { "s1": "aduyyk", "s2": "v", "s3": "lpyt" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "xd", "s2": "sl", "s3": "azoeaje" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "bbbaa", "s2": "bacab", "s3": "b" }
assert my_solution.findMinimumOperations(**test_input) == 8

test_input = { "s1": "cibn", "s2": "ioom", "s3": "bxa" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "bcb", "s2": "bbac", "s3": "cbbc" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "aabbb", "s2": "cc", "s3": "cccb" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "i", "s2": "xqsfy", "s3": "diqae" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "iq", "s2": "iimanmy", "s3": "id" }
assert my_solution.findMinimumOperations(**test_input) == 8

test_input = { "s1": "pitggt", "s2": "pi", "s3": "pih" }
assert my_solution.findMinimumOperations(**test_input) == 5

test_input = { "s1": "ten", "s2": "ten", "s3": "tenob" }
assert my_solution.findMinimumOperations(**test_input) == 2

test_input = { "s1": "vejy", "s2": "fbqfo", "s3": "gl" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "aca", "s2": "abcc", "s3": "accba" }
assert my_solution.findMinimumOperations(**test_input) == 9

test_input = { "s1": "br", "s2": "br", "s3": "brvhgtou" }
assert my_solution.findMinimumOperations(**test_input) == 6

test_input = { "s1": "c", "s2": "bcc", "s3": "aacbcaca" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "cab", "s2": "caac", "s3": "cacbb" }
assert my_solution.findMinimumOperations(**test_input) == 6

test_input = { "s1": "ccab", "s2": "cbbcbb", "s3": "ca" }
assert my_solution.findMinimumOperations(**test_input) == 9

test_input = { "s1": "inuc", "s2": "iwpdfj", "s3": "ib" }
assert my_solution.findMinimumOperations(**test_input) == 9

test_input = { "s1": "jrrpyyc", "s2": "jr", "s3": "jrt" }
assert my_solution.findMinimumOperations(**test_input) == 6

test_input = { "s1": "l", "s2": "gebqrgnz", "s3": "jkr" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "naynn", "s2": "ax", "s3": "bhdcz" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "rexmx", "s2": "ujmbg", "s3": "gg" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "aacbcb", "s2": "a", "s3": "acaaac" }
assert my_solution.findMinimumOperations(**test_input) == 10

test_input = { "s1": "acbb", "s2": "acbacc", "s3": "acb" }
assert my_solution.findMinimumOperations(**test_input) == 4

test_input = { "s1": "baacbab", "s2": "bcc", "s3": "bca" }
assert my_solution.findMinimumOperations(**test_input) == 10

test_input = { "s1": "bcacbba", "s2": "bca", "s3": "bca" }
assert my_solution.findMinimumOperations(**test_input) == 4

test_input = { "s1": "bcaca", "s2": "bcaba", "s3": "bca" }
assert my_solution.findMinimumOperations(**test_input) == 4

test_input = { "s1": "ba", "s2": "bcbcab", "s3": "bbcbb" }
assert my_solution.findMinimumOperations(**test_input) == 10

test_input = { "s1": "cabc", "s2": "cab", "s3": "cabbac" }
assert my_solution.findMinimumOperations(**test_input) == 4

test_input = { "s1": "bbbbcaac", "s2": "a", "s3": "cbcc" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "gjbtodtym", "s2": "gxp", "s3": "g" }
assert my_solution.findMinimumOperations(**test_input) == 10

test_input = { "s1": "hfkq", "s2": "hfrbvno", "s3": "hf" }
assert my_solution.findMinimumOperations(**test_input) == 7

test_input = { "s1": "hym", "s2": "hl", "s3": "hshxmbbj" }
assert my_solution.findMinimumOperations(**test_input) == 10

test_input = { "s1": "mkdflu", "s2": "mmbn", "s3": "mge" }
assert my_solution.findMinimumOperations(**test_input) == 10

test_input = { "s1": "nvlobl", "s2": "mekbzd", "s3": "s" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "rpa", "s2": "rpaxpoh", "s3": "rpa" }
assert my_solution.findMinimumOperations(**test_input) == 4

test_input = { "s1": "ac", "s2": "aacccccbc", "s3": "acc" }
assert my_solution.findMinimumOperations(**test_input) == 11

test_input = { "s1": "abb", "s2": "abaac", "s3": "abcaca" }
assert my_solution.findMinimumOperations(**test_input) == 8

test_input = { "s1": "caa", "s2": "caccaccacb", "s3": "c" }
assert my_solution.findMinimumOperations(**test_input) == 11

test_input = { "s1": "baccaab", "s2": "cababc", "s3": "a" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "cacbb", "s2": "ca", "s3": "cacbcac" }
assert my_solution.findMinimumOperations(**test_input) == 8

test_input = { "s1": "cbba", "s2": "cabcabab", "s3": "ca" }
assert my_solution.findMinimumOperations(**test_input) == 11

test_input = { "s1": "cb", "s2": "cbcbb", "s3": "cbaaabb" }
assert my_solution.findMinimumOperations(**test_input) == 8

test_input = { "s1": "ccabaa", "s2": "ccabc", "s3": "cca" }
assert my_solution.findMinimumOperations(**test_input) == 5

test_input = { "s1": "ccb", "s2": "ccac", "s3": "cccaaca" }
assert my_solution.findMinimumOperations(**test_input) == 8

test_input = { "s1": "ccccbb", "s2": "cccc", "s3": "cccc" }
assert my_solution.findMinimumOperations(**test_input) == 2

test_input = { "s1": "cxxq", "s2": "cxx", "s3": "cxxdeqh" }
assert my_solution.findMinimumOperations(**test_input) == 5

test_input = { "s1": "d", "s2": "dffjiulzya", "s3": "dke" }
assert my_solution.findMinimumOperations(**test_input) == 11

test_input = { "s1": "dogv", "s2": "dofjkhx", "s3": "dog" }
assert my_solution.findMinimumOperations(**test_input) == 8

test_input = { "s1": "dwefrocz", "s2": "dzz", "s3": "dwn" }
assert my_solution.findMinimumOperations(**test_input) == 11

test_input = { "s1": "etr", "s2": "ejb", "s3": "etpubpvr" }
assert my_solution.findMinimumOperations(**test_input) == 11

test_input = { "s1": "f", "s2": "morycy", "s3": "vledqoo" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "ful", "s2": "fular", "s3": "fulvkv" }
assert my_solution.findMinimumOperations(**test_input) == 5

test_input = { "s1": "kzwat", "s2": "ku", "s3": "koftvbd" }
assert my_solution.findMinimumOperations(**test_input) == 11

test_input = { "s1": "qey", "s2": "qevtkbss", "s3": "qeb" }
assert my_solution.findMinimumOperations(**test_input) == 8

test_input = { "s1": "saqy", "s2": "hvufcpko", "s3": "xm" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "tllwgcdi", "s2": "t", "s3": "tvham" }
assert my_solution.findMinimumOperations(**test_input) == 11

test_input = { "s1": "vmwdmadn", "s2": "vmw", "s3": "vmw" }
assert my_solution.findMinimumOperations(**test_input) == 5

test_input = { "s1": "xobwwhu", "s2": "xobb", "s3": "xob" }
assert my_solution.findMinimumOperations(**test_input) == 5

test_input = { "s1": "yptajimiz", "s2": "yp", "s3": "ypr" }
assert my_solution.findMinimumOperations(**test_input) == 8

test_input = { "s1": "z", "s2": "zcrouxlukb", "s3": "zbb" }
assert my_solution.findMinimumOperations(**test_input) == 11

test_input = { "s1": "aaabc", "s2": "aaaa", "s3": "aaaabc" }
assert my_solution.findMinimumOperations(**test_input) == 6

test_input = { "s1": "aaa", "s2": "aab", "s3": "aabaacaab" }
assert my_solution.findMinimumOperations(**test_input) == 9

test_input = { "s1": "aac", "s2": "aac", "s3": "aacabbbca" }
assert my_solution.findMinimumOperations(**test_input) == 6

test_input = { "s1": "abaab", "s2": "abaabb", "s3": "abaa" }
assert my_solution.findMinimumOperations(**test_input) == 3

test_input = { "s1": "abcomon", "s2": "gkuneup", "s3": "q" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "acc", "s2": "accacb", "s3": "acbabc" }
assert my_solution.findMinimumOperations(**test_input) == 9

test_input = { "s1": "cca", "s2": "caaab", "s3": "babbacc" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "bccbc", "s2": "bc", "s3": "bcccbcac" }
assert my_solution.findMinimumOperations(**test_input) == 9

test_input = { "s1": "bpp", "s2": "bin", "s3": "bfkbyhubw" }
assert my_solution.findMinimumOperations(**test_input) == 12

test_input = { "s1": "bbsyg", "s2": "blbp", "s3": "brghkr" }
assert my_solution.findMinimumOperations(**test_input) == 12

test_input = { "s1": "bxpvamp", "s2": "bxpv", "s3": "bxpv" }
assert my_solution.findMinimumOperations(**test_input) == 3

test_input = { "s1": "ccbabca", "s2": "cbcbaca", "s3": "c" }
assert my_solution.findMinimumOperations(**test_input) == 12

test_input = { "s1": "accb", "s2": "bbc", "s3": "cbbaccba" }
assert my_solution.findMinimumOperations(**test_input) == -1

test_input = { "s1": "cbccc", "s2": "cbc", "s3": "cbcccba" }
assert my_solution.findMinimumOperations(**test_input) == 6

test_input = { "s1": "cac", "s2": "ccacc", "s3": "cabacba" }
assert my_solution.findMinimumOperations(**test_input) == 12

test_input = { "s1": "ccb", "s2": "ccbcb", "s3": "ccbccab" }
assert my_solution.findMinimumOperations(**test_input) == 6

test_input = { "s1": "caacabcbc", "s2": "ccb", "s3": "ccc" }
assert my_solution.findMinimumOperations(**test_input) == 12

test_input = { "s1": "cccabaacc", "s2": "ccc", "s3": "ccc" }
assert my_solution.findMinimumOperations(**test_input) == 6

test_input = { "s1": "ajjdre", "s2": "gsrq", "s3": "eurcj" }
assert my_solution.findMinimumOperations(**test_input) == -1