Skip to content

Instantly share code, notes, and snippets.

View igorvanloo's full-sized avatar

Igor igorvanloo

View GitHub Profile
@igorvanloo
igorvanloo / p46.py
Created July 25, 2021 03:34
Problem 46
def goldbachs(number):
for x in range(1, int(math.sqrt(number))+1):
temp_var = number - 2*(x**2)
if is_prime(temp_var) == True:
return True
return False
def compute():
count = 33
while True:
@igorvanloo
igorvanloo / p79.py
Created July 24, 2021 13:23
Problem 79
def all_numbers(alist):
nums = set()
for x in alist:
for y in x:
nums.add(y)
return list(nums)
def method1():
possible_numbers = (all_numbers(keys))
possible_passcode = list(itertools.permutations(possible_numbers))
@igorvanloo
igorvanloo / p45.py
Created July 24, 2021 07:11
Problem 45
def is_pentagonal(x):
#Take the inverse function to test whether or not a number is pentagonal
if (1+(24*x+1)**0.5) % 6 == 0:
return True
return False
def is_hexagonal(x):
#Take the inverse function to test whether or not a number is hexagonal
if (1+(8*x+1)**0.5) % 4 == 0:
return True
@igorvanloo
igorvanloo / p44.py
Created July 24, 2021 07:02
Problem 44
def is_pentagonal(x):
#Take the inverse function to test whether or not a number is pentagonal
if (1+(24*x+1)**0.5) % 6 == 0:
return True
return False
def compute():
k = 1
while True:
for j in range(1,k): # this ensures that a > b therefore a-b is minimised
@igorvanloo
igorvanloo / p42.py
Created July 24, 2021 06:24
Problem 42
Triangle_number = [ "the triangle numbers from the txt file" ]
def sumofname(x):
namesum = 0
for i in range(len(words[x])):
namesum += ord(words[x][i])-64
return namesum
def compute():
count = 0
@igorvanloo
igorvanloo / p38.py
Created July 23, 2021 11:14
Problem 38
def compute():
checker = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
concatenated_product_list = []
for z in range(2,10):
for x in range(1,10**math.floor(9/z)):
temp_str = ""
for y in range(1,z+1):
product = x*y
temp_str += str(product)
if sorted(temp_str) == checker:
@igorvanloo
igorvanloo / p34.py
Created July 23, 2021 06:01
Problem 34
def sum_digits_mod(x):
facts = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880]
totalsum = 0
while x != 0:
totalsum += facts[x % 10]
x = x // 10
return totalsum
def compute():
overalltotal = 0
@igorvanloo
igorvanloo / p33.py
Created July 23, 2021 05:46
Problem 33
def compute():
values = []
numer = 1
denom = 1
for x in range(10,100):
for y in range(x+1, 100):
if x%10 != 0 and y%10 != 0:
value1 = str(x)
value2 = str(y)
for a in value1:
@igorvanloo
igorvanloo / p32.py
Created July 23, 2021 03:44
Problem 32
def compute():
testlist = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
values = set()
for x in range(9,99):
for y in range(99,999):
answer = x*y
if answer < 10000:
testingvalue = sorted(str(x) + str(y) + str(answer))
if testingvalue == testlist:
values.add(answer)
@igorvanloo
igorvanloo / p31.py
Created July 23, 2021 03:23
Problem 31
def compute():
totalways = 1
for a in range(0,3):
for b in range(0,(2-a)*2 + 1):
for c in range(0,math.ceil((2-a-b*0.5)*10)+1):
for d in range(0,math.ceil((2-a-b*0.5-c*0.2)*20)+1):
for e in range(0,math.ceil((2-a-b*0.5-c*0.2-d*0.1)*40)+1):
for f in range(0,math.ceil((2-a-b*0.5-c*0.2-d*0.1-e*0.05)*100)+1):
for g in range(0,math.ceil((2-a-b*0.5-c*0.2-d*0.1-e*0.05-f*0.02)*200)+1):
if a*100 + b*50 + c*20 + d*10 + e*5 + f*2 + g*1 == 200: