Beispiel #1
0
 def test1(self):
     for f in functions:
         a = list_to_linkedlist([7, 2, 4, 3])
         b = list_to_linkedlist([5, 6, 4])
         node = f(a, b)
         self.assertEqual(linkedlist_to_list(node), [7, 8, 0, 7],
                          f.__name__)
 def test1(self):
     for f in functions:
         node1 = Node(3)
         node2 = Node(3)
         node3 = Node(3)
         node1.next = node2
         node2.next = node3
         node2.random = node1
         self.assertEqual(linkedlist_to_list(f(node1)), [3, 3, 3],
                          f.__name__)
 def test1(self):
     f = Solution().insert
     node3 = f(None, 3)
     self.assertEqual(linkedlist_to_list(f(node3, 1)), [3,1])
     self.assertEqual(linkedlist_to_list(f(node3, 4)), [3,4,1])
     self.assertEqual(linkedlist_to_list(f(node3, 0)), [3,4,0,1])
     self.assertEqual(linkedlist_to_list(f(node3, 5)), [3,4,5,0,1])
     self.assertEqual(linkedlist_to_list(f(node3, 2)), [3,4,5,0,1,2])
     self.assertEqual(linkedlist_to_list(f(node3, 3)), [3,3,4,5,0,1,2])
     self.assertTrue(detect_linkedlist_cycle(node3))
 def test(self):
     for f in functions:
         l1 = list_to_linkedlist([2,3,5])
         l2 = list_to_linkedlist([1,3,6])
         merged = f([l1, l2])
         self.assertEqual(linkedlist_to_list(merged), [1,2,3,3,5,6], f.__name__)
Beispiel #5
0
 def test1(self):
     for f in functions:
         node = list_to_linkedlist([1,2,2,1])
         self.assertEqual(f(node), True, f.__name__)
         self.assertEqual(linkedlist_to_list(node), [1,2,2,1], f.__name__)
Beispiel #6
0
 def test1(self):
     for f in functions:
         a = list_to_linkedlist([2, 3, 5])
         b = list_to_linkedlist([1, 4, 6])
         self.assertEqual(linkedlist_to_list(f(a, b)), [1, 2, 3, 4, 5, 6],
                          f.__name__)
Beispiel #7
0
 def test1(self):
     for f in functions:
         node = list_to_linkedlist([1, 2, 3, 3, 3, 4, 4, 5])
         self.assertEqual(linkedlist_to_list(f(node)), [1, 2, 3, 4, 5],
                          f.__name__)
Beispiel #8
0
 def test1(self):
     for f in functions:
         a = list_to_linkedlist([2, 4, 3])
         b = list_to_linkedlist([5, 6, 4])
         self.assertEqual(linkedlist_to_list(f(a, b)), [7, 0, 8],
                          f.__name__)
 def test1(self):
     for f in functions:
         self.assertEqual(
             linkedlist_to_list(f(list_to_linkedlist([1, 2, 3, 4, 5]))),
             [5, 4, 3, 2, 1], f.__name__)