X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=list_utils.py;h=88c436be24f88e73093f2c6f509a157e181ed6f9;hb=e8671a716da868332d3ac1f66d4d2f7f8d33fc28;hp=992f1ae4207228711c17573bb779cc0aaae2d0f8;hpb=5f75cf834725ac26b289cc5f157af0cb71cd5f0e;p=python_utils.git diff --git a/list_utils.py b/list_utils.py index 992f1ae..88c436b 100644 --- a/list_utils.py +++ b/list_utils.py @@ -216,6 +216,7 @@ def permute(seq: Sequence[Any]): """ yield from _permute(seq, "") + def _permute(seq: Sequence[Any], path): if len(seq) == 0: yield path @@ -228,7 +229,7 @@ def _permute(seq: Sequence[Any], path): yield from _permute(cdr, path + car) -def binary_search(lst: Sequence[Any], target:Any) -> Tuple[bool, int]: +def binary_search(lst: Sequence[Any], target: Any) -> Tuple[bool, int]: """Performs a binary search on lst (which must already be sorted). Returns a Tuple composed of a bool which indicates whether the target was found and an int which indicates the index closest to