Skip to content

Instantly share code, notes, and snippets.

View fahnub's full-sized avatar

Fahad fahnub

View GitHub Profile
@fahnub
fahnub / solution2.py
Last active June 20, 2023 04:50
Foobar Level 2 Problem 2 (hey I already did that)
def order(n):
return int(''.join(sorted(n, reverse=True))), int(''.join(sorted(n)))
def subtract(n, b):
k = len(n)
x, y = order(n)
difference = ""
borrow = 0
@fahnub
fahnub / solution1.py
Created June 20, 2023 04:39
Foobar Level 2 Problem 1 (bunny worker locations)
def solution(x, y):
worker_id = (((x + y - 2) * (x + y - 1)) / 2) + x
return str(worker_id)
@fahnub
fahnub / solution.py
Created June 19, 2023 12:55
Foobar Level 1 Problem 1 (the cake is not a lie)
from math import sqrt
def get_factors(n):
factors = set()
for i in range(1, int(sqrt(n)) + 1):
if n % i == 0:
factors.update([i, n//i])