13 ms·
Project Euler
- cdancette 9y agoI 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-traduction-des-problemes-1-a-50 https://www.lucaswillems.com/fr/articles/19/project-euler-tr...
- americanjetset 9y agoThis is exactly what I use it for.
- ctur 9y agoI've used it for the same purpose, but one thing to bear in mind is the problems are incredibly focused on a small domain, so while you can pick up some bits of a language, it is nowhere near a thorough introduction.
- Insanity 9y ago(They do ask not to share the solutions.) But nice job translating them :-)
- cdancette 9y agoThat's not me, but I found those translations very useful a few years ago! Hope it can help someone.
- mathattack 9y agoSimilar w/me. I picked up Python that way.
- hxtk 9y ago> Some problems can even be solved without any programming. Here's a fairly comprehensive list of those problems, but it hasn't been updated in a while, e.g., 601 is solvable with pencil and paper but it's new enough that it isn't on the list. https://projecteuler.chat/viewtopic.php?t=1982 https://projecteuler.chat/viewtopic.php?t=1982
- 10-6 9y agoshameless 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 9y agoThank 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 9y agoI 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 9y agoMy 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 9y agoI 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 9y agoThat would be really cool.
- fareesh 9y agoThe 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&Itemid=8 https://uva.onlinejudge.org/index.php?option=com_onlinejudge...
- of 9y agoI use project euler whenever I want to learn a new language. I've used it recently with ocaml - https://github.com/nikolas/projecteuler https://github.com/nikolas/projecteuler
- luckyt 9y agoSolutions here: https://github.com/luckytoilet/projecteuler-solutions https://github.com/luckytoilet/projecteuler-solutions
- apricot 9y agoFrom the Project Euler website: I learned so much solving problem XXX so is it okay to publish my solution elsewhere? It appears that you have answered your own question. There is nothing quite like that "Aha!" moment when you finally beat a problem which you have been working on for some time. It is often through the best of intentions in wishing to share our insights so that others can enjoy that moment too. Sadly, however, that will not be the case for your readers. Real learning is an active process and seeing how it is done is a long way from experiencing that epiphany of discovery. Please do not deny others what you have so richly valued yourself.
- cantrip 9y agoYeah why? Why would you publish strictly an answer key, with no solutions or discussion when the site itself, a well known and cherished part of the software development community has explicitly requested that you don't?
- brookside 9y agoWhy are you publishing the answers when the creators of Euler explicitly asked you not to?
- delibes 9y agoAh, 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?
- bunderbunder 9y agoThe 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 <- [1..999], (mod x 3 == 0) || (mod x 5 == 0)] 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.
- aportnoy 9y agoWhat language is this?
- deleted 9y ago[deleted]
- farresito 9y agoHaskell
- brians 9y agoIt’s a Haskell list comprehension. You read it as: The sum of x for x from one to 999 where x mod three is zero or x mod five is zero. well, the bit in square brackets is a comprehension. `sum `is just ordinary function application.
- deleted 9y ago
- 3princip 9y agoProject 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 :(
- DonbunEf7 9y agoThe 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.
- pacuna 9y agogood luck with that
- mathattack 9y agoHis point is correct. There are usually efficient and inefficient ways to attack each problem. It's better to solve the math problem first, before the coding problem.
- tedmiston 9y agoOnly when the scale truly matters is the most efficient algorithm the best choice though. For a lot of problems, especially in early stage startups, the brute force solution is more than sufficient and avoids premature optimization. Having perfect algorithms for everything comes with an opportunity cost in startup land that isn't aligned with whether or not your business succeeds most of the time. (This really only applies when the efficient implementation doesn't already exist in the standard library or a package.)
- sixstringtheory 9y agoSome problems simply will never return the result if you brute force it. I've run a brute-force solver and written the elegant approach while I waited for a result that'd never come. Most of the elegant solutions do exist in libraries out there, but the point is to pass down the underlying knowledge. I don't think it's really fair to liken something like mathematics to the startup world, something that has all sorts of nondeterministic factors involved.
- 9y ago
- scranglis 9y agoIf 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).
- sevensor 9y agoAfter 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 9y agoMy 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 9y agoI 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 9y agoThere are forums for the problems where you can ask for general directions, so long as hints are not asked / provided.
- amorphid 9y agoYeah, 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!
- Veedrac 9y agoI'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.
- nishparadox 9y agoProject Euler gives me nostalgia for some unknown reasons. During my BE, I used to get lost in the problem space. Now, it's different.
- utopcell 9y agoAre 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 9y agoI'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 9y agoThat is quite an achievement. Can you comment on your background ? type of education, work.
- NabiNaga 9y agoI 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 9y agoThat'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 9y ago
- archgoon 9y agohttp://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 9y agoRosalind 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.
- robertkrahn01 9y agobright-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 9y agoShameless Plug There are literally thousands of problems here www.mathalon.us
- hemantv 9y agoPlug for www.mathalon.us very similar and lot of questions
- b0rsuk 9y agoIn 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.
- hellofunk 9y agoI 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 9y agoI 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 9y agoI 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 9y agoI second that. The NodeSchool [1] workshops are awesome. [1] http://nodeschool.io http://nodeschool.io
- sbergot 9y agoProject Euler is nice for math problems. It has little real world value for developers. The first ones can be a nice hands on introduction to problem solving.
- BuildTheRobots 9y agoFor 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 9y agoI 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
- jlebrech 9y agoi would love to see problems that have bounties on them and you get a sciencecoin or something for solving it.
- minusSeven 9y agoWhy 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.
- jwilk 9y agoBecause someone submitted it and people found it interesting. There's no requirement to submit only "new" things.
- fogetti 9y agoCan 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 9y agoSorry 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.
- thetalkingcode 9y agoDoSelect has some good programming problems including API based questions and competitive coding questions. https://doselect.com/ https://doselect.com/
- debbiedowner 9y agoTo 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 9y agoIf you write it and it doesn't finish in a minute, I'm sure it's not that trick.
- pogden 9y agoSomewhere in the instructions it says that your solution should run in less than a minute on ordinary computer hardware. Sometimes it's just as interesting to make your brute force solution more performant as it is to find 'the trick.'
- deleted 9y ago[deleted]
- ronnypostsstuff 9y agoDid 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.
- alanbernstein 9y agoI had an interview screening question once that was very similar to Project Euler type questions. I solved it correctly, and quickly, and that probably helped get me in the door.
- plastikmissile 9y agoHappened 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.
- huherto 9y agoBack 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 9y agoIt is possible to sort them by difficulty. Some of the newer problems are easier than some of the first 100 problems, appearantly.
- spectrum1234 9y agoIt really depends on your goals but for coding interviews I've found leetcode.com to be the best by far.
- deleted 9y ago[deleted]
- ww2 9y agoProject Euler is a good place for teenagers to start learning programming, better than the routes of game or website design.
- cubano 9y agoa26a zbuild 1b c ratty