Compare commits

...

10 Commits

Author SHA1 Message Date
Silicon27
206e2a06d7
Merge b6fd43f29e6ba4516fe9222581f91090f8967ecb into e59d819d091efdb30e385f4ecfe9ab5d36c3be71 2025-02-08 12:59:48 +01:00
pre-commit-ci[bot]
e59d819d09
[pre-commit.ci] pre-commit autoupdate (#12554)
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.9.3 → v0.9.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.3...v0.9.4)
- [github.com/codespell-project/codespell: v2.4.0 → v2.4.1](https://github.com/codespell-project/codespell/compare/v2.4.0...v2.4.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-02-05 20:47:41 +01:00
pre-commit-ci[bot]
b6fd43f29e [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2024-10-13 10:51:51 +00:00
Silicon27
1aac36937e
Update quantum_bogo_sort.py line too long error resolved 2024-10-13 12:50:37 +02:00
pre-commit-ci[bot]
4a9404f6f0 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2024-10-13 10:47:49 +00:00
Silicon27
e12524497a
Update quantum_bogo_sort.py to be in compliance with ruff 2024-10-13 12:44:55 +02:00
pre-commit-ci[bot]
153009ea9e [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2024-10-13 10:43:05 +00:00
Silicon27
fc5411cd44
Update quantum_bogo_sort.py to include a reference to a wiki page 2024-10-13 12:41:32 +02:00
Silicon27
3064dd13a1
Update quantum_bogo_sort.py to be in compliance with [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md) 2024-10-13 12:37:04 +02:00
Silicon27
f04ddbb9a6
Create quantum_bogo_sort.py
Added `quantum_bogo_sort`, a theoretical sorting algorithm that uses quantum mechanics to sort the elements. 

It assumes all elements are already in the superposition of sorted and unsorted states, therefore only requiring it to be returned after being called.
2024-10-13 12:14:57 +02:00
2 changed files with 36 additions and 2 deletions

View File

@ -16,13 +16,13 @@ repos:
- id: auto-walrus
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.3
rev: v0.9.4
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/codespell-project/codespell
rev: v2.4.0
rev: v2.4.1
hooks:
- id: codespell
additional_dependencies:

View 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))