Skip to content

Instantly share code, notes, and snippets.

@levisre
Created February 25, 2015 08:21
Show Gist options
  • Save levisre/1c428446a48def383488 to your computer and use it in GitHub Desktop.
Save levisre/1c428446a48def383488 to your computer and use it in GitHub Desktop.
Flufferduff sCTF 2015
def sumOdd(a):
i=1
result=0
while i<a:
result+=i
i+=2
return result
def getPrime(a):
result =[]
for i in range(2,a):
for j in range(2,i/2):
if i%j==0:
break
else:
result.append(i)
return result
def sumPrime(a):
global pList
result=0
for i in pList:
if i<a:
result+=i
else:
return result
def main():
c=0
for i in range(0,1000):
if sumPrime(i)-sumOdd(i)<0:
c+=1
print "Number of flufferduffs: %d" % c
pList = getPrime(1000)
main()
@MiloATH
Copy link

MiloATH commented Nov 25, 2015

Why does pList include 4?

@MiloATH
Copy link

MiloATH commented Nov 25, 2015

Even when 4 is included, the answer is the same as when 4 is not included

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment