inteligentny-traktor/decisionTree/generator.py
2023-06-15 14:03:24 +02:00

24 lines
620 B
Python

import random
# Generowanie unikalnej losowej linii tekstu
def generate_unique_line(existing_lines):
while True:
line = ''.join(random.choice(['0', '1']) for _ in range(7))
last_digit = random.choice(['1', '2', '3', '0'])
line += last_digit
if line not in existing_lines:
return line
# Generowanie 200 unikalnych linii tekstu
lines = []
while len(lines) < 200:
line = generate_unique_line(lines)
lines.append(line)
# Zapisywanie linii tekstu do pliku
with open('decisionTree/database.txt', 'w') as file:
for line in lines:
file.write(line + '\n')