Algorithms
Medium
2914
3174
Minimum Number of Changes to Make Binary String Beautiful
minimum-number-of-changes-to-make-binary-string-beautiful
"""
You are given a 0-indexed binary string s having an even length.

A string is beautiful if it's possible to partition it into one or more substrings such that:

 * Each substring has an even length.
 * Each substring contains only 1's or only 0's.

You can change any character in s to 0 or 1.

Return the minimum number of changes required to make the string s beautiful.

Example 1:

Input: s = "1001"
Output: 2
Explanation: We change s[1] to 1 and s[3] to 0 to get string "1100".
It can be seen that the string "1100" is beautiful because we can partition it into "11|00".
It can be proven that 2 is the minimum number of changes needed to make the string beautiful.

Example 2:

Input: s = "10"
Output: 1
Explanation: We change s[1] to 1 to get string "11".
It can be seen that the string "11" is beautiful because we can partition it into "11".
It can be proven that 1 is the minimum number of changes needed to make the string beautiful.

Example 3:

Input: s = "0000"
Output: 0
Explanation: We don't need to make any changes as the string "0000" is beautiful already.


Constraints:

 * 2 <= s.length <= 105
 * s has an even length.
 * s[i] is either '0' or '1'.
"""
class Solution:
    def minChanges(self, s: str) -> int:
        
You are given a 0-indexed binary string s having an even length.

A string is beautiful if it's possible to partition it into one or more substrings such that:

 * Each substring has an even length.
 * Each substring contains only 1's or only 0's.

You can change any character in s to 0 or 1.

Return the minimum number of changes required to make the string s beautiful.

Example 1:

Input: s = "1001"
Output: 2
Explanation: We change s[1] to 1 and s[3] to 0 to get string "1100".
It can be seen that the string "1100" is beautiful because we can partition it into "11|00".
It can be proven that 2 is the minimum number of changes needed to make the string beautiful.

Example 2:

Input: s = "10"
Output: 1
Explanation: We change s[1] to 1 to get string "11".
It can be seen that the string "11" is beautiful because we can partition it into "11".
It can be proven that 1 is the minimum number of changes needed to make the string beautiful.

Example 3:

Input: s = "0000"
Output: 0
Explanation: We don't need to make any changes as the string "0000" is beautiful already.


Constraints:

 * 2 <= s.length <= 105
 * s has an even length.
 * s[i] is either '0' or '1'.


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

my_solution = Solution()

test_input = { "s": "1001" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "10" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "0000" }
assert my_solution.minChanges(**test_input) == 0

test_input = { "s": "11000111" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "01010001" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "010010" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "111111111110010001" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "01010000011001001101" }
assert my_solution.minChanges(**test_input) == 6

test_input = { "s": "011011100001110111" }
assert my_solution.minChanges(**test_input) == 5

test_input = { "s": "1001000010111010" }
assert my_solution.minChanges(**test_input) == 5

test_input = { "s": "0011" }
assert my_solution.minChanges(**test_input) == 0

test_input = { "s": "11100100010010" }
assert my_solution.minChanges(**test_input) == 4

test_input = { "s": "110100" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "01" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "10110010" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "0010" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "01000011000111" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "0001110001" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "000000001010100011" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "100001" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "10010010" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "101100" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "000010" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "011011000001100011" }
assert my_solution.minChanges(**test_input) == 4

test_input = { "s": "01101111" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "000000011101" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "011011011111111011" }
assert my_solution.minChanges(**test_input) == 4

test_input = { "s": "110011" }
assert my_solution.minChanges(**test_input) == 0

test_input = { "s": "1111101111101011" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "11000101011001100110" }
assert my_solution.minChanges(**test_input) == 8

test_input = { "s": "101101101110110010" }
assert my_solution.minChanges(**test_input) == 5

test_input = { "s": "11011110" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "1011100101" }
assert my_solution.minChanges(**test_input) == 4

test_input = { "s": "0011000101001000" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "00" }
assert my_solution.minChanges(**test_input) == 0

test_input = { "s": "10110111010001000010" }
assert my_solution.minChanges(**test_input) == 5

test_input = { "s": "0101" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "0010101100" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "11001110101001" }
assert my_solution.minChanges(**test_input) == 4

test_input = { "s": "010101000011011111" }
assert my_solution.minChanges(**test_input) == 4

test_input = { "s": "0010111010000001" }
assert my_solution.minChanges(**test_input) == 4

test_input = { "s": "0000010101" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "10100011101010" }
assert my_solution.minChanges(**test_input) == 5

test_input = { "s": "101111" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "11" }
assert my_solution.minChanges(**test_input) == 0

test_input = { "s": "110110" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "001001110111010101" }
assert my_solution.minChanges(**test_input) == 6

test_input = { "s": "11110011" }
assert my_solution.minChanges(**test_input) == 0

test_input = { "s": "1100000101101110" }
assert my_solution.minChanges(**test_input) == 4

test_input = { "s": "111010" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "100000100010011100" }
assert my_solution.minChanges(**test_input) == 4

test_input = { "s": "0111" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "0100110011111101" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "010111" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "000100" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "00110111000111110001" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "01010010" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "01110101001001" }
assert my_solution.minChanges(**test_input) == 5

test_input = { "s": "00111100010111" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "001110" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "00010101111101" }
assert my_solution.minChanges(**test_input) == 4

test_input = { "s": "111011" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "011110" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "1010" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "011101010011101011" }
assert my_solution.minChanges(**test_input) == 5

test_input = { "s": "1001110001111100" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "011000101100" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "1110111000111111" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "1110" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "10110110" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "1000" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "0111110110" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "011000011101" }
assert my_solution.minChanges(**test_input) == 4

test_input = { "s": "0100101000010101" }
assert my_solution.minChanges(**test_input) == 6

test_input = { "s": "0100001100" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "100010010010110001" }
assert my_solution.minChanges(**test_input) == 5

test_input = { "s": "101001111001111001" }
assert my_solution.minChanges(**test_input) == 7

test_input = { "s": "111001" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "111010001000" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "0110" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "11011010" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "100111" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "11000110000001" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "010111010011011000" }
assert my_solution.minChanges(**test_input) == 5

test_input = { "s": "000101" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "000010101010101011" }
assert my_solution.minChanges(**test_input) == 6

test_input = { "s": "11011000" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "010101" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "10011010110110101100" }
assert my_solution.minChanges(**test_input) == 7

test_input = { "s": "10100011" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "11010100000000" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "101100101111010011" }
assert my_solution.minChanges(**test_input) == 3

test_input = { "s": "110111111100" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "111110110100" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "011110110101010100" }
assert my_solution.minChanges(**test_input) == 6

test_input = { "s": "000111" }
assert my_solution.minChanges(**test_input) == 1

test_input = { "s": "00000010001101" }
assert my_solution.minChanges(**test_input) == 2

test_input = { "s": "01111001101001" }
assert my_solution.minChanges(**test_input) == 6

test_input = { "s": "010110011101" }
assert my_solution.minChanges(**test_input) == 5

test_input = { "s": "0111011101" }
assert my_solution.minChanges(**test_input) == 3