• Stars
    star
    123
  • Rank 290,145 (Top 6 %)
  • Language
    C++
  • Created almost 5 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

C++ solutions for more than 300 Project Euler problems

This is a mirror of my C++ solutions for about half of the Project Euler problems

You can find the code along with in-depth explanations and live demos at https://euler.stephan-brumme.com

Below is an excerpt from https://euler.stephan-brumme.com/why/ :

Why do I publish my solutions ?

Almost always the solutions for problems at Project Euler consist of two parts:

  1. finding a mathematical way to break down the problem's structure into its elements
  2. writing an efficient program for step 1

I strive to:

  • explain my choice of algorithms and data structures
  • write fully commented C++ source code that compiles without warnings and without any external libraries
  • interactive tests for most problems
  • link to relevant Wikipedia / MathWorld / OEIS pages
  • link to other solutions, especially those that are written in other programming languages

Let's not forget that it helps me, too: only if I can explain a solution to someone else then I can be sure that I truly understood it in the first place. And practicing some of the lesser used features of C++ (such as algorithms hidden inside STL, like std::next_permutation) improves my overall coding skills as well.

Sounds like a win-win situation ...

"But You Shouldn't Publish Your Solutions !"

Project Euler encourages you NOT to publish solutions.

I have a different point of view:

  • 99% of my knowledge is based on things I was taught, I saw somewhere or I stumbled across
  • and maybe 1% is "original"
  • I'm pretty sure it's not just me - it's the way how all of us gain knowledge

So it boils down to:

  • having a good teacher
  • access to well-equipped library
  • and probably most important today: your skills in working with a search engine

If someone visits my website/repository then he/she already realized that he/she can't solve that problem and is doing the right thing: ask someone. That's the only way how knowledge can be spread - all famous scientists wrote books. Leonhard Euler was one of the most productive mathematicians and he published 866 papers/books/etc. He shared his knowledge. And a substantial number of my solutions is based on some of his formulas, I only solved them because I could look up his works.

Admittedly, there is no use in publishing lists of the results to Project Euler problems. In my opinion, these numbers don't matter at all: noone really cares whether the result of problem 1 is 233167, 233168 or 233169. That's why you find algorithms, explanations, links, code, ..., basically everything on my website - but not the results. Because these numbers don't teach you anything.