2026-rff_mp/ZelentsovAV/task1/generator.py

18 lines
865 B
Python
Raw Normal View History

2026-05-24 17:18:54 +00:00
import random
def generate_test_data(N): #Генерирует N записей с именами User_00000 ... User_N-1
records = [(f"User_{i:05d}", f"+7-999-{i:05d}") for i in range(N)]
records_shuffled = records.copy()
random.shuffle(records_shuffled)
records_sorted = sorted(records, key=lambda x: x[0])
return records, records_shuffled, records_sorted
def get_names_for_operations(records, num_find=100, num_delete=50, num_nonexistent=10): #Подготавливает имена для операций поиска и удаления
existing_names = [name for name, _ in records[:num_find + num_delete]]
names_to_find = existing_names[:num_find] + [f"None_{i}" for i in range(num_nonexistent)]
names_to_delete = existing_names[num_find:num_find + num_delete]
return names_to_find, names_to_delete