Skip to main content

Big O(Weird)

#!/usr/bin/env python
steps = 0


def f(x):
    global steps
    for i in range(x * x | 42, x | 42, -42):
        steps += 1
        yield i


def g(y):
    global steps
    z1 = f(y)
    z2 = f(y*y)
    z1l = [z for z in z1]
    steps += len(z1l)
    xyz = 0
    for z1, z2 in zip(z1l, z2):
        steps += 1
        if z1 == z2:
            pass
        xyz += (z1 + z2)
    return xyz


def h(z):
    global steps
    tots = 0
    for i in range(z):
        steps += 1
        if not i % 3:
            tots += g(i)
        elif not i % 2:
            tots += sum(f(i))
        else:
            pass
    return tots


print(h(1))
print(steps)

print(h(10))
print(steps)

print(h(100))
print(steps)

print(h(1000))
print(steps)

Comments