Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- FRONTPLATTEN = (5, 3, 7, 8, 12, 24)
- def f_kombi(platz):
- multiplikatoren = [list(range(0, platz // m + 1)) for m in FRONTPLATTEN]
- for multi in itertools.product(*multiplikatoren):
- if sum(f * m for f, m in zip(FRONTPLATTEN, multi)) == platz:
- yield multi
- def ausgabe(platz, ergebnisse=None):
- vers = 16
- iterator = f_kombi(platz)
- if ergebnisse is not None:
- iterator = itertools.islice(f_kombi(platz), 0, ergebnisse)
- for multi in iterator:
- print("Frontplatten".ljust(vers) + ":", " | ".join(f"{f:>2d}" for f in FRONTPLATTEN))
- print("-" * 12, " " * 6, " | ".join(" " for _ in range(len(FRONTPLATTEN))),sep="")
- print("Anzahl".ljust(vers) + ":", " | ".join(f"{m:>2d}" if m != 0 else " " for m in multi))
- s = tuple(f * m for f, m in zip(FRONTPLATTEN, multi))
- s = " | ".join(f"{ss:>2d}" if ss != 0 else " " for ss in s)
- print(f"{'Produkte':<{vers}}: {s} => {platz}", end="\n\n\n")
- print("Ich hab zuviel CDL getrunken")
- # Frontplatten : 5 | 3 | 7 | 8 | 12 | 24
- # ------------ | | | | |
- # Anzahl : | 1 | 1 | | |
- # Produkte : | 3 | 7 | | | => 10
- # Frontplatten : 5 | 3 | 7 | 8 | 12 | 24
- # ------------ | | | | |
- # Anzahl : 2 | | | | |
- # Produkte : 10 | | | | | => 10
- # Ich hab zuviel CDL getrunken
Add Comment
Please, Sign In to add comment