mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 15:01:08 +00:00
Compare commits
13 Commits
f582e65e66
...
15aef8db99
Author | SHA1 | Date | |
---|---|---|---|
|
15aef8db99 | ||
|
f3f32ae3ca | ||
|
e3bd7721c8 | ||
|
e3f3d668be | ||
|
3e9ca92ca9 | ||
|
b6fd43f29e | ||
|
1aac36937e | ||
|
4a9404f6f0 | ||
|
e12524497a | ||
|
153009ea9e | ||
|
fc5411cd44 | ||
|
3064dd13a1 | ||
|
f04ddbb9a6 |
|
@ -16,7 +16,7 @@ repos:
|
||||||
- id: auto-walrus
|
- id: auto-walrus
|
||||||
|
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.7.1
|
rev: v0.7.4
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
- id: ruff-format
|
- id: ruff-format
|
||||||
|
@ -29,7 +29,7 @@ repos:
|
||||||
- tomli
|
- tomli
|
||||||
|
|
||||||
- repo: https://github.com/tox-dev/pyproject-fmt
|
- repo: https://github.com/tox-dev/pyproject-fmt
|
||||||
rev: "v2.4.3"
|
rev: "v2.5.0"
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyproject-fmt
|
- id: pyproject-fmt
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ repos:
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
|
|
||||||
- repo: https://github.com/abravalheri/validate-pyproject
|
- repo: https://github.com/abravalheri/validate-pyproject
|
||||||
rev: v0.22
|
rev: v0.23
|
||||||
hooks:
|
hooks:
|
||||||
- id: validate-pyproject
|
- id: validate-pyproject
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ def solved(values):
|
||||||
|
|
||||||
def from_file(filename, sep="\n"):
|
def from_file(filename, sep="\n"):
|
||||||
"Parse a file into a list of strings, separated by sep."
|
"Parse a file into a list of strings, separated by sep."
|
||||||
return open(filename).read().strip().split(sep) # noqa: SIM115
|
return open(filename).read().strip().split(sep)
|
||||||
|
|
||||||
|
|
||||||
def random_puzzle(assignments=17):
|
def random_puzzle(assignments=17):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python3
|
#!python
|
||||||
import os
|
import os
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
34
sorts/quantum_bogo_sort.py
Normal file
34
sorts/quantum_bogo_sort.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
def quantum_bogo_sort(arr: list[int]) -> list[int]:
|
||||||
|
"""
|
||||||
|
Quantum Bogo Sort is a theoretical sorting algorithm that uses quantum
|
||||||
|
mechanics to sort the elements. It is not practically feasible and is
|
||||||
|
included here for humor.
|
||||||
|
|
||||||
|
More info:
|
||||||
|
https://en.wikipedia.org/wiki/Bogosort#:~:text=achieve%20massive%20complexity.-,Quantum%20bogosort,-A%20hypothetical%20sorting
|
||||||
|
|
||||||
|
:param arr: list[int] - The list of numbers to sort.
|
||||||
|
:return: list[int] - The sorted list, humorously assumed to be
|
||||||
|
instantly sorted using quantum superposition.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
>>> quantum_bogo_sort([2, 1, 4, 3])
|
||||||
|
[1, 2, 3, 4]
|
||||||
|
|
||||||
|
>>> quantum_bogo_sort([10, -1, 0])
|
||||||
|
[-1, 0, 10]
|
||||||
|
|
||||||
|
>>> quantum_bogo_sort([5])
|
||||||
|
[5]
|
||||||
|
|
||||||
|
>>> quantum_bogo_sort([])
|
||||||
|
[]
|
||||||
|
"""
|
||||||
|
return sorted(
|
||||||
|
arr
|
||||||
|
) # Sorting is assumed to be done instantly via quantum superposition
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
my_array: list[int] = [2, 1, 4, 3]
|
||||||
|
print(quantum_bogo_sort(my_array))
|
Loading…
Reference in New Issue
Block a user