From 664712c2500a7d75e54bc0c64fd3df40b08cab54 Mon Sep 17 00:00:00 2001 From: samyakpagariya <72349392+samyakpagariya@users.noreply.github.com> Date: Mon, 3 Oct 2022 10:41:59 +0530 Subject: [PATCH 1/3] For the better understanding of time taken. In this change I have initialized a variable p with the value of (1e9+7) and then took the modulus of process time with it . This modification gives better time taken by the process . Firstly it was giving answer in the exponential now it gives in the integer form. --- sorts/bubble_sort.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sorts/bubble_sort.py b/sorts/bubble_sort.py index d4f0d25ca77c..f35266d6f530 100644 --- a/sorts/bubble_sort.py +++ b/sorts/bubble_sort.py @@ -48,5 +48,6 @@ def bubble_sort(collection): user_input = input("Enter numbers separated by a comma:").strip() unsorted = [int(item) for item in user_input.split(",")] start = time.process_time() + p = (int)(1e9+7) print(*bubble_sort(unsorted), sep=",") - print(f"Processing time: {time.process_time() - start}") + print(f"Processing time: {(time.process_time() - start)%p}") From 4cfdd0fb96719bfdc9aa68e6f5d30084f9b22a5a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 3 Oct 2022 05:23:11 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- sorts/bubble_sort.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sorts/bubble_sort.py b/sorts/bubble_sort.py index f35266d6f530..9f30b49c105e 100644 --- a/sorts/bubble_sort.py +++ b/sorts/bubble_sort.py @@ -48,6 +48,6 @@ def bubble_sort(collection): user_input = input("Enter numbers separated by a comma:").strip() unsorted = [int(item) for item in user_input.split(",")] start = time.process_time() - p = (int)(1e9+7) + p = (int)(1e9 + 7) print(*bubble_sort(unsorted), sep=",") print(f"Processing time: {(time.process_time() - start)%p}") From d51fc94fd321de6ca3af6651a719d96290c519d1 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 30 Oct 2022 11:27:28 +0100 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Caeden Perelli-Harris --- sorts/bubble_sort.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sorts/bubble_sort.py b/sorts/bubble_sort.py index 9f30b49c105e..aef2da272bd0 100644 --- a/sorts/bubble_sort.py +++ b/sorts/bubble_sort.py @@ -48,6 +48,5 @@ def bubble_sort(collection): user_input = input("Enter numbers separated by a comma:").strip() unsorted = [int(item) for item in user_input.split(",")] start = time.process_time() - p = (int)(1e9 + 7) print(*bubble_sort(unsorted), sep=",") - print(f"Processing time: {(time.process_time() - start)%p}") + print(f"Processing time: {(time.process_time() - start)%1e9 + 7}")