mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
[mypy] Fix other/fischer_yates_shuffle.py
(#5789)
* [mypy] Fix `other/fischer_yates_shuffle.py` * Update mypy.ini
This commit is contained in:
parent
8ac86f2ce5
commit
accee50cde
2
mypy.ini
2
mypy.ini
@ -2,5 +2,5 @@
|
|||||||
ignore_missing_imports = True
|
ignore_missing_imports = True
|
||||||
install_types = True
|
install_types = True
|
||||||
non_interactive = 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.
|
wikipedia/Fischer-Yates-Shuffle.
|
||||||
"""
|
"""
|
||||||
import random
|
import random
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
|
||||||
def fisher_yates_shuffle(data: list) -> list:
|
def fisher_yates_shuffle(data: list) -> list[Any]:
|
||||||
for _ in range(len(list)):
|
for _ in range(len(data)):
|
||||||
a = random.randint(0, len(list) - 1)
|
a = random.randint(0, len(data) - 1)
|
||||||
b = random.randint(0, len(list) - 1)
|
b = random.randint(0, len(data) - 1)
|
||||||
list[a], list[b] = list[b], list[a]
|
data[a], data[b] = data[b], data[a]
|
||||||
return list
|
return data
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user