"""DuckieDai Fraction Simplifier for TI-84 Plus CE Python."""
def duckiedai_intro(program_name, wait=True):
    title=program_name[:16]; empty=16-len(title); left=empty//2; right=empty-left
    print("+----------------------+"); print("|   "+" "*left+title+" "*right+"   |"); print("|                      |"); print("|       __             |"); print("|   ___(o )>  quack!   |"); print("|   \\ <_. )           |"); print("|    `---'             |"); print("|     by DuckieDai     |"); print("+----------------------+"); print("Loading...")
    if wait: input("Press enter to start "); print("\n"*8)
def clear_screen(): print("\n"*8)
def gcd(a,b):
    a=abs(a); b=abs(b)
    while b!=0: a,b=b,a%b
    return a
def run_solver():
    clear_screen(); print("FRACTION SIMPLIFY"); print("-----------------"); print("")
    top=int(input("Numerator: ")); bottom=int(input("Denominator: "))
    if bottom==0: clear_screen(); print("INVALID"); print("Denominator"); print("cannot be 0"); return
    if bottom<0: top=-top; bottom=-bottom
    common=gcd(top,bottom); top//=common; bottom//=common
    clear_screen(); print("SIMPLIFIED"); print("----------"); print(top if bottom==1 else str(top)+"/"+str(bottom))
duckiedai_intro("Fraction Simpl")
while True:
    run_solver(); print("")
    if input("Again? y/n: ").lower()!="y": break
clear_screen(); print("DuckieDai says: done!")
