Live data from Hacker News

Project Euler

projecteuler.net

1–10 of 172 posts

Re: Project Euler

#2
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...

Re: Project Euler

#3
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.

Re: Project Euler

#4

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 efficien…

This is exactly what I use it for.

Re: Project Euler

#5
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.

Re: Project Euler

#9
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?

Re: Project Euler

#10
post #9

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 =…

The best point to be made from this isn't that it's more computationally efficient. It's that, compared to something like

  sum [x | x 
which is really just bluntly translating the question into a programming language and letting it take care of the rest, your approach involves some actual insight into the underlying math.
Post reply on HN