未验证 提交 accee50c 编写于 作者: R Rohan R Bharadwaj 提交者: GitHub

[mypy] Fix `other/fischer_yates_shuffle.py` (#5789)

* [mypy] Fix `other/fischer_yates_shuffle.py`

* Update mypy.ini
上级 8ac86f2c
......@@ -2,5 +2,5 @@
ignore_missing_imports = True
install_types = True
non_interactive = True
exclude = (data_structures/stacks/next_greater_element.py|graphs/boruvka.py|graphs/breadth_first_search.py|graphs/breadth_first_search_2.py|graphs/check_cycle.py|graphs/finding_bridges.py|graphs/greedy_min_vertex_cover.py|graphs/random_graph_generator.py|maths/average_mode.py|maths/gamma_recursive.py|maths/proth_number.py|maths/series/geometric_series.py|maths/series/p_series.py|matrix_operation.py|other/fischer_yates_shuffle.py|other/least_recently_used.py|other/lfu_cache.py|other/lru_cache.py|searches/simulated_annealing.py|searches/ternary_search.py)
exclude = (data_structures/stacks/next_greater_element.py|graphs/boruvka.py|graphs/breadth_first_search.py|graphs/breadth_first_search_2.py|graphs/check_cycle.py|graphs/finding_bridges.py|graphs/greedy_min_vertex_cover.py|graphs/random_graph_generator.py|maths/average_mode.py|maths/gamma_recursive.py|maths/proth_number.py|maths/series/geometric_series.py|maths/series/p_series.py|matrix_operation.py|other/least_recently_used.py|other/lfu_cache.py|other/lru_cache.py|searches/simulated_annealing.py|searches/ternary_search.py)
......@@ -6,14 +6,15 @@ For more details visit
wikipedia/Fischer-Yates-Shuffle.
"""
import random
from typing import Any
def fisher_yates_shuffle(data: list) -> list:
for _ in range(len(list)):
a = random.randint(0, len(list) - 1)
b = random.randint(0, len(list) - 1)
list[a], list[b] = list[b], list[a]
return list
def fisher_yates_shuffle(data: list) -> list[Any]:
for _ in range(len(data)):
a = random.randint(0, len(data) - 1)
b = random.randint(0, len(data) - 1)
data[a], data[b] = data[b], data[a]
return data
if __name__ == "__main__":
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册