UNI_Python/ext_01/control.py
2024-01-14 16:14:29 +01:00

51 lines
1.1 KiB
Python

import itertools
length = 5
digits = set(range(10))
numbers = set(itertools.product(digits, repeat=length))
print(f"|Z| = {len(digits)}")
print(f"|N| = {len(numbers)}")
counter = 0
for n in numbers:
if len(set(n)) == 1:
counter += 1
print(f"|A| = {counter}")
# Ausgabe: |A| = 10
counter = 0
for n in numbers:
if sum(n.count(x) == 4 for x in set(n)) > 0:
counter += 1
print(f"|B| = {counter}")
# Ausgabe: |B| = 450
counter = 0
for n in numbers:
if len(set(n)) == 3 and any(n.count(x) == 3 for x in set(n)):
counter += 1
print(f"|C| = {counter}")
# Ausgabe: |C| = 7200
counter = 0
for n in numbers:
if len(set(n)) == 2 and any(n.count(x) == 3 for x in set(n)):
counter += 1
print(f"|D| = {counter}")
# Ausgabe: |D| = 900
counter = 0
for n in numbers:
if len(set(n)) == 3 and any(x != y and n.count(y) == 2 and n.count(x) == 2 for x in set(n) for y in set(n)):
counter += 1
print(f"|E| = {counter}")
# Ausgabe: |E| = 10800
counter = 0
for n in numbers:
if len(set(n)) == 5:
counter += 1
print(f"|F| = {counter}")
# Ausgabe: |F| = 30240