minimum-number-of-pushes-to-type-word-i

Minimum Number of Pushes to Type Word I

Prompt:
"""
给你一个字符串 word，由 不同 小写英文字母组成。
电话键盘上的按键与 不同 小写英文字母集合相映射，可以通过按压按键来组成单词。例如，按键 2 对应 ["a","b","c"]，我们需要按一次键来输入 "a"，按两次键来输入 "b"，按三次键来输入 "c"。
现在允许你将编号为 2 到 9 的按键重新映射到 不同 字母集合。每个按键可以映射到 任意数量 的字母，但每个字母 必须 恰好 映射到 一个 按键上。你需要找到输入字符串 word 所需的 最少 按键次数。
返回重新映射按键后输入 word 所需的 最少 按键次数。
下面给出了一种电话键盘上字母到按键的映射作为示例。注意 1，*，# 和 0 不 对应任何字母。

示例 1：

输入：word = "abcde"
输出：5
解释：图片中给出的重新映射方案的输入成本最小。
"a" -> 在按键 2 上按一次
"b" -> 在按键 3 上按一次
"c" -> 在按键 4 上按一次
"d" -> 在按键 5 上按一次
"e" -> 在按键 6 上按一次
总成本为 1 + 1 + 1 + 1 + 1 = 5 。
可以证明不存在其他成本更低的映射方案。

示例 2：

输入：word = "xycdefghij"
输出：12
解释：图片中给出的重新映射方案的输入成本最小。
"x" -> 在按键 2 上按一次
"y" -> 在按键 2 上按两次
"c" -> 在按键 3 上按一次
"d" -> 在按键 3 上按两次
"e" -> 在按键 4 上按一次
"f" -> 在按键 5 上按一次
"g" -> 在按键 6 上按一次
"h" -> 在按键 7 上按一次
"i" -> 在按键 8 上按一次
"j" -> 在按键 9 上按一次
总成本为 1 + 2 + 1 + 2 + 1 + 1 + 1 + 1 + 1 + 1 = 12 。
可以证明不存在其他成本更低的映射方案。

提示：

1 <= word.length <= 26
word 仅由小写英文字母组成。
word 中的所有字母互不相同。
"""
class Solution:
    def minimumPushes(self, word: str) -> int:

给你一个字符串 word，由 不同 小写英文字母组成。
电话键盘上的按键与 不同 小写英文字母集合相映射，可以通过按压按键来组成单词。例如，按键 2 对应 ["a","b","c"]，我们需要按一次键来输入 "a"，按两次键来输入 "b"，按三次键来输入 "c"。
现在允许你将编号为 2 到 9 的按键重新映射到 不同 字母集合。每个按键可以映射到 任意数量 的字母，但每个字母 必须 恰好 映射到 一个 按键上。你需要找到输入字符串 word 所需的 最少 按键次数。
返回重新映射按键后输入 word 所需的 最少 按键次数。
下面给出了一种电话键盘上字母到按键的映射作为示例。注意 1，*，# 和 0 不 对应任何字母。

示例 1：

输入：word = "abcde"
输出：5
解释：图片中给出的重新映射方案的输入成本最小。
"a" -> 在按键 2 上按一次
"b" -> 在按键 3 上按一次
"c" -> 在按键 4 上按一次
"d" -> 在按键 5 上按一次
"e" -> 在按键 6 上按一次
总成本为 1 + 1 + 1 + 1 + 1 = 5 。
可以证明不存在其他成本更低的映射方案。

示例 2：

输入：word = "xycdefghij"
输出：12
解释：图片中给出的重新映射方案的输入成本最小。
"x" -> 在按键 2 上按一次
"y" -> 在按键 2 上按两次
"c" -> 在按键 3 上按一次
"d" -> 在按键 3 上按两次
"e" -> 在按键 4 上按一次
"f" -> 在按键 5 上按一次
"g" -> 在按键 6 上按一次
"h" -> 在按键 7 上按一次
"i" -> 在按键 8 上按一次
"j" -> 在按键 9 上按一次
总成本为 1 + 2 + 1 + 2 + 1 + 1 + 1 + 1 + 1 + 1 = 12 。
可以证明不存在其他成本更低的映射方案。

提示：

1 <= word.length <= 26
word 仅由小写英文字母组成。
word 中的所有字母互不相同。

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

```

my_solution = Solution()

test_input = { "word": "abcde" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "xycdefghij" }
assert my_solution.minimumPushes(**test_input) == 12

test_input = { "word": "b" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "d" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "e" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "f" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "g" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "h" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "i" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "k" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "n" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "o" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "q" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "u" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "v" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "w" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "x" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "bc" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "cu" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "dl" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "dn" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "ev" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "gn" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "gq" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "hu" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "jr" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "ln" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "lz" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "mv" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "mw" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "sw" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "wz" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "amw" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "bco" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "btx" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "cgp" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "cjq" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "clu" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "clx" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "crs" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "csz" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "dfp" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "htv" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "iwz" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "kux" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "nsv" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "svz" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "cfos" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "demr" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "dimo" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "dnpt" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "dorz" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "fgkn" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "fimn" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "hior" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "jkpy" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "jluv" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "knpv" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "kopu" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "lmpt" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "ltuw" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "qwxz" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "abhoz" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "aejwx" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "agjnr" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "aikmu" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "ajkmv" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "cflvx" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "dhstu" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "djmnx" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "dlovx" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "eglqy" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "ejntw" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "ekrsz" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "fopuz" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "jlnvz" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "jnstu" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "afikno" }
assert my_solution.minimumPushes(**test_input) == 6

test_input = { "word": "almsyz" }
assert my_solution.minimumPushes(**test_input) == 6

test_input = { "word": "bcehov" }
assert my_solution.minimumPushes(**test_input) == 6

test_input = { "word": "bdmprt" }
assert my_solution.minimumPushes(**test_input) == 6

test_input = { "word": "bfhmnu" }
assert my_solution.minimumPushes(**test_input) == 6

test_input = { "word": "bfhpty" }
assert my_solution.minimumPushes(**test_input) == 6

test_input = { "word": "bfjstu" }
assert my_solution.minimumPushes(**test_input) == 6

test_input = { "word": "cdfjmw" }
assert my_solution.minimumPushes(**test_input) == 6

test_input = { "word": "dfilps" }
assert my_solution.minimumPushes(**test_input) == 6

test_input = { "word": "dmswyz" }
assert my_solution.minimumPushes(**test_input) == 6

test_input = { "word": "dpqruw" }
assert my_solution.minimumPushes(**test_input) == 6

test_input = { "word": "fhmprz" }
assert my_solution.minimumPushes(**test_input) == 6

test_input = { "word": "gjqrvy" }
assert my_solution.minimumPushes(**test_input) == 6

test_input = { "word": "ijopsv" }
assert my_solution.minimumPushes(**test_input) == 6

test_input = { "word": "lmqrtz" }
assert my_solution.minimumPushes(**test_input) == 6

test_input = { "word": "bxnqpha" }
assert my_solution.minimumPushes(**test_input) == 7

test_input = { "word": "ekbfqat" }
assert my_solution.minimumPushes(**test_input) == 7

test_input = { "word": "esoizcx" }
assert my_solution.minimumPushes(**test_input) == 7

test_input = { "word": "fmteczo" }
assert my_solution.minimumPushes(**test_input) == 7

test_input = { "word": "lrywetm" }
assert my_solution.minimumPushes(**test_input) == 7

test_input = { "word": "lvbornx" }
assert my_solution.minimumPushes(**test_input) == 7

test_input = { "word": "pesmonc" }
assert my_solution.minimumPushes(**test_input) == 7

test_input = { "word": "pudymjw" }
assert my_solution.minimumPushes(**test_input) == 7


count-the-number-of-houses-at-a-certain-distance-i

Count the Number of Houses at a Certain Distance I

Prompt:
"""
给你三个 正整数 n 、x 和 y 。
在城市中，存在编号从 1 到 n 的房屋，由 n 条街道相连。对所有 1 <= i < n ，都存在一条街道连接编号为 i 的房屋与编号为 i + 1 的房屋。另存在一条街道连接编号为 x 的房屋与编号为 y 的房屋。
对于每个 k（1 <= k <= n），你需要找出所有满足要求的 房屋对 [house1, house2] ，即从 house1 到 house2 需要经过的 最少 街道数为 k 。
返回一个下标从 1 开始且长度为 n 的数组 result ，其中 result[k] 表示所有满足要求的房屋对的数量，即从一个房屋到另一个房屋需要经过的 最少 街道数为 k 。
注意，x 与 y 可以 相等 。

示例 1：

输入：n = 3, x = 1, y = 3
输出：[6,0,0]
解释：让我们检视每个房屋对
- 对于房屋对 (1, 2)，可以直接从房屋 1 到房屋 2。
- 对于房屋对 (2, 1)，可以直接从房屋 2 到房屋 1。
- 对于房屋对 (1, 3)，可以直接从房屋 1 到房屋 3。
- 对于房屋对 (3, 1)，可以直接从房屋 3 到房屋 1。
- 对于房屋对 (2, 3)，可以直接从房屋 2 到房屋 3。
- 对于房屋对 (3, 2)，可以直接从房屋 3 到房屋 2。

示例 2：

输入：n = 5, x = 2, y = 4
输出：[10,8,2,0,0]
解释：对于每个距离 k ，满足要求的房屋对如下：
- 对于 k == 1，满足要求的房屋对有 (1, 2), (2, 1), (2, 3), (3, 2), (2, 4), (4, 2), (3, 4), (4, 3), (4, 5), 以及 (5, 4)。
- 对于 k == 2，满足要求的房屋对有 (1, 3), (3, 1), (1, 4), (4, 1), (2, 5), (5, 2), (3, 5), 以及 (5, 3)。
- 对于 k == 3，满足要求的房屋对有 (1, 5)，以及 (5, 1) 。
- 对于 k == 4 和 k == 5，不存在满足要求的房屋对。

示例 3：

输入：n = 4, x = 1, y = 1
输出：[6,4,2,0]
解释：对于每个距离 k ，满足要求的房屋对如下：
- 对于 k == 1，满足要求的房屋对有 (1, 2), (2, 1), (2, 3), (3, 2), (3, 4), 以及 (4, 3)。
- 对于 k == 2，满足要求的房屋对有 (1, 3), (3, 1), (2, 4), 以及 (4, 2)。
- 对于 k == 3，满足要求的房屋对有 (1, 4), 以及 (4, 1)。
- 对于 k == 4，不存在满足要求的房屋对。

提示：

2 <= n <= 100
1 <= x, y <= n
"""
class Solution:
    def countOfPairs(self, n: int, x: int, y: int) -> List[int]:

给你三个 正整数 n 、x 和 y 。
在城市中，存在编号从 1 到 n 的房屋，由 n 条街道相连。对所有 1 <= i < n ，都存在一条街道连接编号为 i 的房屋与编号为 i + 1 的房屋。另存在一条街道连接编号为 x 的房屋与编号为 y 的房屋。
对于每个 k（1 <= k <= n），你需要找出所有满足要求的 房屋对 [house1, house2] ，即从 house1 到 house2 需要经过的 最少 街道数为 k 。
返回一个下标从 1 开始且长度为 n 的数组 result ，其中 result[k] 表示所有满足要求的房屋对的数量，即从一个房屋到另一个房屋需要经过的 最少 街道数为 k 。
注意，x 与 y 可以 相等 。

示例 1：

输入：n = 3, x = 1, y = 3
输出：[6,0,0]
解释：让我们检视每个房屋对
- 对于房屋对 (1, 2)，可以直接从房屋 1 到房屋 2。
- 对于房屋对 (2, 1)，可以直接从房屋 2 到房屋 1。
- 对于房屋对 (1, 3)，可以直接从房屋 1 到房屋 3。
- 对于房屋对 (3, 1)，可以直接从房屋 3 到房屋 1。
- 对于房屋对 (2, 3)，可以直接从房屋 2 到房屋 3。
- 对于房屋对 (3, 2)，可以直接从房屋 3 到房屋 2。

示例 2：

输入：n = 5, x = 2, y = 4
输出：[10,8,2,0,0]
解释：对于每个距离 k ，满足要求的房屋对如下：
- 对于 k == 1，满足要求的房屋对有 (1, 2), (2, 1), (2, 3), (3, 2), (2, 4), (4, 2), (3, 4), (4, 3), (4, 5), 以及 (5, 4)。
- 对于 k == 2，满足要求的房屋对有 (1, 3), (3, 1), (1, 4), (4, 1), (2, 5), (5, 2), (3, 5), 以及 (5, 3)。
- 对于 k == 3，满足要求的房屋对有 (1, 5)，以及 (5, 1) 。
- 对于 k == 4 和 k == 5，不存在满足要求的房屋对。

示例 3：

输入：n = 4, x = 1, y = 1
输出：[6,4,2,0]
解释：对于每个距离 k ，满足要求的房屋对如下：
- 对于 k == 1，满足要求的房屋对有 (1, 2), (2, 1), (2, 3), (3, 2), (3, 4), 以及 (4, 3)。
- 对于 k == 2，满足要求的房屋对有 (1, 3), (3, 1), (2, 4), 以及 (4, 2)。
- 对于 k == 3，满足要求的房屋对有 (1, 4), 以及 (4, 1)。
- 对于 k == 4，不存在满足要求的房屋对。

提示：

2 <= n <= 100
1 <= x, y <= n

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

```

