- sets, python.PNG (21.05 KiB) Viewed 2551 times
Svært takknemlig for alle innspill. Står helt fast

Moderators: Vektormannen, espen180, Aleks855, Solar Plexsus, Gustav, Nebuchadnezzar, Janhaa
Code: Select all
def a_func(x):
if (b_func(x)%2==0):
return c_func(x)+11
else:
return 2*c_func(x)-129
def b_func(x):
return a_func(x)*c_func(x) % 2377
def c_func(x):
k=0
c0=0
ovre = a_func(x)-1
for i in range(0, ovre+1):
c0 = b_func(x) - 7 * k
k+=1
return c0+142
def all(x):
return a_func(x), b_func(x), c_func(x)
for x in range(1, 449):
print all(x)
Code: Select all
for a in range(1,449):
for b in range(1, 449):
for c in range(1, 449):
#a-funksjonen
if b%2==0:
a=c+11
elif b%2!=0:
a=2*c-129
#b-funksjonen
b = (a*c)%2377
#c-funksjonen
k = 0
c0=0
upper = a-1
for i in range(0, upper+1):
c0 = b-7*i
k+=1
c = c0 + 142
print a, b, c
Code: Select all
def s(x,y):
return x*y-7*sum(xrange(0,x)) + 142
for b in xrange(1,450):
for c in xrange(1,450):
if b%2 == 0 :
a = c+11
if b == a*c %2377 and c == s(a,b) :
print a,b,c
else :
a = 2*c-129
if b == a*c %2377 and c == s(a,b) :
print a,b,c
Det går an å gjøre koden kjappere hvis det er poenget. F.eks. kan vi erstatte summen i funksjonen s med summeformelen, så vi får kodenpi-ra wrote:Oppdaget nå at koden din var mye kjappere da den bokstavelig talt var ti ganger kjappere - takk!
Code: Select all
def s(x,y): return (y-3.5*(x-1))*x + 142
for b in xrange(0,450):
for c in xrange(0,450):
if b%2 == 0 :
a = c+11
if b == a*c %2377 and c == s(a,b) :
print a,b,c
else :
a = 2*c-129
if b == a*c %2377 and c == s(a,b) :
print a,b,c