
Project Euler - vinchuco
https://projecteuler.net
======
sevensor
After hearing about it for years, I decided to start working through Project
Euler about two weeks ago. It really is much more about math than programming,
although it's a lot of fun to take on the problems with a language that has
tail call optimization because so many of the problems involve recurrence
relations.

I like that the problems are constructed in a way that usually punishes you
for trying to use brute force. Sometimes there's a problem that doesn't have a
more elegant solution, though, as if to remind us that brute force often works
remarkably well.

~~~
bhrgunatha
My only real complaint is (according to my experience) unless you happen to
understand some mathematical concept/s involved in the question, it's
incredibly difficult to get some insight or clue for _how_ to go about solving
it.

The forums are a fantastic resource _once you already know how to solve the
problem_.

~~~
ehsankia
I definitely wish there was a hint system / forum where you could get pointers
towards concepts you should read up on, and not the full answer.

~~~
utopcell
There are forums for the problems where you can ask for general directions, so
long as hints are not asked / provided.

~~~
amorphid
Yeah, I "cheated" by using the forums a lot when I was going through Project
Euler, too. One thing that helped me to understand different approaches was to
write any solution that worked, and then benchmark my solution against all of
the other submissions in my language of choice (Ruby at the time). There are
so many other sites about learning to code, reviewing answers in the forums is
kind of like giving yourself the lecture with content, and then you go do the
real homework somewhere else. It doesn't matter how you learn it, as long as
the learning sticks!

------
cdancette
I really like to use project euler when I want to learn a new language.
Exercises are sorted more or less by difficulty, at least for the first
50-100, and are completely langage agnostic (you just need to answer a
question in a text input).

It's also very good to learn algorithm and maths. Some problems can even be
solved without any programming. And for some, a certain amount of math is
necessary to have a efficient solution to the problem.

Ps: you can find the first 50 problems in french here :
[https://www.lucaswillems.com/fr/articles/19/project-euler-
tr...](https://www.lucaswillems.com/fr/articles/19/project-euler-traduction-
des-problemes-1-a-50)

~~~
Insanity
(They do ask not to share the solutions.)

But nice job translating them :-)

~~~
cdancette
That's not me, but I found those translations very useful a few years ago!
Hope it can help someone.

------
BuildTheRobots
For anyone looking for some less math-based coding challenges than Project
Euler, then I highly recommend looking at AdventOfCode.

It's presented as an advent calendar (so a challenge per day of December) and
when you unlock the first half it gives you a second challenge based in the
same domain.

There's at least a couple of previous years too, if you just want to crack on
and work though something.

