else: node_list.append(l) p = l._next l._next = None l = p return 'Error' if __name__ == '__main__': l = Node(np.random.randint(1, 10)) count = 1 p = l node = l for i in range(2): l.append(np.random.randint(1, 10)) p = p._next count += 1 print('p should be', p) for i in range(2): l.append(np.random.randint(1, 10)) count += 1 if np.random.randint(0, 2) > 0: l.append(p) count += 1 print('Should be True') print('total %d s nodes' % count) p = l for i in range(count): print(p, end='->') p = p._next
if p2._next == None: break else: p2 = p2._next if l1._next == None: break else: l1 = l1._next return 'No intersecting node' if __name__ == '__main__': l1 = Node(np.random.randint(1, 10)) l2 = Node(np.random.randint(1, 10)) for i in range(np.random.randint(0, 3)): l1.append(np.random.randint(1, 10)) for i in range(np.random.randint(0, 3)): l2.append(np.random.randint(1, 10)) inter = Node(item=128) l1.append(inter) l2.append(inter) for i in range(3): l1.append(np.random.randint(1, 10)) for i in range(np.random.randint(0, 5)): l2.append(np.random.randint(1, 10)) print('L1:') display(l1) print('L2:') display(l2) result = check_intersection(l1, l2)