minimum-edge-reversals-so-every-node-is-reachable

Minimum Edge Reversals So Every Node Is Reachable

Prompt:
"""
给你一个 n 个点的 简单有向图 （没有重复边的有向图），节点编号为 0 到 n - 1 。如果这些边是双向边，那么这个图形成一棵 树 。

给你一个整数 n 和一个 二维 整数数组 edges ，其中 edges[i] = [ui, vi] 表示从节点 ui 到节点 vi 有一条 有向边 。

边反转 指的是将一条边的方向反转，也就是说一条从节点 ui 到节点 vi 的边会变为一条从节点 vi 到节点 ui 的边。

对于范围 [0, n - 1] 中的每一个节点 i ，你的任务是分别 独立 计算 最少 需要多少次 边反转 ，从节点 i 出发经过 一系列有向边 ，可以到达所有的节点。

请你返回一个长度为 n 的整数数组 answer ，其中 answer[i]表示从节点 i 出发，可以到达所有节点的 最少边反转 次数。

示例 1：

[https://assets.leetcode.com/uploads/2023/08/26/image-20230826221104-3.png]

输入：n = 4, edges = [[2,0],[2,1],[1,3]]
输出：[1,1,0,2]
解释：上图表示了与输入对应的简单有向图。
对于节点 0 ：反转 [2,0] ，从节点 0 出发可以到达所有节点。
所以 answer[0] = 1 。
对于节点 1 ：反转 [2,1] ，从节点 1 出发可以到达所有节点。
所以 answer[1] = 1 。
对于节点 2 ：不需要反转就可以从节点 2 出发到达所有节点。
所以 answer[2] = 0 。
对于节点 3 ：反转 [1,3] 和 [2,1] ，从节点 3 出发可以到达所有节点。
所以 answer[3] = 2 。

示例 2：

[https://assets.leetcode.com/uploads/2023/08/26/image-20230826225541-2.png]

输入：n = 3, edges = [[1,2],[2,0]]
输出：[2,0,1]
解释：上图表示了与输入对应的简单有向图。
对于节点 0 ：反转 [2,0] 和 [1,2] ，从节点 0 出发可以到达所有节点。
所以 answer[0] = 2 。
对于节点 1 ：不需要反转就可以从节点 2 出发到达所有节点。
所以 answer[1] = 0 。
对于节点 2 ：反转 [1,2] ，从节点 2 出发可以到达所有节点。
所以 answer[2] = 1 。

提示：

 * 2 <= n <= 105
 * edges.length == n - 1
 * edges[i].length == 2
 * 0 <= ui == edges[i][0] < n
 * 0 <= vi == edges[i][1] < n
 * ui != vi
 * 输入保证如果边是双向边，可以得到一棵树。
"""
class Solution:
    def minEdgeReversals(self, n: int, edges: List[List[int]]) -> List[int]:

给你一个 n 个点的 简单有向图 （没有重复边的有向图），节点编号为 0 到 n - 1 。如果这些边是双向边，那么这个图形成一棵 树 。

给你一个整数 n 和一个 二维 整数数组 edges ，其中 edges[i] = [ui, vi] 表示从节点 ui 到节点 vi 有一条 有向边 。

边反转 指的是将一条边的方向反转，也就是说一条从节点 ui 到节点 vi 的边会变为一条从节点 vi 到节点 ui 的边。

对于范围 [0, n - 1] 中的每一个节点 i ，你的任务是分别 独立 计算 最少 需要多少次 边反转 ，从节点 i 出发经过 一系列有向边 ，可以到达所有的节点。

请你返回一个长度为 n 的整数数组 answer ，其中 answer[i]表示从节点 i 出发，可以到达所有节点的 最少边反转 次数。

示例 1：

