示例#1
0
def p14(stop: int) -> int:
    number_with_max_collatz_length = 0
    max_collatz_length = 0
    if stop == 1: return 1
    for n in range(stop // 2, stop):
        length = collatz_length(n)
        if length > max_collatz_length:
            max_collatz_length = length
            number_with_max_collatz_length = n

    return number_with_max_collatz_length
 def test_13(self):
     self.assertEqual(collatz_length(13), 10)
 def test_1(self):
     self.assertEqual(collatz_length(1), 1)
 def test_cache(self):
     reset_cached_lengths()
     collatz_length(4)
     self.assertEqual(collatz_length(16), 5)
 def test_reset(self):
     collatz_length(1)
     reset_cached_lengths()
     self.assertEqual(collatz_lengths, {})
示例#6
0
 def test_02(self):
     self.assertEqual(1, collatz.collatz_length(1))
示例#7
0
 def test_01(self):
     self.assertEqual(2, collatz.collatz_length(2))
示例#8
0
 def test_05(self):
     self.assertEqual(3, collatz.collatz_length(4))
示例#9
0
 def test_04(self):
     self.assertEqual(8, collatz.collatz_length(3))
示例#10
0
 def test_03(self):
     self.assertEqual(4, collatz.collatz_length(8))