Algorithms
Hard
2827
3017
Number of Beautiful Integers in the Range
number-of-beautiful-integers-in-the-range
"""
You are given positive integers low, high, and k.

A number is beautiful if it meets both of the following conditions:

 * The count of even digits in the number is equal to the count of odd digits.
 * The number is divisible by k.

Return the number of beautiful integers in the range [low, high].

Example 1:

Input: low = 10, high = 20, k = 3
Output: 2
Explanation: There are 2 beautiful integers in the given range: [12,18].
- 12 is beautiful because it contains 1 odd digit and 1 even digit, and is divisible by k = 3.
- 18 is beautiful because it contains 1 odd digit and 1 even digit, and is divisible by k = 3.
Additionally we can see that:
- 16 is not beautiful because it is not divisible by k = 3.
- 15 is not beautiful because it does not contain equal counts even and odd digits.
It can be shown that there are only 2 beautiful integers in the given range.

Example 2:

Input: low = 1, high = 10, k = 1
Output: 1
Explanation: There is 1 beautiful integer in the given range: [10].
- 10 is beautiful because it contains 1 odd digit and 1 even digit, and is divisible by k = 1.
It can be shown that there is only 1 beautiful integer in the given range.

Example 3:

Input: low = 5, high = 5, k = 2
Output: 0
Explanation: There are 0 beautiful integers in the given range.
- 5 is not beautiful because it is not divisible by k = 2 and it does not contain equal even and odd digits.


Constraints:

 * 0 < low <= high <= 109
 * 0 < k <= 20
"""
class Solution:
    def numberOfBeautifulIntegers(self, low: int, high: int, k: int) -> int:
        
You are given positive integers low, high, and k.

A number is beautiful if it meets both of the following conditions:

 * The count of even digits in the number is equal to the count of odd digits.
 * The number is divisible by k.

Return the number of beautiful integers in the range [low, high].

Example 1:

Input: low = 10, high = 20, k = 3
Output: 2
Explanation: There are 2 beautiful integers in the given range: [12,18].
- 12 is beautiful because it contains 1 odd digit and 1 even digit, and is divisible by k = 3.
- 18 is beautiful because it contains 1 odd digit and 1 even digit, and is divisible by k = 3.
Additionally we can see that:
- 16 is not beautiful because it is not divisible by k = 3.
- 15 is not beautiful because it does not contain equal counts even and odd digits.
It can be shown that there are only 2 beautiful integers in the given range.

Example 2:

Input: low = 1, high = 10, k = 1
Output: 1
Explanation: There is 1 beautiful integer in the given range: [10].
- 10 is beautiful because it contains 1 odd digit and 1 even digit, and is divisible by k = 1.
It can be shown that there is only 1 beautiful integer in the given range.

Example 3:

Input: low = 5, high = 5, k = 2
Output: 0
Explanation: There are 0 beautiful integers in the given range.
- 5 is not beautiful because it is not divisible by k = 2 and it does not contain equal even and odd digits.


Constraints:

 * 0 < low <= high <= 109
 * 0 < k <= 20


Please complete the code below to solve above prblem:
```python
class Solution:
    def numberOfBeautifulIntegers(self, low: int, high: int, k: int) -> int:
        
```

my_solution = Solution()

