2026-04-10 04:26:53 +00:00
|
|
|
import random as rnd
|
|
|
|
|
#############################################################################################
|
2026-04-22 14:02:37 +00:00
|
|
|
head = None
|
2026-04-10 04:26:53 +00:00
|
|
|
|
|
|
|
|
def ll_insert(head, name, phone):
|
|
|
|
|
next_node = {'name': name, 'phone': phone, 'next': None}
|
|
|
|
|
if head is None: return next_node
|
|
|
|
|
|
|
|
|
|
running = head
|
|
|
|
|
while running is not None:
|
|
|
|
|
if running['name'] == name:
|
|
|
|
|
running['phone'] = phone
|
|
|
|
|
return head
|
|
|
|
|
running = running['next']
|
|
|
|
|
|
|
|
|
|
running = head
|
|
|
|
|
while running['next'] is not None: running = running['next']
|
|
|
|
|
running['next'] = next_node
|
|
|
|
|
return head
|
|
|
|
|
|
2026-04-22 14:02:37 +00:00
|
|
|
print('======== TESTING LL_INSERT ==========')
|
|
|
|
|
Name = ['Dima', 'Ivan', 'Maxim', 'Alex']
|
2026-04-10 04:26:53 +00:00
|
|
|
|
2026-04-22 14:02:37 +00:00
|
|
|
for _ in range(10):
|
|
|
|
|
name = Name[rnd.randint(0, 3)]
|
|
|
|
|
phone = str(rnd.randint(0,9)) + str(rnd.randint(0,9)) + str(rnd.randint(0,9)) + '-' + \
|
|
|
|
|
str(rnd.randint(0,9)) + str(rnd.randint(0,9)) + str(rnd.randint(0,9))
|
|
|
|
|
print(name, phone)
|
|
|
|
|
head = ll_insert(head, name, phone)
|
|
|
|
|
print(head)
|
|
|
|
|
print('-----------------------------------\n')
|
2026-04-10 04:26:53 +00:00
|
|
|
|
2026-04-22 14:02:37 +00:00
|
|
|
print('======== END TESTING ================')
|