добавлен файл с генерацией тестовых данных
This commit is contained in:
parent
d43389ec5e
commit
274784ea0a
0
konnovaea/experiments.py
Normal file
0
konnovaea/experiments.py
Normal file
|
|
@ -1,13 +1,16 @@
|
||||||
def ll_insert(head, name, phone):
|
def ll_insert(head, name, phone):
|
||||||
|
|
||||||
|
new_node = {'name': name, 'phone': phone, 'next': None}
|
||||||
|
|
||||||
|
if head is None:
|
||||||
|
return new_node
|
||||||
|
|
||||||
current = head
|
current = head
|
||||||
while current is not None:
|
while current['next'] is not None:
|
||||||
if current['name'] == name:
|
|
||||||
current['phone'] = phone
|
|
||||||
return head
|
|
||||||
current = current['next']
|
current = current['next']
|
||||||
|
|
||||||
new_node = {'name': name, 'phone': phone, 'next': head}
|
current['next'] = new_node
|
||||||
return 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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user