This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random, time | |
### Test case functions | |
# Check for sorted list | |
def is_sorted(a:list) -> bool: | |
for i in range(len(a) - 1): | |
if a[i] > a[i + 1]: | |
return False | |
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def brute_search(recursion_depth:int = 200): | |
nums = list(range(recursion_depth)) | |
i = 1 | |
while i < len(nums): | |
a = nums[i] | |
for b in range(a, recursion_depth): | |
c = math.sqrt(a**2 + b**2) # Pythagorean theorem | |
if c.is_integer(): |