inteligentny-traktor/decisionTree/generator.py

24 lines
620 B
Python
Raw Normal View History

2023-05-24 18:26:25 +02:00
import random
2023-06-15 14:03:24 +02:00
2023-05-24 18:26:25 +02:00
# 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
2023-06-15 14:03:24 +02:00
2023-05-24 18:26:25 +02:00
# 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:
2023-06-15 14:03:24 +02:00
file.write(line + '\n')