def test_trivial_case(self): self.assertEqual(lastDigitNaive(3, 7), 1) self.assertEqual(lastDigitNaive(10, 10), 5) self.assertEqual(lastDigitNaive(10, 200), 2) self.assertEqual(lastDigitSolution(3, 7), 1) self.assertEqual(lastDigitSolution(10, 10), 5) self.assertEqual(lastDigitSolution(10, 200), 2)
def test_large_inputs(self): n = int(1e7) start_time = time.time() ## lastDigitNaive(n) # Fails test lastDigitSolution(n) elapsed_seconds = time.time() - start_time print '\nElapsed seconds for large input (n=%s): %.3f' % \ (n, elapsed_seconds) self.assertTrue(elapsed_seconds < TIME_LIMIT_SECONDS)
def test_stress(self): for dummy_ind in range(100): n = random.randint(2, 1e5) print n self.assertEqual(lastDigitNaive(n), lastDigitSolution(n))
def test_trivial_case(self): self.assertEqual(lastDigitNaive(3), 2) self.assertEqual(lastDigitNaive(331), 9) self.assertEqual(lastDigitSolution(3), 2) self.assertEqual(lastDigitSolution(331), 9) self.assertEqual(lastDigitSolution(327305), 5)
def test_stress(self): for dummy_ind in range(100): m = random.randint(2, 1e7) n = random.randint(m, 1e7) print m, n self.assertEqual(lastDigitNaive(m, n), lastDigitSolution(m, n))
def test_trivial_case(self): self.assertEqual(lastDigitNaive(3), 4) self.assertEqual(lastDigitNaive(100), 5) self.assertEqual(lastDigitSolution(3), 4) self.assertEqual(lastDigitSolution(100), 5)