From f04ddbb9a6402738dad9a326b67088c050574ea3 Mon Sep 17 00:00:00 2001 From: Silicon27 <99114143+Silicon27@users.noreply.github.com> Date: Sun, 13 Oct 2024 12:14:57 +0200 Subject: [PATCH 1/8] 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. --- sorts/quantum_bogo_sort.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 sorts/quantum_bogo_sort.py diff --git a/sorts/quantum_bogo_sort.py b/sorts/quantum_bogo_sort.py new file mode 100644 index 000000000..36862b342 --- /dev/null +++ b/sorts/quantum_bogo_sort.py @@ -0,0 +1,14 @@ +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. + + :param arr: List[int] - The list of numbers to sort. + :return: List[int] - The sorted list. + """ + return arr # The elements are already in a superposition of sorted and unsorted states + + +if __name__ == "__main__": + my_array = [2, 1, 4, 3] + quantum_bogo_sort(my_array) From 3064dd13a1f11cffde2f2170301bd5a99ef97d2d Mon Sep 17 00:00:00 2001 From: Silicon27 <99114143+Silicon27@users.noreply.github.com> Date: Sun, 13 Oct 2024 12:37:04 +0200 Subject: [PATCH 2/8] Update quantum_bogo_sort.py to be in compliance with [CONTRIBUTING.md](https://github.com/TheAlgorithms/Python/blob/master/CONTRIBUTING.md) --- sorts/quantum_bogo_sort.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/sorts/quantum_bogo_sort.py b/sorts/quantum_bogo_sort.py index 36862b342..2551dee43 100644 --- a/sorts/quantum_bogo_sort.py +++ b/sorts/quantum_bogo_sort.py @@ -1,14 +1,29 @@ +from typing import List + 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. :param arr: List[int] - The list of numbers to sort. - :return: List[int] - The sorted list. + :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 arr # The elements are already in a superposition of sorted and unsorted states + return sorted(arr) # Sorting is assumed to be done instantly via quantum superposition if __name__ == "__main__": - my_array = [2, 1, 4, 3] - quantum_bogo_sort(my_array) + my_array: List[int] = [2, 1, 4, 3] + print(quantum_bogo_sort(my_array)) From fc5411cd44bf5047acd66f51c66029536a341995 Mon Sep 17 00:00:00 2001 From: Silicon27 <99114143+Silicon27@users.noreply.github.com> Date: Sun, 13 Oct 2024 12:41:32 +0200 Subject: [PATCH 3/8] Update quantum_bogo_sort.py to include a reference to a wiki page --- sorts/quantum_bogo_sort.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sorts/quantum_bogo_sort.py b/sorts/quantum_bogo_sort.py index 2551dee43..8150a76d4 100644 --- a/sorts/quantum_bogo_sort.py +++ b/sorts/quantum_bogo_sort.py @@ -4,6 +4,9 @@ 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. + + Reference: + 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. From 153009ea9ebba0883c0d8bd7343bc7823370c5e8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 13 Oct 2024 10:43:04 +0000 Subject: [PATCH 4/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- sorts/quantum_bogo_sort.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sorts/quantum_bogo_sort.py b/sorts/quantum_bogo_sort.py index 8150a76d4..7bc8f8e4d 100644 --- a/sorts/quantum_bogo_sort.py +++ b/sorts/quantum_bogo_sort.py @@ -1,10 +1,11 @@ from typing import List + 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. - + Reference: https://en.wikipedia.org/wiki/Bogosort#:~:text=achieve%20massive%20complexity.-,Quantum%20bogosort,-A%20hypothetical%20sorting @@ -14,17 +15,19 @@ def quantum_bogo_sort(arr: List[int]) -> List[int]: 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 + return sorted( + arr + ) # Sorting is assumed to be done instantly via quantum superposition if __name__ == "__main__": From e12524497a64a84540aefbe98c6f0a02cdf7979d Mon Sep 17 00:00:00 2001 From: Silicon27 <99114143+Silicon27@users.noreply.github.com> Date: Sun, 13 Oct 2024 12:44:55 +0200 Subject: [PATCH 5/8] Update quantum_bogo_sort.py to be in compliance with ruff --- sorts/quantum_bogo_sort.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sorts/quantum_bogo_sort.py b/sorts/quantum_bogo_sort.py index 7bc8f8e4d..d493bf76b 100644 --- a/sorts/quantum_bogo_sort.py +++ b/sorts/quantum_bogo_sort.py @@ -1,7 +1,4 @@ -from typing import List - - -def quantum_bogo_sort(arr: List[int]) -> List[int]: +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. @@ -9,8 +6,8 @@ def quantum_bogo_sort(arr: List[int]) -> List[int]: Reference: 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. + :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]) @@ -25,11 +22,9 @@ def quantum_bogo_sort(arr: List[int]) -> List[int]: >>> quantum_bogo_sort([]) [] """ - return sorted( - arr - ) # Sorting is assumed to be done instantly via quantum superposition + return sorted(arr) # Sorting is assumed to be done instantly via quantum superposition if __name__ == "__main__": - my_array: List[int] = [2, 1, 4, 3] + my_array: list[int] = [2, 1, 4, 3] print(quantum_bogo_sort(my_array)) From 4a9404f6f09be28ccb1e3fc0bf3eaa2be81f84e4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 13 Oct 2024 10:47:48 +0000 Subject: [PATCH 6/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- sorts/quantum_bogo_sort.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sorts/quantum_bogo_sort.py b/sorts/quantum_bogo_sort.py index d493bf76b..1b2e7dec7 100644 --- a/sorts/quantum_bogo_sort.py +++ b/sorts/quantum_bogo_sort.py @@ -22,7 +22,9 @@ def quantum_bogo_sort(arr: list[int]) -> list[int]: >>> quantum_bogo_sort([]) [] """ - return sorted(arr) # Sorting is assumed to be done instantly via quantum superposition + return sorted( + arr + ) # Sorting is assumed to be done instantly via quantum superposition if __name__ == "__main__": From 1aac36937e4bd99e42240c2c46559b345287f35c Mon Sep 17 00:00:00 2001 From: Silicon27 <99114143+Silicon27@users.noreply.github.com> Date: Sun, 13 Oct 2024 12:50:37 +0200 Subject: [PATCH 7/8] Update quantum_bogo_sort.py line too long error resolved --- sorts/quantum_bogo_sort.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sorts/quantum_bogo_sort.py b/sorts/quantum_bogo_sort.py index 1b2e7dec7..08cf24e36 100644 --- a/sorts/quantum_bogo_sort.py +++ b/sorts/quantum_bogo_sort.py @@ -1,30 +1,30 @@ 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. + 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. - Reference: + 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. + :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 + return sorted(arr) # Sorting is assumed to be done instantly via quantum superposition if __name__ == "__main__": From b6fd43f29e6ba4516fe9222581f91090f8967ecb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 13 Oct 2024 10:51:51 +0000 Subject: [PATCH 8/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- sorts/quantum_bogo_sort.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sorts/quantum_bogo_sort.py b/sorts/quantum_bogo_sort.py index 08cf24e36..dc39651b6 100644 --- a/sorts/quantum_bogo_sort.py +++ b/sorts/quantum_bogo_sort.py @@ -1,30 +1,32 @@ 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. + 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: + 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 + :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 + return sorted( + arr + ) # Sorting is assumed to be done instantly via quantum superposition if __name__ == "__main__":