mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 15:01:08 +00: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
|
||||
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__":
|
||||
|
|
Loading…
Reference in New Issue
Block a user