Conceptually similar, but the problems are focused around bioinformatics. Most lot of the problems contain some background context that teaches you a little biology/statistics as well.
For me it's been other way round. I mean I was actually very much interested in genetics so I encountered Rosalind. Going through Rosalind, I realized I need to learn Python and I didn't know any programming till then. So my first lessons of Python were from Rosalind! I started loving Python and programming. Then I encountered Project Euler...
I have big love for PE. I've learnt so much in the process of trying to solve some of these problems. In particular, number theory and data structures are two fields that I have come to love almost entirely because of this website. I did a random selection of the first 200 problems on my own about a decade ago but ran out of steam as the problems got harder.
Recently, however, I introduced it at work as a way of encouraging the team I manage to work collaboratively. We have a fortnightly catch up where we talk through solutions, pick new problems (we have a script that randomly picks an easy, medium and hard problem, which has become an exciting ritual), and then we have an initial discussion about each of the new problems.
It's a good way to foster group work. It's also a great way to introduce people to using version control and pull-requests in a non-scary way!
Most PE problems are more math than data-structure based. There are plenty of number theory problems, but lots of other areas as well, especially combinatorics and probability. I’ve learned about many more niche areas, like impartial games and chromatic polynomials, via PE.
But there are definitely more CS-oriented problems. I can recall problems solved by using segment trees, Aho-Corasick, simple parsing, etc. And lots and lots of dynamic programming.
Also, working your way through the first 100 problems will require writing code to evaluate poker hands and solve Sudoku boards.
So I'm a mostly self trained low level programmer and found Project Euler is great but there is a level of math knowledge that left me more puzzled on the formulas than actual coding. Is this something I should focus on as someone learning to code, or the other coding puzzle sites with "linked list" type of challenges are just as good.
No, you shouldn't focus on this. PE is _mostly_ a math site, which if you want to learn that is great, but it's not the same as programming.
What other sites are you looking at? I don't actually know that I'd recommend any puzzle sites to a new programmer. The ones I know of are for fun, not for improving your software dev skills.
A friend of mine applied to Amazon, and they told him he should do the first ~100 problems of Project Euler to prep for the interview. As someone who is not at all advanced in math, I found this to be fairly discouraging. I feel like I’m a reasonably strong programmer without advanced math knowledge, and not sure why it would be necessary for a general dev job.
Definitely, though some of the AoC challenges are pretty mathy too, or at least benefit from some basic knowledge around combinatorics, factoring, etc.
If you’re learning to code try build stuff (unless you enjoy project Euler style challenges - enjoyment is the priority). Trying to model the inventory system of Skyrim or something is more useful in the long run than puzzles, IMO. When you find something feels wrong with your design; that’s when you start identifying new and better data structures.
I agree it’s more fun creating your own little games or problems to solve. Someone posted an elevator coding game here a couple months back[0]. Those are more fun to me. I found Euler too math-heavy and I spent most of my time in Wikipedia trying to understand the question.
There's no real need to know so much math for most professional programming jobs. Math problems tend to be over-represented on challenge sites because they are easy to implement.
Multiples of 3 or 5
Problem 1
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
The naive idea is: iterate from 0 to 1000, test each number, add it to an (initially zeroed) accumulator when adequate. A little bit of thinking... ok, sum the multiples of 3, add the multiples of 5 and subtract multiples of 15. A little more bit of thinking: sum of multiples of 3, 5 and subtract multiples of 15. These can be calculated using an arithmetic progression formula in O(1) and limits can be found using rest of division operation.
Cool! Even a simple problem made me think of a naive solution and how to iteratively improve it.
Solution 2 is still iterating, once by 3, then by 5 then by 15.
Solution 3 uses the closed-form solutions the the question "what is the sum of the multiples of k between x and y".
If you're not familiar with that last part, it's pretty easy to get there from the formula for the sum of numbers from 1 to n, ie n(n+1)/2 (which is itself ~easy to see by pairing up 1 and n, then 2 and (n-1) and etc.)
In general I think there are a lot of project Euler problems (at least after the first 100) that are basically “here is some theorem/construction you might see in undergrad (or maybe early postgrad) number theory, except we don’t tell you what it is, instead we just give you a problem to which it applies.” And if you don’t know the theorem you are SOL.
When I was last doing PE, that Knowledge was relatively fresh in my mind so I could know that the solution was Pell’s equation or whatever (good luck finding the wiki page if you don’t know the name…) but even then it felt a bit silly. I think the solution I was most proud of was to an older problem (they weren’t adding new ones at the time) with less than 100 solves and it basically boiled down to Gaussian elimination without much mathematical knowledge. Mostly I was proud because I got the achievement for solving one early.
In my experience some of the most fun programming problems are the ones where an optimum solution is known to academia, but the participant doesn't know the optimum and has to cobble together the best suboptimal solution they can come up with on their own
When I was poking PE many many years ago, one approach I took was "make a brute-force solver, feed it small inputs, see if there is an easy way to reason myself to a closed form".
This sometimes involved looking sequences up in OEIS, sometimes the closed for was obvious from the sequence, and sometimes I used differentials to find it.
Years back I did a couple hundred problems on this site. It's very good at making you learn about important results in basic math and algorithm complexity. It forces you to write your own library of efficient functions for factoring, etc... because you have to use them so many times and as the problems get harder anything brute force will take too long.
I’m definitely curious about other people’s approach to Project Euler. My experience was that the first several were pretty straightforward, but I pretty quickly ran into a wall where I couldn’t rely on my intuition to generate a solution that would work in an acceptable time frame (python is a hobby for me, and I’m not sure that I have the quantitative ability to go much farther than that. Im curious how many other people look up algorithms and then implement them when they run into a similar wall, or how many people sit and think and implement ideas until they have an answer.
Project Euler problems for the most part aren't like brainteasers. Sometimes you just do not have the mathematical context to arrive at an optimal solution. Browse Wikipedia a bit or watch some math videos or something when you're stuck, and think about how to exploit the fast nature of computers with what rigorous mathematical understanding of the problem you have.
Also, I once spent over thirty cumulative hours on a single PE problem, and I never solved it, I gave up. Don't feel bad. It doesn't make you a bad programmer, just a bad mathematician. That's probably not that big of a deal!
I don't think it necessarily makes you a bad mathematician either. We all sometimes focus on a problem and start thinking inside the box whereas it has a simple out-of-the-box solution that we're missing because of our focus. Just like a novice programmer can sometimes easily spot an expert programmer's bug in a mere of minutes.
My approach has always been to read about relevant mathematical concepts but avoid looking at specific algorithms or code. I figure I'm not going to reinvent some concept from abstract algebra or rediscover some formula named after Euler, but I still want to have some challenge of figuring things out beyond just writing the code.
Project Euler is how I learn new languages (caveat, I don't deal in databases, web frameworks, etc). But... they're exercises in mathematics. It's easy to brute-force many solutions, but achieving actual high performance requires doing the math, and figuring out how to reduce the parameter space. Very big on "pick the right algorithm," even the best-performing brute-force just won't do it.
A big leap forward for me was learning how to properly use "lazy" data structures (i.e. streams) to pipeline the processing steps and stop as soon as a solution is found without any extra work. Memoization is also really important for some problems.
Project Euler is why I am a programmer - i spent many nights in university doing PE problems instead of studying and nothing in class gave me the visceral excitement like doing PE
Conceptually similar, but the problems are focused around bioinformatics. Most lot of the problems contain some background context that teaches you a little biology/statistics as well.
Recently, however, I introduced it at work as a way of encouraging the team I manage to work collaboratively. We have a fortnightly catch up where we talk through solutions, pick new problems (we have a script that randomly picks an easy, medium and hard problem, which has become an exciting ritual), and then we have an initial discussion about each of the new problems.
It's a good way to foster group work. It's also a great way to introduce people to using version control and pull-requests in a non-scary way!
But there are definitely more CS-oriented problems. I can recall problems solved by using segment trees, Aho-Corasick, simple parsing, etc. And lots and lots of dynamic programming.
Also, working your way through the first 100 problems will require writing code to evaluate poker hands and solve Sudoku boards.
What other sites are you looking at? I don't actually know that I'd recommend any puzzle sites to a new programmer. The ones I know of are for fun, not for improving your software dev skills.
Or meet fellow devs at meetups and get into open source.
Or meet people at a local hacker space.
Basically, developing requires people to inject interesting projects and perspectives at you.
Yes. Coding requires social skills. I'm not taking that back.
[0] https://play.elevatorsaga.com/
Cool! Even a simple problem made me think of a naive solution and how to iteratively improve it.
1.
2. 3.Solution 3 uses the closed-form solutions the the question "what is the sum of the multiples of k between x and y".
If you're not familiar with that last part, it's pretty easy to get there from the formula for the sum of numbers from 1 to n, ie n(n+1)/2 (which is itself ~easy to see by pairing up 1 and n, then 2 and (n-1) and etc.)
When I was last doing PE, that Knowledge was relatively fresh in my mind so I could know that the solution was Pell’s equation or whatever (good luck finding the wiki page if you don’t know the name…) but even then it felt a bit silly. I think the solution I was most proud of was to an older problem (they weren’t adding new ones at the time) with less than 100 solves and it basically boiled down to Gaussian elimination without much mathematical knowledge. Mostly I was proud because I got the achievement for solving one early.
This sometimes involved looking sequences up in OEIS, sometimes the closed for was obvious from the sequence, and sometimes I used differentials to find it.
Yes! This is when I knew I was in too deep lol
Also, I once spent over thirty cumulative hours on a single PE problem, and I never solved it, I gave up. Don't feel bad. It doesn't make you a bad programmer, just a bad mathematician. That's probably not that big of a deal!
https://projecteuler.net/problem=453