[1] [http://adventofcode.com/2015](http://adventofcode.com/2015)

~~~
StreakyCobra
I discovered AOC this year, I clearly recommend it over ProjectEuler if you
want programming challenges that requires less math knowledge to go through.

It is also a great platform to learn a new programming language. I'm using it
as an opportunity to improve my (small) knowledge of rust.

[1] [https://github.com/StreakyCobra/advent-of-
code-2017](https://github.com/StreakyCobra/advent-of-code-2017)

------
delibes
Ah, memories. Back in 2010 I whinged to colleagues who were using their fancy
functional languages to solve problem 1 inefficiently in 2 lines of code...

" Project Euler problem 1 :-

It helps to know the sum of (1 .. x) is 0.5 * n * (n+1).

Multiples of 3 less than 1000 are (3 .. 999) == (1 .. 333) * 3 = 0.5 * 333 *
334 * 3 = 166833

Multiples of 5 less than 1000 are (5 .. 995) == (1 .. 199) * 5 = 0.5 * 199 *
200 * 5 = 99500

We must subtract common multiples (those of 15), so (15 .. 990) = (1 .. 66) *
15 = 0.5 * 66 * 67 * 15 = -33165

166833 + 99500 - 33165 = 233168

O(1) solution FTW :P Nice looking code is good, but a smart algorithm makes a
big difference. "

OK, I was a smug arsehole, but there's a point to be made y'know?

~~~
jackweirdy
> It helps to know the sum of (1 .. x) is 0.5 * n * (n+1)

This is cool. As someone out of full time education, and who dropped maths
relatively early, where’s a good place to start learning some of this stuff?
By stuff I mean things related to algebra and whatever the black magic I
quoted is

~~~
toAnswerIt
to see it consider this:

S = 1 + 2 + 3 + ... + n-1 + n

+

S = n + n-1 + n-2 + ...+ 2 + 1

=

2S = n+1 + n+1 + n+1 + ... + n+1 + n+1

every column sums to n+1

~~~
colejohnson66
Random fact: this only works if the series is finite. Otherwise you end up
with sum(1...inf) equaling -1/12.

~~~
skierscott
Not true. Infinite sums are not defined for series that don’t converge, and
sum(1..n) does not converge as n => infinity.

Yes, you can play a nice trick with that sum if you ignore the fact that inf-
inf is meaningless.

~~~
fantispug
It depends on how you define the summation of infinite series. With the
standard convergence type definitions you are correct. But it is possible to
define this sum in a consistent way (e.g. Ramanujan summation or Riemann Zeta
analytic continuation) as shown in Hardy's “Divergent Series”. The cost is
that they have properties like rearranging the order of the terms gives a
different result. Apparently this sum can come up in Quantum Field Theory when
calculating vacuum force between two conducting plates.

------
archgoon
[http://rosalind.info](http://rosalind.info) (named after Rosalind Franklin)
is similar, for bioinformatics. It has the advantage over Project Euler that
it provides some background and hints to the solution to the problem it
presents, plus an additional graph structure of concept dependencies.

Many of the bioinformatics problems are also pure Math and CS, so it's
probably of broad interest beyond just an interest in biology.

~~~
iClaudiusX
Rosalind is a great intro to the fundamentals like graph and set theories,
efficient string algorithms, combinatorics, etc.

My one criticism is that the examples for some problems are trivial and don't
adequately account for any of the complexity of the problem. It can feel a bit
like the "Learn to Drawn an Owl" meme: Step 1) Draw an oval. Step 2) Draw the
rest of the owl.

------
10-6
shameless plug: I loved project euler and topcoder when I in high school. In
2011, there weren't really any _nice, easy-to-use, interactive_ websites that
allowed me to solve coding/algorithms challenges online easily, so that winter
break my first year of college I made coderbyte.com for people to solve
challenges online. Been running it ever since, but now there are like 20
similar websites as well.

~~~
iandanforth
Thank you! I love coderbyte. I _especially_ love that you can immediately go
back, correct your answer and get a perfect score. There is nothing more
frustrating than a competitive screening tool that masquerades as an
educational tool. Emphasizing mastery over getting it right on the first try
is something that I deeply appreciate.

~~~
tedmiston
I haven't used Coderbyte yet, but I love the idea of going back and getting
credit for showing what you learned / how you improved. (I mostly use Codewars
which has a similar feature though.)

I've always wished academia worked this way. Seems logical to me. Everything
else we do is iterative.

------
dhbradshaw
My favorite part of Project Euler is the solutions forum that you can access
after entering the correct answer to a problem. Having different solutions to
the same problem to browse though is fantastic for learning new idioms and
tricks.

Sadly, only a small portion of the solutions posted are retained, so if you're
not looking for Python or C you'll probably only see a couple of different
variations in your language of interest. It would be a huge deal for learning
new languages if we could retain all solutions and then sort or filter by
language.

~~~
mulmen
I like this idea but project Euler seems to focus much more on math than
programming languages so it makes sense they don’t retain all answers.

I would really like to see something similar for actual programming challenges
though. Some real-world examples, maybe with predefined test cases that you
then solve and optimize for CPU/Memory/Time/lines/whatever.

~~~
dhbradshaw
That would be really cool.

------
hellofunk
I guess I'm becoming an old fart. I used to like programming puzzles,
challenges, things like this. But as time marches on, I realize that the real-
world problems I have to solve are already so challenging and require enough
critical thinking, that I'm best served just focusing on them. Between family
life, doing real-world challenges for income, downtime to breathe, diverse
hobbies for the spiritual good of my person, I just don't see how to fit in
Euler problems and other similar endeavors. Perhaps if I was a teenager again,
I'd be jumping into them with much enjoyment.

~~~
abhiyerra
I am the same though I'm only 30. I no longer seek out puzzles but to solve
interesting real world problems. The time you put into a challenging Euler
puzzle, you can use React/Rails/NodeJs/Go/Rust/lang du jour to solve real
world problem, helping real people.

Also as a liberal arts in programming, Euler, is fun in the sense of a well
done proof is fun in math. If that is your thing you'll enjoy Euler, otherwise
as in most programming you will brute force your way to a solution.

~~~
epicide
I definitely agree that puzzles/challenges for their own sake are pretty
pointlesss. However, I also think (guided) puzzles/challenges are really good
for learning new tools/languages. It can be hard to just sit down in front of
a real world type problem with even just one new tool and know what to do with
it.

The best approach is probably somewhere in the middle. Best example I've seen
of this are the "workshopper" lessons on NodeSchool.

~~~
johnsonjo
I second that. The NodeSchool [1] workshops are awesome.

[1] [http://nodeschool.io](http://nodeschool.io)

------
fareesh
The UVA online judge also has some great programming problems that I went
through in college for competitive events. Not sure if the site has answers
now, haven't visited in many years.

[https://uva.onlinejudge.org/index.php?option=com_onlinejudge...](https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8)

------
scranglis
If you like PE, you might love:
[https://brilliant.org/discussions/thread/forest-
fires/](https://brilliant.org/discussions/thread/forest-fires/) (includes in-
browser Python runner, too).

------
minusSeven
Why is project Euler being shown in hackernews now ? This isn't something new
and has been there for long time. I often use the easier problems in project
Euler for interviews to test candidates.

Having said that the problems in project Euler are more math based in nature.

~~~
fogetti
Can I ask how do you evaluate the candidates with these problems? I mean: do
they have to solve similar problems on their daily job as well? Or what is the
take-away in your specific case?

~~~
minusSeven
Sorry for late reply. I don't give the exact same problem but use these
problems for references.

For instance I often start interview with asking candidate to write a program
to find a palindrome. After they answer that my follow up question is to write
a program to find the longest palindrome in a given string which is a question
taken from project euler.

Here I am mainly interested in their logic and approach to problem solving
rather than a workable solution first time round. I don't give take-away
problems neither do candidates have to do this in their daily jobs.

------
utopcell
Are there any 200+ PE readers here ? If so, how long did it take you to reach
you level and what was the most challenging problem you solved ?

~~~
NabiNaga
I've solved 273 as of now
([https://projecteuler.net/profile/NabiNaga.png](https://projecteuler.net/profile/NabiNaga.png)).
It took me a little less than 2 years to get to 250 problems, but I was
spending quite a bit of time on them haha. I've learned an incredible amount
of math and algorithm skills from PE. There have been lots of really
challenging ones, but one that stands out is 494. That was the first "really
hard" one I solved, and my first time to be in the first 50 solvers.

~~~
huherto
That is quite an achievement. Can you comment on your background ? type of
education, work.

~~~
NabiNaga
I was finishing up the second year of a computer engineering degree when I
discovered Project Euler, and after a few months of solving the problems I
realized I wanted to study math instead, so I switched my major to applied
math. Honestly I learned more from solving PE problems than school. Now I'm
working in industry on AI.

~~~
telchar
That's encouraging to hear. I'm 30 problems in so far since starting ~1.5
months ago. I starting working through the PE problems to develop my python
and general programming skills since I have been primarily using R as a data
scientist. I'm glad someone else has found it useful for this field.

~~~
NabiNaga
My routine was to solve the problem, then spend time reading through the
solutions in the forum to see how I could optimize my code. Many times this
meant completely rewriting my solution. For a lot of problems I spent more
time making my code run as fast as possible than I did solving the problem in
the first place. Doing this was critical for learning algorithms and
techniques that I needed to solve future problems.

------
3princip
Project Euler was so much fun when I discovered it, it also helped prepare me
for an unexpected interview which included similar challenges and they seemed
a breeze in comparison. Had I not been challenging myself, no way would I have
passed.

Solved 38 problems and forgot my password after a short pause, haven't been
able to log in for years :(

------
huherto
Back in the day I solved the first ~100 problems in order. It was a great
practice to sharpen your programming logic and I learned a ton of math. The
problems became harder. But I haven't done any in many years. Do you think the
newer problems are very very hard ? I have to admire the dedication of those
who have kept on it.

~~~
FredrikMeyer
It is possible to sort them by difficulty. Some of the newer problems are
easier than some of the first 100 problems, appearantly.

------
debbiedowner
To ask people who solved many of these questions:

Once you find "the" trick, is there still a lot of computation involved? Do
you still write loops? How many orders of magnitude times do those loops run?
How do you know when your code is too computationally intensive and you
haven't found "the" trick yet?

~~~
enedil
If you write it and it doesn't finish in a minute, I'm sure it's not that
trick.

------
spectrum1234
It really depends on your goals but for coding interviews I've found
leetcode.com to be the best by far.

------
ronnypostsstuff
Did any of you interview and having a good Project Euler account was
positively recognized?

This never happened to me. No one seems to know the site. They seem to be
mostly interested in Top Coder and similar platforms.

~~~
plastikmissile
Happened to me once. I have my PE score on my resume and during the first
technical interview on the phone the interviewer commented positively on it. I
moved on to onsite interviews after that, but I'm unsure how much my PE score
helped in that regard.

------
Veedrac
I've solved #555 and #561, which were a lot of fun. Any other good
recommendations? Some of the questions in that area look pretty intimidating,
but those two were surprisingly approachable.

~~~
hxtk
#601 is pretty easy. Also, #512 and #521 if you have some background in prime
number theory.

------
thetalkingcode
DoSelect has some good programming problems including API based questions and
competitive coding questions.

[https://doselect.com/](https://doselect.com/)

------
DonbunEf7
The best tool for solving these problems is a whiteboard; writing code should
be seen as a last resort, and brute-force solutions should be shunned, as they
provide no insight.

~~~
tikhonj
Some friends and I used to hold a hybrid drinking/Project Euler contest. You
would have hated our solutions. I remember winning on the back of _nine_
nested for-loops and, on a separate occasion, doing a primality check using a
literal array containing the first 80,000 primes.

That's what happens when time-to-solution is what you optimize for. I'm sure
it's familiar to startup programmers :).

~~~
torbjorn
Wow, that sounds like an awesome party =)

------
nishparadox
Project Euler gives me nostalgia for some unknown reasons. During my BE, I
used to get lost in the problem space. Now, it's different.

------
ww2
Project Euler is a good place for teenagers to start learning programming,
better than the routes of game or website design.

------
robertkrahn01
bright-shadows.net [1] was a Project-Eulerish site around security related
challenges. I think it's pretty dead now but I remember lots of interesting
problems that motivated to learn new stuff.

[http://bright-shadows.net](http://bright-shadows.net)

------
hemantv
Shameless Plug

There are literally thousands of problems here www.mathalon.us

------
hemantv
Plug for www.mathalon.us very similar and lot of questions

------
b0rsuk
In a way, Project Euler was years ahead of its time. It's a set of problems
for aspiring machine learning and data science specialists. They should really
update their description.

------
cubano
a26a zbuild 1b c ratty

------
jlebrech
i would love to see problems that have bounties on them and you get a
sciencecoin or something for solving it.