test_input = { "low": 10, "high": 20, "k": 3 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 1, "high": 10, "k": 1 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 5, "high": 5, "k": 2 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 3, "high": 31, "k": 16 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 25, "high": 31, "k": 11 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 9, "high": 25, "k": 4 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 58, "high": 72, "k": 16 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 5, "high": 79, "k": 12 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 26, "high": 74, "k": 7 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 4

test_input = { "low": 36, "high": 65, "k": 7 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 12, "high": 84, "k": 8 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 4

test_input = { "low": 13, "high": 91, "k": 13 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 8, "high": 18, "k": 4 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 22, "high": 59, "k": 6 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 15, "high": 27, "k": 9 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 4, "high": 9, "k": 19 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 14, "high": 81, "k": 17 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 12, "high": 33, "k": 18 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 10, "high": 17, "k": 8 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 42, "high": 58, "k": 3 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 22, "high": 42, "k": 4 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 5, "high": 8, "k": 5 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 12, "high": 75, "k": 13 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 2, "high": 28, "k": 1 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 9

test_input = { "low": 29, "high": 35, "k": 17 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 13, "high": 21, "k": 9 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 1, "high": 13, "k": 15 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 12, "high": 21, "k": 16 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 47, "high": 72, "k": 13 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 1, "high": 35, "k": 12 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 38, "high": 52, "k": 4 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 10, "high": 74, "k": 3 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 11

test_input = { "low": 60, "high": 92, "k": 11 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 3, "high": 25, "k": 15 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 63, "high": 65, "k": 20 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 22, "high": 77, "k": 7 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 4

test_input = { "low": 1, "high": 1, "k": 4 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 28, "high": 73, "k": 20 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 21, "high": 32, "k": 6 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 43, "high": 43, "k": 11 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 31, "high": 68, "k": 16 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 1, "high": 8, "k": 4 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 47, "high": 100, "k": 18 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 45, "high": 84, "k": 19 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 31, "high": 80, "k": 11 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 14, "high": 14, "k": 5 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 21, "high": 88, "k": 10 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 11, "high": 42, "k": 3 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 6

test_input = { "low": 19, "high": 53, "k": 16 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 57, "high": 98, "k": 6 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 4

test_input = { "low": 57, "high": 69, "k": 9 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 17, "high": 64, "k": 1 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 23

test_input = { "low": 29, "high": 40, "k": 15 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 36, "high": 60, "k": 3 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 16, "high": 23, "k": 13 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 36, "high": 99, "k": 3 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 11

test_input = { "low": 23, "high": 83, "k": 4 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 6

test_input = { "low": 4, "high": 5, "k": 9 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 15, "high": 21, "k": 2 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 51, "high": 76, "k": 7 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 24, "high": 34, "k": 8 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 24, "high": 99, "k": 1 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 38

test_input = { "low": 37, "high": 63, "k": 10 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 19, "high": 23, "k": 6 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 35, "high": 70, "k": 17 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 3, "high": 18, "k": 19 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 30, "high": 64, "k": 12 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 3, "high": 12, "k": 9 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 14, "high": 21, "k": 16 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 19, "high": 21, "k": 12 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 54, "high": 78, "k": 16 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 24, "high": 36, "k": 20 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 54, "high": 58, "k": 13 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 74, "high": 88, "k": 12 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 45, "high": 58, "k": 14 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 51, "high": 99, "k": 8 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 8, "high": 26, "k": 13 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 12, "high": 92, "k": 3 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 15

test_input = { "low": 18, "high": 91, "k": 11 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 14, "high": 53, "k": 15 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 2

test_input = { "low": 4, "high": 10, "k": 11 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 7, "high": 24, "k": 5 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 1, "high": 25, "k": 8 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 7, "high": 20, "k": 15 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 51, "high": 92, "k": 1 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 21

test_input = { "low": 73, "high": 73, "k": 3 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 50, "high": 63, "k": 19 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 30, "high": 51, "k": 19 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 2, "high": 65, "k": 7 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 5

test_input = { "low": 49, "high": 87, "k": 20 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 3, "high": 6, "k": 1 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 16, "high": 17, "k": 6 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 17, "high": 32, "k": 16 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 13, "high": 14, "k": 6 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 25, "high": 42, "k": 11 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 18, "high": 46, "k": 5 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 3

test_input = { "low": 1, "high": 65, "k": 6 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 5

test_input = { "low": 6, "high": 43, "k": 15 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 1

test_input = { "low": 5, "high": 9, "k": 12 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 0

test_input = { "low": 1, "high": 75, "k": 9 }
assert my_solution.numberOfBeautifulIntegers(**test_input) == 7