diff --git a/KuzminskiyAA/Task 1/Dogs/Data/main.py b/KuzminskiyAA/Task 1/Dogs/Data/1.py similarity index 70% rename from KuzminskiyAA/Task 1/Dogs/Data/main.py rename to KuzminskiyAA/Task 1/Dogs/Data/1.py index 148494c..f9d5525 100644 --- a/KuzminskiyAA/Task 1/Dogs/Data/main.py +++ b/KuzminskiyAA/Task 1/Dogs/Data/1.py @@ -1,22 +1,22 @@ +import time +import random +import csv +import matplotlib.pyplot as plt +import numpy as np + def ll_insert(head, name, phone): - """Вставка в конец списка. Возвращает голову.""" new_node = {'name': name, 'phone': phone, 'next': None} - if head is None: return new_node - current = head - while current['next']: + while current: if current['name'] == name: current['phone'] = phone return head + if current['next'] is None: + current['next'] = new_node + return head current = current['next'] - - if current['name'] == name: - current['phone'] = phone - else: - current['next'] = new_node - return head def ll_find(head, name): @@ -30,24 +30,20 @@ def ll_find(head, name): def ll_delete(head, name): if head is None: return None - if head['name'] == name: return head['next'] - current = head while current['next']: if current['next']['name'] == name: current['next'] = current['next']['next'] return head current = current['next'] - return head def ll_list_all(head): - entries = [] + records = [] current = head while current: - entries.append((current['name'], current['phone'])) + records.append((current['name'], current['phone'])) current = current['next'] - entries.sort(key=lambda x: x[0]) - return entries \ No newline at end of file + return sorted(records, key=lambda x: x[0]) \ No newline at end of file