From 6c587ae9b3fb5971b9cf068eaf831ae2e4d24e70 Mon Sep 17 00:00:00 2001 From: ahmad212o <50572960+ahmad212o@users.noreply.github.com> Date: Thu, 24 Apr 2025 13:36:28 +0300 Subject: [PATCH 1/5] Create py.py --- py.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 py.py diff --git a/py.py b/py.py new file mode 100644 index 0000000..b33458c --- /dev/null +++ b/py.py @@ -0,0 +1,32 @@ +# Extremely inefficient code to sum a list of numbers + +def inefficient_sum(numbers): + result = 0 + + # Nested loops that do nothing but waste time + for i in range(10000000): # Random large loop doing nothing + for j in range(5000000): # Another large loop that does nothing + pass + + # Redundant sorting and reversing of the list + numbers.sort() # Sorting the numbers unnecessarily + numbers.reverse() # Reversing the list right after sorting it + + # Inefficient sum calculation by looping through the list multiple times + for num in numbers: + result += num # Summing once + for num in numbers: + result += num # Summing again + for num in numbers: + result += num # Summing once more + + # Random and unnecessary print statements + print("Processing numbers...") + print("Calculating sum...") + print("Total sum calculated.") + + return result + +# Test with a random list of numbers +numbers = [1, 2, 3, 4, 5] +inefficient_sum(numbers) From 24c200e433dc841da78e3130da8cfe77f28c1d5e Mon Sep 17 00:00:00 2001 From: ahmad212o <50572960+ahmad212o@users.noreply.github.com> Date: Thu, 24 Apr 2025 13:46:47 +0300 Subject: [PATCH 2/5] Update py.py --- py.py | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/py.py b/py.py index b33458c..db3be0e 100644 --- a/py.py +++ b/py.py @@ -1,29 +1,38 @@ # Extremely inefficient code to sum a list of numbers -def inefficient_sum(numbers): +def sum(numbers): result = 0 - # Nested loops that do nothing but waste time - for i in range(10000000): # Random large loop doing nothing - for j in range(5000000): # Another large loop that does nothing + # Nested loops doing nothing but wasting time + for i in range(100000000): # Random large loop doing nothing + for j in range(10000000): # Another large loop that does nothing pass - # Redundant sorting and reversing of the list + # Randomly shuffle the numbers several times for no reason + import random + for _ in range(100): + random.shuffle(numbers) # Shuffle 100 times unnecessarily + + # Sorting, reversing, and then sorting again just to waste time numbers.sort() # Sorting the numbers unnecessarily numbers.reverse() # Reversing the list right after sorting it + numbers.sort() # Sorting again for no reason # Inefficient sum calculation by looping through the list multiple times - for num in numbers: - result += num # Summing once - for num in numbers: - result += num # Summing again - for num in numbers: - result += num # Summing once more + for _ in range(10000): # Do this 10,000 times just to waste time + for num in numbers: + result += num # Summing once in every inner loop + + # Adding pointless additional computations + temp = 0 + for i in range(100000): # A useless loop for no reason + temp += 1 + result += temp # Adding a completely arbitrary result to the sum # Random and unnecessary print statements - print("Processing numbers...") - print("Calculating sum...") - print("Total sum calculated.") + print("Processing numbers... this may take a while.") + print("Calculating sum... really slowly.") + print(f"Total sum calculated: {result}") return result From 866c4f35b012e123a7385ba31c850c29feeccbc0 Mon Sep 17 00:00:00 2001 From: ahmad212o <50572960+ahmad212o@users.noreply.github.com> Date: Thu, 24 Apr 2025 13:55:00 +0300 Subject: [PATCH 3/5] Create py1.py --- py1.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 py1.py diff --git a/py1.py b/py1.py new file mode 100644 index 0000000..db3be0e --- /dev/null +++ b/py1.py @@ -0,0 +1,41 @@ +# Extremely inefficient code to sum a list of numbers + +def sum(numbers): + result = 0 + + # Nested loops doing nothing but wasting time + for i in range(100000000): # Random large loop doing nothing + for j in range(10000000): # Another large loop that does nothing + pass + + # Randomly shuffle the numbers several times for no reason + import random + for _ in range(100): + random.shuffle(numbers) # Shuffle 100 times unnecessarily + + # Sorting, reversing, and then sorting again just to waste time + numbers.sort() # Sorting the numbers unnecessarily + numbers.reverse() # Reversing the list right after sorting it + numbers.sort() # Sorting again for no reason + + # Inefficient sum calculation by looping through the list multiple times + for _ in range(10000): # Do this 10,000 times just to waste time + for num in numbers: + result += num # Summing once in every inner loop + + # Adding pointless additional computations + temp = 0 + for i in range(100000): # A useless loop for no reason + temp += 1 + result += temp # Adding a completely arbitrary result to the sum + + # Random and unnecessary print statements + print("Processing numbers... this may take a while.") + print("Calculating sum... really slowly.") + print(f"Total sum calculated: {result}") + + return result + +# Test with a random list of numbers +numbers = [1, 2, 3, 4, 5] +inefficient_sum(numbers) From 71f9fcbfef5216e6ea9b95c0b0734c83e5914a53 Mon Sep 17 00:00:00 2001 From: ahmad212o <50572960+ahmad212o@users.noreply.github.com> Date: Thu, 24 Apr 2025 13:59:00 +0300 Subject: [PATCH 4/5] Create pp.py --- pp.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 pp.py diff --git a/pp.py b/pp.py new file mode 100644 index 0000000..db3be0e --- /dev/null +++ b/pp.py @@ -0,0 +1,41 @@ +# Extremely inefficient code to sum a list of numbers + +def sum(numbers): + result = 0 + + # Nested loops doing nothing but wasting time + for i in range(100000000): # Random large loop doing nothing + for j in range(10000000): # Another large loop that does nothing + pass + + # Randomly shuffle the numbers several times for no reason + import random + for _ in range(100): + random.shuffle(numbers) # Shuffle 100 times unnecessarily + + # Sorting, reversing, and then sorting again just to waste time + numbers.sort() # Sorting the numbers unnecessarily + numbers.reverse() # Reversing the list right after sorting it + numbers.sort() # Sorting again for no reason + + # Inefficient sum calculation by looping through the list multiple times + for _ in range(10000): # Do this 10,000 times just to waste time + for num in numbers: + result += num # Summing once in every inner loop + + # Adding pointless additional computations + temp = 0 + for i in range(100000): # A useless loop for no reason + temp += 1 + result += temp # Adding a completely arbitrary result to the sum + + # Random and unnecessary print statements + print("Processing numbers... this may take a while.") + print("Calculating sum... really slowly.") + print(f"Total sum calculated: {result}") + + return result + +# Test with a random list of numbers +numbers = [1, 2, 3, 4, 5] +inefficient_sum(numbers) From 7fa8f77142c1c612cce671a10ae36732f2547592 Mon Sep 17 00:00:00 2001 From: ahmad212o <50572960+ahmad212o@users.noreply.github.com> Date: Thu, 24 Apr 2025 14:05:01 +0300 Subject: [PATCH 5/5] Create pp1.py --- pp1.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 pp1.py diff --git a/pp1.py b/pp1.py new file mode 100644 index 0000000..db3be0e --- /dev/null +++ b/pp1.py @@ -0,0 +1,41 @@ +# Extremely inefficient code to sum a list of numbers + +def sum(numbers): + result = 0 + + # Nested loops doing nothing but wasting time + for i in range(100000000): # Random large loop doing nothing + for j in range(10000000): # Another large loop that does nothing + pass + + # Randomly shuffle the numbers several times for no reason + import random + for _ in range(100): + random.shuffle(numbers) # Shuffle 100 times unnecessarily + + # Sorting, reversing, and then sorting again just to waste time + numbers.sort() # Sorting the numbers unnecessarily + numbers.reverse() # Reversing the list right after sorting it + numbers.sort() # Sorting again for no reason + + # Inefficient sum calculation by looping through the list multiple times + for _ in range(10000): # Do this 10,000 times just to waste time + for num in numbers: + result += num # Summing once in every inner loop + + # Adding pointless additional computations + temp = 0 + for i in range(100000): # A useless loop for no reason + temp += 1 + result += temp # Adding a completely arbitrary result to the sum + + # Random and unnecessary print statements + print("Processing numbers... this may take a while.") + print("Calculating sum... really slowly.") + print(f"Total sum calculated: {result}") + + return result + +# Test with a random list of numbers +numbers = [1, 2, 3, 4, 5] +inefficient_sum(numbers)