Limit permutations to 1000 (#383)

limit permutations to 1000

Co-authored-by: jjanzen <jjanzen@jjanzen.ca>
This commit is contained in:
jjanzen 2025-01-18 13:08:12 -06:00 committed by GitHub
parent 02c64ef281
commit 211beb7b6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,7 +7,7 @@ import importlib.util
import json import json
import random import random
import traceback import traceback
from itertools import permutations from itertools import permutations, islice
from math import ceil from math import ceil
from . import termenv, neofetch_util, pride_month from . import termenv, neofetch_util, pride_month
@ -251,7 +251,7 @@ def create_config() -> Config:
slots = list(set(map(int, re.findall('(?<=\\${c)[0-9](?=})', asc)))) slots = list(set(map(int, re.findall('(?<=\\${c)[0-9](?=})', asc))))
while len(pis) < len(slots): while len(pis) < len(slots):
pis += pis pis += pis
perm = {p[:len(slots)] for p in permutations(pis)} perm = {p[:len(slots)] for p in islice(permutations(pis), 1000)}
random_count = max(0, ascii_per_row * ascii_rows - len(arrangements)) random_count = max(0, ascii_per_row * ascii_rows - len(arrangements))
if random_count > len(perm): if random_count > len(perm):
choices = perm choices = perm