3333#
3434# 4) There are at least same three numbers other than last digit.
3535
36+ from collections .abc import Iterable , Sequence
3637from functools import reduce
3738from itertools import combinations , count
3839
@@ -85,7 +86,7 @@ def flip_bits(pos_tpl: tuple[int, tuple[int, ...]]) -> tuple[int, list[int]]:
8586
8687# assemble_num(231, [0, 1, 1, 1, 0, 0], 7)
8788# --> 237771
88- def assemble_num (i : int , pat : list [int ], r : int ) -> int :
89+ def assemble_num (i : int , pat : Iterable [int ], r : int ) -> int :
8990 lst = []
9091 for flag in pat :
9192 if flag == 0 :
@@ -97,7 +98,7 @@ def assemble_num(i: int, pat: list[int], r: int) -> int:
9798 return reduce (lambda x , y : 10 * x + y , reversed (lst ))
9899
99100
100- def is_probable (i : int , pat : list [int ], current_min : int ) -> bool :
101+ def is_probable (i : int , pat : Sequence [int ], current_min : int ) -> bool :
101102 # Is MSB target digit to replace or not?
102103 if pat [- 1 ] == 1 :
103104 return assemble_num (i , pat , 1 ) < current_min
@@ -106,7 +107,7 @@ def is_probable(i: int, pat: list[int], current_min: int) -> bool:
106107
107108
108109# Check all cases
109- def find_prime (i : int , pat : list [int ]) -> int | None :
110+ def find_prime (i : int , pat : Sequence [int ]) -> int | None :
110111 # If MSB is target digit to replace, '0' is not applicable.
111112 start = 0
112113 if pat [- 1 ] == 1 :
0 commit comments