import multiply as mlt top_value = int("0b" + input("Top value (in binary): "), 2) m = int(input("Method: ")) total_iterations = (top_value + 1) ** 2 print(f"Total test amount: {top_value + 1}^2 = {total_iterations}") errors = [] for x in range(top_value): for y in range(top_value): n = max([len(bin(i)[2:]) for i in (x, y)]) expected_result = mlt.al(bin(x*y)[2:], 2*n) _, r = mlt.multiply(n, x, y, m) if r == expected_result: print(f"{str(x*top_value+y).rjust(len(str(total_iterations)))}/{total_iterations}", end = "\r") else: errors.append([x, y, expected_result, r]) print(f"Failed at {x}*{y}; expected {expected_result} but got {r}!") if len(errors) == 0: print("Testing finished, no miscalculations detected.\nIt's safe to use!") else: print(f"Testing failed with {len(errors)} errors.")