Ejemplo n.º 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
Ejemplo n.º 2
0
 def test_13(self):
     self.assertEqual(collatz_length(13), 10)
Ejemplo n.º 3
0
 def test_1(self):
     self.assertEqual(collatz_length(1), 1)
Ejemplo n.º 4
0
 def test_cache(self):
     reset_cached_lengths()
     collatz_length(4)
     self.assertEqual(collatz_length(16), 5)
Ejemplo n.º 5
0
 def test_reset(self):
     collatz_length(1)
     reset_cached_lengths()
     self.assertEqual(collatz_lengths, {})
Ejemplo n.º 6
0
 def test_02(self):
     self.assertEqual(1, collatz.collatz_length(1))
Ejemplo n.º 7
0
 def test_01(self):
     self.assertEqual(2, collatz.collatz_length(2))
Ejemplo n.º 8
0
 def test_05(self):
     self.assertEqual(3, collatz.collatz_length(4))
Ejemplo n.º 9
0
 def test_04(self):
     self.assertEqual(8, collatz.collatz_length(3))
Ejemplo n.º 10
0
 def test_03(self):
     self.assertEqual(4, collatz.collatz_length(8))