Algorithms
Medium
2957
3230
Remove Adjacent Almost-Equal Characters
remove-adjacent-almost-equal-characters
"""
You are given a 0-indexed string word.
In one operation, you can pick any index i of word and change word[i] to any lowercase English letter.
Return the minimum number of operations needed to remove all adjacent almost-equal characters from word.
Two characters a and b are almost-equal if a == b or a and b are adjacent in the alphabet.

Example 1:

Input: word = "aaaaa"
Output: 2
Explanation: We can change word into "acaca" which does not have any adjacent almost-equal characters.
It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 2.

Example 2:

Input: word = "abddez"
Output: 2
Explanation: We can change word into "ybdoez" which does not have any adjacent almost-equal characters.
It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 2.
Example 3:

Input: word = "zyxyxyz"
Output: 3
Explanation: We can change word into "zaxaxaz" which does not have any adjacent almost-equal characters. 
It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 3.


Constraints:

1 <= word.length <= 100
word consists only of lowercase English letters.
"""
class Solution:
    def removeAlmostEqualCharacters(self, word: str) -> int:
        
You are given a 0-indexed string word.
In one operation, you can pick any index i of word and change word[i] to any lowercase English letter.
Return the minimum number of operations needed to remove all adjacent almost-equal characters from word.
Two characters a and b are almost-equal if a == b or a and b are adjacent in the alphabet.

Example 1:

Input: word = "aaaaa"
Output: 2
Explanation: We can change word into "acaca" which does not have any adjacent almost-equal characters.
It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 2.

Example 2:

Input: word = "abddez"
Output: 2
Explanation: We can change word into "ybdoez" which does not have any adjacent almost-equal characters.
It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 2.
Example 3:

Input: word = "zyxyxyz"
Output: 3
Explanation: We can change word into "zaxaxaz" which does not have any adjacent almost-equal characters. 
It can be shown that the minimum number of operations needed to remove all adjacent almost-equal characters from word is 3.


Constraints:

1 <= word.length <= 100
word consists only of lowercase English letters.


Please complete the code below to solve above prblem:
```python
class Solution:
    def removeAlmostEqualCharacters(self, word: str) -> int:
        
```

my_solution = Solution()

test_input = { "word": "aaaaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "abddez" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "zyxyxyz" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 3

test_input = { "word": "a" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 0

test_input = { "word": "b" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 0

test_input = { "word": "c" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 0

test_input = { "word": "aa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "ab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "ac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 0

test_input = { "word": "ba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "ca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 0

test_input = { "word": "cb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "cc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "aaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "aab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "aac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "aba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "abb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "abc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "aca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 0

test_input = { "word": "acb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "acc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "baa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bbb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bbc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bcb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bcc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "caa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "cab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "cac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 0

test_input = { "word": "cba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "cbb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "cbc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "cca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "ccb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "ccc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "aaaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "aaab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "aaac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "aaba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "aabb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "aabc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "aaca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "aacb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "aacc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "abaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "abab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "abac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "abba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "abbb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "abbc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "abca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "abcb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "abcc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "acaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "acab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "acac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 0

test_input = { "word": "acba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "acbb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "acbc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "acca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "accb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "accc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "baaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "baab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "baac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "baba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "babb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "babc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "baca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bacb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bacc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bbaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bbab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bbac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bbba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bbbb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bbbc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bbca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bbcb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bbcc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bcaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bcab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bcac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bcba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bcbb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bcbc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bcca" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "bccb" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "bccc" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 2

test_input = { "word": "caaa" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "caab" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "caac" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1

test_input = { "word": "caba" }
assert my_solution.removeAlmostEqualCharacters(**test_input) == 1