I absolutely love project Euler. The math on the harder problems is way over my head but it is still my go-to site whenever I want to learn a new language. By the time you've done a bunch of them you'll be more than underway in understanding the territory and in a much better position to understand tutorials (which inevitably are written by experts in the language and usually make a ton of assumptions).<p>Alternating between project Euler, a book (or two), back to project Euler for a bit is a very fast school, and you determine how fast you can pace yourself.
"Saturday 31st of January Project Euler will reach a major milestone with the publication of our 500th problem. To celebrate this the team has composed a special problem in which the number 500 occurs repeatedly. In addition we're going to publish an ordinary problem simultaneously as problem 501. Both problems are published at 13:00 London time.<p>We invite all members to participate in our problem solving party. As celebrator of this jubilee we're allowed to ask the participants for a present. Well, here's our wish: please don't share any information about our party and the dishes we're serving you outside the fora dedicated to our dishes after your meal. This to allow those that are late to the party to consume our dishes undisturbed by premature revelations about what we are serving."<p><a href="https://projecteuler.net/news" rel="nofollow">https://projecteuler.net/news</a>
For Project Euler enthusiasts: here's a similar site focused on bioinformatics that I've found very very good: <a href="http://rosalind.info/" rel="nofollow">http://rosalind.info/</a><p>Also suitable for learning new languages (and bioinformatics).<p>The implementation of the site is awesome.
If you're interesting in the birth, inspiration and pedagogy behind Project Euler, I recommend this article [1].<p><i>And it's an effective teacher because those problems are arranged like the programs in the ORIC-1's manual, in what Hughes calls an "inductive chain":<p>The problems range in difficulty and for many the experience is inductive chain learning. That is, by solving one problem it will expose you to a new concept that allows you to undertake a previously inaccessible problem. So the determined participant will slowly but surely work his/her way through every problem.</i><p>[1]<a href="http://www.theatlantic.com/technology/print/2011/06/how-i-failed-failed-and-finally-succeeded-at-learning-how-to-code/239855/" rel="nofollow">http://www.theatlantic.com/technology/print/2011/06/how-i-fa...</a>
After you solve a problem Project Euler lets you browse through a giant list of solutions by those who have gone before. It's really fun to see and compare all the different approaches.<p>If I could do one thing to augment the project I would make it possible to filter previous solutions by language and/or author.<p>For example, if I'm learning rust, I would love to see all the rust solutions right there together.
Happy 500th!<p>If you've never tried Project Euler, it's a great way to learn new mathematical concepts, sequences, dynamic programming and other algorithms.<p><a href="https://projecteuler.net/problem=368" rel="nofollow">https://projecteuler.net/problem=368</a> was one of my favorites, because it involved turning an algorithm described in a paper into code.<p>I don't consider this a spoiler for problem #500, but if you're counting the number of divisors, you'll need this function:
<a href="http://oeis.org/wiki/Number_of_divisors_function#Formulae_for_the_number_of_divisors_function" rel="nofollow">http://oeis.org/wiki/Number_of_divisors_function#Formulae_fo...</a><p>As an example,
120 = 2^3 * 3^1 * 5^1<p>number of divisors of 120 => (3+1)<i>(1+1)</i>(1+1)<p>Even if you don't solve it, exploring the problem is a fun afternoon for a person with a computer.
I love Project Euler. In this thread I've found references for similar projects but focussed more on actual coding (http:(<a href="http://oj.leetcode.com" rel="nofollow">http://oj.leetcode.com</a>) or on BioInformatics (<a href="http://rosalind.info/problems/locations/" rel="nofollow">http://rosalind.info/problems/locations/</a>).<p>Any chance you guys know of a similar project for Computer Vision or general AI topics?
This is a nice little problem, I had fun solving it.<p>For those of us who are familiar with TopCoder, CodeForces or, perhaps, ACM ICPC, this should be daily bread and butter on prime numbers and data structures :)<p>Here is my solution if you are curious: <a href="https://gist.github.com/Slava/74276f5b7889a1d68a71" rel="nofollow">https://gist.github.com/Slava/74276f5b7889a1d68a71</a> - computes the result in 400ms<p>Edit: hah, looking at the problems discussion board I took a very bruteforce approach, other people solved utilizing math, I used priority_queue for no particular reason :)
I was only recently introduced to Project Euler but already I'm addicted. I've got a folder where I've named each solution as pXXX.ext and try solving the problems in multiple different languages. I refuse to move on to a new problem until I've solved the previous one (I don't solve every problem in multiple languages. Instead I've been using it to learn/play with languages here and there I don't really know).<p>Congrats to Project Euler on their 500th problem!
Screamed at JavaScript for failing at big integer multiplications. Got it after rewriting in python. Here is my poorly written explanation.<p>--------- MAJOR SPOILERS ---------<p>Let's multiply unique prime numbers and count their factors.<p><pre><code> n Number of factors
2 2 (1, 2)
2x3 4 (1, 2, 3, 6)
2x3x5 8
2x3x5x7 16
</code></pre>
Notice that each time you add a new prime number, the factor count doubles<p>i.e. 2x3x5x...x500500th prime will have 2^500500 factors<p>The 500500th prime is 7376507 (thanks to wolframalpha), and it's not very big.<p>We can easily get the product of the above with 500500 multiplications while modding result of each step by 500500507 to get an answer.<p>Except that the product of first 500500 primes isn't the smallest number containing 2^500500 factors. This can be made smaller.<p>Observe that<p><pre><code> (2x3x5x...x500499th prime)x2
</code></pre>
has<p><pre><code> 2^500499 + 2^500498 factors.
</code></pre>
This is because with the extra 2 we added, it produces additional factors with existing factors that are a multiples of 2.<p>Continuing with this, we see that<p><pre><code> (2x3x5x...x500499th prime) x (2 x 2)
</code></pre>
has<p><pre><code> 2^500499 + 2^500498 + 2^500498 = 2^500500 factors.
</code></pre>
This is a better solution, since 2x2 is smaller than the 500500th prime.<p>If we want continue doubling factor count by multiplying 2s, we will need to multiply by 2x2x2x2 next, and 2^8 after, which becomes inefficient quickly.
Instead, why not use 3? Multiplying (2x3x5x...x500499th prime) by (3 x 3) also doubles the factor count.<p>So at this point, we think about doubling factor count and the ways we can do it. Out options are<p><1>. Multiply by a prime that we have never used so far<p><2>. Multiply by an existing prime k + 1 times, where k is the number of times it has been used<p>We repeat this 500500 times, using rule <1> and <2> (which can be generalized to one rule) and the result is the final answer.<p><pre><code> factor count n
2 2
4 2*3 <1>
8 2*3*2*2 <2>
16 2*3*2*2*5 <1>
32 2*3*2*2*5*7 <1>
64 2*3*2*2*5*7*3*3 <2>
128 2*3*2*2*5*7*3*3*11 <1>
</code></pre>
For 16 factors the number works out to be 120 (just like the example!). For numbers shown in the questions, sieving the prime takes some time, I also found it helpful to use a binary heap for speeding up finding the next smallest factors.