[https://assets.leetcode.com/uploads/2023/08/26/image-20230826221104-3.png]

输入：n = 4, edges = [[2,0],[2,1],[1,3]]
输出：[1,1,0,2]
解释：上图表示了与输入对应的简单有向图。
对于节点 0 ：反转 [2,0] ，从节点 0 出发可以到达所有节点。
所以 answer[0] = 1 。
对于节点 1 ：反转 [2,1] ，从节点 1 出发可以到达所有节点。
所以 answer[1] = 1 。
对于节点 2 ：不需要反转就可以从节点 2 出发到达所有节点。
所以 answer[2] = 0 。
对于节点 3 ：反转 [1,3] 和 [2,1] ，从节点 3 出发可以到达所有节点。
所以 answer[3] = 2 。

示例 2：

[https://assets.leetcode.com/uploads/2023/08/26/image-20230826225541-2.png]

输入：n = 3, edges = [[1,2],[2,0]]
输出：[2,0,1]
解释：上图表示了与输入对应的简单有向图。
对于节点 0 ：反转 [2,0] 和 [1,2] ，从节点 0 出发可以到达所有节点。
所以 answer[0] = 2 。
对于节点 1 ：不需要反转就可以从节点 2 出发到达所有节点。
所以 answer[1] = 0 。
对于节点 2 ：反转 [1,2] ，从节点 2 出发可以到达所有节点。
所以 answer[2] = 1 。

提示：

 * 2 <= n <= 105
 * edges.length == n - 1
 * edges[i].length == 2
 * 0 <= ui == edges[i][0] < n
 * 0 <= vi == edges[i][1] < n
 * ui != vi
 * 输入保证如果边是双向边，可以得到一棵树。

请完成下面的代码来解决上述问题:
```python
class Solution:
    def minEdgeReversals(self, n: int, edges: List[List[int]]) -> List[int]:

```

my_solution = Solution()

test_input = { "n": 4, "edges": [[2,0],[2,1],[1,3]] }
assert my_solution.minEdgeReversals(**test_input) == [1,1,0,2]

test_input = { "n": 3, "edges": [[1,2],[2,0]] }
assert my_solution.minEdgeReversals(**test_input) == [2,0,1]

test_input = { "n": 2, "edges": [[0,1]] }
assert my_solution.minEdgeReversals(**test_input) == [0,1]

test_input = { "n": 3, "edges": [[2,0],[2,1]] }
assert my_solution.minEdgeReversals(**test_input) == [1,1,0]

test_input = { "n": 4, "edges": [[0,1],[3,0],[2,3]] }
assert my_solution.minEdgeReversals(**test_input) == [2,3,0,1]

test_input = { "n": 4, "edges": [[0,2],[0,3],[3,1]] }
assert my_solution.minEdgeReversals(**test_input) == [0,2,1,1]

test_input = { "n": 4, "edges": [[0,3],[1,2],[2,3]] }
assert my_solution.minEdgeReversals(**test_input) == [2,1,2,3]

test_input = { "n": 4, "edges": [[0,3],[1,2],[3,1]] }
assert my_solution.minEdgeReversals(**test_input) == [0,2,3,1]

test_input = { "n": 4, "edges": [[0,3],[2,1],[3,1]] }
assert my_solution.minEdgeReversals(**test_input) == [1,3,2,2]

test_input = { "n": 4, "edges": [[1,0],[2,0],[3,2]] }
assert my_solution.minEdgeReversals(**test_input) == [3,2,2,1]

test_input = { "n": 5, "edges": [[0,1],[0,4],[2,3],[4,2]] }
assert my_solution.minEdgeReversals(**test_input) == [0,1,2,3,1]

test_input = { "n": 5, "edges": [[0,1],[2,0],[0,4],[3,4]] }
assert my_solution.minEdgeReversals(**test_input) == [2,3,1,2,3]

test_input = { "n": 5, "edges": [[0,2],[0,1],[3,1],[4,1]] }
assert my_solution.minEdgeReversals(**test_input) == [2,3,3,2,2]

test_input = { "n": 5, "edges": [[0,2],[0,1],[3,1],[4,3]] }
assert my_solution.minEdgeReversals(**test_input) == [2,3,3,2,1]

test_input = { "n": 5, "edges": [[0,2],[1,3],[1,4],[2,4]] }
assert my_solution.minEdgeReversals(**test_input) == [1,2,2,3,3]

test_input = { "n": 5, "edges": [[0,2],[1,3],[2,3],[4,2]] }
assert my_solution.minEdgeReversals(**test_input) == [2,3,3,4,2]

test_input = { "n": 5, "edges": [[0,2],[2,1],[2,3],[4,3]] }
assert my_solution.minEdgeReversals(**test_input) == [1,3,2,3,2]

test_input = { "n": 5, "edges": [[0,3],[0,4],[1,2],[4,1]] }
assert my_solution.minEdgeReversals(**test_input) == [0,2,3,1,1]

test_input = { "n": 5, "edges": [[1,0],[3,0],[0,4],[2,3]] }
assert my_solution.minEdgeReversals(**test_input) == [3,2,1,2,4]

test_input = { "n": 5, "edges": [[3,0],[0,4],[1,3],[2,3]] }
assert my_solution.minEdgeReversals(**test_input) == [3,1,1,2,4]

test_input = { "n": 6, "edges": [[0,1],[0,5],[1,2],[3,2],[2,4]] }
assert my_solution.minEdgeReversals(**test_input) == [1,2,3,2,4,2]

test_input = { "n": 6, "edges": [[0,1],[2,1],[1,5],[2,3],[4,3]] }
assert my_solution.minEdgeReversals(**test_input) == [2,3,2,3,2,4]

test_input = { "n": 6, "edges": [[0,2],[0,3],[0,1],[0,5],[1,4]] }
assert my_solution.minEdgeReversals(**test_input) == [0,1,1,1,2,1]

test_input = { "n": 6, "edges": [[0,2],[1,3],[1,2],[2,4],[2,5]] }
assert my_solution.minEdgeReversals(**test_input) == [1,1,2,2,3,3]

test_input = { "n": 6, "edges": [[0,4],[1,2],[3,1],[5,1],[4,5]] }
assert my_solution.minEdgeReversals(**test_input) == [1,4,5,3,2,3]

test_input = { "n": 6, "edges": [[1,0],[0,4],[2,4],[2,3],[3,5]] }
assert my_solution.minEdgeReversals(**test_input) == [2,1,2,3,3,4]

test_input = { "n": 6, "edges": [[1,0],[3,1],[1,4],[2,5],[4,5]] }
assert my_solution.minEdgeReversals(**test_input) == [3,2,3,1,3,4]

test_input = { "n": 7, "edges": [[0,5],[2,0],[1,3],[6,2],[4,3],[3,5]] }
assert my_solution.minEdgeReversals(**test_input) == [5,4,4,5,4,6,3]

test_input = { "n": 7, "edges": [[0,6],[2,1],[6,1],[2,5],[5,3],[6,4]] }
assert my_solution.minEdgeReversals(**test_input) == [1,3,2,4,3,3,2]

test_input = { "n": 7, "edges": [[5,0],[2,0],[6,1],[2,4],[2,3],[3,6]] }
assert my_solution.minEdgeReversals(**test_input) == [2,4,1,2,2,1,3]

test_input = { "n": 8, "edges": [[0,4],[0,3],[7,0],[1,4],[2,5],[2,3],[6,5]] }
assert my_solution.minEdgeReversals(**test_input) == [4,4,4,5,5,5,4,3]

test_input = { "n": 8, "edges": [[0,5],[1,0],[1,6],[1,2],[2,3],[2,7],[4,7]] }
assert my_solution.minEdgeReversals(**test_input) == [2,1,2,3,2,3,2,3]

test_input = { "n": 8, "edges": [[1,0],[7,1],[2,6],[5,2],[3,6],[5,4],[5,7]] }
assert my_solution.minEdgeReversals(**test_input) == [4,3,2,2,2,1,3,2]

test_input = { "n": 8, "edges": [[2,0],[5,0],[3,1],[1,4],[6,2],[4,5],[7,5]] }
assert my_solution.minEdgeReversals(**test_input) == [7,4,6,3,5,6,5,5]

test_input = { "n": 8, "edges": [[4,0],[0,1],[1,3],[3,2],[6,2],[2,7],[5,7]] }
assert my_solution.minEdgeReversals(**test_input) == [3,4,6,5,2,6,5,7]

test_input = { "n": 8, "edges": [[4,0],[7,1],[2,3],[7,2],[5,3],[4,6],[7,6]] }
assert my_solution.minEdgeReversals(**test_input) == [3,3,3,4,2,3,3,2]

test_input = { "n": 9, "edges": [[0,5],[0,2],[0,7],[0,4],[7,1],[3,2],[6,3],[8,4]] }
assert my_solution.minEdgeReversals(**test_input) == [3,5,4,3,4,4,2,4,3]

test_input = { "n": 9, "edges": [[0,5],[0,6],[0,2],[5,1],[7,2],[4,2],[3,6],[8,4]] }
assert my_solution.minEdgeReversals(**test_input) == [4,6,5,4,4,5,5,4,3]

test_input = { "n": 9, "edges": [[0,5],[7,0],[1,6],[1,3],[2,8],[3,4],[3,7],[7,8]] }
assert my_solution.minEdgeReversals(**test_input) == [4,1,3,2,3,5,2,3,4]

test_input = { "n": 9, "edges": [[2,0],[1,6],[1,5],[2,3],[2,5],[4,5],[5,7],[8,7]] }
assert my_solution.minEdgeReversals(**test_input) == [4,3,3,4,3,4,4,5,4]

test_input = { "n": 9, "edges": [[7,0],[0,6],[1,2],[2,6],[3,6],[4,5],[5,8],[8,6]] }
assert my_solution.minEdgeReversals(**test_input) == [7,6,7,7,5,6,8,6,7]

test_input = { "n": 10, "edges": [[0,1],[0,2],[2,4],[6,2],[3,9],[5,4],[4,8],[5,7],[9,6]] }
assert my_solution.minEdgeReversals(**test_input) == [4,5,5,2,6,5,4,6,7,3]

test_input = { "n": 10, "edges": [[0,3],[0,5],[0,1],[8,1],[6,1],[2,3],[4,6],[9,4],[5,7]] }
assert my_solution.minEdgeReversals(**test_input) == [5,6,5,6,4,6,5,7,5,3]

test_input = { "n": 10, "edges": [[0,5],[1,3],[1,9],[2,7],[4,2],[6,3],[3,4],[5,4],[7,8]] }
assert my_solution.minEdgeReversals(**test_input) == [3,3,6,4,5,4,3,7,8,4]

test_input = { "n": 10, "edges": [[1,0],[0,5],[6,0],[2,3],[4,2],[2,6],[8,2],[2,9],[8,7]] }
assert my_solution.minEdgeReversals(**test_input) == [5,4,3,4,2,6,4,3,2,4]

test_input = { "n": 10, "edges": [[6,0],[7,0],[4,1],[1,9],[2,7],[9,2],[3,7],[5,7],[8,9]] }
assert my_solution.minEdgeReversals(**test_input) == [9,5,7,7,4,7,8,8,5,6]

test_input = { "n": 10, "edges": [[7,0],[1,2],[1,9],[2,3],[2,8],[5,3],[4,6],[6,7],[7,9]] }
assert my_solution.minEdgeReversals(**test_input) == [5,4,5,6,2,5,3,4,6,5]

test_input = { "n": 10, "edges": [[7,0],[1,5],[2,6],[8,2],[7,3],[4,5],[5,6],[9,7],[8,9]] }
assert my_solution.minEdgeReversals(**test_input) == [6,3,4,6,3,4,5,5,3,4]

test_input = { "n": 11, "edges": [[0,1],[1,2],[8,1],[2,4],[3,9],[3,7],[6,4],[5,7],[5,6],[10,8]] }
assert my_solution.minEdgeReversals(**test_input) == [5,6,7,6,8,6,7,7,5,7,4]

test_input = { "n": 11, "edges": [[0,3],[0,2],[1,4],[1,5],[2,9],[3,5],[7,6],[7,9],[7,8],[8,10]] }
assert my_solution.minEdgeReversals(**test_input) == [2,3,3,3,4,4,4,3,4,4,5]

test_input = { "n": 11, "edges": [[0,3],[0,7],[0,9],[0,10],[1,4],[4,2],[2,6],[6,3],[5,6],[7,8]] }
assert my_solution.minEdgeReversals(**test_input) == [5,2,4,6,3,4,5,6,7,6,6]

test_input = { "n": 11, "edges": [[2,0],[0,9],[1,5],[2,8],[3,5],[3,8],[9,4],[9,6],[6,10],[7,10]] }
assert my_solution.minEdgeReversals(**test_input) == [4,3,3,3,6,4,6,6,4,5,7]

test_input = { "n": 11, "edges": [[6,0],[0,1],[1,4],[2,8],[9,3],[4,10],[5,8],[5,6],[6,9],[10,7]] }
assert my_solution.minEdgeReversals(**test_input) == [3,4,1,4,5,1,2,7,2,3,6]

test_input = { "n": 11, "edges": [[7,0],[1,0],[1,6],[5,1],[4,2],[8,2],[9,2],[7,3],[5,9],[10,5]] }
assert my_solution.minEdgeReversals(**test_input) == [6,5,6,6,5,4,6,5,5,5,3]

test_input = { "n": 11, "edges": [[8,0],[6,1],[7,1],[1,10],[3,2],[4,3],[3,8],[5,8],[8,9],[9,10]] }
assert my_solution.minEdgeReversals(**test_input) == [7,7,6,5,4,5,6,6,6,7,8]

test_input = { "n": 11, "edges": [[10,0],[1,2],[1,10],[2,8],[3,9],[3,5],[4,6],[7,4],[4,8],[5,8]] }
assert my_solution.minEdgeReversals(**test_input) == [6,4,5,4,5,5,6,4,6,5,5]

test_input = { "n": 12, "edges": [[0,10],[1,3],[1,10],[2,7],[2,11],[3,4],[5,9],[5,11],[6,9],[9,8],[9,10]] }
assert my_solution.minEdgeReversals(**test_input) == [5,5,4,6,7,4,4,5,6,5,6,5]

test_input = { "n": 12, "edges": [[3,0],[10,0],[6,0],[1,9],[3,2],[4,6],[4,7],[5,11],[11,7],[8,10],[9,11]] }
assert my_solution.minEdgeReversals(**test_input) == [9,5,9,8,7,6,8,8,7,6,8,7]

test_input = { "n": 12, "edges": [[4,0],[11,0],[1,9],[1,3],[6,2],[2,7],[2,3],[3,10],[4,10],[5,6],[10,8]] }
assert my_solution.minEdgeReversals(**test_input) == [7,5,5,6,6,3,4,6,8,6,7,6]

test_input = { "n": 12, "edges": [[10,0],[0,3],[1,6],[1,8],[1,5],[2,3],[2,4],[3,5],[4,7],[4,11],[10,9]] }
assert my_solution.minEdgeReversals(**test_input) == [3,4,3,4,4,5,5,5,5,3,2,5]

test_input = { "n": 13, "edges": [[0,5],[1,10],[2,4],[2,7],[10,2],[3,5],[5,12],[11,6],[6,12],[8,10],[8,11],[10,9]] }
assert my_solution.minEdgeReversals(**test_input) == [5,4,6,5,7,6,6,7,4,6,5,5,7]

test_input = { "n": 13, "edges": [[0,11],[1,4],[1,8],[1,3],[3,2],[10,3],[12,3],[12,5],[6,11],[10,7],[9,10],[11,12]] }
assert my_solution.minEdgeReversals(**test_input) == [4,6,8,7,7,7,4,7,7,5,6,5,6]

test_input = { "n": 13, "edges": [[5,0],[0,2],[0,9],[10,1],[6,1],[7,2],[2,6],[3,7],[8,4],[4,11],[4,12],[9,12]] }
assert my_solution.minEdgeReversals(**test_input) == [6,9,7,5,7,5,8,6,6,7,8,8,8]

test_input = { "n": 13, "edges": [[7,0],[3,1],[2,4],[2,8],[10,2],[3,10],[9,5],[5,7],[6,11],[6,12],[12,7],[10,12]] }
assert my_solution.minEdgeReversals(**test_input) == [7,4,5,3,6,5,4,6,6,4,4,5,5]

test_input = { "n": 14, "edges": [[0,1],[0,7],[2,6],[2,8],[11,3],[4,12],[4,11],[5,10],[7,11],[13,7],[8,10],[10,9],[9,12]] }
assert my_solution.minEdgeReversals(**test_input) == [7,8,5,10,8,6,6,8,6,8,7,9,9,7]

test_input = { "n": 14, "edges": [[0,1],[1,2],[2,8],[9,2],[6,2],[13,2],[3,4],[5,4],[7,5],[6,10],[12,6],[11,7],[11,10]] }
assert my_solution.minEdgeReversals(**test_input) == [6,7,8,9,10,9,7,8,9,7,8,7,6,7]

test_input = { "n": 14, "edges": [[0,2],[0,3],[0,13],[1,3],[2,4],[8,2],[11,3],[12,3],[4,6],[5,7],[7,9],[7,11],[10,12]] }
assert my_solution.minEdgeReversals(**test_input) == [7,7,8,8,9,5,10,6,7,7,6,7,7,8]

test_input = { "n": 14, "edges": [[0,4],[0,8],[1,3],[1,13],[2,9],[4,11],[4,12],[5,11],[8,6],[13,6],[7,9],[7,8],[10,8]] }
assert my_solution.minEdgeReversals(**test_input) == [6,6,6,7,7,7,8,6,7,7,6,8,8,7]

test_input = { "n": 14, "edges": [[0,6],[5,0],[2,0],[12,1],[13,2],[12,3],[4,7],[5,7],[7,12],[8,13],[9,11],[9,10],[10,13]] }
assert my_solution.minEdgeReversals(**test_input) == [7,9,6,9,6,6,8,7,4,3,4,4,8,5]

test_input = { "n": 14, "edges": [[0,9],[0,11],[0,5],[1,6],[1,11],[7,2],[3,5],[3,12],[3,13],[11,4],[6,10],[9,7],[11,8]] }
assert my_solution.minEdgeReversals(**test_input) == [2,2,5,2,4,3,3,4,4,3,4,3,3,3]

test_input = { "n": 14, "edges": [[0,11],[1,2],[1,10],[1,6],[3,6],[4,11],[10,4],[5,12],[13,6],[8,7],[8,9],[8,12],[8,13]] }
assert my_solution.minEdgeReversals(**test_input) == [7,5,6,5,7,4,6,5,4,5,6,8,5,5]

test_input = { "n": 14, "edges": [[1,0],[1,8],[7,2],[2,11],[2,13],[3,9],[8,3],[3,11],[4,12],[4,8],[5,11],[6,10],[10,12]] }
assert my_solution.minEdgeReversals(**test_input) == [7,6,8,8,6,8,5,7,7,9,6,9,7,9]

test_input = { "n": 14, "edges": [[1,0],[11,0],[6,0],[7,2],[2,8],[10,3],[4,10],[5,12],[12,6],[13,6],[7,10],[9,8],[8,12]] }
assert my_solution.minEdgeReversals(**test_input) == [11,10,7,8,6,8,10,6,8,7,7,10,9,9]

test_input = { "n": 14, "edges": [[3,0],[5,0],[0,7],[1,8],[1,4],[12,2],[4,3],[10,3],[12,5],[13,6],[7,13],[9,10],[10,11]] }
assert my_solution.minEdgeReversals(**test_input) == [7,4,6,6,5,6,10,8,5,4,5,6,5,9]

test_input = { "n": 15, "edges": [[0,5],[1,9],[4,1],[1,5],[14,1],[2,5],[4,3],[4,6],[5,11],[5,7],[10,6],[7,8],[13,7],[14,12]] }
assert my_solution.minEdgeReversals(**test_input) == [6,6,6,6,5,7,6,8,9,7,5,8,6,7,5]

test_input = { "n": 15, "edges": [[0,6],[13,0],[1,2],[10,1],[3,12],[4,11],[5,12],[10,7],[9,7],[7,13],[11,8],[8,9],[12,11],[13,14]] }
assert my_solution.minEdgeReversals(**test_input) == [10,8,9,3,4,3,11,8,6,7,7,5,4,9,10]

test_input = { "n": 15, "edges": [[0,7],[12,1],[5,2],[4,2],[3,8],[3,14],[12,4],[4,7],[5,6],[10,5],[11,5],[6,9],[7,14],[13,12]] }
assert my_solution.minEdgeReversals(**test_input) == [7,7,8,8,7,7,8,8,9,9,6,6,6,5,9]

test_input = { "n": 15, "edges": [[1,0],[10,1],[2,8],[2,3],[5,3],[4,8],[9,5],[6,12],[7,12],[8,7],[9,11],[11,10],[10,13],[10,14]] }
assert my_solution.minEdgeReversals(**test_input) == [7,6,4,5,4,4,6,6,5,3,5,4,7,6,6]

test_input = { "n": 15, "edges": [[2,0],[0,7],[0,5],[1,6],[1,7],[3,4],[8,4],[10,4],[5,12],[5,10],[11,7],[9,13],[10,14],[13,14]] }
assert my_solution.minEdgeReversals(**test_input) == [7,7,6,9,10,8,8,8,9,8,9,7,9,9,10]

test_input = { "n": 15, "edges": [[8,0],[1,0],[1,13],[1,14],[9,2],[3,13],[4,11],[4,14],[5,8],[12,6],[9,6],[7,8],[14,9],[10,13]] }
assert my_solution.minEdgeReversals(**test_input) == [8,7,10,7,7,6,10,6,7,9,7,8,9,8,8]

test_input = { "n": 15, "edges": [[12,0],[0,8],[1,3],[2,1],[2,7],[12,2],[9,3],[4,11],[11,5],[5,7],[6,13],[6,9],[8,14],[10,12]] }
assert my_solution.minEdgeReversals(**test_input) == [7,8,7,9,5,7,7,8,8,8,5,6,6,8,9]

test_input = { "n": 15, "edges": [[12,0],[1,12],[1,7],[2,12],[3,7],[3,14],[4,6],[5,6],[5,7],[6,8],[6,10],[11,6],[7,13],[9,14]] }
assert my_solution.minEdgeReversals(**test_input) == [8,6,6,6,6,6,7,7,8,6,8,6,7,8,7]

test_input = { "n": 16, "edges": [[0,1],[5,0],[0,2],[0,4],[2,12],[10,3],[3,15],[4,7],[8,6],[6,9],[7,14],[7,13],[11,9],[13,9],[10,13]] }
assert my_solution.minEdgeReversals(**test_input) == [5,6,6,8,6,4,8,7,7,9,7,8,7,8,8,9]

test_input = { "n": 16, "edges": [[2,0],[0,4],[4,1],[1,11],[5,2],[8,3],[4,3],[4,13],[14,4],[7,5],[5,12],[6,9],[12,9],[10,14],[11,15]] }
assert my_solution.minEdgeReversals(**test_input) == [7,9,6,9,8,5,6,4,8,7,6,10,6,9,7,11]

test_input = { "n": 16, "edges": [[8,0],[1,6],[10,1],[8,2],[3,15],[14,4],[12,5],[13,5],[8,6],[6,9],[6,13],[11,7],[7,13],[15,10],[11,14]] }
assert my_solution.minEdgeReversals(**test_input) == [8,7,8,4,9,10,8,8,7,9,6,7,9,9,8,5]

test_input = { "n": 17, "edges": [[0,4],[0,9],[13,1],[5,1],[6,2],[13,2],[3,8],[3,15],[3,9],[4,5],[5,10],[11,6],[7,16],[12,9],[16,9],[12,14]] }
assert my_solution.minEdgeReversals(**test_input) == [7,10,10,7,8,9,9,6,8,8,10,8,7,9,8,8,7]

test_input = { "n": 17, "edges": [[0,7],[15,1],[2,3],[2,7],[3,8],[15,3],[5,4],[4,16],[6,14],[16,7],[16,9],[10,14],[10,16],[16,11],[12,14],[15,13]] }
assert my_solution.minEdgeReversals(**test_input) == [8,9,8,9,7,6,7,9,10,9,7,9,7,9,8,8,8]

test_input = { "n": 17, "edges": [[0,10],[12,0],[0,14],[0,7],[0,16],[1,8],[1,7],[2,8],[3,5],[4,15],[5,9],[11,5],[14,6],[11,7],[15,8],[13,16]] }
assert my_solution.minEdgeReversals(**test_input) == [8,8,8,8,7,9,10,9,9,10,9,8,7,8,9,8,9]

test_input = { "n": 17, "edges": [[0,12],[1,2],[1,13],[1,14],[4,3],[3,15],[5,4],[10,6],[14,6],[6,15],[7,11],[8,11],[13,9],[10,11],[15,12],[16,15]] }
assert my_solution.minEdgeReversals(**test_input) == [11,8,9,10,9,8,10,9,9,10,9,10,12,9,9,11,10]

test_input = { "n": 17, "edges": [[0,13],[15,0],[1,5],[1,6],[11,1],[1,13],[8,2],[3,16],[4,16],[7,14],[11,8],[9,10],[9,16],[14,12],[14,15],[15,16]] }
assert my_solution.minEdgeReversals(**test_input) == [8,8,9,7,7,9,9,5,8,7,8,7,7,9,6,7,8]

test_input = { "n": 17, "edges": [[8,0],[0,10],[6,1],[1,15],[15,2],[3,2],[12,3],[9,4],[5,7],[13,7],[9,10],[10,11],[10,14],[13,12],[16,12],[14,15]] }
assert my_solution.minEdgeReversals(**test_input) == [9,11,13,12,10,10,10,11,8,9,10,11,11,10,11,12,10]

test_input = { "n": 17, "edges": [[10,0],[0,5],[1,8],[1,16],[7,2],[2,8],[3,5],[8,3],[4,11],[13,4],[16,6],[16,9],[14,12],[14,13],[14,15],[15,16]] }
assert my_solution.minEdgeReversals(**test_input) == [8,6,6,8,7,9,8,5,7,8,7,8,6,6,5,6,7]

test_input = { "n": 18, "edges": [[0,3],[16,1],[1,10],[2,13],[2,8],[14,3],[4,12],[5,10],[13,6],[7,11],[10,7],[9,7],[14,8],[9,8],[9,17],[12,14],[13,15]] }
assert my_solution.minEdgeReversals(**test_input) == [9,8,9,10,7,8,11,10,10,9,9,11,8,10,9,11,7,10]

test_input = { "n": 18, "edges": [[0,10],[0,17],[1,3],[1,2],[2,9],[2,17],[16,3],[4,7],[4,13],[4,6],[5,12],[5,17],[6,17],[8,15],[11,8],[16,11],[13,14]] }
assert my_solution.minEdgeReversals(**test_input) == [6,5,6,6,5,6,6,6,7,7,7,6,7,6,7,8,5,7]

test_input = { "n": 18, "edges": [[11,0],[5,1],[1,10],[1,3],[1,17],[14,2],[2,13],[3,13],[4,7],[4,12],[4,17],[6,17],[7,8],[15,9],[16,11],[11,14],[14,15]] }
assert my_solution.minEdgeReversals(**test_input) == [7,7,8,8,7,6,7,8,9,9,8,6,8,9,7,8,5,8]

test_input = { "n": 19, "edges": [[0,3],[0,5],[4,0],[12,1],[1,5],[2,17],[2,4],[3,13],[4,8],[5,7],[18,6],[18,8],[14,9],[9,15],[16,9],[10,12],[11,17],[12,16]] }
assert my_solution.minEdgeReversals(**test_input) == [8,8,6,9,7,9,8,10,8,9,6,6,7,10,8,10,8,7,7]

test_input = { "n": 19, "edges": [[0,5],[0,9],[14,1],[2,11],[3,12],[3,8],[10,3],[4,13],[4,12],[6,17],[10,7],[7,14],[8,11],[16,8],[9,14],[9,17],[15,17],[15,18]] }
assert my_solution.minEdgeReversals(**test_input) == [7,10,9,8,8,8,8,8,9,8,7,10,9,9,9,8,8,9,9]

test_input = { "n": 19, "edges": [[0,12],[13,1],[12,1],[14,2],[2,11],[3,9],[11,3],[15,4],[4,11],[5,12],[17,6],[8,7],[8,10],[16,8],[9,12],[11,18],[16,18],[17,18]] }
assert my_solution.minEdgeReversals(**test_input) == [11,13,8,10,8,11,10,11,10,11,11,9,12,12,7,7,9,9,10]

test_input = { "n": 19, "edges": [[0,18],[8,1],[5,1],[9,2],[6,2],[3,11],[17,3],[4,12],[4,6],[18,4],[14,5],[5,16],[6,7],[16,7],[17,7],[15,8],[10,14],[14,13]] }
assert my_solution.minEdgeReversals(**test_input) == [8,11,12,12,10,10,11,12,10,11,8,13,11,10,9,9,11,11,9]

test_input = { "n": 19, "edges": [[1,0],[0,13],[15,0],[1,9],[5,2],[2,13],[3,12],[3,16],[4,12],[5,7],[8,6],[12,8],[16,10],[13,10],[17,11],[13,11],[14,13],[15,18]] }
assert my_solution.minEdgeReversals(**test_input) == [9,8,9,9,9,8,12,9,11,9,11,11,10,10,9,8,10,10,9]


points-that-intersect-with-cars

Points That Intersect With Cars

Prompt:
"""
给你一个下标从 0 开始的二维整数数组 nums 表示汽车停放在数轴上的坐标。对于任意下标 i，nums[i] = [starti, endi] ，其中 starti 是第 i 辆车的起点，endi 是第 i 辆车的终点。

返回数轴上被车 任意部分 覆盖的整数点的数目。

示例 1：

输入：nums = [[3,6],[1,5],[4,7]]
输出：7
解释：从 1 到 7 的所有点都至少与一辆车相交，因此答案为 7 。

示例 2：

输入：nums = [[1,3],[5,8]]
输出：7
解释：1、2、3、5、6、7、8 共计 7 个点满足至少与一辆车相交，因此答案为 7 。

提示：

 * 1 <= nums.length <= 100
 * nums[i].length == 2
 * 1 <= starti <= endi <= 100
"""
class Solution:
    def numberOfPoints(self, nums: List[List[int]]) -> int:

给你一个下标从 0 开始的二维整数数组 nums 表示汽车停放在数轴上的坐标。对于任意下标 i，nums[i] = [starti, endi] ，其中 starti 是第 i 辆车的起点，endi 是第 i 辆车的终点。

返回数轴上被车 任意部分 覆盖的整数点的数目。

示例 1：

输入：nums = [[3,6],[1,5],[4,7]]
输出：7
解释：从 1 到 7 的所有点都至少与一辆车相交，因此答案为 7 。

示例 2：

输入：nums = [[1,3],[5,8]]
输出：7
解释：1、2、3、5、6、7、8 共计 7 个点满足至少与一辆车相交，因此答案为 7 。

提示：

 * 1 <= nums.length <= 100
 * nums[i].length == 2
 * 1 <= starti <= endi <= 100

请完成下面的代码来解决上述问题:
```python
class Solution:
    def numberOfPoints(self, nums: List[List[int]]) -> int:

```


determine-if-a-cell-is-reachable-at-a-given-time

Determine if a Cell Is Reachable at a Given Time

Prompt:
"""
给你四个整数 sx、sy、fx、fy  以及一个 非负整数 t 。

在一个无限的二维网格中，你从单元格 (sx, sy) 开始出发。每一秒，你 必须 移动到任一与之前所处单元格相邻的单元格中。

如果你能在 恰好 t 秒 后到达单元格 (fx, fy) ，返回 true ；否则，返回  false 。

单元格的 相邻单元格 是指该单元格周围与其至少共享一个角的 8 个单元格。你可以多次访问同一个单元格。

示例 1：

[https://assets.leetcode.com/uploads/2023/08/05/example2.svg]

输入：sx = 2, sy = 4, fx = 7, fy = 7, t = 6
输出：true
解释：从单元格 (2, 4) 开始出发，穿过上图标注的单元格，可以在恰好 6 秒后到达单元格 (7, 7) 。

示例 2：

[https://assets.leetcode.com/uploads/2023/08/05/example1.svg]

输入：sx = 3, sy = 1, fx = 7, fy = 3, t = 3
输出：false
解释：从单元格 (3, 1) 开始出发，穿过上图标注的单元格，至少需要 4 秒后到达单元格 (7, 3) 。 因此，无法在 3 秒后到达单元格 (7, 3) 。

提示：

 * 1 <= sx, sy, fx, fy <= 109
 * 0 <= t <= 109
"""
class Solution:
    def isReachableAtTime(self, sx: int, sy: int, fx: int, fy: int, t: int) -> bool:

给你四个整数 sx、sy、fx、fy  以及一个 非负整数 t 。

在一个无限的二维网格中，你从单元格 (sx, sy) 开始出发。每一秒，你 必须 移动到任一与之前所处单元格相邻的单元格中。

如果你能在 恰好 t 秒 后到达单元格 (fx, fy) ，返回 true ；否则，返回  false 。

单元格的 相邻单元格 是指该单元格周围与其至少共享一个角的 8 个单元格。你可以多次访问同一个单元格。

示例 1：

[https://assets.leetcode.com/uploads/2023/08/05/example2.svg]

输入：sx = 2, sy = 4, fx = 7, fy = 7, t = 6
输出：true
解释：从单元格 (2, 4) 开始出发，穿过上图标注的单元格，可以在恰好 6 秒后到达单元格 (7, 7) 。

示例 2：

[https://assets.leetcode.com/uploads/2023/08/05/example1.svg]

输入：sx = 3, sy = 1, fx = 7, fy = 3, t = 3
输出：false
解释：从单元格 (3, 1) 开始出发，穿过上图标注的单元格，至少需要 4 秒后到达单元格 (7, 3) 。 因此，无法在 3 秒后到达单元格 (7, 3) 。

提示：

 * 1 <= sx, sy, fx, fy <= 109
 * 0 <= t <= 109

请完成下面的代码来解决上述问题:
```python
class Solution:
    def isReachableAtTime(self, sx: int, sy: int, fx: int, fy: int, t: int) -> bool:

```

my_solution = Solution()

test_input = { "sx": 3, "sy": 1, "fx": 7, "fy": 3, "t": 3 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 2, "sy": 4, "fx": 7, "fy": 7, "t": 6 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 1, "fx": 1, "fy": 2, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 1, "fx": 2, "fy": 4, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 1, "fx": 3, "fy": 4, "t": 1 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 1, "fx": 3, "fy": 5, "t": 1 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 1, "fx": 1, "fy": 1, "t": 3 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 1, "fx": 1, "fy": 3, "t": 2 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 1, "fx": 4, "fy": 1, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 1, "fx": 4, "fy": 2, "t": 1 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 1, "fx": 1, "fy": 4, "t": 3 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 1, "fx": 1, "fy": 5, "t": 8 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 1, "fx": 2, "fy": 1, "t": 2 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 1, "fx": 4, "fy": 3, "t": 2 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 1, "fx": 2, "fy": 2, "t": 1 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 1, "fx": 4, "fy": 4, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 1, "fx": 5, "fy": 1, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 1, "fx": 2, "fy": 3, "t": 2 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 1, "fx": 5, "fy": 2, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 1, "fx": 2, "fy": 5, "t": 6 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 1, "fx": 3, "fy": 1, "t": 3 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 1, "fx": 3, "fy": 2, "t": 4 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 1, "fx": 3, "fy": 3, "t": 9 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 1, "fx": 4, "fy": 5, "t": 9 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 1, "fx": 5, "fy": 3, "t": 9 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 1, "fx": 5, "fy": 4, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 2, "fx": 1, "fy": 1, "t": 2 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 1, "fx": 5, "fy": 5, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 2, "fx": 1, "fy": 2, "t": 1 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 2, "fx": 1, "fy": 3, "t": 6 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 2, "fx": 1, "fy": 4, "t": 4 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 2, "fx": 2, "fy": 5, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 2, "fx": 3, "fy": 4, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 2, "fx": 1, "fy": 5, "t": 5 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 2, "fx": 3, "fy": 5, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 2, "fx": 4, "fy": 1, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 2, "fx": 2, "fy": 1, "t": 10 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 2, "fx": 2, "fy": 2, "t": 9 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 2, "fx": 2, "fy": 3, "t": 1 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 2, "fx": 4, "fy": 2, "t": 1 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 2, "fx": 2, "fy": 4, "t": 2 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 2, "fx": 4, "fy": 3, "t": 1 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 2, "fx": 4, "fy": 4, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 2, "fx": 3, "fy": 1, "t": 2 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 2, "fx": 3, "fy": 2, "t": 2 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 2, "fx": 4, "fy": 5, "t": 2 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 2, "fx": 3, "fy": 3, "t": 4 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 2, "fx": 5, "fy": 1, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 2, "fx": 5, "fy": 3, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 2, "fx": 5, "fy": 2, "t": 4 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 2, "fx": 5, "fy": 4, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 3, "fx": 1, "fy": 1, "t": 2 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 3, "fx": 1, "fy": 2, "t": 3 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 2, "fx": 5, "fy": 5, "t": 2 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 3, "fx": 2, "fy": 1, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 3, "fx": 2, "fy": 4, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 3, "fx": 1, "fy": 3, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 3, "fx": 1, "fy": 4, "t": 4 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 3, "fx": 1, "fy": 5, "t": 4 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 3, "fx": 2, "fy": 2, "t": 2 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 3, "fx": 2, "fy": 3, "t": 3 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 3, "fx": 3, "fy": 1, "t": 3 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 3, "fx": 2, "fy": 5, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 3, "fx": 4, "fy": 1, "t": 1 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 3, "fx": 3, "fy": 2, "t": 2 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 3, "fx": 3, "fy": 3, "t": 8 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 3, "fx": 4, "fy": 5, "t": 1 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 3, "fx": 5, "fy": 1, "t": 3 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 3, "fx": 5, "fy": 2, "t": 2 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 3, "fx": 5, "fy": 3, "t": 3 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 3, "fx": 5, "fy": 4, "t": 3 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 3, "fx": 5, "fy": 5, "t": 1 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 3, "fx": 3, "fy": 4, "t": 4 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 3, "fx": 3, "fy": 5, "t": 2 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 4, "fx": 1, "fy": 2, "t": 1 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 3, "fx": 4, "fy": 2, "t": 3 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 3, "fx": 4, "fy": 3, "t": 10 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 3, "fx": 4, "fy": 4, "t": 10 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 4, "fx": 1, "fy": 1, "t": 4 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 4, "fx": 1, "fy": 3, "t": 1 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 4, "fx": 1, "fy": 4, "t": 6 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 4, "fx": 2, "fy": 2, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 4, "fx": 1, "fy": 5, "t": 6 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 4, "fx": 2, "fy": 4, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 4, "fx": 2, "fy": 1, "t": 4 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 4, "fx": 3, "fy": 3, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 4, "fx": 2, "fy": 3, "t": 3 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 4, "fx": 2, "fy": 5, "t": 3 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 4, "fx": 3, "fy": 1, "t": 4 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 4, "fx": 3, "fy": 2, "t": 5 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 4, "fx": 4, "fy": 1, "t": 7 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 4, "fx": 3, "fy": 4, "t": 1 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 4, "fx": 4, "fy": 4, "t": 10 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 4, "fx": 4, "fy": 5, "t": 3 }
assert my_solution.isReachableAtTime(**test_input) == True

test_input = { "sx": 1, "sy": 4, "fx": 3, "fy": 5, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 4, "fx": 4, "fy": 2, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 4, "fx": 4, "fy": 3, "t": 1 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 4, "fx": 5, "fy": 2, "t": 1 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 4, "fx": 5, "fy": 4, "t": 3 }
assert my_solution.isReachableAtTime(**test_input) == False

test_input = { "sx": 1, "sy": 4, "fx": 5, "fy": 5, "t": 0 }
assert my_solution.isReachableAtTime(**test_input) == False


minimum-moves-to-spread-stones-over-grid

Minimum Moves to Spread Stones Over Grid

Prompt:
"""
给你一个大小为 3 * 3 ，下标从 0 开始的二维整数矩阵 grid ，分别表示每一个格子里石头的数目。网格图中总共恰好有 9 个石头，一个格子里可能会有 多个 石头。

每一次操作中，你可以将一个石头从它当前所在格子移动到一个至少有一条公共边的相邻格子。

请你返回每个格子恰好有一个石头的 最少移动次数 。

示例 1：

[https://assets.leetcode.com/uploads/2023/08/23/example1-3.svg]

输入：grid = [[1,1,0],[1,1,1],[1,2,1]]
输出：3
解释：让每个格子都有一个石头的一个操作序列为：
1 - 将一个石头从格子 (2,1) 移动到 (2,2) 。
2 - 将一个石头从格子 (2,2) 移动到 (1,2) 。
3 - 将一个石头从格子 (1,2) 移动到 (0,2) 。
总共需要 3 次操作让每个格子都有一个石头。
让每个格子都有一个石头的最少操作次数为 3 。

示例 2：

[https://assets.leetcode.com/uploads/2023/08/23/example2-2.svg]

输入：grid = [[1,3,0],[1,0,0],[1,0,3]]
输出：4
解释：让每个格子都有一个石头的一个操作序列为：
1 - 将一个石头从格子 (0,1) 移动到 (0,2) 。
2 - 将一个石头从格子 (0,1) 移动到 (1,1) 。
3 - 将一个石头从格子 (2,2) 移动到 (1,2) 。
4 - 将一个石头从格子 (2,2) 移动到 (2,1) 。
总共需要 4 次操作让每个格子都有一个石头。
让每个格子都有一个石头的最少操作次数为 4 。

提示：

 * grid.length == grid[i].length == 3
 * 0 <= grid[i][j] <= 9
 * grid 中元素之和为 9 。
"""
class Solution:
    def minimumMoves(self, grid: List[List[int]]) -> int:

给你一个大小为 3 * 3 ，下标从 0 开始的二维整数矩阵 grid ，分别表示每一个格子里石头的数目。网格图中总共恰好有 9 个石头，一个格子里可能会有 多个 石头。

每一次操作中，你可以将一个石头从它当前所在格子移动到一个至少有一条公共边的相邻格子。

请你返回每个格子恰好有一个石头的 最少移动次数 。

示例 1：

[https://assets.leetcode.com/uploads/2023/08/23/example1-3.svg]

输入：grid = [[1,1,0],[1,1,1],[1,2,1]]
输出：3
解释：让每个格子都有一个石头的一个操作序列为：
1 - 将一个石头从格子 (2,1) 移动到 (2,2) 。
2 - 将一个石头从格子 (2,2) 移动到 (1,2) 。
3 - 将一个石头从格子 (1,2) 移动到 (0,2) 。
总共需要 3 次操作让每个格子都有一个石头。
让每个格子都有一个石头的最少操作次数为 3 。

示例 2：

[https://assets.leetcode.com/uploads/2023/08/23/example2-2.svg]

输入：grid = [[1,3,0],[1,0,0],[1,0,3]]
输出：4
解释：让每个格子都有一个石头的一个操作序列为：
1 - 将一个石头从格子 (0,1) 移动到 (0,2) 。
2 - 将一个石头从格子 (0,1) 移动到 (1,1) 。
3 - 将一个石头从格子 (2,2) 移动到 (1,2) 。
4 - 将一个石头从格子 (2,2) 移动到 (2,1) 。
总共需要 4 次操作让每个格子都有一个石头。
让每个格子都有一个石头的最少操作次数为 4 。

提示：

 * grid.length == grid[i].length == 3
 * 0 <= grid[i][j] <= 9
 * grid 中元素之和为 9 。

请完成下面的代码来解决上述问题:
```python
class Solution:
    def minimumMoves(self, grid: List[List[int]]) -> int:

```

my_solution = Solution()

test_input = { "grid": [[1,1,0],[1,1,1],[1,2,1]] }
assert my_solution.minimumMoves(**test_input) == 3

test_input = { "grid": [[1,3,0],[1,0,0],[1,0,3]] }
assert my_solution.minimumMoves(**test_input) == 4

test_input = { "grid": [[1,2,2],[1,1,0],[0,1,1]] }
assert my_solution.minimumMoves(**test_input) == 4

test_input = { "grid": [[1,3,3],[1,0,0],[0,1,0]] }
assert my_solution.minimumMoves(**test_input) == 7

test_input = { "grid": [[3,2,0],[0,1,0],[0,3,0]] }
assert my_solution.minimumMoves(**test_input) == 7

test_input = { "grid": [[1,0,4],[2,0,0],[2,0,0]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[0,1,3],[3,1,0],[0,1,0]] }
assert my_solution.minimumMoves(**test_input) == 5

test_input = { "grid": [[3,0,0],[0,2,1],[1,0,2]] }
assert my_solution.minimumMoves(**test_input) == 5

test_input = { "grid": [[1,0,0],[4,1,1],[0,2,0]] }
assert my_solution.minimumMoves(**test_input) == 7

test_input = { "grid": [[0,2,3],[2,0,1],[0,1,0]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[4,0,0],[0,0,2],[3,0,0]] }
assert my_solution.minimumMoves(**test_input) == 8

test_input = { "grid": [[3,0,0],[4,1,0],[1,0,0]] }
assert my_solution.minimumMoves(**test_input) == 10

test_input = { "grid": [[0,2,1],[1,2,0],[3,0,0]] }
assert my_solution.minimumMoves(**test_input) == 5

test_input = { "grid": [[1,3,0],[0,0,1],[2,1,1]] }
assert my_solution.minimumMoves(**test_input) == 3

test_input = { "grid": [[3,0,0],[1,0,1],[0,2,2]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[4,2,2],[0,1,0],[0,0,0]] }
assert my_solution.minimumMoves(**test_input) == 10

test_input = { "grid": [[3,2,1],[1,1,0],[1,0,0]] }
assert my_solution.minimumMoves(**test_input) == 9

test_input = { "grid": [[0,3,0],[2,0,0],[1,3,0]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[0,0,0],[3,0,0],[4,2,0]] }
assert my_solution.minimumMoves(**test_input) == 13

test_input = { "grid": [[1,1,2],[0,0,0],[0,4,1]] }
assert my_solution.minimumMoves(**test_input) == 5

test_input = { "grid": [[4,0,0],[0,0,0],[1,2,2]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[1,3,1],[0,0,0],[1,2,1]] }
assert my_solution.minimumMoves(**test_input) == 5

test_input = { "grid": [[3,1,0],[1,2,2],[0,0,0]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[2,3,2],[0,1,0],[0,0,1]] }
assert my_solution.minimumMoves(**test_input) == 7

test_input = { "grid": [[0,1,4],[0,3,0],[0,1,0]] }
assert my_solution.minimumMoves(**test_input) == 8

test_input = { "grid": [[0,1,0],[1,4,0],[0,3,0]] }
assert my_solution.minimumMoves(**test_input) == 7

test_input = { "grid": [[0,0,1],[0,0,3],[2,2,1]] }
assert my_solution.minimumMoves(**test_input) == 7

test_input = { "grid": [[1,0,1],[1,2,0],[1,0,3]] }
assert my_solution.minimumMoves(**test_input) == 3

test_input = { "grid": [[0,0,0],[4,1,2],[1,1,0]] }
assert my_solution.minimumMoves(**test_input) == 7

test_input = { "grid": [[2,2,1],[0,2,1],[0,1,0]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[1,0,0],[0,2,0],[4,2,0]] }
assert my_solution.minimumMoves(**test_input) == 10

test_input = { "grid": [[2,0,1],[4,0,0],[0,2,0]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[0,0,3],[0,2,0],[1,3,0]] }
assert my_solution.minimumMoves(**test_input) == 7

test_input = { "grid": [[2,0,1],[1,0,0],[4,0,1]] }
assert my_solution.minimumMoves(**test_input) == 7

test_input = { "grid": [[0,1,0],[1,0,3],[0,3,1]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[0,3,1],[0,0,0],[3,1,1]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[3,0,1],[0,3,1],[0,0,1]] }
assert my_solution.minimumMoves(**test_input) == 5

test_input = { "grid": [[0,4,0],[1,0,0],[0,2,2]] }
assert my_solution.minimumMoves(**test_input) == 5

test_input = { "grid": [[4,2,0],[0,0,0],[1,1,1]] }
assert my_solution.minimumMoves(**test_input) == 7

test_input = { "grid": [[0,2,0],[2,1,2],[0,2,0]] }
assert my_solution.minimumMoves(**test_input) == 4

test_input = { "grid": [[0,1,0],[2,1,1],[4,0,0]] }
assert my_solution.minimumMoves(**test_input) == 8

test_input = { "grid": [[0,4,1],[1,0,1],[0,0,2]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[1,0,0],[0,0,0],[1,3,4]] }
assert my_solution.minimumMoves(**test_input) == 9

test_input = { "grid": [[0,7,1],[0,1,0],[0,0,0]] }
assert my_solution.minimumMoves(**test_input) == 13

test_input = { "grid": [[0,1,1],[0,2,1],[2,0,2]] }
assert my_solution.minimumMoves(**test_input) == 4

test_input = { "grid": [[0,2,0],[3,0,0],[3,1,0]] }
assert my_solution.minimumMoves(**test_input) == 8

test_input = { "grid": [[0,0,0],[2,0,2],[0,2,3]] }
assert my_solution.minimumMoves(**test_input) == 8

test_input = { "grid": [[0,3,4],[0,1,0],[1,0,0]] }
assert my_solution.minimumMoves(**test_input) == 9

test_input = { "grid": [[1,0,0],[0,0,1],[7,0,0]] }
assert my_solution.minimumMoves(**test_input) == 13

test_input = { "grid": [[0,0,2],[2,0,0],[1,4,0]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[2,0,1],[1,3,0],[0,2,0]] }
assert my_solution.minimumMoves(**test_input) == 5

test_input = { "grid": [[1,0,2],[2,3,0],[1,0,0]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[1,1,2],[0,0,0],[3,1,1]] }
assert my_solution.minimumMoves(**test_input) == 4

test_input = { "grid": [[0,2,0],[0,1,0],[0,0,6]] }
assert my_solution.minimumMoves(**test_input) == 10

test_input = { "grid": [[1,1,1],[3,0,0],[2,1,0]] }
assert my_solution.minimumMoves(**test_input) == 5

test_input = { "grid": [[2,0,0],[2,0,1],[3,1,0]] }
assert my_solution.minimumMoves(**test_input) == 8

test_input = { "grid": [[1,1,0],[0,2,2],[0,3,0]] }
assert my_solution.minimumMoves(**test_input) == 4

test_input = { "grid": [[1,0,3],[1,1,0],[1,0,2]] }
assert my_solution.minimumMoves(**test_input) == 3

test_input = { "grid": [[1,3,0],[2,0,0],[3,0,0]] }
assert my_solution.minimumMoves(**test_input) == 7

test_input = { "grid": [[1,0,1],[0,0,1],[0,1,5]] }
assert my_solution.minimumMoves(**test_input) == 10

test_input = { "grid": [[2,0,0],[0,2,1],[1,1,2]] }
assert my_solution.minimumMoves(**test_input) == 4

test_input = { "grid": [[1,2,3],[1,0,1],[0,0,1]] }
assert my_solution.minimumMoves(**test_input) == 8

test_input = { "grid": [[0,2,3],[1,0,0],[0,1,2]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[4,1,0],[0,1,1],[2,0,0]] }
assert my_solution.minimumMoves(**test_input) == 8

test_input = { "grid": [[2,0,1],[1,0,1],[1,2,1]] }
assert my_solution.minimumMoves(**test_input) == 2

test_input = { "grid": [[3,0,3],[0,0,0],[1,1,1]] }
assert my_solution.minimumMoves(**test_input) == 5

test_input = { "grid": [[0,0,0],[3,4,2],[0,0,0]] }
assert my_solution.minimumMoves(**test_input) == 7

test_input = { "grid": [[2,1,2],[0,0,1],[3,0,0]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[1,0,0],[0,3,3],[0,0,2]] }
assert my_solution.minimumMoves(**test_input) == 7

test_input = { "grid": [[0,2,0],[1,0,1],[1,3,1]] }
assert my_solution.minimumMoves(**test_input) == 5

test_input = { "grid": [[0,1,0],[2,0,4],[1,0,1]] }
assert my_solution.minimumMoves(**test_input) == 5

test_input = { "grid": [[1,0,3],[0,0,2],[0,1,2]] }
assert my_solution.minimumMoves(**test_input) == 7

test_input = { "grid": [[2,1,1],[0,0,0],[0,1,4]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[2,0,1],[0,2,0],[1,3,0]] }
assert my_solution.minimumMoves(**test_input) == 5

test_input = { "grid": [[2,0,2],[0,0,2],[0,0,3]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[0,2,2],[2,0,1],[1,1,0]] }
assert my_solution.minimumMoves(**test_input) == 4

test_input = { "grid": [[0,0,1],[2,3,2],[1,0,0]] }
assert my_solution.minimumMoves(**test_input) == 4

test_input = { "grid": [[1,1,0],[3,0,4],[0,0,0]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[1,0,0],[0,0,0],[5,1,2]] }
assert my_solution.minimumMoves(**test_input) == 11

test_input = { "grid": [[1,0,0],[3,5,0],[0,0,0]] }
assert my_solution.minimumMoves(**test_input) == 9

test_input = { "grid": [[3,1,1],[1,1,0],[2,0,0]] }
assert my_solution.minimumMoves(**test_input) == 8

test_input = { "grid": [[0,1,3],[0,0,1],[1,2,1]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[0,0,0],[1,2,0],[3,0,3]] }
assert my_solution.minimumMoves(**test_input) == 7

test_input = { "grid": [[0,0,0],[1,2,2],[2,0,2]] }
assert my_solution.minimumMoves(**test_input) == 5

test_input = { "grid": [[4,0,0],[2,3,0],[0,0,0]] }
assert my_solution.minimumMoves(**test_input) == 10

test_input = { "grid": [[1,1,0],[1,0,1],[4,1,0]] }
assert my_solution.minimumMoves(**test_input) == 8

test_input = { "grid": [[0,0,1],[0,1,2],[1,0,4]] }
assert my_solution.minimumMoves(**test_input) == 10

test_input = { "grid": [[0,1,3],[2,0,0],[0,3,0]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[0,0,0],[5,0,1],[1,1,1]] }
assert my_solution.minimumMoves(**test_input) == 7

test_input = { "grid": [[0,1,1],[0,0,3],[2,1,1]] }
assert my_solution.minimumMoves(**test_input) == 5

test_input = { "grid": [[2,0,1],[0,0,1],[2,2,1]] }
assert my_solution.minimumMoves(**test_input) == 3

test_input = { "grid": [[3,0,2],[2,1,0],[0,0,1]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[0,0,2],[0,0,2],[4,0,1]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[3,0,0],[0,2,0],[0,0,4]] }
assert my_solution.minimumMoves(**test_input) == 8

test_input = { "grid": [[0,1,3],[1,0,0],[0,4,0]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[2,1,2],[0,2,1],[1,0,0]] }
assert my_solution.minimumMoves(**test_input) == 4

test_input = { "grid": [[0,0,2],[1,0,3],[1,0,2]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[0,2,2],[0,1,4],[0,0,0]] }
assert my_solution.minimumMoves(**test_input) == 10

test_input = { "grid": [[1,0,1],[0,0,5],[1,1,0]] }
assert my_solution.minimumMoves(**test_input) == 6

test_input = { "grid": [[3,1,0],[0,0,0],[0,1,4]] }
assert my_solution.minimumMoves(**test_input) == 8


string-transformation

String Transformation

Prompt:
"""
给你两个长度都为 n 的字符串 s 和 t 。你可以对字符串 s 执行以下操作：

 * 将 s 长度为 l （0 < l < n）的 后缀字符串 删除，并将它添加在 s 的开头。
   比方说，s = 'abcd' ，那么一次操作中，你可以删除后缀 'cd' ，并将它添加到 s 的开头，得到 s = 'cdab' 。

给你一个整数 k ，请你返回 恰好 k 次操作将 s 变为 t 的方案数。

由于答案可能很大，返回答案对 109 + 7 取余 后的结果。

示例 1：

输入：s = "abcd", t = "cdab", k = 2
输出：2
解释：
第一种方案：
第一次操作，选择 index = 3 开始的后缀，得到 s = "dabc" 。
第二次操作，选择 index = 3 开始的后缀，得到 s = "cdab" 。

第二种方案：
第一次操作，选择 index = 1 开始的后缀，得到 s = "bcda" 。
第二次操作，选择 index = 1 开始的后缀，得到 s = "cdab" 。

示例 2：

输入：s = "ababab", t = "ababab", k = 1
输出：2
解释：
第一种方案：
选择 index = 2 开始的后缀，得到 s = "ababab" 。

第二种方案：
选择 index = 4 开始的后缀，得到 s = "ababab" 。

提示：

 * 2 <= s.length <= 5 * 105
 * 1 <= k <= 1015
 * s.length == t.length
 * s 和 t 都只包含小写英文字母。
"""
class Solution:
    def numberOfWays(self, s: str, t: str, k: int) -> int:

给你两个长度都为 n 的字符串 s 和 t 。你可以对字符串 s 执行以下操作：

 * 将 s 长度为 l （0 < l < n）的 后缀字符串 删除，并将它添加在 s 的开头。
   比方说，s = 'abcd' ，那么一次操作中，你可以删除后缀 'cd' ，并将它添加到 s 的开头，得到 s = 'cdab' 。

给你一个整数 k ，请你返回 恰好 k 次操作将 s 变为 t 的方案数。

由于答案可能很大，返回答案对 109 + 7 取余 后的结果。

示例 1：

输入：s = "abcd", t = "cdab", k = 2
输出：2
解释：
第一种方案：
第一次操作，选择 index = 3 开始的后缀，得到 s = "dabc" 。
第二次操作，选择 index = 3 开始的后缀，得到 s = "cdab" 。

第二种方案：
第一次操作，选择 index = 1 开始的后缀，得到 s = "bcda" 。
第二次操作，选择 index = 1 开始的后缀，得到 s = "cdab" 。

示例 2：

输入：s = "ababab", t = "ababab", k = 1
输出：2
解释：
第一种方案：
选择 index = 2 开始的后缀，得到 s = "ababab" 。

第二种方案：
选择 index = 4 开始的后缀，得到 s = "ababab" 。

提示：

 * 2 <= s.length <= 5 * 105
 * 1 <= k <= 1015
 * s.length == t.length
 * s 和 t 都只包含小写英文字母。

请完成下面的代码来解决上述问题:
```python
class Solution:
    def numberOfWays(self, s: str, t: str, k: int) -> int:

```

my_solution = Solution()

test_input = { "s": "abcd", "t": "cdab", "k": 2 }
assert my_solution.numberOfWays(**test_input) == 2

test_input = { "s": "ababab", "t": "ababab", "k": 1 }
assert my_solution.numberOfWays(**test_input) == 2

test_input = { "s": "goxoq", "t": "dfqgl", "k": 244326024901249 }
assert my_solution.numberOfWays(**test_input) == 0

test_input = { "s": "ceoceo", "t": "eoceoc", "k": 4 }
assert my_solution.numberOfWays(**test_input) == 208

test_input = { "s": "ib", "t": "ib", "k": 10 }
assert my_solution.numberOfWays(**test_input) == 1

test_input = { "s": "ttttttt", "t": "ttttttt", "k": 5 }
assert my_solution.numberOfWays(**test_input) == 7776

test_input = { "s": "aaaa", "t": "aaaa", "k": 8 }
assert my_solution.numberOfWays(**test_input) == 6561

test_input = { "s": "meplrmeplr", "t": "eplrmeplrm", "k": 7 }
assert my_solution.numberOfWays(**test_input) == 956594

test_input = { "s": "dsmn", "t": "smnd", "k": 3 }
assert my_solution.numberOfWays(**test_input) == 7

test_input = { "s": "jjj", "t": "jjj", "k": 10 }
assert my_solution.numberOfWays(**test_input) == 1024

test_input = { "s": "rrrrr", "t": "rrrrr", "k": 1 }
assert my_solution.numberOfWays(**test_input) == 4

test_input = { "s": "fefe", "t": "fefe", "k": 9 }
assert my_solution.numberOfWays(**test_input) == 9841

test_input = { "s": "pfly", "t": "wvqr", "k": 840550364246523 }
assert my_solution.numberOfWays(**test_input) == 0

test_input = { "s": "ltjwwltjww", "t": "jwwltjwwlt", "k": 1 }
assert my_solution.numberOfWays(**test_input) == 2

test_input = { "s": "mb", "t": "mb", "k": 3 }
assert my_solution.numberOfWays(**test_input) == 0

test_input = { "s": "jjjjjjjjjj", "t": "jjjjjjjjjj", "k": 3 }
assert my_solution.numberOfWays(**test_input) == 729

test_input = { "s": "oqytlmi", "t": "lmioqyt", "k": 8 }
assert my_solution.numberOfWays(**test_input) == 239945

test_input = { "s": "hpcg", "t": "pcgh", "k": 5 }
assert my_solution.numberOfWays(**test_input) == 61

test_input = { "s": "bqbqbqbqbq", "t": "bqbqbqbqbq", "k": 9 }
assert my_solution.numberOfWays(**test_input) == 193710244

test_input = { "s": "ccccccccc", "t": "ccccccccc", "k": 7 }
assert my_solution.numberOfWays(**test_input) == 2097152

test_input = { "s": "jjjjjjjjjj", "t": "jjjjjjjjjj", "k": 9 }
assert my_solution.numberOfWays(**test_input) == 387420489

test_input = { "s": "qqqq", "t": "qqqq", "k": 9 }
assert my_solution.numberOfWays(**test_input) == 19683

test_input = { "s": "loppaqg", "t": "nvbxtmh", "k": 104865546226045 }
assert my_solution.numberOfWays(**test_input) == 0

test_input = { "s": "qqqqqqqqqq", "t": "qqqqqqqqqq", "k": 3 }
assert my_solution.numberOfWays(**test_input) == 729

test_input = { "s": "qsqsqsqsqs", "t": "qsqsqsqsqs", "k": 2 }
assert my_solution.numberOfWays(**test_input) == 41

test_input = { "s": "nnnnn", "t": "nnnnn", "k": 5 }
assert my_solution.numberOfWays(**test_input) == 1024

test_input = { "s": "klncccd", "t": "klncccd", "k": 1 }
assert my_solution.numberOfWays(**test_input) == 0

test_input = { "s": "qqqqq", "t": "qqqqq", "k": 9 }
assert my_solution.numberOfWays(**test_input) == 262144

test_input = { "s": "qvxrlh", "t": "hqvxrl", "k": 6 }
assert my_solution.numberOfWays(**test_input) == 2604

test_input = { "s": "uuuu", "t": "uuuu", "k": 9 }
assert my_solution.numberOfWays(**test_input) == 19683

test_input = { "s": "sss", "t": "sss", "k": 7 }
assert my_solution.numberOfWays(**test_input) == 128

test_input = { "s": "gggggggggg", "t": "gggggggggg", "k": 1 }
assert my_solution.numberOfWays(**test_input) == 9

test_input = { "s": "ks", "t": "cj", "k": 400700574233583 }
assert my_solution.numberOfWays(**test_input) == 0

test_input = { "s": "lllllllll", "t": "lllllllll", "k": 5 }
assert my_solution.numberOfWays(**test_input) == 32768

test_input = { "s": "uhixx", "t": "xxuhi", "k": 3 }
assert my_solution.numberOfWays(**test_input) == 13

test_input = { "s": "vkrvkrvkr", "t": "rvkrvkrvk", "k": 2 }
assert my_solution.numberOfWays(**test_input) == 21

test_input = { "s": "xtxtxtxt", "t": "xtxtxtxt", "k": 8 }
assert my_solution.numberOfWays(**test_input) == 2882401

test_input = { "s": "nzybrhi", "t": "rhinzyb", "k": 6 }
assert my_solution.numberOfWays(**test_input) == 6665

test_input = { "s": "ff", "t": "ff", "k": 4 }
assert my_solution.numberOfWays(**test_input) == 1

test_input = { "s": "ubagdasws", "t": "aswsubagd", "k": 9 }
assert my_solution.numberOfWays(**test_input) == 14913081

test_input = { "s": "aaaaa", "t": "aaaaa", "k": 10 }
assert my_solution.numberOfWays(**test_input) == 1048576

test_input = { "s": "iiiiiiiiii", "t": "iiiiiiiiii", "k": 4 }
assert my_solution.numberOfWays(**test_input) == 6561

test_input = { "s": "nnjqjmgome", "t": "gbfuecwlqc", "k": 359221508193514 }
assert my_solution.numberOfWays(**test_input) == 0

test_input = { "s": "slmzyj", "t": "slmzyj", "k": 4 }
assert my_solution.numberOfWays(**test_input) == 105

test_input = { "s": "vfyxl", "t": "vfyxl", "k": 10 }
assert my_solution.numberOfWays(**test_input) == 209716

test_input = { "s": "sxzfvsxzfv", "t": "vsxzfvsxzf", "k": 2 }
assert my_solution.numberOfWays(**test_input) == 16

test_input = { "s": "kalt", "t": "ltka", "k": 7 }
assert my_solution.numberOfWays(**test_input) == 547

test_input = { "s": "jj", "t": "jj", "k": 7 }
assert my_solution.numberOfWays(**test_input) == 1

test_input = { "s": "bcriunp", "t": "criunpb", "k": 2 }
assert my_solution.numberOfWays(**test_input) == 5

test_input = { "s": "rutmzyj", "t": "zyjrutm", "k": 6 }
assert my_solution.numberOfWays(**test_input) == 6665

test_input = { "s": "vvvvv", "t": "vvvvv", "k": 3 }
assert my_solution.numberOfWays(**test_input) == 64

test_input = { "s": "hlld", "t": "hlld", "k": 9 }
assert my_solution.numberOfWays(**test_input) == 4920

test_input = { "s": "kctcsgswa", "t": "qfyyjeohe", "k": 966836940319300 }
assert my_solution.numberOfWays(**test_input) == 0

test_input = { "s": "otwqxmpktt", "t": "totwqxmpkt", "k": 7 }
assert my_solution.numberOfWays(**test_input) == 478297

test_input = { "s": "kkkkkkk", "t": "kkkkkkk", "k": 7 }
assert my_solution.numberOfWays(**test_input) == 279936

test_input = { "s": "iyl", "t": "iyl", "k": 6 }
assert my_solution.numberOfWays(**test_input) == 22

test_input = { "s": "glao", "t": "ogla", "k": 10 }
assert my_solution.numberOfWays(**test_input) == 14762

test_input = { "s": "jp", "t": "jp", "k": 8 }
assert my_solution.numberOfWays(**test_input) == 1

test_input = { "s": "uuuuuu", "t": "uuuuuu", "k": 7 }
assert my_solution.numberOfWays(**test_input) == 78125

test_input = { "s": "achach", "t": "achach", "k": 10 }
assert my_solution.numberOfWays(**test_input) == 3255209

test_input = { "s": "uuuuuuuu", "t": "uuuuuuuu", "k": 7 }
assert my_solution.numberOfWays(**test_input) == 823543

test_input = { "s": "gjh", "t": "jhg", "k": 9 }
assert my_solution.numberOfWays(**test_input) == 171

test_input = { "s": "cliuw", "t": "fphcn", "k": 647756904366432 }
assert my_solution.numberOfWays(**test_input) == 0

test_input = { "s": "zmcum", "t": "mzmcu", "k": 1 }
assert my_solution.numberOfWays(**test_input) == 1

test_input = { "s": "ll", "t": "ll", "k": 5 }
assert my_solution.numberOfWays(**test_input) == 1

test_input = { "s": "ccccc", "t": "ccccc", "k": 1 }
assert my_solution.numberOfWays(**test_input) == 4

test_input = { "s": "rrrr", "t": "rrrr", "k": 1 }
assert my_solution.numberOfWays(**test_input) == 3

test_input = { "s": "ih", "t": "hi", "k": 8 }
assert my_solution.numberOfWays(**test_input) == 0

test_input = { "s": "qfgihqrw", "t": "rwqfgihq", "k": 8 }
assert my_solution.numberOfWays(**test_input) == 720600

test_input = { "s": "cd", "t": "cd", "k": 2 }
assert my_solution.numberOfWays(**test_input) == 1

test_input = { "s": "oooooooooo", "t": "oooooooooo", "k": 4 }
assert my_solution.numberOfWays(**test_input) == 6561

test_input = { "s": "wp", "t": "wp", "k": 6 }
assert my_solution.numberOfWays(**test_input) == 1

test_input = { "s": "rqq", "t": "nln", "k": 776508964349618 }
assert my_solution.numberOfWays(**test_input) == 0

test_input = { "s": "rr", "t": "rr", "k": 9 }
assert my_solution.numberOfWays(**test_input) == 1

test_input = { "s": "knwppsd", "t": "psdknwp", "k": 2 }
assert my_solution.numberOfWays(**test_input) == 5

test_input = { "s": "epfeepfe", "t": "feepfeep", "k": 9 }
assert my_solution.numberOfWays(**test_input) == 10088402

test_input = { "s": "wwwww", "t": "wwwww", "k": 9 }
assert my_solution.numberOfWays(**test_input) == 262144

test_input = { "s": "cdcdcdcd", "t": "cdcdcdcd", "k": 6 }
assert my_solution.numberOfWays(**test_input) == 58825

test_input = { "s": "uphfr", "t": "fruph", "k": 7 }
assert my_solution.numberOfWays(**test_input) == 3277

test_input = { "s": "cocococo", "t": "cocococo", "k": 3 }
assert my_solution.numberOfWays(**test_input) == 171

test_input = { "s": "vhzjo", "t": "jovhz", "k": 1 }
assert my_solution.numberOfWays(**test_input) == 1

test_input = { "s": "bbbbbbbbbb", "t": "bbbbbbbbbb", "k": 1 }
assert my_solution.numberOfWays(**test_input) == 9

test_input = { "s": "pgnrstuh", "t": "yjzhldlg", "k": 618648276258027 }
assert my_solution.numberOfWays(**test_input) == 0

test_input = { "s": "cccccc", "t": "cccccc", "k": 5 }
assert my_solution.numberOfWays(**test_input) == 3125

test_input = { "s": "kkkkkkk", "t": "kkkkkkk", "k": 3 }
assert my_solution.numberOfWays(**test_input) == 216

test_input = { "s": "lxqqzsvej", "t": "svejlxqqz", "k": 3 }
assert my_solution.numberOfWays(**test_input) == 57

test_input = { "s": "lllll", "t": "lllll", "k": 3 }
assert my_solution.numberOfWays(**test_input) == 64

test_input = { "s": "hhhhhhhhhh", "t": "hhhhhhhhhh", "k": 8 }
assert my_solution.numberOfWays(**test_input) == 43046721

test_input = { "s": "gggg", "t": "gggg", "k": 5 }
assert my_solution.numberOfWays(**test_input) == 243

test_input = { "s": "jj", "t": "jj", "k": 6 }
assert my_solution.numberOfWays(**test_input) == 1

test_input = { "s": "uuuuuuuuu", "t": "uuuuuuuuu", "k": 10 }
assert my_solution.numberOfWays(**test_input) == 73741817

test_input = { "s": "qvx", "t": "vxq", "k": 8 }
assert my_solution.numberOfWays(**test_input) == 85

test_input = { "s": "nolnqlgqcs", "t": "jkguybcfcu", "k": 179216079747558 }
assert my_solution.numberOfWays(**test_input) == 0

test_input = { "s": "xpk", "t": "xpk", "k": 6 }
assert my_solution.numberOfWays(**test_input) == 22

test_input = { "s": "xzoyb", "t": "bxzoy", "k": 5 }
assert my_solution.numberOfWays(**test_input) == 205

test_input = { "s": "krxjvvg", "t": "krxjvvg", "k": 2 }
assert my_solution.numberOfWays(**test_input) == 6

test_input = { "s": "ks", "t": "sk", "k": 2 }
assert my_solution.numberOfWays(**test_input) == 0

test_input = { "s": "ty", "t": "ty", "k": 6 }
assert my_solution.numberOfWays(**test_input) == 1

test_input = { "s": "otototot", "t": "totototo", "k": 7 }
assert my_solution.numberOfWays(**test_input) == 411772

test_input = { "s": "uoaowbdznp", "t": "npuoaowbdz", "k": 10 }
assert my_solution.numberOfWays(**test_input) == 348678440


count-symmetric-integers

Count Symmetric Integers

Prompt:
"""
给你两个正整数 low 和 high 。

对于一个由 2 * n 位数字组成的整数 x ，如果其前 n 位数字之和与后 n 位数字之和相等，则认为这个数字是一个对称整数。

返回在 [low, high] 范围内的 对称整数的数目 。

示例 1：

输入：low = 1, high = 100
输出：9
解释：在 1 到 100 范围内共有 9 个对称整数：11、22、33、44、55、66、77、88 和 99 。

示例 2：

输入：low = 1200, high = 1230
输出：4
解释：在 1200 到 1230 范围内共有 4 个对称整数：1203、1212、1221 和 1230 。

提示：

 * 1 <= low <= high <= 104
"""
class Solution:
    def countSymmetricIntegers(self, low: int, high: int) -> int:

给你两个正整数 low 和 high 。

对于一个由 2 * n 位数字组成的整数 x ，如果其前 n 位数字之和与后 n 位数字之和相等，则认为这个数字是一个对称整数。

返回在 [low, high] 范围内的 对称整数的数目 。

示例 1：

输入：low = 1, high = 100
输出：9
解释：在 1 到 100 范围内共有 9 个对称整数：11、22、33、44、55、66、77、88 和 99 。

示例 2：

输入：low = 1200, high = 1230
输出：4
解释：在 1200 到 1230 范围内共有 4 个对称整数：1203、1212、1221 和 1230 。

提示：

 * 1 <= low <= high <= 104

请完成下面的代码来解决上述问题:
```python
class Solution:
    def countSymmetricIntegers(self, low: int, high: int) -> int:

```

my_solution = Solution()

test_input = { "low": 1, "high": 100 }
assert my_solution.countSymmetricIntegers(**test_input) == 9

test_input = { "low": 1200, "high": 1230 }
assert my_solution.countSymmetricIntegers(**test_input) == 4

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

test_input = { "low": 1, "high": 2 }
assert my_solution.countSymmetricIntegers(**test_input) == 0

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

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

test_input = { "low": 1, "high": 5 }
assert my_solution.countSymmetricIntegers(**test_input) == 0

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

test_input = { "low": 1, "high": 7 }
assert my_solution.countSymmetricIntegers(**test_input) == 0

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

test_input = { "low": 1, "high": 9 }
assert my_solution.countSymmetricIntegers(**test_input) == 0

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

test_input = { "low": 1, "high": 11 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

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

test_input = { "low": 1, "high": 13 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 1, "high": 14 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 1, "high": 15 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 1, "high": 16 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 1, "high": 17 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 1, "high": 18 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 1, "high": 19 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 1, "high": 20 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 1, "high": 21 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 1, "high": 22 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 1, "high": 23 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 1, "high": 24 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 1, "high": 25 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 1, "high": 26 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 1, "high": 27 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

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

test_input = { "low": 1, "high": 29 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 1, "high": 30 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 1, "high": 31 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 1, "high": 32 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 1, "high": 33 }
assert my_solution.countSymmetricIntegers(**test_input) == 3

test_input = { "low": 1, "high": 34 }
assert my_solution.countSymmetricIntegers(**test_input) == 3

test_input = { "low": 1, "high": 35 }
assert my_solution.countSymmetricIntegers(**test_input) == 3

test_input = { "low": 1, "high": 36 }
assert my_solution.countSymmetricIntegers(**test_input) == 3

test_input = { "low": 1, "high": 37 }
assert my_solution.countSymmetricIntegers(**test_input) == 3

test_input = { "low": 1, "high": 38 }
assert my_solution.countSymmetricIntegers(**test_input) == 3

test_input = { "low": 1, "high": 39 }
assert my_solution.countSymmetricIntegers(**test_input) == 3

test_input = { "low": 1, "high": 40 }
assert my_solution.countSymmetricIntegers(**test_input) == 3

test_input = { "low": 1, "high": 41 }
assert my_solution.countSymmetricIntegers(**test_input) == 3

test_input = { "low": 1, "high": 42 }
assert my_solution.countSymmetricIntegers(**test_input) == 3

test_input = { "low": 1, "high": 43 }
assert my_solution.countSymmetricIntegers(**test_input) == 3

test_input = { "low": 1, "high": 44 }
assert my_solution.countSymmetricIntegers(**test_input) == 4

test_input = { "low": 1, "high": 45 }
assert my_solution.countSymmetricIntegers(**test_input) == 4

test_input = { "low": 1, "high": 46 }
assert my_solution.countSymmetricIntegers(**test_input) == 4

test_input = { "low": 1, "high": 47 }
assert my_solution.countSymmetricIntegers(**test_input) == 4

test_input = { "low": 1, "high": 48 }
assert my_solution.countSymmetricIntegers(**test_input) == 4

test_input = { "low": 100, "high": 1782 }
assert my_solution.countSymmetricIntegers(**test_input) == 44

test_input = { "low": 1, "high": 49 }
assert my_solution.countSymmetricIntegers(**test_input) == 4

test_input = { "low": 1, "high": 50 }
assert my_solution.countSymmetricIntegers(**test_input) == 4

test_input = { "low": 1, "high": 51 }
assert my_solution.countSymmetricIntegers(**test_input) == 4

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

test_input = { "low": 1, "high": 53 }
assert my_solution.countSymmetricIntegers(**test_input) == 4

test_input = { "low": 1, "high": 54 }
assert my_solution.countSymmetricIntegers(**test_input) == 4

test_input = { "low": 1, "high": 55 }
assert my_solution.countSymmetricIntegers(**test_input) == 5

test_input = { "low": 1, "high": 56 }
assert my_solution.countSymmetricIntegers(**test_input) == 5

test_input = { "low": 1, "high": 57 }
assert my_solution.countSymmetricIntegers(**test_input) == 5

test_input = { "low": 1, "high": 58 }
assert my_solution.countSymmetricIntegers(**test_input) == 5

test_input = { "low": 1, "high": 59 }
assert my_solution.countSymmetricIntegers(**test_input) == 5

test_input = { "low": 1, "high": 60 }
assert my_solution.countSymmetricIntegers(**test_input) == 5

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

test_input = { "low": 2, "high": 3 }
assert my_solution.countSymmetricIntegers(**test_input) == 0

test_input = { "low": 2, "high": 4 }
assert my_solution.countSymmetricIntegers(**test_input) == 0

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

test_input = { "low": 2, "high": 6 }
assert my_solution.countSymmetricIntegers(**test_input) == 0

test_input = { "low": 2, "high": 7 }
assert my_solution.countSymmetricIntegers(**test_input) == 0

test_input = { "low": 2, "high": 8 }
assert my_solution.countSymmetricIntegers(**test_input) == 0

test_input = { "low": 2, "high": 9 }
assert my_solution.countSymmetricIntegers(**test_input) == 0

test_input = { "low": 2, "high": 10 }
assert my_solution.countSymmetricIntegers(**test_input) == 0

test_input = { "low": 2, "high": 11 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 2, "high": 12 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 2, "high": 13 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 2, "high": 14 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 2, "high": 15 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 2, "high": 16 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 2, "high": 17 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 2, "high": 18 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 2, "high": 19 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 2, "high": 20 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 2, "high": 21 }
assert my_solution.countSymmetricIntegers(**test_input) == 1

test_input = { "low": 2, "high": 22 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 2, "high": 23 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 2, "high": 24 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 2, "high": 25 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 2, "high": 26 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 2, "high": 27 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 2, "high": 28 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 2, "high": 29 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 2, "high": 30 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 2, "high": 31 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 2, "high": 32 }
assert my_solution.countSymmetricIntegers(**test_input) == 2

test_input = { "low": 2, "high": 33 }
assert my_solution.countSymmetricIntegers(**test_input) == 3

test_input = { "low": 2, "high": 34 }
assert my_solution.countSymmetricIntegers(**test_input) == 3

test_input = { "low": 2, "high": 35 }
assert my_solution.countSymmetricIntegers(**test_input) == 3

test_input = { "low": 2, "high": 36 }
assert my_solution.countSymmetricIntegers(**test_input) == 3

test_input = { "low": 2, "high": 37 }
assert my_solution.countSymmetricIntegers(**test_input) == 3

test_input = { "low": 2, "high": 38 }
assert my_solution.countSymmetricIntegers(**test_input) == 3


minimum-operations-to-make-a-special-number

Minimum Operations to Make a Special Number

Prompt:
"""
给你一个下标从 0 开始的字符串 num ，表示一个非负整数。

在一次操作中，您可以选择 num 的任意一位数字并将其删除。请注意，如果你删除 num 中的所有数字，则 num 变为 0。

返回最少需要多少次操作可以使 num 变成特殊数字。

如果整数 x 能被 25 整除，则该整数 x 被认为是特殊数字。

示例 1：

输入：num = "2245047"
输出：2
解释：删除数字 num[5] 和 num[6] ，得到数字 "22450" ，可以被 25 整除。
可以证明要使数字变成特殊数字，最少需要删除 2 位数字。

示例 2：

输入：num = "2908305"
输出：3
解释：删除 num[3]、num[4] 和 num[6] ，得到数字 "2900" ，可以被 25 整除。
可以证明要使数字变成特殊数字，最少需要删除 3 位数字。

示例 3：

输入：num = "10"
输出：1
解释：删除 num[0] ，得到数字 "0" ，可以被 25 整除。
可以证明要使数字变成特殊数字，最少需要删除 1 位数字。

提示

 * 1 <= num.length <= 100
 * num 仅由数字 '0' 到 '9' 组成
 * num 不含任何前导零
"""
class Solution:
    def minimumOperations(self, num: str) -> int:

给你一个下标从 0 开始的字符串 num ，表示一个非负整数。

在一次操作中，您可以选择 num 的任意一位数字并将其删除。请注意，如果你删除 num 中的所有数字，则 num 变为 0。

返回最少需要多少次操作可以使 num 变成特殊数字。

如果整数 x 能被 25 整除，则该整数 x 被认为是特殊数字。

示例 1：

输入：num = "2245047"
输出：2
解释：删除数字 num[5] 和 num[6] ，得到数字 "22450" ，可以被 25 整除。
可以证明要使数字变成特殊数字，最少需要删除 2 位数字。

示例 2：

输入：num = "2908305"
输出：3
解释：删除 num[3]、num[4] 和 num[6] ，得到数字 "2900" ，可以被 25 整除。
可以证明要使数字变成特殊数字，最少需要删除 3 位数字。

示例 3：

输入：num = "10"
输出：1
解释：删除 num[0] ，得到数字 "0" ，可以被 25 整除。
可以证明要使数字变成特殊数字，最少需要删除 1 位数字。

提示

 * 1 <= num.length <= 100
 * num 仅由数字 '0' 到 '9' 组成
 * num 不含任何前导零

请完成下面的代码来解决上述问题:
```python
class Solution:
    def minimumOperations(self, num: str) -> int:

```

my_solution = Solution()

test_input = { "num": "2245047" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "2908305" }
assert my_solution.minimumOperations(**test_input) == 3

test_input = { "num": "10" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "1" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "2" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "3" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "4" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "5" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "6" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "7" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "8" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "9" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "11" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "12" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "13" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "14" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "15" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "16" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "17" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "18" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "19" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "20" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "21" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "22" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "23" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "24" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "25" }
assert my_solution.minimumOperations(**test_input) == 0

test_input = { "num": "26" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "27" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "28" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "29" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "30" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "31" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "32" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "33" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "34" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "35" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "36" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "37" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "38" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "39" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "40" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "41" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "42" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "43" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "44" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "45" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "46" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "47" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "48" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "49" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "50" }
assert my_solution.minimumOperations(**test_input) == 0

test_input = { "num": "51" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "52" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "53" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "54" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "55" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "56" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "57" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "58" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "59" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "60" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "61" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "62" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "63" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "64" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "65" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "66" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "67" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "68" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "69" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "70" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "71" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "72" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "73" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "74" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "75" }
assert my_solution.minimumOperations(**test_input) == 0

test_input = { "num": "76" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "77" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "78" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "79" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "80" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "81" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "82" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "83" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "84" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "85" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "86" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "87" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "88" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "89" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "90" }
assert my_solution.minimumOperations(**test_input) == 1

test_input = { "num": "91" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "92" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "93" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "94" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "95" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "96" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "97" }
assert my_solution.minimumOperations(**test_input) == 2

test_input = { "num": "98" }
assert my_solution.minimumOperations(**test_input) == 2


count-of-interesting-subarrays

Count of Interesting Subarrays

Prompt:
"""
给你一个下标从 0 开始的整数数组 nums ，以及整数 modulo 和整数 k 。

请你找出并统计数组中 趣味子数组 的数目。

如果 子数组 nums[l..r] 满足下述条件，则称其为 趣味子数组 ：

 * 在范围 [l, r] 内，设 cnt 为满足 nums[i] % modulo == k 的索引 i 的数量。并且 cnt % modulo == k 。

以整数形式表示并返回趣味子数组的数目。

注意：子数组是数组中的一个连续非空的元素序列。

示例 1：

输入：nums = [3,2,4], modulo = 2, k = 1
输出：3
解释：在这个示例中，趣味子数组分别是：
子数组 nums[0..0] ，也就是 [3] 。
- 在范围 [0, 0] 内，只存在 1 个下标 i = 0 满足 nums[i] % modulo == k 。
- 因此 cnt = 1 ，且 cnt % modulo == k 。
子数组 nums[0..1] ，也就是 [3,2] 。
- 在范围 [0, 1] 内，只存在 1 个下标 i = 0 满足 nums[i] % modulo == k 。
- 因此 cnt = 1 ，且 cnt % modulo == k 。
子数组 nums[0..2] ，也就是 [3,2,4] 。
- 在范围 [0, 2] 内，只存在 1 个下标 i = 0 满足 nums[i] % modulo == k 。
- 因此 cnt = 1 ，且 cnt % modulo == k 。
可以证明不存在其他趣味子数组。因此，答案为 3 。

示例 2：

输入：nums = [3,1,9,6], modulo = 3, k = 0
输出：2
解释：在这个示例中，趣味子数组分别是：
子数组 nums[0..3] ，也就是 [3,1,9,6] 。
- 在范围 [0, 3] 内，只存在 3 个下标 i = 0, 2, 3 满足 nums[i] % modulo == k 。
- 因此 cnt = 3 ，且 cnt % modulo == k 。
子数组 nums[1..1] ，也就是 [1] 。
- 在范围 [1, 1] 内，不存在下标满足 nums[i] % modulo == k 。
- 因此 cnt = 0 ，且 cnt % modulo == k 。
可以证明不存在其他趣味子数组，因此答案为 2 。

提示：

 * 1 <= nums.length <= 105
 * 1 <= nums[i] <= 109
 * 1 <= modulo <= 109
 * 0 <= k < modulo
"""
class Solution:
    def countInterestingSubarrays(self, nums: List[int], modulo: int, k: int) -> int:

给你一个下标从 0 开始的整数数组 nums ，以及整数 modulo 和整数 k 。

请你找出并统计数组中 趣味子数组 的数目。

如果 子数组 nums[l..r] 满足下述条件，则称其为 趣味子数组 ：

 * 在范围 [l, r] 内，设 cnt 为满足 nums[i] % modulo == k 的索引 i 的数量。并且 cnt % modulo == k 。

以整数形式表示并返回趣味子数组的数目。

注意：子数组是数组中的一个连续非空的元素序列。

示例 1：

输入：nums = [3,2,4], modulo = 2, k = 1
输出：3
解释：在这个示例中，趣味子数组分别是：
子数组 nums[0..0] ，也就是 [3] 。
- 在范围 [0, 0] 内，只存在 1 个下标 i = 0 满足 nums[i] % modulo == k 。
- 因此 cnt = 1 ，且 cnt % modulo == k 。
子数组 nums[0..1] ，也就是 [3,2] 。
- 在范围 [0, 1] 内，只存在 1 个下标 i = 0 满足 nums[i] % modulo == k 。
- 因此 cnt = 1 ，且 cnt % modulo == k 。
子数组 nums[0..2] ，也就是 [3,2,4] 。
- 在范围 [0, 2] 内，只存在 1 个下标 i = 0 满足 nums[i] % modulo == k 。
- 因此 cnt = 1 ，且 cnt % modulo == k 。
可以证明不存在其他趣味子数组。因此，答案为 3 。

示例 2：

输入：nums = [3,1,9,6], modulo = 3, k = 0
输出：2
解释：在这个示例中，趣味子数组分别是：
子数组 nums[0..3] ，也就是 [3,1,9,6] 。
- 在范围 [0, 3] 内，只存在 3 个下标 i = 0, 2, 3 满足 nums[i] % modulo == k 。
- 因此 cnt = 3 ，且 cnt % modulo == k 。
子数组 nums[1..1] ，也就是 [1] 。
- 在范围 [1, 1] 内，不存在下标满足 nums[i] % modulo == k 。
- 因此 cnt = 0 ，且 cnt % modulo == k 。
可以证明不存在其他趣味子数组，因此答案为 2 。

提示：

 * 1 <= nums.length <= 105
 * 1 <= nums[i] <= 109
 * 1 <= modulo <= 109
 * 0 <= k < modulo

请完成下面的代码来解决上述问题:
```python
class Solution:
    def countInterestingSubarrays(self, nums: List[int], modulo: int, k: int) -> int:

```

my_solution = Solution()

test_input = { "nums": [3,2,4], "modulo": 2, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 3

test_input = { "nums": [3,1,9,6], "modulo": 3, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 2

test_input = { "nums": [11,12,21,31], "modulo": 10, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 5

test_input = { "nums": [2,4], "modulo": 7, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [2,7], "modulo": 7, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 1

test_input = { "nums": [2,45], "modulo": 13, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [3,3], "modulo": 5, "k": 3 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [3,4], "modulo": 8, "k": 3 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [4,5], "modulo": 1, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 3

test_input = { "nums": [5,1], "modulo": 6, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 2

test_input = { "nums": [7,2], "modulo": 7, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 1

test_input = { "nums": [7,4], "modulo": 7, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 1

test_input = { "nums": [8,8], "modulo": 4, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [9,2], "modulo": 2, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 1

test_input = { "nums": [18,43], "modulo": 3, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 1

test_input = { "nums": [19,67], "modulo": 47, "k": 19 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [20,8], "modulo": 41, "k": 8 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [26,5], "modulo": 21, "k": 5 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [81,36], "modulo": 4, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 1

test_input = { "nums": [2,1,5], "modulo": 9, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 4

test_input = { "nums": [2,2,5], "modulo": 3, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 2

test_input = { "nums": [2,2,5], "modulo": 4, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 2

test_input = { "nums": [2,3,2], "modulo": 6, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 1

test_input = { "nums": [3,2,5], "modulo": 1, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 6

test_input = { "nums": [5,1,6], "modulo": 2, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 3

test_input = { "nums": [5,2,8], "modulo": 2, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 3

test_input = { "nums": [6,5,6], "modulo": 6, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 1

test_input = { "nums": [7,1,2], "modulo": 1, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 6

test_input = { "nums": [7,2,9], "modulo": 4, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 3

test_input = { "nums": [7,5,6], "modulo": 4, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 4

test_input = { "nums": [9,1,6], "modulo": 7, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 4

test_input = { "nums": [40,1,24], "modulo": 41, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 4

test_input = { "nums": [48,36,27], "modulo": 9, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 1

test_input = { "nums": [1,9,6,1], "modulo": 2, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 6

test_input = { "nums": [2,2,1,2], "modulo": 3, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 3

test_input = { "nums": [3,5,4,2], "modulo": 5, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 4

test_input = { "nums": [4,18,38,15], "modulo": 21, "k": 4 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [6,6,1,4], "modulo": 7, "k": 6 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [7,5,2,1], "modulo": 1, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 10

test_input = { "nums": [7,5,3,4], "modulo": 3, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 6

test_input = { "nums": [8,6,5,6], "modulo": 3, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 2

test_input = { "nums": [8,7,3,2], "modulo": 6, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 1

test_input = { "nums": [9,2,2,6], "modulo": 7, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 3

test_input = { "nums": [9,7,4,1], "modulo": 2, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 6

test_input = { "nums": [9,7,8,9], "modulo": 5, "k": 4 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [9,48,32,11], "modulo": 2, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 6

test_input = { "nums": [53,44,40,37], "modulo": 2, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 6

test_input = { "nums": [91,5,60,93], "modulo": 59, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 6

test_input = { "nums": [2,1,1,3,5], "modulo": 4, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 6

test_input = { "nums": [2,2,5,4,3], "modulo": 5, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 4

test_input = { "nums": [2,2,5,6,1], "modulo": 1, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 15

test_input = { "nums": [2,6,2,3,1], "modulo": 9, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 3

test_input = { "nums": [2,7,4,8,5], "modulo": 2, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 7

test_input = { "nums": [4,2,1,8,8], "modulo": 3, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 4

test_input = { "nums": [4,2,8,8,2], "modulo": 9, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 2

test_input = { "nums": [5,6,3,9,3], "modulo": 9, "k": 3 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [6,7,1,9,2], "modulo": 1, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 15

test_input = { "nums": [6,9,5,1,6], "modulo": 5, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 7

test_input = { "nums": [7,3,6,2,6], "modulo": 1, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 15

test_input = { "nums": [7,7,9,5,8], "modulo": 4, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 5

test_input = { "nums": [7,9,1,3,2], "modulo": 8, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 5

test_input = { "nums": [8,6,9,4,4], "modulo": 9, "k": 4 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [8,8,6,8,9], "modulo": 9, "k": 8 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [9,7,8,7,8], "modulo": 7, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 3

test_input = { "nums": [26,9,14,4,24], "modulo": 26, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 10

test_input = { "nums": [31,30,24,34,20], "modulo": 22, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [39,41,6,30,38], "modulo": 43, "k": 6 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [1,2,7,1,6,6], "modulo": 5, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 8

test_input = { "nums": [1,6,2,1,9,7], "modulo": 3, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 11

test_input = { "nums": [1,7,8,2,5,9], "modulo": 7, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 10

test_input = { "nums": [2,4,6,6,5,1], "modulo": 8, "k": 6 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [2,8,2,9,2,8], "modulo": 5, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 6

test_input = { "nums": [2,9,1,6,5,7], "modulo": 7, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 5

test_input = { "nums": [2,9,1,6,6,7], "modulo": 9, "k": 6 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [2,9,6,8,8,3], "modulo": 1, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 21

test_input = { "nums": [4,8,4,3,7,5], "modulo": 4, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 6

test_input = { "nums": [4,9,4,9,7,7], "modulo": 9, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 5

test_input = { "nums": [5,3,7,9,8,7], "modulo": 3, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 5

test_input = { "nums": [7,1,6,1,7,2], "modulo": 6, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 7

test_input = { "nums": [7,3,1,9,1,3], "modulo": 5, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 10

test_input = { "nums": [7,4,9,8,3,4], "modulo": 1, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 21

test_input = { "nums": [7,5,1,7,7,7], "modulo": 8, "k": 7 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [8,4,5,6,7,4], "modulo": 4, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 6

test_input = { "nums": [8,7,3,8,4,8], "modulo": 8, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 4

test_input = { "nums": [8,7,5,5,2,1], "modulo": 5, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 6

test_input = { "nums": [8,18,36,50,12,37], "modulo": 18, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 7

test_input = { "nums": [9,9,6,7,2,3], "modulo": 5, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 8

test_input = { "nums": [16,1,33,39,15,1], "modulo": 30, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 12

test_input = { "nums": [17,25,9,20,41,26], "modulo": 38, "k": 3 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [21,26,39,21,31,49], "modulo": 22, "k": 21 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [37,44,17,22,50,15], "modulo": 6, "k": 2 }
assert my_solution.countInterestingSubarrays(**test_input) == 4

test_input = { "nums": [40,10,31,40,30,32], "modulo": 50, "k": 40 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [40,22,22,35,2,16], "modulo": 24, "k": 16 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [98,23,66,13,70,34], "modulo": 74, "k": 13 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [1,1,4,8,3,2,7], "modulo": 9, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 7

test_input = { "nums": [1,8,6,3,2,8,8], "modulo": 2, "k": 0 }
assert my_solution.countInterestingSubarrays(**test_input) == 13

test_input = { "nums": [1,9,2,1,5,4,8], "modulo": 4, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 8

test_input = { "nums": [4,6,8,3,4,3,4], "modulo": 7, "k": 4 }
assert my_solution.countInterestingSubarrays(**test_input) == 0

test_input = { "nums": [5,4,5,8,9,1,9], "modulo": 4, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 11

test_input = { "nums": [5,4,6,1,3,2,7], "modulo": 9, "k": 1 }
assert my_solution.countInterestingSubarrays(**test_input) == 16