proinf

from typing import List, Tuple, Union, Callable

Number = Union[int, float]

"""
Aufgabe 1
"""
def truediv(number, divider) -> bool:
    return (number % divider) == 0 and not number == divider

def dividers(number) -> List[Number]:
    count: int = 0
    dividers: List[Number] = []
    while (count < number):
        count += 1
        if truediv(number, count):
            dividers.append(count)

    return dividers

def friend_numbers(number1: Number, number2: Number) -> bool:
    dividers1 = dividers(number1)
    return sum(dividers1) == number2

"""
Aufgabe 2
"""
import sys

def charPicture(chooseChar, size):
    for y in range( 0, size):
        for x in range( 0, size):
            sys.stdout.write( chooseChar( x, y, size) )

        print()

def pattern(x: int, y: int, size: int) -> str:
    third = size // 3
    two_thirds = third * 2

    if ((y < third) and (x < third)) or ((y >= two_thirds) and (x >= two_thirds)):
        return "-"

    if x % 3 != 0:
        return "."
    else:
        return "*"


def pattern2(x: int, y: int, size: int) -> str:
    third = size // 3
    two_thirds = third * 2

    if ((y < third) and (x < third)) or ((y >= two_thirds) and (x >= two_thirds)):
        return "|"

    if (y > third) and (x > third) and (y < two_thirds) and (x < two_thirds):
        return "*"

    return "."

"""
Aufgabe 3
"""
def weekday(year: int, month: int, day: int) -> str:
    y0 = year - ((14-month)//12)
    x = y0 + y0//4 - y0//100 + y0//400
    m0 = month + 12*((14-month)//12) - 2
    index = (day + x + (31*m0)//12) % 7

    weekdays: List[str] = ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"]
    return weekdays[index]

"""
Aufgabe 4
"""
def is_paranthesis(char: str) -> bool:
    return char in ("[", "]", "(", ")", "{", "}")

"""
Aufgabe 5
"""
def product(numbers: Tuple[Number, ...]) -> float:
    if len(numbers) < 1:
        return 0

    product: float = numbers[0];
    for number in numbers[1:]:
        product *= number

    return product;


"""
Aufgabe 6
"""
import random

def gluecksspiel(startgeld: int) -> int:
    geld = startgeld

    counter: int = 0

    while (geld > 0 and geld < startgeld * 2):
        counter += 1
        if bool(random.randint(0, 1)):
            geld += 1
        else:
            geld -= 1

    print("Geld zum ende des Spiels:", geld)

    return counter

if __name__ == "__main__":
    #print(product((1, 2, 3, 4, 5)))
    #geld = int(input("Startgeld: "))
    #print("Runden", gluecksspiel(geld))
    #charPicture(pattern2, 18)
    #print(friend_numbers(220, 284))