2026-rff_mp/ZelentsovAV/generator.py
2026-05-21 19:38:10 +03:00

18 lines
865 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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