добавлен файл с генерацией тестовых данных

This commit is contained in:
konnovaea 2026-04-26 16:39:00 +03:00
parent d43389ec5e
commit 274784ea0a
2 changed files with 13 additions and 10 deletions

0
konnovaea/experiments.py Normal file
View File

View File

@ -1,13 +1,16 @@
def ll_insert(head, name, phone): def ll_insert(head, name, phone):
current = head
while current is not None:
if current['name'] == name:
current['phone'] = phone
return head
current = current['next']
new_node = {'name': name, 'phone': phone, 'next': head} new_node = {'name': name, 'phone': phone, 'next': None}
return new_node
if head is None:
return new_node
current = head
while current['next'] is not None:
current = current['next']
current['next'] = new_node
return head
def ll_find(head, name): def ll_find(head, name):
current = head current = head
@ -25,7 +28,7 @@ def ll_delete(head, name):
current = head current = head
while current['next'] is not None: while current['next'] is not None:
if current['next']['name'] == name: if current['next']['name'] == name:
current['next'] = current['naext']['next'] current['next'] = current['next']['next']
return head return head
current = current['next'] current = current['next']
return head return head
@ -35,7 +38,7 @@ def ll_list_all(head):
current = head current = head
while current is not None: while current is not None:
records.append((current['name'], current['phine'])) records.append((current['name'], current['phone']))
current = current['next'] current = current['next']
records.sort(key=lambda x: x[0]) records.sort(key=lambda x: x[0])
return records return records