
Project Euler - gprasanth
http://projecteuler.net/
======
jboggan
The best technical interview I ever had involved picking a random Project
Euler problem in the hundreds and pair-programming our way through it. The CTO
wrote his version in Python and I worked in Perl . . . he was astounded mine
ran 8x faster.

The same company also had regular hack night where everyone drinks a lot of
Tecate, agress on a Project Euler problem and a language no one knows, and
races. Fun times.

~~~
dangoldin
When I was conducting quantitative interviews I ended up doing the same thing.
One of my favorite problems to give was 267
([http://projecteuler.net/problem=267](http://projecteuler.net/problem=267)).
It has a few "aha" moments but also requires coding to get it done.

~~~
jkscm
Is there a list with Project Euler problems that focus less on number theory
like this one?

~~~
TylerE
You might like Rosalind ([http://rosalind.info/](http://rosalind.info/)). It's
like Project Euler, but with a strong bioinformatics (espeically) genetics
slant. There is certainly math, especially combinatrics (for obvious reasons),
but much more so that Euler there is background given in the problems, so it's
often much more about coding a reasonable implementation than about knowing
some obscure corner of number theory.

------
habosa
I can't adequately express how great of a resource Project Euler is to someone
learning about programming.

The way I learned to code was working my way through Project Euler problems in
Python, eventually getting to a score of about 55 before I was at the point
where I decided to try making "real" programs like Android apps.

When you learn to code people tell you that X or Y is bad for performance, and
you should do A or B instead. The problem is that most beginner-type programs
run in a few milliseconds and there is no way to see the performance either
way. When you're doing a PE problem, a performance tweak can change your
answer from a 1-minute runtime to a 1-second runtime. That's something anyone
can appreciate, and it lets you experiment with performance on interesting
math problems.

Another advantage of Project Euler is it makes you realize just how powerful a
computer can be in the right hands. These are problems that nobody in their
right mind would try to solve by hand, but they're so tractable with
programming knowledge. That was a very exciting realization to me and it
pushed me towards a career in software.

~~~
mathattack
I've been using Euler to learn Python too. It's been so much fun that I kept
going. Now I wonder if I should switch again.

------
b0b0b0b
I love project euler, but I've come to the realization that its purpose is to
beat programmers soundly about the head and neck with a big math stick. At
work last week, we were working on project euler at lunch, and had the one CS
PhD in our midst not jumped up and explained the chinese remainder theorem to
us, we wouldn't have had a chance.

~~~
peeters
I feel the same way. It was presented to me as a great way to learn new
programming languages. But really it's challenging your ability to design
algorithms, and overwhelmingly mathematics-related algorithms. (I'm not saying
the site itself claims anything different).

It doesn't heavily challenge you to advance past a most basic level of a
programming language. For example, most Project Euler problems are solved in
Java most efficiently by using the features of Java that map 1:1 to features
in C. You could do pretty much the entire suite of problems without even
understanding the motivation of a language like Java.

I did find it better as a tool for learning functional programming languages
(like Haskell) however, perhaps unsurprisingly.

~~~
quenlinlom
What we need now is more focus towards females. Men are already sufficiently
saturated in the maths/CS fields. What we need is to market the idea of maths
as fun to more females.

~~~
wanda
As a female math grad and CS postgrad, I would like to say firstly that you
have successfully trolled me. I do hereby take your bait.

Now for the points I would like to make, primarily for the benefit of the few
who _actually_ think as you claim to think:

Women are actually similar to men in a number of novel ways.

We have eyes, and those eyes are intricately connected to very powerful and
compact organic computers—capable of independent thought—called brains.

That's right, men and women can both have brains.

And those of us women fortunate enough to be blessed with brains are quite
capable not only of independent thoughts, but even decision-making. And yet
another way in which we women are similar to men is that each of us, as
individuals, comes to have certain aptitudes, preferences and values.

Some of us, like myself, discover to their amazement that they can understand
mathematics and even think mathematically about pretty much anything, and
develop an interest in technology and computation because of the possibilities
it opens up for mathematics and because of the ways mathematics can
reflexively provide insights into computer science and programming.

Other women have an aptitude/preference for: polishing nails; answering
telephones; designing cute little things that men can give to women at
Christmas; and so on. Are women like myself a minority? Perhaps, but it isn't
because we have to be shown things like maths and programming with striking
adverts, responsive websites and pretty flyers.

I'm not going to pretend that society has been engineered into a patriarchy,
over thousands of years, as part of a sinister plot by the Illuminati to
preclude the success and independence of the children of the mother-goddess.

I'm likewise not going to pretend to think that there are men with power who
purposefully keep women from rising up, or give preferential treatment to male
candidates for scholarships/whatever without even realising it. Because
ultimately I have no proof of such things and neither do I care about some
male-dominant society, because in my experience, what matters is the talent;
if you have it, if you have an original idea, a way how to implement it, or if
you're simply the best at what you do, you will succeed if you want to, male
or female. I do not care why my boss, my clients or my investors choose me, I
just want the opportunity to do what I do best, what I like doing.

If you think women simply haven't been exposed to the magical and fun
possibilities of mathematics and computers, think again. If women were
ignorant to these fields and what they involve, they wouldn't laugh at you for
being a "nerd" or date muscular/rich guys instead of you.

They know what maths is, and they know what programming is, and they'll never
want to visit a forum and tell everyone how awesome it was when they elegantly
solved some mathematical problems or came up with a new proof for some random
theorem. They will on the contrary yearn to talk about shoes, interior design,
literature, art, perfume, TV shows, movies, diets and so on.

The select few women who prefer mathematics/compsci and find it genuinely fun
and inspiring were already posting on newsgroups, were already on IRC, were
already subscribed to ars technica and slashdot on google reader, were already
here; and they are already here; or they will be here in the future, or
wherever else that such subjects can be discussed in the future.

It is not a case of marketing the idea to a mass of women who have no idea
what makes their iPhone so useful, or how their cars' brakes are engineered.
Women do not go to fashion forums and tell everyone about how much I wish I
could expose men to the glories of haute couture. Women do not tell their
nutritionists how much they wish they could entice their male friends with raw
food diets and veganism.

There are the lost, unwashed masses who will never amount to anything, who
will become a carbon copy of their parents and aspire to nothing beyond some
repetition-of-basic-tasks job in an office or in retail, and the members of
these masses are of both genders. You will fail to "market" math/compsci to
these people, regardless of gender, because they cannot do it. Women who
aspire to something and want to succeed do not generally want to do it with
math and programming.

So, to all of you who think women need to have math/compsci marketed to them:
kindly stop talking crap and just ignore the gender issue. It doesn't do you
any credit. Women are here. We don't typically scream that we're women because
why should we? We're just professionals or students trying to succeed and
learn, no different to you gents.

If you want to encourage women to get into math/compsci, have a daughter and
buy her a cheap laptop and "The C Programming Language" when she's young. If
she takes to it, bang, she had an aptitude that would have gone unnoticed and
you saved her from a life of instagram and film studies.

If she deletes some system folders she doesn't think she needs, watches make-
up tutorials on youtube and checks facebook every 2 hours, you know you've got
yourself a typical woman.

Protip: I don't think the statistics of how many women study math/compsci will
be much different in the aforementioned compsci-introduced generation of
daughters.

~~~
skybrian
Seems like you're promoting some myths as well.

Kids don't magically decide that math or science or computer programming is
fun. They're heavily influenced by what they're exposed to and what they see
other people they respect doing. Yes, that's "marketing" or perhaps better
call it education.

And no, giving a kid the "C programming language" isn't going to cut it unless
they've previously had enough exposure to math or engineering to understand
why it's interesting. (Based on what I've heard, Minecraft seems to be working
a lot better.)

~~~
wanda
Okay, perhaps I am being subjective. I got into this stuff on my own, maybe
exposure makes a difference for some. But let's face it, there's no objective
reason why math/compsci/engineering should be interesting even after you
understand it. It's not like you can just explain it _x_ many times and
suddenly a girl will be like "wow it's so amazing and deep and clever." You
and I may appreciate it, but can you say why? Can you give me the fundamental
reason why it should be interesting as a matter of fact? Besides, we're in the
21st century. Girls can expose themselves to whatever they want. I don't think
programming and calculus are terribly obscure.

~~~
skybrian
I'm not sure calculus is a great example for your argument. How many kids do
you think would actually learn calculus on their own? It's something that most
kids think is way beyond them and they don't even know what it is (other than
a kind of math) until they actually study it in school.

And that's a standard subject taught in high school. I think if instead you
look at why kids learn music or art or dance or drama or sports or a foreign
language or religion, you'll find that the parents and relatives and friends
often (not always) have a lot to do with it. And even with parental support,
often the kids decide it's not for them. And that's fine; at least they got
the chance.

I don't see computer programming as being all that different; not every kid is
going to be into any given activity, but if they're not exposed to it in a way
that makes it seem interesting, that's going to drastically reduce the number
of kids who even try it. And that exposure is going to vary pretty
dramatically depending on where you grew up.

------
FigBug
I was really into Project Euler when I had a job where I didn't have to do
anything. I've solved 122 problems. Now I work for myself and don't have the
time, as well I solved all I was able to solve. I last solved a problem in
2009 I think.

It's fun, I encourage everybody to do a few. Get past the easy ones at least.

------
datawander
To be honest, I'm shocked this is on the front page as this website has been
out for years and already notably mentioned, but I guess it's good to recycle
very important websites for those who haven't heard of it.

My favorite problems is 98. This problem, along with the Sudoku one at 96,
require much more careful programming than some of the others due the
drastically fewer number of people who solved it compared to the surrounding
problems.

~~~
pedrosorio
You may have inadvertently reversed the arrow of causality there :)

------
henrik_w
Another good one for (more general) programming problems is Programming
Praxis: [http://programmingpraxis.com/](http://programmingpraxis.com/)

------
mixedbit
I love project Euler. A nice way to improve programming skills in a new
language is to go through others solutions in the same language after you
solved a problem. This allows to break bad habits. Say you are a C programmer
learning Ruby or Lisp, 'C-ish' approach will often seem the most
straightforward, but will rarely be optimal and idiomatic in the new language
you are learning.

------
gaius
A dozen Project Euler solutions in a given language can be an excellent pre-
interview candidate screening technique. Quite simple to check for plagiarism
too, within reason.

~~~
gjm11
_A dozen_? Perhaps a dozen of the easiest ones that one can do in a few
minutes, but even so it seems like a lot of work for a pre-interview
screening. But many Project Euler problems require a great deal of thought and
are mostly testing mathematical prowess.

How much work are you comfortable making your candidates do before they even
know whether they're getting an interview?

~~~
gaius
Yep sure, I'd expect any competent programmer to be able to bash out the first
dozen without it being too onerous. Think of it as FizzBuzz-on-steroids.
Remember this is only a screen, and it's something many programmers would find
to be fun anyway!

~~~
danielweber
Our time is still finite, especially when we are in job hunt mode. One party
should not expect the other party to invest a lot of time in the process
without doing so themselves.

I'm particularly sore because I spent a bunch of time working on learning
something domain-specific for a potential employer who verbally indicated the
interview process would be proceeding, but then forgot to tell me for a week
they had decided to end the process.

~~~
gaius
That's why I like Euler for this, there's no possibility that someone is
trying to get some free work out of you.

~~~
danielweber
It's not the "free work," it's asking the candidate to make a large time
commitment that she cannot use for pursuing other job opportunities.

~~~
recursive
> a large time commitment

No. Solving the first 12 PE problems should not take a competent programmer
more than 30 minutes.

~~~
gjm11
Well, I just did it. It took me about 35 minutes. I am terribly, terribly old
(43 years) but I'm pretty sure I am a more than competent programmer and I
have a very strong mathematical background. I was working on a laptop but a
reasonably decent one, in an environment less distraction-free than an
interview room but still not bad. I didn't particularly go all-out for maximum
speed but wasn't gratuitously slothful.

I (deliberately) didn't use a programming language with, e.g., facilities for
prime factorization built in; that would have made it much quicker but would
also have made the whole thing useless as a programming test. So I had to
implement the sieve of Eratosthenes, the number-of-divisors function (via
prime factorization), etc.

I estimate that about 8 minutes of that time was the result of a couple of
silly bugs. (It's surprising how many seconds one can lose to forgetting that
16 is less than 20.) That figure could easily have been zero or twice as much.
I lost perhaps two minutes to spousal distraction.

These are all straightforward problems; in no case did I have to spend more
than a few seconds thinking how to proceed, though in a couple of cases my
response to having written buggy code was to replace it with something more
simple-minded.

 _recursive_ , I invite you to actually sit down and implement solutions to
the first 12 PE problems in, say, Python or Ruby or some similar language and
tell us how comfortably under 30 minutes you come in. For the avoidance of
doubt, I'm not at all saying you won't manage it -- I wasn't far off and you
may very well be quicker than me. But I'll be surprised if you're so far ahead
that after the exercise you still think every competent programmer should
finish in at most 30 minutes.

(My rough timings for the 12 problems, in order, in minutes: 1, 1.5, 1.5, 1,
3, 1, 3, 2, 1, 4, 5, 10. These figures include bugfixing and checking against
the PE site. Total lines of code: about 115.)

~~~
recursive
I had almost the same exact result as you. It did take me a little over 30
minutes. I finished with 125 lines.

Duly chastened, I take it back. But if the numbers were changed to 8 problems,
and 1 hour, I still don't think that's unreasonable.

------
asgard1024
I solved about 80 of them, then my interest waned a little. But I wonder, are
there any hints or recommended reading for the harder ones? Some of them I
have no idea how to even start working on..

~~~
dominotw
> Some of them I have no idea how to even start working on

Do you have an example of such a problem?

~~~
asgard1024
I am sorry, it's like 5 years back when I did it, and I don't remember (nor I
am inclined in pursuing it further). (I didn't gave up because it became
impossible, I just became less interested.)

But lot of those harder ones - as far as I can tell - required pretty deep
knowledge of number theory, which even though I studied math (10 years ago),
didn't have. I think it would be nice if there was sometimes a hint about what
the people should study to be able to solve it.

------
ahuth
There's only one problem for me with Project Euler. Eventually, the problems
become more about coming up with the mathematical algorithm you need to solve
it.

That may be what you want. However, a lot of these are outside my math
knowledge/ability, without really expanding my programming ability.

~~~
gaius
In many of them, the naive solution is intractable in terms of time or memory,
so some programming skill is required.

~~~
ahuth
This is definitely true. Finding the non-naive solution is still more of a
math exercise, though.

I've spent a lot of time reading wikipedia articles for algorithms that I
don't understand trying to solve some these problems.

~~~
pmiller2
I agree. I think the "hard" (and some of the "medium") challenges on
codeeval.com are much better in terms of requiring coding ability vs requiring
math ability. Math ability won't hurt, but it won't get you quite all the way
there.

------
dmunoz
A lot of good links to similar sites in this comment thread.

I enjoy Project Euler, but as with many people slowly got annoyed by lack of
specific mathematical knowledge as opposed to programming. One thing I believe
would really help with this would be a resource that discussed the problem in
the abstract. As an example, for most of the programs that rely on using
primes, whether it be iterating them (e.g. first 1M primes) or the unique
prime factorization of a number, discuss the known algorithms in pseudocode.
Perhaps this is a bit much, as I would be satisfied with just knowing the
words I need to go find resources for myself. This is what I tend to do anyway
after I have taken a fair stab at a problem: "Oh, I'm doing prime
factorization. I wonder if there are better algorithms than I have used."
Indeed, one resource for this is the forums that are made available after the
problem is solved.

Some might see this as ruining the fun, but I would personally have more fun
and solve more problems if this was available.

------
kozikow
In my opinion it may be better to do practice SRMs/Codeforces contests instead
of project Euler. Topcoder rank imo tends to mean more, since it is timed. If
someone says "I solved x problems on site X" you can't say if he done it in
days or weeks of effort. If someone says he's red on topcoder you can say he's
awesome.

------
doughj3
Project Euler is great but as others here have said it is very math focused.
Can anyone share other programming challenge sites? I saw one the other day
here on HN in a comment but can't find it again. The only thing I remember is
the problem I checked out was a kind of AI / pathfinding for a "floor cleaning
robot" and code was submitted directly in the page.

[Edit] Just found it going through my history:
[https://www.hackerrank.com/](https://www.hackerrank.com/)

~~~
elteto
The UVA Online Judge [1] is one of the largest and oldest programming
competition sites on the web. They have a _huge_ library with problems in
pretty much any CS area. However it can be a little overwhelming at first, so
is better to use UHunt [2], which categorizes problems according to difficulty
_and_ area, such as Data Structures, Computational Geometry, String
Manipulation, etc.

[1]
[http://uva.onlinejudge.org/index.php](http://uva.onlinejudge.org/index.php)
[2] [http://uhunt.felix-halim.net/id/339](http://uhunt.felix-halim.net/id/339)

------
donquichotte
Problem that has been solved by the smallest number of people (31):
[http://projecteuler.net/problem=453](http://projecteuler.net/problem=453)

~~~
yankoff
It also was added just recently (relatively). So not necessarily it's the
hardest one.

~~~
Adrock
Back when I was working on PE problems, I had a spreadsheet of the problems
and I'd sort them by the ratio of solvers to solvers of the preceding problem.
It's a handy way to find the low hanging fruit and partially eliminates the
recency factor.

------
blacksmythe
If you are not challenged by these problems, here is an alternative that I
found considerably more difficult:

[http://www.spoj.com/](http://www.spoj.com/)

------
Karunamon
I'm trying to go through this with Ruby right now and having a lot of fun.
Being a bit rusty on basic algorithms and higher algebra has not helped much,
though.

------
captn3m0
Tangentially related: I made a pseudo-terminal web interface to Project Euler
called CodeBot[1]. You can view problems, submit solutions, and do much more
(some *nix commands work) in your browser. Its even open-source[2] on GitHub

[1]: [http://codebot.sdslabs.co.in/](http://codebot.sdslabs.co.in/)

[2]: [http://github.com/sdslabs/codebot](http://github.com/sdslabs/codebot)

------
bradleyjg
These are a lot of fun to do, especially in a new language you want to play
with. However they are as much an exercise of your math skills (mostly basic
number theory and combinatorics) as programming. One thing I'd suggest is that
you pick an algorithm reference and stick with it, if you google anything too
specific you will come across one of the many sites where people have blogged
about thier solutions.

------
JakeStone
I always love this site for when things get a little slow and I think I could
use some relaxation.

Then I remember that I only took a little bit of math, so then there's the
research, the papers to read and decipher, the code to write, and I finally
solve the problem and swear I'll never come back.

So, yeah, I just finished a batch of problems last week so I could get a
couple of ego badges just within reach. 75 down, 379 to go!

------
aezell
I always liked this set of challenges/riddles, though it is directed at Python
specifically. I appreciated that it forced you to deal with some Internet-
related programming tools and concepts.

[http://www.pythonchallenge.com/](http://www.pythonchallenge.com/)

------
yankoff
Project Euler is great. Another one, but more algorithm and CS oriented:
hackerrank.com

~~~
wambotron
Hackerrank is great. Thanks for sharing!

------
kylemaxwell
For those interested I keep a list of these sorts of things at
[https://github.com/technoskald/coding-
entertainment](https://github.com/technoskald/coding-entertainment).

------
prothid
This site is great fun to tinker with a new programming language.

~~~
strickjb9
I learned Python on this site. Started from the beginning until I had to start
skipping a few.

------
yetanotherphd
The best and worst thing about project Euler is the binary feedback they give
you: either you pass or you fail.

On the one hand, it is a good lesson in how hard it can be to write correct
code.

On the other hand, real world problems aren't black boxes where you try an
integer until you get the right one. Problems with multiple tests needed to
pass (like topcoder) are much more realistic.

------
wanda
Weird, I was just talking about this earlier when someone asked for productive
activity on train journeys to/from work.

I used to do these problems years ago when I was still a student and later
when commuting to London. I did as many as I could on paper before trying to
program solutions. I'll have to log in sometime and finish the few I missed.

~~~
gprasanth
really weird. I saw that post and your reply too when I was browsing the 'new'
section after posting this.

------
careersuicide
Here's a little side project I've been working on for a few months:
[https://github.com/seaneshbaugh/rosetta-
euler/](https://github.com/seaneshbaugh/rosetta-euler/)

I've been a little busy lately so it's been neglected somewhat. Why is Prolog
so hard?

------
sricciardi
I used it to learn the basics of F# and solving algorithms using a functional
approach.

------
elwell
How does it work? Do you submit code or just input your answer as a number?

~~~
btian
Input your answer as number. There are people who solve problems by hand.

------
Sgoettschkes
Learning haskell with ProjectEuler right now. It's great and after solving it,
one can always look up the forums and improve the own code or learn different
ways to implement the solution!

------
elwell
How does a site this old get so many upvotes? whatever, I guess it's worth
bringing back into the collective consciousness.

------
selectnull
I love it, although I found I lack math knowledge to really be good at it.

I enjoyed solving a few of those problems using SQL, that was fun.

------
lquist
If I see a github with 30+ solved Project Euler problems, 99% chance it
becomes a hire.

------
veritas9
On CodeEval.com we have over 126+ executable programming challenges in 18
languages :)

~~~
arkinologist13
Yeah! i tried some challenges in CodeEval and they're all cool!

------
TallboyOne
more like this:
[http://pineapple.io/resources/tagged/challenges](http://pineapple.io/resources/tagged/challenges)

------
jbeja
I will start this with python.

~~~
krazydad
Even though I know python fairly decently, I found working on Project Euler
problems improved my Python skills a lot - in particular, I had not had much
awareness, nor need for the 'yield' command, but I ended up using it a lot on
PE problems.

