Solving Project Euler Problems

Euler Project Site: https://projecteuler.net/about

My Friend Scott told me about this site and I found some interesting problems to solve. Please let me know if anyone has interesting ideas. My email is: chuan.cheng.1@stonybrook.edu.

2021/04/23: Project Euler 100 — forever — I wrote a brute force and no wonder it is going to take forever! The equation to solve is equivalent to solve: x^2 – 2y^2 = -1. I look at this form and feels very familiar but I was not able to remember then I started brute force… This is actually a standard Pell equation problem. The classical solutions can be found by some Googling but essentially the equation can be viewed as: (x – sqrt(2)y)(x + sqrt(2)y) = -1, which can be closely related to the expansion of (1+-sqrt(2))^n. The solution is unique in this expansion because of the ring type of feature for shape (a+-b*sqrt(k))^n, where a^2 – b^2*k = +-1.

2021/04/23: Project Euler 169 — time is very little — this problem is very friendly in the binary format. I am able to derive the formula between (10..10..)_2 to newly (10..(10..10..))_2 by finding the recursive formula for g(change the 1st (1)_2) and g(not change the 1st (1)_2). So the whole problem becomes trivial, one just need to get all the sequence of how many (0)_2 are in between (1)_2. But I suffered quite a lot on the first step, meaning 5^25 is exceeding int64! I have no idea on how to overcome this for now so I just found the sequence online… So sad… Note some results f(10) = 5, f(42) = 13, f(10^5) = 713.

2021/04/15: Project Euler 144 — Matlab 2019b Ubuntu 2ms — nothing much but to correctly assign new direction and intersection to the oval(x,y,slope). Someone in the discussion mentioned that this convex shape is helpful for round up errors while concave shape will amplify these errors. I think this is an interesting argument.

2021/04/11: Project Euler 238 (not done yet) — Matlab 2019b Ubuntu 5s for the first k <= 1.2M using some sort of brutal force. That will cost me to roughly 4.3e5 hours to do the whole k <= 2e15!! But I realized that the generator array will repeat itself starting from somewhere. So it is probably using this repeating property somehow.

2021/04/06: Project Euler 243 — Matlab 2019b Ubuntu, 1.0ms if don’t take into account the prime table generation time — this problem is quite intruiguing , I recommand people to think of different ways of calculating the numbers: either the number of  resilient numerator or the number of non-resilient numerator.

2021/04/01: Project Euler 043 — Matlab 2019b Ubuntu, 9.4ms — the actual number of strings fulfilling the requirement is very limited (actually only 6). So it is not a good option to go through all the possible pandigits. Instead, expanding the digits to pandigits step by step by adding a new digit and check if the new position has fulfilled the requirement is faster.

2021/03/31: Project Euler 031 — Matlab 2019b Ubuntu, 4.6ms — this problem is very friendly to set theory (and/or generation function). My way of solving it is to recursively solve it —  expand the existing set by adding a new coin and compute the number of different ways for any final sum [0 200].

2021/03/18: Project Euler 023 — Matlab 2019b Ubuntu, 0.192s — better to compute the whole table of sum of divisors and then compute the sum of available abundant numbers — to quickly finish the first step, instead of running for each n/p pair, simply go the other way, which is to add p for any k*p.