Problems
Problems
Since the last post I’ve been solving one project Euler and one Leetcode problem per day, the problems have been easy to moderate difficulty for me, out of the problems I have to pick a select few that really took a bit of thinking for me
Euler problems
Problem 4 took a bit of time to find an elegant solution that didnt involve too much computing, although I got it down, the whole code is on my github but here’s a small snippet of the solution
for i in range(minNum,maxNum,1):
str_number = str(i)
if(str_number == str_number[::-1]):
for num1 in range(999, 99, -1):
if i % num1 == 0:
num2 = i // num1
if(num2<1000):
print(num1,num2)Leetcode problems
Stairs this “easy” problem took me about 2-3 hours. And it’s not hard. It’s not a complex problem. I think it’s just that things are getting to me and it broke me down a bit, it took me so long to figure out. And I did figure it out but I couldn’t code it out. Here’s a snippet of my solution while talking to google.
for twos in range(max_twos + 1):
ones = number - 2 * twos # Remaining positions are "1-blocks"
if ones < 0:
break
result += factorial(twos + ones) // (factorial(twos) * factorial(ones))
print(result)Conclusion
The main takeaway is that problems are getting harder and I’m hardly getting smarter. But it’s fun. I like having fun. I hope I at least get to 100 of these. That was kinda my idea with this, get to 100 problems. 1014383 people solved the first problem on project Euler and only 18104 solved the 100th problem. I wish to be one of those 18000, one day.