my_solution = Solution()

test_input = { "n": 3, "x": 1, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [6,0,0]

test_input = { "n": 5, "x": 2, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [10,8,2,0,0]

test_input = { "n": 4, "x": 1, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 2, "x": 1, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [2,0]

test_input = { "n": 2, "x": 1, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [2,0]

test_input = { "n": 2, "x": 2, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [2,0]

test_input = { "n": 2, "x": 2, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [2,0]

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

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

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

test_input = { "n": 3, "x": 2, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [4,2,0]

test_input = { "n": 3, "x": 2, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [4,2,0]

test_input = { "n": 3, "x": 3, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [6,0,0]

test_input = { "n": 3, "x": 3, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [4,2,0]

test_input = { "n": 3, "x": 3, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [4,2,0]

test_input = { "n": 4, "x": 1, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 4, "x": 1, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [8,4,0,0]

test_input = { "n": 4, "x": 1, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [8,4,0,0]

test_input = { "n": 4, "x": 2, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 4, "x": 2, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 4, "x": 2, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 4, "x": 2, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [8,4,0,0]

test_input = { "n": 4, "x": 3, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [8,4,0,0]

test_input = { "n": 4, "x": 3, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 4, "x": 3, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 4, "x": 3, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 4, "x": 4, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [8,4,0,0]

test_input = { "n": 4, "x": 4, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [8,4,0,0]

test_input = { "n": 4, "x": 4, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 4, "x": 4, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 5, "x": 1, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 5, "x": 1, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 5, "x": 1, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [10,6,4,0,0]

test_input = { "n": 5, "x": 1, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [10,8,2,0,0]

test_input = { "n": 5, "x": 1, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [10,10,0,0,0]

test_input = { "n": 5, "x": 2, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 5, "x": 2, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 5, "x": 2, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 5, "x": 2, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [10,8,2,0,0]

test_input = { "n": 5, "x": 3, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [10,6,4,0,0]

test_input = { "n": 5, "x": 3, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 5, "x": 3, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 5, "x": 3, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 5, "x": 3, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [10,6,4,0,0]

test_input = { "n": 5, "x": 4, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [10,8,2,0,0]

test_input = { "n": 5, "x": 4, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [10,8,2,0,0]

test_input = { "n": 5, "x": 4, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 5, "x": 4, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 5, "x": 4, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 5, "x": 5, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [10,10,0,0,0]

test_input = { "n": 5, "x": 5, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [10,8,2,0,0]

test_input = { "n": 5, "x": 5, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [10,6,4,0,0]

test_input = { "n": 5, "x": 5, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 5, "x": 5, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 6, "x": 1, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 1, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 1, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [12,8,6,4,0,0]

test_input = { "n": 6, "x": 1, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [12,10,6,2,0,0]

test_input = { "n": 6, "x": 1, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [12,14,4,0,0,0]

test_input = { "n": 6, "x": 1, "y": 6 }
assert my_solution.countOfPairs(**test_input) == [12,12,6,0,0,0]

test_input = { "n": 6, "x": 2, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 2, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 2, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [12,12,6,0,0,0]

test_input = { "n": 6, "x": 2, "y": 6 }
assert my_solution.countOfPairs(**test_input) == [12,14,4,0,0,0]

test_input = { "n": 6, "x": 3, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [12,8,6,4,0,0]

test_input = { "n": 6, "x": 3, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 3, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 3, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 3, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [12,10,6,2,0,0]

test_input = { "n": 6, "x": 3, "y": 6 }
assert my_solution.countOfPairs(**test_input) == [12,10,6,2,0,0]

test_input = { "n": 6, "x": 4, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [12,10,6,2,0,0]

test_input = { "n": 6, "x": 4, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [12,10,6,2,0,0]

test_input = { "n": 6, "x": 4, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 4, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 4, "y": 6 }
assert my_solution.countOfPairs(**test_input) == [12,8,6,4,0,0]

test_input = { "n": 6, "x": 5, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [12,14,4,0,0,0]

test_input = { "n": 6, "x": 5, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [12,12,6,0,0,0]

test_input = { "n": 6, "x": 5, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [12,10,6,2,0,0]

test_input = { "n": 6, "x": 5, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 5, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 5, "y": 6 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 6, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [12,12,6,0,0,0]

test_input = { "n": 6, "x": 6, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [12,14,4,0,0,0]

test_input = { "n": 6, "x": 6, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [12,10,6,2,0,0]

test_input = { "n": 6, "x": 6, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [12,8,6,4,0,0]

test_input = { "n": 6, "x": 6, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 6, "y": 6 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 7, "x": 1, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [12,10,8,6,4,2,0]

test_input = { "n": 7, "x": 1, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [14,10,8,6,4,0,0]

test_input = { "n": 7, "x": 1, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [14,12,8,6,2,0,0]

test_input = { "n": 7, "x": 1, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [14,16,8,4,0,0,0]

test_input = { "n": 7, "x": 1, "y": 6 }
assert my_solution.countOfPairs(**test_input) == [14,16,10,2,0,0,0]

test_input = { "n": 7, "x": 1, "y": 7 }
assert my_solution.countOfPairs(**test_input) == [14,14,14,0,0,0,0]

test_input = { "n": 7, "x": 2, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [12,10,8,6,4,2,0]

test_input = { "n": 7, "x": 2, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [12,10,8,6,4,2,0]

test_input = { "n": 7, "x": 2, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [12,10,8,6,4,2,0]

test_input = { "n": 7, "x": 2, "y": 7 }
assert my_solution.countOfPairs(**test_input) == [14,16,10,2,0,0,0]

test_input = { "n": 7, "x": 3, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [14,10,8,6,4,0,0]

test_input = { "n": 7, "x": 3, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [12,10,8,6,4,2,0]

test_input = { "n": 7, "x": 3, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [12,10,8,6,4,2,0]


minimum-number-of-pushes-to-type-word-ii

Minimum Number of Pushes to Type Word II

Prompt:
"""
给你一个字符串 word，由 不同 小写英文字母组成。
电话键盘上的按键与 不同 小写英文字母集合相映射，可以通过按压按键来组成单词。例如，按键 2 对应 ["a","b","c"]，我们需要按一次键来输入 "a"，按两次键来输入 "b"，按三次键来输入 "c"。
现在允许你将编号为 2 到 9 的按键重新映射到 不同 字母集合。每个按键可以映射到 任意数量 的字母，但每个字母 必须 恰好 映射到 一个 按键上。你需要找到输入字符串 word 所需的 最少 按键次数。
返回重新映射按键后输入 word 所需的 最少 按键次数。
下面给出了一种电话键盘上字母到按键的映射作为示例。注意 1，*，# 和 0 不 对应任何字母。

示例 1：

输入：word = "abcde"
输出：5
解释：图片中给出的重新映射方案的输入成本最小。
"a" -> 在按键 2 上按一次
"b" -> 在按键 3 上按一次
"c" -> 在按键 4 上按一次
"d" -> 在按键 5 上按一次
"e" -> 在按键 6 上按一次
总成本为 1 + 1 + 1 + 1 + 1 = 5 。
可以证明不存在其他成本更低的映射方案。

示例 2：

输入：word = "xyzxyzxyzxyz"
输出：12
解释：图片中给出的重新映射方案的输入成本最小。
"x" -> 在按键 2 上按一次
"y" -> 在按键 3 上按一次
"z" -> 在按键 4 上按一次
总成本为 1 * 4 + 1 * 4 + 1 * 4 = 12 。
可以证明不存在其他成本更低的映射方案。
注意按键 9 没有映射到任何字母：不必让每个按键都存在与之映射的字母，但是每个字母都必须映射到按键上。

示例 3：

输入：word = "aabbccddeeffgghhiiiiii"
输出：24
解释：图片中给出的重新映射方案的输入成本最小。
"a" -> 在按键 2 上按一次
"b" -> 在按键 3 上按一次
"c" -> 在按键 4 上按一次
"d" -> 在按键 5 上按一次
"e" -> 在按键 6 上按一次
"f" -> 在按键 7 上按一次
"g" -> 在按键 8 上按一次
"h" -> 在按键 9 上按两次
"i" -> 在按键 9 上按一次
总成本为 1 * 2 + 1 * 2 + 1 * 2 + 1 * 2 + 1 * 2 + 1 * 2 + 1 * 2 + 2 * 2 + 6 * 1 = 24 。
可以证明不存在其他成本更低的映射方案。

提示：

1 <= word.length <= 105
word 仅由小写英文字母组成。
"""
class Solution:
    def minimumPushes(self, word: str) -> int:

给你一个字符串 word，由 不同 小写英文字母组成。
电话键盘上的按键与 不同 小写英文字母集合相映射，可以通过按压按键来组成单词。例如，按键 2 对应 ["a","b","c"]，我们需要按一次键来输入 "a"，按两次键来输入 "b"，按三次键来输入 "c"。
现在允许你将编号为 2 到 9 的按键重新映射到 不同 字母集合。每个按键可以映射到 任意数量 的字母，但每个字母 必须 恰好 映射到 一个 按键上。你需要找到输入字符串 word 所需的 最少 按键次数。
返回重新映射按键后输入 word 所需的 最少 按键次数。
下面给出了一种电话键盘上字母到按键的映射作为示例。注意 1，*，# 和 0 不 对应任何字母。

示例 1：

输入：word = "abcde"
输出：5
解释：图片中给出的重新映射方案的输入成本最小。
"a" -> 在按键 2 上按一次
"b" -> 在按键 3 上按一次
"c" -> 在按键 4 上按一次
"d" -> 在按键 5 上按一次
"e" -> 在按键 6 上按一次
总成本为 1 + 1 + 1 + 1 + 1 = 5 。
可以证明不存在其他成本更低的映射方案。

示例 2：

输入：word = "xyzxyzxyzxyz"
输出：12
解释：图片中给出的重新映射方案的输入成本最小。
"x" -> 在按键 2 上按一次
"y" -> 在按键 3 上按一次
"z" -> 在按键 4 上按一次
总成本为 1 * 4 + 1 * 4 + 1 * 4 = 12 。
可以证明不存在其他成本更低的映射方案。
注意按键 9 没有映射到任何字母：不必让每个按键都存在与之映射的字母，但是每个字母都必须映射到按键上。

示例 3：

输入：word = "aabbccddeeffgghhiiiiii"
输出：24
解释：图片中给出的重新映射方案的输入成本最小。
"a" -> 在按键 2 上按一次
"b" -> 在按键 3 上按一次
"c" -> 在按键 4 上按一次
"d" -> 在按键 5 上按一次
"e" -> 在按键 6 上按一次
"f" -> 在按键 7 上按一次
"g" -> 在按键 8 上按一次
"h" -> 在按键 9 上按两次
"i" -> 在按键 9 上按一次
总成本为 1 * 2 + 1 * 2 + 1 * 2 + 1 * 2 + 1 * 2 + 1 * 2 + 1 * 2 + 2 * 2 + 6 * 1 = 24 。
可以证明不存在其他成本更低的映射方案。

提示：

1 <= word.length <= 105
word 仅由小写英文字母组成。

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

```

my_solution = Solution()

test_input = { "word": "abcde" }
assert my_solution.minimumPushes(**test_input) == 5

test_input = { "word": "xyzxyzxyzxyz" }
assert my_solution.minimumPushes(**test_input) == 12

test_input = { "word": "aabbccddeeffgghhiiiiii" }
assert my_solution.minimumPushes(**test_input) == 24

test_input = { "word": "a" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "f" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "h" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "i" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "l" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "o" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "q" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "s" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "t" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "u" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "x" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "y" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "z" }
assert my_solution.minimumPushes(**test_input) == 1

test_input = { "word": "at" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "aw" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "bd" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "bs" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "ck" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "de" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "ex" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "fy" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "fz" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "hu" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "ir" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "iz" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "km" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "lr" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "lu" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "mz" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "ng" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "nu" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "oo" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "qc" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "rv" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "se" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "up" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "wb" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "xg" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "yg" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "zv" }
assert my_solution.minimumPushes(**test_input) == 2

test_input = { "word": "abx" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "amw" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "bem" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "bhs" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "blg" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "bwq" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "cku" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "cmo" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "cnr" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "dgh" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "dmh" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "dqf" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "eys" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "fff" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "foz" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "fqw" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "fsh" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "gjz" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "gpx" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "gqu" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "jcc" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "nmu" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "pzm" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "rdz" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "rvy" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "rya" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "sbn" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "szd" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "tbd" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "uqk" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "vbh" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "vgr" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "vxy" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "xbp" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "yex" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "ynx" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "yuv" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "zih" }
assert my_solution.minimumPushes(**test_input) == 3

test_input = { "word": "acpy" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "ainw" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "aluw" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "ayfb" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "bbmr" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "bgta" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "bitn" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "bwif" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "bwrz" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "cdcl" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "dglo" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "dxng" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "earx" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "feig" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "fgjk" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "flmd" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "fnfp" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "glms" }
assert my_solution.minimumPushes(**test_input) == 4

test_input = { "word": "glou" }
assert my_solution.minimumPushes(**test_input) == 4


count-the-number-of-houses-at-a-certain-distance-ii

Count the Number of Houses at a Certain Distance II

Prompt:
"""
给你三个 正整数 n 、x 和 y 。
在城市中，存在编号从 1 到 n 的房屋，由 n 条街道相连。对所有 1 <= i < n ，都存在一条街道连接编号为 i 的房屋与编号为 i + 1 的房屋。另存在一条街道连接编号为 x 的房屋与编号为 y 的房屋。
对于每个 k（1 <= k <= n），你需要找出所有满足要求的 房屋对 [house1, house2] ，即从 house1 到 house2 需要经过的 最少 街道数为 k 。
返回一个下标从 1 开始且长度为 n 的数组 result ，其中 result[k] 表示所有满足要求的房屋对的数量，即从一个房屋到另一个房屋需要经过的 最少 街道数为 k 。
注意，x 与 y 可以 相等 。

示例 1：

输入：n = 3, x = 1, y = 3
输出：[6,0,0]
解释：让我们检视每个房屋对
- 对于房屋对 (1, 2)，可以直接从房屋 1 到房屋 2。
- 对于房屋对 (2, 1)，可以直接从房屋 2 到房屋 1。
- 对于房屋对 (1, 3)，可以直接从房屋 1 到房屋 3。
- 对于房屋对 (3, 1)，可以直接从房屋 3 到房屋 1。
- 对于房屋对 (2, 3)，可以直接从房屋 2 到房屋 3。
- 对于房屋对 (3, 2)，可以直接从房屋 3 到房屋 2。

示例 2：

输入：n = 5, x = 2, y = 4
输出：[10,8,2,0,0]
解释：对于每个距离 k ，满足要求的房屋对如下：
- 对于 k == 1，满足要求的房屋对有 (1, 2), (2, 1), (2, 3), (3, 2), (2, 4), (4, 2), (3, 4), (4, 3), (4, 5), 以及 (5, 4)。
- 对于 k == 2，满足要求的房屋对有 (1, 3), (3, 1), (1, 4), (4, 1), (2, 5), (5, 2), (3, 5), 以及 (5, 3)。
- 对于 k == 3，满足要求的房屋对有 (1, 5)，以及 (5, 1) 。
- 对于 k == 4 和 k == 5，不存在满足要求的房屋对。

示例 3：

输入：n = 4, x = 1, y = 1
输出：[6,4,2,0]
解释：对于每个距离 k ，满足要求的房屋对如下：
- 对于 k == 1，满足要求的房屋对有 (1, 2), (2, 1), (2, 3), (3, 2), (3, 4), 以及 (4, 3)。
- 对于 k == 2，满足要求的房屋对有 (1, 3), (3, 1), (2, 4), 以及 (4, 2)。
- 对于 k == 3，满足要求的房屋对有 (1, 4), 以及 (4, 1)。
- 对于 k == 4，不存在满足要求的房屋对。

提示：

2 <= n <= 105
1 <= x, y <= n
"""
class Solution:
    def countOfPairs(self, n: int, x: int, y: int) -> List[int]:

给你三个 正整数 n 、x 和 y 。
在城市中，存在编号从 1 到 n 的房屋，由 n 条街道相连。对所有 1 <= i < n ，都存在一条街道连接编号为 i 的房屋与编号为 i + 1 的房屋。另存在一条街道连接编号为 x 的房屋与编号为 y 的房屋。
对于每个 k（1 <= k <= n），你需要找出所有满足要求的 房屋对 [house1, house2] ，即从 house1 到 house2 需要经过的 最少 街道数为 k 。
返回一个下标从 1 开始且长度为 n 的数组 result ，其中 result[k] 表示所有满足要求的房屋对的数量，即从一个房屋到另一个房屋需要经过的 最少 街道数为 k 。
注意，x 与 y 可以 相等 。

示例 1：

输入：n = 3, x = 1, y = 3
输出：[6,0,0]
解释：让我们检视每个房屋对
- 对于房屋对 (1, 2)，可以直接从房屋 1 到房屋 2。
- 对于房屋对 (2, 1)，可以直接从房屋 2 到房屋 1。
- 对于房屋对 (1, 3)，可以直接从房屋 1 到房屋 3。
- 对于房屋对 (3, 1)，可以直接从房屋 3 到房屋 1。
- 对于房屋对 (2, 3)，可以直接从房屋 2 到房屋 3。
- 对于房屋对 (3, 2)，可以直接从房屋 3 到房屋 2。

示例 2：

输入：n = 5, x = 2, y = 4
输出：[10,8,2,0,0]
解释：对于每个距离 k ，满足要求的房屋对如下：
- 对于 k == 1，满足要求的房屋对有 (1, 2), (2, 1), (2, 3), (3, 2), (2, 4), (4, 2), (3, 4), (4, 3), (4, 5), 以及 (5, 4)。
- 对于 k == 2，满足要求的房屋对有 (1, 3), (3, 1), (1, 4), (4, 1), (2, 5), (5, 2), (3, 5), 以及 (5, 3)。
- 对于 k == 3，满足要求的房屋对有 (1, 5)，以及 (5, 1) 。
- 对于 k == 4 和 k == 5，不存在满足要求的房屋对。

示例 3：

输入：n = 4, x = 1, y = 1
输出：[6,4,2,0]
解释：对于每个距离 k ，满足要求的房屋对如下：
- 对于 k == 1，满足要求的房屋对有 (1, 2), (2, 1), (2, 3), (3, 2), (3, 4), 以及 (4, 3)。
- 对于 k == 2，满足要求的房屋对有 (1, 3), (3, 1), (2, 4), 以及 (4, 2)。
- 对于 k == 3，满足要求的房屋对有 (1, 4), 以及 (4, 1)。
- 对于 k == 4，不存在满足要求的房屋对。

提示：

2 <= n <= 105
1 <= x, y <= n

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

```

my_solution = Solution()

test_input = { "n": 3, "x": 1, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [6,0,0]

test_input = { "n": 5, "x": 2, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [10,8,2,0,0]

test_input = { "n": 4, "x": 1, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 2, "x": 1, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [2,0]

test_input = { "n": 2, "x": 1, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [2,0]

test_input = { "n": 2, "x": 2, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [2,0]

test_input = { "n": 2, "x": 2, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [2,0]

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

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

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

test_input = { "n": 3, "x": 2, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [4,2,0]

test_input = { "n": 3, "x": 2, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [4,2,0]

test_input = { "n": 3, "x": 3, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [6,0,0]

test_input = { "n": 3, "x": 3, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [4,2,0]

test_input = { "n": 3, "x": 3, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [4,2,0]

test_input = { "n": 4, "x": 1, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 4, "x": 1, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [8,4,0,0]

test_input = { "n": 4, "x": 1, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [8,4,0,0]

test_input = { "n": 4, "x": 2, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 4, "x": 2, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 4, "x": 2, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 4, "x": 2, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [8,4,0,0]

test_input = { "n": 4, "x": 3, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [8,4,0,0]

test_input = { "n": 4, "x": 3, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 4, "x": 3, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 4, "x": 3, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 4, "x": 4, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [8,4,0,0]

test_input = { "n": 4, "x": 4, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [8,4,0,0]

test_input = { "n": 4, "x": 4, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 4, "x": 4, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [6,4,2,0]

test_input = { "n": 5, "x": 1, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 5, "x": 1, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [10,6,4,0,0]

test_input = { "n": 5, "x": 2, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 5, "x": 2, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [10,8,2,0,0]

test_input = { "n": 5, "x": 3, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [10,6,4,0,0]

test_input = { "n": 5, "x": 4, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [10,8,2,0,0]

test_input = { "n": 5, "x": 4, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 5, "x": 5, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [10,6,4,0,0]

test_input = { "n": 5, "x": 5, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 5, "x": 5, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [8,6,4,2,0]

test_input = { "n": 6, "x": 1, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [12,10,6,2,0,0]

test_input = { "n": 6, "x": 1, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [12,14,4,0,0,0]

test_input = { "n": 6, "x": 1, "y": 6 }
assert my_solution.countOfPairs(**test_input) == [12,12,6,0,0,0]

test_input = { "n": 6, "x": 3, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 3, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [12,10,6,2,0,0]

test_input = { "n": 6, "x": 4, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 4, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 4, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 4, "y": 6 }
assert my_solution.countOfPairs(**test_input) == [12,8,6,4,0,0]

test_input = { "n": 6, "x": 5, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [12,12,6,0,0,0]

test_input = { "n": 6, "x": 5, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 6, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [12,14,4,0,0,0]

test_input = { "n": 6, "x": 6, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [12,8,6,4,0,0]

test_input = { "n": 6, "x": 6, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 6, "x": 6, "y": 6 }
assert my_solution.countOfPairs(**test_input) == [10,8,6,4,2,0]

test_input = { "n": 7, "x": 1, "y": 7 }
assert my_solution.countOfPairs(**test_input) == [14,14,14,0,0,0,0]

test_input = { "n": 7, "x": 2, "y": 6 }
assert my_solution.countOfPairs(**test_input) == [14,18,10,0,0,0,0]

test_input = { "n": 7, "x": 3, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [12,10,8,6,4,2,0]

test_input = { "n": 7, "x": 3, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [12,10,8,6,4,2,0]

test_input = { "n": 7, "x": 3, "y": 6 }
assert my_solution.countOfPairs(**test_input) == [14,14,10,4,0,0,0]

test_input = { "n": 7, "x": 4, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [12,10,8,6,4,2,0]

test_input = { "n": 7, "x": 4, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [12,10,8,6,4,2,0]

test_input = { "n": 7, "x": 4, "y": 7 }
assert my_solution.countOfPairs(**test_input) == [14,12,8,6,2,0,0]

test_input = { "n": 7, "x": 5, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [14,12,10,4,2,0,0]

test_input = { "n": 7, "x": 5, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [12,10,8,6,4,2,0]

test_input = { "n": 7, "x": 5, "y": 7 }
assert my_solution.countOfPairs(**test_input) == [14,10,8,6,4,0,0]

test_input = { "n": 7, "x": 6, "y": 6 }
assert my_solution.countOfPairs(**test_input) == [12,10,8,6,4,2,0]

test_input = { "n": 7, "x": 6, "y": 7 }
assert my_solution.countOfPairs(**test_input) == [12,10,8,6,4,2,0]

test_input = { "n": 7, "x": 7, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [14,12,8,6,2,0,0]

test_input = { "n": 8, "x": 1, "y": 2 }
assert my_solution.countOfPairs(**test_input) == [14,12,10,8,6,4,2,0]

test_input = { "n": 8, "x": 2, "y": 7 }
assert my_solution.countOfPairs(**test_input) == [16,20,16,4,0,0,0,0]

test_input = { "n": 8, "x": 3, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [16,14,12,8,4,2,0,0]

test_input = { "n": 8, "x": 3, "y": 6 }
assert my_solution.countOfPairs(**test_input) == [16,16,14,8,2,0,0,0]

test_input = { "n": 8, "x": 4, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [14,12,10,8,6,4,2,0]

test_input = { "n": 8, "x": 4, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [14,12,10,8,6,4,2,0]

test_input = { "n": 8, "x": 4, "y": 8 }
assert my_solution.countOfPairs(**test_input) == [16,18,10,8,4,0,0,0]

test_input = { "n": 8, "x": 5, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [16,14,12,8,4,2,0,0]

test_input = { "n": 8, "x": 5, "y": 7 }
assert my_solution.countOfPairs(**test_input) == [16,14,10,8,6,2,0,0]

test_input = { "n": 8, "x": 6, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [16,16,14,8,2,0,0,0]

test_input = { "n": 8, "x": 6, "y": 7 }
assert my_solution.countOfPairs(**test_input) == [14,12,10,8,6,4,2,0]

test_input = { "n": 8, "x": 6, "y": 8 }
assert my_solution.countOfPairs(**test_input) == [16,12,10,8,6,4,0,0]

test_input = { "n": 8, "x": 7, "y": 8 }
assert my_solution.countOfPairs(**test_input) == [14,12,10,8,6,4,2,0]

test_input = { "n": 8, "x": 8, "y": 1 }
assert my_solution.countOfPairs(**test_input) == [16,16,16,8,0,0,0,0]

test_input = { "n": 8, "x": 8, "y": 7 }
assert my_solution.countOfPairs(**test_input) == [14,12,10,8,6,4,2,0]

test_input = { "n": 8, "x": 8, "y": 8 }
assert my_solution.countOfPairs(**test_input) == [14,12,10,8,6,4,2,0]

test_input = { "n": 9, "x": 1, "y": 3 }
assert my_solution.countOfPairs(**test_input) == [18,14,12,10,8,6,4,0,0]

test_input = { "n": 9, "x": 4, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [16,14,12,10,8,6,4,2,0]

test_input = { "n": 9, "x": 4, "y": 6 }
assert my_solution.countOfPairs(**test_input) == [18,16,14,12,6,4,2,0,0]

test_input = { "n": 9, "x": 4, "y": 9 }
assert my_solution.countOfPairs(**test_input) == [18,20,16,10,6,2,0,0,0]

test_input = { "n": 9, "x": 5, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [16,14,12,10,8,6,4,2,0]

test_input = { "n": 9, "x": 5, "y": 9 }
assert my_solution.countOfPairs(**test_input) == [18,20,12,10,8,4,0,0,0]

test_input = { "n": 9, "x": 6, "y": 7 }
assert my_solution.countOfPairs(**test_input) == [16,14,12,10,8,6,4,2,0]

test_input = { "n": 9, "x": 7, "y": 7 }
assert my_solution.countOfPairs(**test_input) == [16,14,12,10,8,6,4,2,0]

test_input = { "n": 9, "x": 8, "y": 4 }
assert my_solution.countOfPairs(**test_input) == [18,22,16,10,6,0,0,0,0]

test_input = { "n": 9, "x": 8, "y": 6 }
assert my_solution.countOfPairs(**test_input) == [18,16,12,10,8,6,2,0,0]

test_input = { "n": 9, "x": 8, "y": 7 }
assert my_solution.countOfPairs(**test_input) == [16,14,12,10,8,6,4,2,0]

test_input = { "n": 9, "x": 8, "y": 9 }
assert my_solution.countOfPairs(**test_input) == [16,14,12,10,8,6,4,2,0]

test_input = { "n": 9, "x": 9, "y": 5 }
assert my_solution.countOfPairs(**test_input) == [18,20,12,10,8,4,0,0,0]

test_input = { "n": 9, "x": 9, "y": 7 }
assert my_solution.countOfPairs(**test_input) == [18,14,12,10,8,6,4,0,0]

test_input = { "n": 9, "x": 9, "y": 8 }
assert my_solution.countOfPairs(**test_input) == [16,14,12,10,8,6,4,2,0]


divide-an-array-into-subarrays-with-minimum-cost-i

Divide an Array Into Subarrays With Minimum Cost I

Prompt:
"""
给你一个长度为 n的整数数组nums。
一个数组的 代价是它的 第一个元素。比方说，[1,2,3]的代价是1，[3,4,1]的代价是3。
你需要将nums分成3个连续且没有交集的子数组。
请你返回这些子数组的 最小代价总和。

示例 1：

输入：nums = [1,2,3,12]
输出：6
解释：最佳分割成 3 个子数组的方案是：[1] ，[2] 和 [3,12] ，总代价为 1 + 2 + 3 = 6 。
其他得到 3 个子数组的方案是：
- [1] ，[2,3] 和 [12] ，总代价是 1 + 2 + 12 = 15 。
- [1,2] ，[3] 和 [12] ，总代价是 1 + 3 + 12 = 16 。

示例 2：

输入：nums = [5,4,3]
输出：12
解释：最佳分割成 3 个子数组的方案是：[5] ，[4] 和 [3] ，总代价为 5 + 4 + 3 = 12 。
12 是所有分割方案里的最小总代价。

示例 3：

输入：nums = [10,3,1,1]
输出：12
解释：最佳分割成 3 个子数组的方案是：[10,3] ，[1] 和 [1] ，总代价为 10 + 1 + 1 = 12 。
12 是所有分割方案里的最小总代价。

提示：

3 <= n <= 50
1 <= nums[i] <= 50
"""
class Solution:
    def minimumCost(self, nums: List[int]) -> int:

给你一个长度为 n的整数数组nums。
一个数组的 代价是它的 第一个元素。比方说，[1,2,3]的代价是1，[3,4,1]的代价是3。
你需要将nums分成3个连续且没有交集的子数组。
请你返回这些子数组的 最小代价总和。

示例 1：

输入：nums = [1,2,3,12]
输出：6
解释：最佳分割成 3 个子数组的方案是：[1] ，[2] 和 [3,12] ，总代价为 1 + 2 + 3 = 6 。
其他得到 3 个子数组的方案是：
- [1] ，[2,3] 和 [12] ，总代价是 1 + 2 + 12 = 15 。
- [1,2] ，[3] 和 [12] ，总代价是 1 + 3 + 12 = 16 。

示例 2：

输入：nums = [5,4,3]
输出：12
解释：最佳分割成 3 个子数组的方案是：[5] ，[4] 和 [3] ，总代价为 5 + 4 + 3 = 12 。
12 是所有分割方案里的最小总代价。

示例 3：

输入：nums = [10,3,1,1]
输出：12
解释：最佳分割成 3 个子数组的方案是：[10,3] ，[1] 和 [1] ，总代价为 10 + 1 + 1 = 12 。
12 是所有分割方案里的最小总代价。

提示：

3 <= n <= 50
1 <= nums[i] <= 50

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

```

my_solution = Solution()

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

test_input = { "nums": [5,4,3] }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "nums": [10,3,1,1] }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "nums": [1,1,1] }
assert my_solution.minimumCost(**test_input) == 3

test_input = { "nums": [1,1,2] }
assert my_solution.minimumCost(**test_input) == 4

test_input = { "nums": [1,1,3] }
assert my_solution.minimumCost(**test_input) == 5

test_input = { "nums": [1,1,4] }
assert my_solution.minimumCost(**test_input) == 6

test_input = { "nums": [1,1,5] }
assert my_solution.minimumCost(**test_input) == 7

test_input = { "nums": [1,2,1] }
assert my_solution.minimumCost(**test_input) == 4

test_input = { "nums": [1,2,2] }
assert my_solution.minimumCost(**test_input) == 5

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

test_input = { "nums": [1,2,4] }
assert my_solution.minimumCost(**test_input) == 7

test_input = { "nums": [1,2,5] }
assert my_solution.minimumCost(**test_input) == 8

test_input = { "nums": [1,3,1] }
assert my_solution.minimumCost(**test_input) == 5

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

test_input = { "nums": [1,3,3] }
assert my_solution.minimumCost(**test_input) == 7

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

test_input = { "nums": [1,3,5] }
assert my_solution.minimumCost(**test_input) == 9

test_input = { "nums": [1,4,1] }
assert my_solution.minimumCost(**test_input) == 6

test_input = { "nums": [1,4,2] }
assert my_solution.minimumCost(**test_input) == 7

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

test_input = { "nums": [1,4,4] }
assert my_solution.minimumCost(**test_input) == 9

test_input = { "nums": [1,4,5] }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [1,5,1] }
assert my_solution.minimumCost(**test_input) == 7

test_input = { "nums": [1,5,2] }
assert my_solution.minimumCost(**test_input) == 8

test_input = { "nums": [1,5,3] }
assert my_solution.minimumCost(**test_input) == 9

test_input = { "nums": [1,5,4] }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [1,5,5] }
assert my_solution.minimumCost(**test_input) == 11

test_input = { "nums": [2,1,1] }
assert my_solution.minimumCost(**test_input) == 4

test_input = { "nums": [2,1,2] }
assert my_solution.minimumCost(**test_input) == 5

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

test_input = { "nums": [2,1,4] }
assert my_solution.minimumCost(**test_input) == 7

test_input = { "nums": [2,1,5] }
assert my_solution.minimumCost(**test_input) == 8

test_input = { "nums": [2,2,1] }
assert my_solution.minimumCost(**test_input) == 5

test_input = { "nums": [2,2,2] }
assert my_solution.minimumCost(**test_input) == 6

test_input = { "nums": [2,2,3] }
assert my_solution.minimumCost(**test_input) == 7

test_input = { "nums": [2,2,4] }
assert my_solution.minimumCost(**test_input) == 8

test_input = { "nums": [2,2,5] }
assert my_solution.minimumCost(**test_input) == 9

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

test_input = { "nums": [2,3,2] }
assert my_solution.minimumCost(**test_input) == 7

test_input = { "nums": [2,3,3] }
assert my_solution.minimumCost(**test_input) == 8

test_input = { "nums": [2,3,4] }
assert my_solution.minimumCost(**test_input) == 9

test_input = { "nums": [2,3,5] }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [2,4,1] }
assert my_solution.minimumCost(**test_input) == 7

test_input = { "nums": [2,4,2] }
assert my_solution.minimumCost(**test_input) == 8

test_input = { "nums": [2,4,3] }
assert my_solution.minimumCost(**test_input) == 9

test_input = { "nums": [2,4,4] }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [2,4,5] }
assert my_solution.minimumCost(**test_input) == 11

test_input = { "nums": [2,5,1] }
assert my_solution.minimumCost(**test_input) == 8

test_input = { "nums": [2,5,2] }
assert my_solution.minimumCost(**test_input) == 9

test_input = { "nums": [2,5,3] }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [2,5,4] }
assert my_solution.minimumCost(**test_input) == 11

test_input = { "nums": [2,5,5] }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "nums": [3,1,1] }
assert my_solution.minimumCost(**test_input) == 5

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

test_input = { "nums": [3,1,3] }
assert my_solution.minimumCost(**test_input) == 7

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

test_input = { "nums": [3,1,5] }
assert my_solution.minimumCost(**test_input) == 9

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

test_input = { "nums": [3,2,2] }
assert my_solution.minimumCost(**test_input) == 7

test_input = { "nums": [3,2,3] }
assert my_solution.minimumCost(**test_input) == 8

test_input = { "nums": [3,2,4] }
assert my_solution.minimumCost(**test_input) == 9

test_input = { "nums": [3,2,5] }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [3,3,1] }
assert my_solution.minimumCost(**test_input) == 7

test_input = { "nums": [3,3,2] }
assert my_solution.minimumCost(**test_input) == 8

test_input = { "nums": [3,3,3] }
assert my_solution.minimumCost(**test_input) == 9

test_input = { "nums": [3,3,4] }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [3,3,5] }
assert my_solution.minimumCost(**test_input) == 11

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

test_input = { "nums": [3,4,2] }
assert my_solution.minimumCost(**test_input) == 9

test_input = { "nums": [3,4,3] }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [3,4,4] }
assert my_solution.minimumCost(**test_input) == 11

test_input = { "nums": [3,4,5] }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "nums": [3,5,1] }
assert my_solution.minimumCost(**test_input) == 9

test_input = { "nums": [3,5,2] }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [3,5,3] }
assert my_solution.minimumCost(**test_input) == 11

test_input = { "nums": [3,5,4] }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "nums": [3,5,5] }
assert my_solution.minimumCost(**test_input) == 13

test_input = { "nums": [4,1,1] }
assert my_solution.minimumCost(**test_input) == 6

test_input = { "nums": [4,1,2] }
assert my_solution.minimumCost(**test_input) == 7

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

test_input = { "nums": [4,1,4] }
assert my_solution.minimumCost(**test_input) == 9

test_input = { "nums": [4,1,5] }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [4,2,1] }
assert my_solution.minimumCost(**test_input) == 7

test_input = { "nums": [4,2,2] }
assert my_solution.minimumCost(**test_input) == 8

test_input = { "nums": [4,2,3] }
assert my_solution.minimumCost(**test_input) == 9

test_input = { "nums": [4,2,4] }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [4,2,5] }
assert my_solution.minimumCost(**test_input) == 11

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

test_input = { "nums": [4,3,2] }
assert my_solution.minimumCost(**test_input) == 9

test_input = { "nums": [4,3,3] }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [4,3,4] }
assert my_solution.minimumCost(**test_input) == 11

test_input = { "nums": [4,3,5] }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "nums": [4,4,1] }
assert my_solution.minimumCost(**test_input) == 9

test_input = { "nums": [4,4,2] }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [4,4,3] }
assert my_solution.minimumCost(**test_input) == 11

test_input = { "nums": [4,4,4] }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "nums": [4,4,5] }
assert my_solution.minimumCost(**test_input) == 13

test_input = { "nums": [4,5,1] }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [4,5,2] }
assert my_solution.minimumCost(**test_input) == 11


find-if-array-can-be-sorted

Find if Array Can Be Sorted

Prompt:
"""
给你一个下标从 0开始且全是 正整数的数组nums。
一次 操作中，如果两个 相邻元素在二进制下数位为 1的数目 相同，那么你可以将这两个元素交换。你可以执行这个操作 任意次（也可以 0 次）。
如果你可以使数组变有序，请你返回true ，否则返回false。

示例 1：

输入：nums = [8,4,2,30,15]
输出：true
解释：我们先观察每个元素的二进制表示。 2 ，4 和 8 分别都只有一个数位为 1 ，分别为 "10" ，"100" 和 "1000" 。15 和 30 分别有 4 个数位为 1 ："1111" 和 "11110" 。
我们可以通过 4 个操作使数组有序：
- 交换 nums[0] 和 nums[1] 。8 和 4 分别只有 1 个数位为 1 。数组变为 [4,8,2,30,15] 。
- 交换 nums[1] 和 nums[2] 。8 和 2 分别只有 1 个数位为 1 。数组变为 [4,2,8,30,15] 。
- 交换 nums[0] 和 nums[1] 。4 和 2 分别只有 1 个数位为 1 。数组变为 [2,4,8,30,15] 。
- 交换 nums[3] 和 nums[4] 。30 和 15 分别有 4 个数位为 1 ，数组变为 [2,4,8,15,30] 。
数组变成有序的，所以我们返回 true 。
注意我们还可以通过其他的操作序列使数组变得有序。

示例 2：

输入：nums = [1,2,3,4,5]
输出：true
解释：数组已经是有序的，所以我们返回 true 。

示例 3：

输入：nums = [3,16,8,4,2]
输出：false
解释：无法通过操作使数组变为有序。

提示：

1 <= nums.length <= 100
1 <= nums[i] <= 28
"""
class Solution:
    def canSortArray(self, nums: List[int]) -> bool:

给你一个下标从 0开始且全是 正整数的数组nums。
一次 操作中，如果两个 相邻元素在二进制下数位为 1的数目 相同，那么你可以将这两个元素交换。你可以执行这个操作 任意次（也可以 0 次）。
如果你可以使数组变有序，请你返回true ，否则返回false。

示例 1：

输入：nums = [8,4,2,30,15]
输出：true
解释：我们先观察每个元素的二进制表示。 2 ，4 和 8 分别都只有一个数位为 1 ，分别为 "10" ，"100" 和 "1000" 。15 和 30 分别有 4 个数位为 1 ："1111" 和 "11110" 。
我们可以通过 4 个操作使数组有序：
- 交换 nums[0] 和 nums[1] 。8 和 4 分别只有 1 个数位为 1 。数组变为 [4,8,2,30,15] 。
- 交换 nums[1] 和 nums[2] 。8 和 2 分别只有 1 个数位为 1 。数组变为 [4,2,8,30,15] 。
- 交换 nums[0] 和 nums[1] 。4 和 2 分别只有 1 个数位为 1 。数组变为 [2,4,8,30,15] 。
- 交换 nums[3] 和 nums[4] 。30 和 15 分别有 4 个数位为 1 ，数组变为 [2,4,8,15,30] 。
数组变成有序的，所以我们返回 true 。
注意我们还可以通过其他的操作序列使数组变得有序。

示例 2：

输入：nums = [1,2,3,4,5]
输出：true
解释：数组已经是有序的，所以我们返回 true 。

示例 3：

输入：nums = [3,16,8,4,2]
输出：false
解释：无法通过操作使数组变为有序。

提示：

1 <= nums.length <= 100
1 <= nums[i] <= 28

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

```

my_solution = Solution()

test_input = { "nums": [8,4,2,30,15] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [1,2,3,4,5] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [1] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [4] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [3,16,8,4,2] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [7] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [10] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [20,16] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [18] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [21,17] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [30] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [26,10] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [1,2] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [2,28,9] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [2,17] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [18,3,8] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [31,18,23] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [75,34,30] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [107,76,52] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [125,92,159] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [136,256,10] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [160,247,127] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [187,4,32] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [197,171,144] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [214,200,176] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [222,191,39] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [24,12] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [225,163,64] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [128,128] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [229,253,127] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [1,2,3] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [1,256,64] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [6,6,192] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [239,83,71] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [6,96,20] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [247,153,90] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [256,255,255] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [1,201,251,191] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [4,157,191,127] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [8,8,2] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [10,34,130] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [12,19,1,11] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [10,91,127] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [15,8,21,25] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [17,25,4,27] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [10,130,206] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [14,183,251] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [29,20,17,4] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [15,147,174] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [16,245,125] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [32,12,25,19] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [22,21,26] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [23,30,32] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [24,72,160] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [33,223,239] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [35,143,127,254] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [55,147,16,8] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [34,52,104] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [100,104,96,144] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [129,70,126,253] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [129,162,158,253] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [145,127,55,43] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [36,177,244] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [159,111,124,233] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [36,213,236] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [175,231,27,92] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [205,234,127,223] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [215,10,8,256] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [223,127,172,210] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [38,221,224] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [41,14,50] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [41,79,239] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [44,124,247] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [225,201,121,103] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [232,45,175,231] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [250,131,50,46] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [254,249,173,163] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [255,255,214,229] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [256,151,141,15] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [47,205,182] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [48,64,251] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [51,253,254] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [53,172,195] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [57,127,251] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [4,98,210,79,254] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [59,31,236] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [8,5,103,247,235] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [8,74,170,254,132] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [8,148,182,62,255] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [62,153,210] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [64,93,253] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [9,28,18,26,11] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [12,208,240,216,139] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [13,21,23,13,32] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [16,24,13,46,156] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [16,192,71,31,239] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [64,195,203] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [65,254,239] }
assert my_solution.canSortArray(**test_input) == True

test_input = { "nums": [17,11,5,20,8] }
assert my_solution.canSortArray(**test_input) == False

test_input = { "nums": [23,12,22,29,20] }
assert my_solution.canSortArray(**test_input) == False


minimize-length-of-array-using-operations

Minimize Length of Array Using Operations

Prompt:
"""
给你一个下标从 0开始的整数数组nums，它只包含 正整数。
你的任务是通过进行以下操作任意次（可以是 0 次）最小化nums的长度：

在 nums中选择 两个不同的下标i和j，满足nums[i] > 0且nums[j] > 0。
将结果nums[i] % nums[j]插入nums的结尾。
将 nums中下标为i和j的元素删除。

请你返回一个整数，它表示进行任意次操作以后nums的 最小长度。

示例 1：

输入：nums = [1,4,3,1]
输出：1
解释：使数组长度最小的一种方法是：
操作 1 ：选择下标 2 和 1 ，插入 nums[2] % nums[1] 到数组末尾，得到 [1,4,3,1,3] ，然后删除下标为 2 和 1 的元素。
nums 变为 [1,1,3] 。
操作 2 ：选择下标 1 和 2 ，插入 nums[1] % nums[2] 到数组末尾，得到 [1,1,3,1] ，然后删除下标为 1 和 2 的元素。
nums 变为 [1,1] 。
操作 3 ：选择下标 1 和 0 ，插入 nums[1] % nums[0] 到数组末尾，得到 [1,1,0] ，然后删除下标为 1 和 0 的元素。
nums 变为 [0] 。
nums 的长度无法进一步减小，所以答案为 1 。
1 是可以得到的最小长度。
示例 2：

输入：nums = [5,5,5,10,5]
输出：2
解释：使数组长度最小的一种方法是：
操作 1 ：选择下标 0 和 3 ，插入 nums[0] % nums[3] 到数组末尾，得到 [5,5,5,10,5,5] ，然后删除下标为 0 和 3 的元素。
nums 变为 [5,5,5,5] 。
操作 2 ：选择下标 2 和 3 ，插入 nums[2] % nums[3] 到数组末尾，得到 [5,5,5,5,0] ，然后删除下标为 2 和 3 的元素。
nums 变为 [5,5,0] 。
操作 3 ：选择下标 0 和 1 ，插入 nums[0] % nums[1] 到数组末尾，得到 [5,5,0,0] ，然后删除下标为 0 和 1 的元素。
nums 变为 [0,0] 。
nums 的长度无法进一步减小，所以答案为 2 。
2 是可以得到的最小长度。
示例 3：

输入：nums = [2,3,4]
输出：1
解释：使数组长度最小的一种方法是：
操作 1 ：选择下标 1 和 2 ，插入 nums[1] % nums[2] 到数组末尾，得到 [2,3,4,3] ，然后删除下标为 1 和 2 的元素。
nums 变为 [2,3] 。
操作 2 ：选择下标 1 和 0 ，插入 nums[1] % nums[0] 到数组末尾，得到 [2,3,1] ，然后删除下标为 1 和 0 的元素。
nums 变为 [1] 。
nums 的长度无法进一步减小，所以答案为 1 。
1 是可以得到的最小长度。

提示：

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

给你一个下标从 0开始的整数数组nums，它只包含 正整数。
你的任务是通过进行以下操作任意次（可以是 0 次）最小化nums的长度：

在 nums中选择 两个不同的下标i和j，满足nums[i] > 0且nums[j] > 0。
将结果nums[i] % nums[j]插入nums的结尾。
将 nums中下标为i和j的元素删除。

请你返回一个整数，它表示进行任意次操作以后nums的 最小长度。

示例 1：

输入：nums = [1,4,3,1]
输出：1
解释：使数组长度最小的一种方法是：
操作 1 ：选择下标 2 和 1 ，插入 nums[2] % nums[1] 到数组末尾，得到 [1,4,3,1,3] ，然后删除下标为 2 和 1 的元素。
nums 变为 [1,1,3] 。
操作 2 ：选择下标 1 和 2 ，插入 nums[1] % nums[2] 到数组末尾，得到 [1,1,3,1] ，然后删除下标为 1 和 2 的元素。
nums 变为 [1,1] 。
操作 3 ：选择下标 1 和 0 ，插入 nums[1] % nums[0] 到数组末尾，得到 [1,1,0] ，然后删除下标为 1 和 0 的元素。
nums 变为 [0] 。
nums 的长度无法进一步减小，所以答案为 1 。
1 是可以得到的最小长度。
示例 2：

输入：nums = [5,5,5,10,5]
输出：2
解释：使数组长度最小的一种方法是：
操作 1 ：选择下标 0 和 3 ，插入 nums[0] % nums[3] 到数组末尾，得到 [5,5,5,10,5,5] ，然后删除下标为 0 和 3 的元素。
nums 变为 [5,5,5,5] 。
操作 2 ：选择下标 2 和 3 ，插入 nums[2] % nums[3] 到数组末尾，得到 [5,5,5,5,0] ，然后删除下标为 2 和 3 的元素。
nums 变为 [5,5,0] 。
操作 3 ：选择下标 0 和 1 ，插入 nums[0] % nums[1] 到数组末尾，得到 [5,5,0,0] ，然后删除下标为 0 和 1 的元素。
nums 变为 [0,0] 。
nums 的长度无法进一步减小，所以答案为 2 。
2 是可以得到的最小长度。
示例 3：

输入：nums = [2,3,4]
输出：1
解释：使数组长度最小的一种方法是：
操作 1 ：选择下标 1 和 2 ，插入 nums[1] % nums[2] 到数组末尾，得到 [2,3,4,3] ，然后删除下标为 1 和 2 的元素。
nums 变为 [2,3] 。
操作 2 ：选择下标 1 和 0 ，插入 nums[1] % nums[0] 到数组末尾，得到 [2,3,1] ，然后删除下标为 1 和 0 的元素。
nums 变为 [1] 。
nums 的长度无法进一步减小，所以答案为 1 。
1 是可以得到的最小长度。

提示：

1 <= nums.length <= 105
1 <= nums[i] <= 109

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

```

my_solution = Solution()

test_input = { "nums": [1,4,3,1] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [5,5,5,10,5] }
assert my_solution.minimumArrayLength(**test_input) == 2

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

test_input = { "nums": [1] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [3] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [6] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [1,4] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [1,5] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [2,4] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [3,4] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [5,3] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [6,9] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [8,2] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [9,9] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [9,10] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [1,2,5] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [2,1,1] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [2,7,10] }
assert my_solution.minimumArrayLength(**test_input) == 1

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

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

test_input = { "nums": [3,2,7] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [3,3,1] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [4,1,3] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [4,4,4] }
assert my_solution.minimumArrayLength(**test_input) == 2

test_input = { "nums": [5,1,5] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [5,5,5] }
assert my_solution.minimumArrayLength(**test_input) == 2

test_input = { "nums": [6,5,1] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [8,4,5] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [9,2,2] }
assert my_solution.minimumArrayLength(**test_input) == 1

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

test_input = { "nums": [1,3,1,7] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [1,5,5,4] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [1,8,7,2] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [2,2,1,1] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [2,7,10,1] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [2,10,1,7] }
assert my_solution.minimumArrayLength(**test_input) == 1

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

test_input = { "nums": [4,4,1,1] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [5,3,10,10] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [6,3,4,4] }
assert my_solution.minimumArrayLength(**test_input) == 1

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

test_input = { "nums": [7,2,5,9] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [1,3,4,4,3] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [4,1,7,10,1] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [4,3,1,4,3] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [4,6,2,6,4] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [6,10,6,3,3] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [1,4,5,4,5,1] }
assert my_solution.minimumArrayLength(**test_input) == 1

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

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

test_input = { "nums": [2,2,4,4,2,1] }
assert my_solution.minimumArrayLength(**test_input) == 1

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

test_input = { "nums": [4,1,4,4,5,1] }
assert my_solution.minimumArrayLength(**test_input) == 1

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

test_input = { "nums": [4,8,8,7,6,8] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [5,2,2,2,9,10] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [7,3,2,4,3,10] }
assert my_solution.minimumArrayLength(**test_input) == 1

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

test_input = { "nums": [8,3,9,4,5,8] }
assert my_solution.minimumArrayLength(**test_input) == 1

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

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

test_input = { "nums": [4,8,7,4,9,3,9] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [5,3,5,7,9,10,10] }
assert my_solution.minimumArrayLength(**test_input) == 1

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

test_input = { "nums": [7,10,1,8,6,1,2] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [9,1,10,7,3,9,7] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [10,10,3,9,8,3,5] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [10,10,4,8,5,2,6] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [1,5,2,10,4,5,10,1] }
assert my_solution.minimumArrayLength(**test_input) == 1

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

test_input = { "nums": [2,2,7,4,5,5,1,2] }
assert my_solution.minimumArrayLength(**test_input) == 1

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

test_input = { "nums": [2,10,6,7,7,2,3,4] }
assert my_solution.minimumArrayLength(**test_input) == 1

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

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

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

test_input = { "nums": [3,6,7,7,6,9,1,6] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [5,1,1,1,1,5,5,5] }
assert my_solution.minimumArrayLength(**test_input) == 2

test_input = { "nums": [6,7,5,5,3,6,1,8] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [8,5,4,5,4,7,6,10] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [8,10,4,6,7,9,2,1] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [2,6,3,8,9,10,9,3,10] }
assert my_solution.minimumArrayLength(**test_input) == 1

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

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

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

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

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

test_input = { "nums": [6,4,5,7,9,10,10,6,9] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [6,5,6,4,9,8,8,3,7] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [9,7,6,10,1,8,5,4,2] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [9,10,1,6,4,10,1,3,4] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [10,5,4,8,4,3,7,10,3] }
assert my_solution.minimumArrayLength(**test_input) == 1

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

test_input = { "nums": [4,5,1,8,2,7,2,7,7,6] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [7,1,3,10,1,4,5,2,9,7] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [7,2,2,9,5,6,6,10,2,3] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [7,7,3,6,8,10,3,7,6,9] }
assert my_solution.minimumArrayLength(**test_input) == 1

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

test_input = { "nums": [4,10,3,8,9,5,7,6,9,10,10] }
assert my_solution.minimumArrayLength(**test_input) == 1

test_input = { "nums": [5,9,3,9,3,10,1,1,6,3,10] }
assert my_solution.minimumArrayLength(**test_input) == 1


divide-an-array-into-subarrays-with-minimum-cost-ii

Divide an Array Into Subarrays With Minimum Cost II

Prompt:
"""
给你一个下标从 0开始长度为 n的整数数组nums和两个 正整数k 和dist。
一个数组的 代价是数组中的 第一个元素。比方说，[1,2,3]的代价为1，[3,4,1]的代价为3。
你需要将 nums分割成 k个 连续且互不相交的子数组，满足 第二个子数组与第 k个子数组中第一个元素的下标距离 不超过dist。换句话说，如果你将nums分割成子数组nums[0..(i1 - 1)], nums[i1..(i2 - 1)], ..., nums[ik-1..(n - 1)]，那么它需要满足ik-1 - i1 <= dist。
请你返回这些子数组的 最小总代价。

示例 1：

输入：nums = [1,3,2,6,4,2], k = 3, dist = 3
输出：5
解释：将数组分割成 3 个子数组的最优方案是：[1,3] ，[2,6,4] 和 [2] 。这是一个合法分割，因为 ik-1 - i1 等于 5 - 2 = 3 ，等于 dist 。总代价为 nums[0] + nums[2] + nums[5] ，也就是 1 + 2 + 2 = 5 。
5 是分割成 3 个子数组的最小总代价。

示例 2：

输入：nums = [10,1,2,2,2,1], k = 4, dist = 3
输出：15
解释：将数组分割成 4 个子数组的最优方案是：[10] ，[1] ，[2] 和 [2,2,1] 。这是一个合法分割，因为 ik-1 - i1 等于 3 - 1 = 2 ，小于 dist 。总代价为 nums[0] + nums[1] + nums[2] + nums[3] ，也就是 10 + 1 + 2 + 2 = 15 。
分割 [10] ，[1] ，[2,2,2] 和 [1] 不是一个合法分割，因为 ik-1 和 i1 的差为 5 - 1 = 4 ，大于 dist 。
15 是分割成 4 个子数组的最小总代价。

示例 3：

输入：nums = [10,8,18,9], k = 3, dist = 1
输出：36
解释：将数组分割成 4 个子数组的最优方案是：[10] ，[8] 和 [18,9] 。这是一个合法分割，因为 ik-1 - i1 等于 2 - 1 = 1 ，等于 dist 。总代价为 nums[0] + nums[1] + nums[2] ，也就是 10 + 8 + 18 = 36 。
分割 [10] ，[8,18] 和 [9] 不是一个合法分割，因为 ik-1 和 i1 的差为 3 - 1 = 2 ，大于 dist 。
36 是分割成 3 个子数组的最小总代价。

提示：

3 <= n <= 105
1 <= nums[i] <= 109
3 <= k <= n
k - 2 <= dist <= n - 2
"""
class Solution:
    def minimumCost(self, nums: List[int], k: int, dist: int) -> int:

给你一个下标从 0开始长度为 n的整数数组nums和两个 正整数k 和dist。
一个数组的 代价是数组中的 第一个元素。比方说，[1,2,3]的代价为1，[3,4,1]的代价为3。
你需要将 nums分割成 k个 连续且互不相交的子数组，满足 第二个子数组与第 k个子数组中第一个元素的下标距离 不超过dist。换句话说，如果你将nums分割成子数组nums[0..(i1 - 1)], nums[i1..(i2 - 1)], ..., nums[ik-1..(n - 1)]，那么它需要满足ik-1 - i1 <= dist。
请你返回这些子数组的 最小总代价。

示例 1：

输入：nums = [1,3,2,6,4,2], k = 3, dist = 3
输出：5
解释：将数组分割成 3 个子数组的最优方案是：[1,3] ，[2,6,4] 和 [2] 。这是一个合法分割，因为 ik-1 - i1 等于 5 - 2 = 3 ，等于 dist 。总代价为 nums[0] + nums[2] + nums[5] ，也就是 1 + 2 + 2 = 5 。
5 是分割成 3 个子数组的最小总代价。

示例 2：

输入：nums = [10,1,2,2,2,1], k = 4, dist = 3
输出：15
解释：将数组分割成 4 个子数组的最优方案是：[10] ，[1] ，[2] 和 [2,2,1] 。这是一个合法分割，因为 ik-1 - i1 等于 3 - 1 = 2 ，小于 dist 。总代价为 nums[0] + nums[1] + nums[2] + nums[3] ，也就是 10 + 1 + 2 + 2 = 15 。
分割 [10] ，[1] ，[2,2,2] 和 [1] 不是一个合法分割，因为 ik-1 和 i1 的差为 5 - 1 = 4 ，大于 dist 。
15 是分割成 4 个子数组的最小总代价。

示例 3：

输入：nums = [10,8,18,9], k = 3, dist = 1
输出：36
解释：将数组分割成 4 个子数组的最优方案是：[10] ，[8] 和 [18,9] 。这是一个合法分割，因为 ik-1 - i1 等于 2 - 1 = 1 ，等于 dist 。总代价为 nums[0] + nums[1] + nums[2] ，也就是 10 + 8 + 18 = 36 。
分割 [10] ，[8,18] 和 [9] 不是一个合法分割，因为 ik-1 和 i1 的差为 3 - 1 = 2 ，大于 dist 。
36 是分割成 3 个子数组的最小总代价。

提示：

3 <= n <= 105
1 <= nums[i] <= 109
3 <= k <= n
k - 2 <= dist <= n - 2

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

```

my_solution = Solution()

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

test_input = { "nums": [10,1,2,2,2,1], "k": 4, "dist": 3 }
assert my_solution.minimumCost(**test_input) == 15

test_input = { "nums": [10,8,18,9], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 36

test_input = { "nums": [1,1,1], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 3

test_input = { "nums": [1,1,3], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 5

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

test_input = { "nums": [1,2,5], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 8

test_input = { "nums": [1,4,4], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 9

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

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

test_input = { "nums": [2,5,4], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 11

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

test_input = { "nums": [3,1,3], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 7

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

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

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

test_input = { "nums": [3,5,3], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 11

test_input = { "nums": [4,1,4], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 9

test_input = { "nums": [4,1,5], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 10

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

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

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

test_input = { "nums": [4,2,5], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 11

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

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

test_input = { "nums": [4,5,3], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "nums": [5,2,1], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 8

test_input = { "nums": [5,3,5], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 13

test_input = { "nums": [50,50,50], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 150

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

test_input = { "nums": [1,5,3,7], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 9

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

test_input = { "nums": [1,5,3,8], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 9

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

test_input = { "nums": [1,5,4,6], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 16

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

test_input = { "nums": [1,6,3,8], "k": 3, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [1,6,4,5], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 16

test_input = { "nums": [1,7,4,6], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 18

test_input = { "nums": [1,7,4,8], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 20

test_input = { "nums": [1,8,3,8], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "nums": [1,8,4,7], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 20

test_input = { "nums": [2,5,3,8], "k": 3, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [2,5,4,7], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 18

test_input = { "nums": [2,5,4,8], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 19

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

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

test_input = { "nums": [2,6,4,5], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 17

test_input = { "nums": [2,6,4,7], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 19

test_input = { "nums": [2,6,4,8], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 20

test_input = { "nums": [2,7,3,5], "k": 3, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [2,7,3,8], "k": 3, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "nums": [2,7,4,6], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 19

test_input = { "nums": [2,8,3,5], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 10

test_input = { "nums": [2,8,4,5], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 19

test_input = { "nums": [3,5,3,5], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 11

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

test_input = { "nums": [3,5,3,8], "k": 3, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 11

test_input = { "nums": [3,5,4,7], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 19

test_input = { "nums": [3,6,3,5], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 11

test_input = { "nums": [3,6,3,7], "k": 3, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "nums": [3,6,3,8], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "nums": [3,6,4,5], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 18

test_input = { "nums": [3,7,3,5], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 11

test_input = { "nums": [3,7,3,5], "k": 3, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 11

test_input = { "nums": [3,7,3,6], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "nums": [3,7,3,8], "k": 3, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 13

test_input = { "nums": [3,7,4,7], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 21

test_input = { "nums": [3,8,3,5], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 11

test_input = { "nums": [3,8,4,6], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 21

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

test_input = { "nums": [4,5,3,6], "k": 3, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "nums": [4,5,3,8], "k": 3, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 12

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

test_input = { "nums": [4,6,3,6], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 13

test_input = { "nums": [4,6,3,7], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 13

test_input = { "nums": [4,6,4,5], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 19

test_input = { "nums": [4,6,4,8], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 22

test_input = { "nums": [4,7,3,6], "k": 3, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 13

test_input = { "nums": [4,7,4,5], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 20

test_input = { "nums": [4,7,4,7], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 22

test_input = { "nums": [4,8,3,5], "k": 3, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "nums": [4,8,3,6], "k": 3, "dist": 1 }
assert my_solution.minimumCost(**test_input) == 13

test_input = { "nums": [4,8,3,7], "k": 3, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 14

test_input = { "nums": [4,8,4,6], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 22

test_input = { "nums": [4,8,4,8], "k": 4, "dist": 2 }
assert my_solution.minimumCost(**test_input) == 24

test_input = { "nums": [1,5,6,6,3,7,2], "k": 6, "dist": 5 }
assert my_solution.minimumCost(**test_input) == 23

test_input = { "nums": [1,6,4,6,2,9,11], "k": 4, "dist": 3 }
assert my_solution.minimumCost(**test_input) == 13

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

test_input = { "nums": [1,6,5,6,4,9,11], "k": 5, "dist": 5 }
assert my_solution.minimumCost(**test_input) == 22

test_input = { "nums": [1,6,5,7,8,7,5], "k": 5, "dist": 4 }
assert my_solution.minimumCost(**test_input) == 25

test_input = { "nums": [1,6,5,8,11,10,6], "k": 5, "dist": 3 }
assert my_solution.minimumCost(**test_input) == 31

test_input = { "nums": [1,6,6,8,4,8,7], "k": 6, "dist": 4 }
assert my_solution.minimumCost(**test_input) == 33

test_input = { "nums": [1,7,6,8,5,10,10], "k": 6, "dist": 5 }
assert my_solution.minimumCost(**test_input) == 37

test_input = { "nums": [1,8,3,8,11,11,10], "k": 3, "dist": 5 }
assert my_solution.minimumCost(**test_input) == 12

test_input = { "nums": [1,8,4,7,11,1,8], "k": 4, "dist": 4 }
assert my_solution.minimumCost(**test_input) == 13

test_input = { "nums": [1,8,6,5,6,12,12], "k": 6, "dist": 5 }
assert my_solution.minimumCost(**test_input) == 38

test_input = { "nums": [1,8,6,6,12,5,2], "k": 6, "dist": 5 }
assert my_solution.minimumCost(**test_input) == 28

test_input = { "nums": [2,5,3,5,7,4,3], "k": 3, "dist": 3 }
assert my_solution.minimumCost(**test_input) == 9

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