def test0096(self): import time from id_0096 import solve arr = [] f = open('id_0096-test.txt') for line in f: arr.append([int(x) for x in line.strip()]) f.close() start = time.time() solve(arr) end = time.time() print("time taken: ", end - start)
def test0096(self): from id_0096 import row, col, cell, check_table, solve, contains_duplicates, contains_duplicates_set from random import randint f = open('id_0096-test.txt') arr = [] for line in f: arr.append([int(x) for x in line.strip()]) f.close() self.assertEqual(row(arr, 1), [9, 0, 0, 3, 0, 5, 0, 0, 1]) self.assertEqual(col(arr, 2), [3, 0, 1, 8, 0, 6, 2, 0, 5]) self.assertEqual(cell(arr, 4), [1, 0, 2, 0, 0, 0, 7, 0, 8]) self.assertEqual(check_table(arr), True) sol = solve(arr) f = open('id_0096-test-ans.txt') arr_sol = [] for line in f: arr_sol.append([int(x) for x in line.strip()]) f.close() self.assertEqual(sol, arr_sol) for n in range(100): arr = [randint(1, 9) for x in range(9)] self.assertEqual(contains_duplicates(arr), contains_duplicates_set(arr))