param_alg/verzweigungsvectoren/main.py
2024-11-14 21:52:57 +01:00

31 lines
529 B
Python
Executable file

#!/usr/bin/env python
from numpy import roots,isreal
from itertools import combinations_with_replacement
solutions = []
s = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in range(2, 7):
for j in combinations_with_replacement(s, i):
p = [-j.count(k) for k in range(max(j) + 1)]
p[0] = 1
r = [float(k) for k in roots(p) if isreal(k) and k > 0.0]
# print(j, max(j), p, r)
solutions.append((j, r[0]))
solutions.sort(key=lambda e: e[1])
for s in solutions:
print(f"{s[1]}\t{s[0]}")