myscript.py

Created by alban-scientifique

Created on March 17, 2024

3.39 KB

UWU


import random

# ajouter des formules ici pour que l'output soit plus complexe.
vals_0 = ["ln(1)",
          "ln(1) / ln(i)",
          "sqrt(1/4) - 1/2",
          "∫[0,0] cos(sin(x)) dx",
          "lim(x → 0) x^(x^2) - 1",
          "lim(x → 0) tan(tan(x)) - 1",
          "lim(x → 0) sqrt(x^x^x)",
          "lim(x → 0) sqrt(x^(cos(2x))) - 1",
          "lim(x → 0) sqrt(x^(sin(2x))) - 1",
          "1/sqrt(pi) * ∫[-∞,+∞] e^(-x^2) dx"]

vals_1 = ["|e^(iπ)|",
          "τ / (8 * arctan(1))",
          "sqrt(arctan(1) / pi) + (pi^0)/2",
          "(lim(l → ∞) arctan(pi^l)) * 2 / pi",
          "∫[0,sqrt(2)] x dx",
          "sum(k=0 to ∞) 1/(2^(k+1))",
          "sqrt(2) * cos(pi/4)"]

vals_2 = ["(2^2 + 2^2)!",
          "8 * cos(pi/3)^2",
          "tan(-i ln(-1)) + 1 + 1",
          "1 + 1",
          "8/4",
          "lim(l → ∞) e^(-x^2) + 2",
          "floor(e)",
          "floor(pi) - 1"]

vals_3 = ["2 + 1",
          "4 - 1",
          "∫[0,sqrt(6)] x dx",
          "floor(pi)",
          "ceil(e)",
          "floor(e) + 1",
          "ln(8) / ln(2)"]

vals_4 = ["2^2",
          "2 + 2",
          "2 * 2",
          "1 + 3",
          "1 + 1 + 1 + 1",
          "1 + 1 + 2"]

vals_5 = ["1 + 1 + 1 + 1 + 1",
          "1 + 2 + 2",
          "1 + 3 + 1",
          "4 + 1",
          "5 + 0",
          "2 + 3",
          "floor(e) + floor(pi)",
          "floor(e) + ceil(e)"]

vals_6 = ["3 + 3",
          "2 + 2 + 2",
          "3 * 2",
          "1 + 1 + 1 + 1 + 1 + 1",
          "2 + 1 + 1 + 1 + 1",
          "1 + 1 + 3 + 1",
          "1 + 4 + 1",
          "1 + 5",
          "6 + 0",
          "0 + 2 + 3 + 1"]

vals_7 = ["6 + 1",
          "5 + 1 + 1",
          "4 + 1 + 1 + 1",
          "3 + 1 + 1 + 1 + 1",
          "2 + 1 + 1 + 1 + 1 + 1",
          "1 + 1 + 1 + 1 + 1 + 1 + 1",
          "3 + 3 + 1",
          "floor(pi) + ceil(pi)"]

vals_8 = ["2^3",
          "2 * 4",
          "6 + 2",
          "4 + 4",
          "1 + 7",
          "8 + 0",
          "3 + 3 + 1 + 1",
          "1 + 2 + 1 + 1 + 2 + 1",
          "1 + 2 + 2 + 2 + 1"]

vals_9 = ["3^2",
          "floor(pi) * 3",
          "ceil(e) * 3",
          "1 + 2 + 3 + 4 - 1",
          "2 + 3 + 2 + 2",
          "3 + 3 + 3",
          "8 + 1",
          "3 + 4 + 1 + 1",
          "8 + 1 + 0"]

vals_pi = ["τ / 2",
           "sum(k=0 to ∞) (-1)^k * (1/(2*k+1))"]

def val_replace(fullstr, substr, choices):
    i = fullstr.find(substr)
    if i == -1:
        return fullstr
    fulllist = list(fullstr)
    chosen = "(" + random.choice(choices) + ")"
    fulllist[i:i+len(substr)] = list(chosen)
    fullstr = ''.join(fulllist)
    return val_replace(fullstr, substr, choices)

def modify_1(formula):
    return val_replace(formula, "1", vals_1)

def modify_2(formula):
    return val_replace(formula, "2", vals_2)

def modify_3(formula):
    return val_replace(formula, "3", vals_3)

def modify_4(formula):
    return val_replace(formula, "4", vals_4)

def modify_0(formula):
    return val_replace(formula, "0", vals_0)

def modify_pi(formula):
    return val_replace(formula, "pi", vals_pi)

def modify(formula):
    return modify_pi(modify_0(modify_1(modify_2(modify_3(modify_4(formula))))))

iterations = 1 
formula = "4" # modifier le résultat voulu ici
for _ in range(iterations):
    for char in formula:
        if char.isdigit(): 
            print(modify(char), end="")
        else:
            print(char, end="")
    print()  

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.