import TestHelper def bubbleSort(arr): # loop over the input for i in range(len(arr)): # loop over the input again for j in range(len(arr) - 1): if arr[j] > arr[j + 1]: arr[j], arr[j + 1] = arr[j + 1], arr[j] # if the first loop var > second loop var swap them a = TestHelper.GenerateRandomIntList(15) print(a) bubbleSort(a) print(a)
import TestHelper def CreatePairs(arr): resultArr = [] for i in arr: for j in arr: if i != j: resultArr.append((i, j)) return resultArr testArr = TestHelper.GenerateRandomIntList(5) result = CreatePairs(testArr) print(result, len(result))