11 ms·
Project Euler
- b0b0b0b 13y agoI 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.
- joshdick 13y agoI like that Project Euler encourages me to learn more math.
- peeters 13y agoI 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 13y agoWhat 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.
- JasonFruit 13y agoAnd midgets. I'm really disappointed that Project Euler doesn't do more to motivate the vertically-challenged to excel in STEM fields.
- wanda 13y agoAs 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.
- Kluny 13y agoAs a woman, I would definitely use Project Euler more often if they came out with a pink version that was smaller and more ergonomic to suit my soft, feminine hands.
- mildtrepidation 13y agoAs a man with relatively small hands, I believe Project Euler should also have a smaller blue version that's more comfortable for me to use.
- VLM 13y ago"most efficiently" Stop doing that and its a lot more fun. It annoys me when a PE problem is specifically designed to make it impossible if you do it the "wrong" way. Most PE problems allow crazy solution strategies. The bad ones only have the one true way that is computationally feasible. A few posts up someone liked problem 267. I would pick random numbers, run them, then keep the winner and make n-1 new random numbers for round 2 and keep running rounds of multiple threads until bored, remembering the best result so far. Yes, that is not a very smart way to solve the problem, but its a very fun way to exercise the heck out of your knowledge of threads in some new language. Or you could make an insane thousand thread pipeline and hope for convergence. Or a thousand processes on a parallel cluster pipelined together. Could I write my random processor using BASH to baby sit a bunch of octave instances? Newtons method at least at first glance would be too easy. Could I solve it graphically, literally, by graphing some results and doing image manipulation and analysis of the generated graphic file to obtain the numerical result and feeding back for more "zoom" detail? Totally ridiculous unless the whole point is some weird computer vision project. Given an emulator for a IBM1620 mini-mainframe from the 60s, could I write a perl script that output random Fortran-II test runs for the emulated mini-mainframe to compile and process and then another perl script to eat the virtual "printer" output of the mini-mainframe to get random run results? Problem 267 looks like a fun one to solve the wrong way. This is the unfortunate part of PE becoming popular at interviews. First of all it surely has nothing remotely to do with almost all programming jobs, secondly, "having fun while doing crazy things" is probably not the ideal IT department mission statement or employee selection criteria (although it would explain some things I've seen over the years...) The proper tool for 99% or so of PE problems isn't a programming language anyway, its octave/mathematica/parigp. So its not too far out of the spirit to try crazy stuff.
- mathattack 13y agoI've been using it to learn Python, and to your point, frequently thought "this would be much easier to do recursively"
- MichaelGG 13y agoI remember doing the Heighway Dragon one (somewhere in the 200s). Took me quite a while to write code efficient enough to finish in well under a minute. Then I get to the forums, and it's a simple combinatorics question you can solve instantly. It certainly inspires me to learn more maths.
- cevn 13y agoI have to agree that the math is a bit too much. If you feel like doing algorithms / data structures work, though, perhaps leetcode will appeal to you: http://oj.leetcode.com/ http://oj.leetcode.com/
- pimentel 13y agoI liked the sound of leetcode, but I see the way to answer is with code (C++/Java) instead of a value answer. That ruins it for me. I want to play with new programming languages, and see if the output is correct while I'm at it.
- cevn 13y agoThat's true. Another one mentioned in this thread is hackerrank: https://www.hackerrank.com/ https://www.hackerrank.com/ - this one offers way more languages, except for rust, the one I'm actually learning :(
- pimentel 13y agoI saw that and just registered/tried. Although it has Clojure (my target language), you still send code instead of an answer, and you get problems like not knowing what's available in terms of libs and whatnot.
- pedrosorio 13y agoThis link may be helpful: https://www.hackerrank.com/environment https://www.hackerrank.com/environment Also, you can usually find information about that kind of stuff in their IRC or even e-mail. They are usually pretty responsive.
- huherto 13y ago> 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. I never had a PhD near by to get help from, but many problems involved doing research online about a theorem, sequence or some sort of mathematical concept.
- prothid 13y agoThis site is great fun to tinker with a new programming language.
- strickjb9 13y agoI learned Python on this site. Started from the beginning until I had to start skipping a few.
- jbeja 13y agoI will start this with python.
- krazydad 13y agoEven 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.
- wingi 13y agoTry to solve some problems in one line. http://united-coders.com/christian-harms/10-one-line-solutions-for-project-euler/ http://united-coders.com/christian-harms/10-one-line-solutio...
- ahuth 13y agoThere'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 13y agoIn many of them, the naive solution is intractable in terms of time or memory, so some programming skill is required.
- ahuth 13y agoThis 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 13y agoI 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.
- donquichotte 13y agoProblem that has been solved by the smallest number of people (31): http://projecteuler.net/problem=453 http://projecteuler.net/problem=453
- yankoff 13y agoIt also was added just recently (relatively). So not necessarily it's the hardest one.
- Adrock 13y agoBack 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.
- elwell 13y agoIt's possible that a different one has been solved by less people. E.g., if someone created multiple accounts, submitting to the same question multiple times, increasing the Solved By count artificially.
- prezjordan 13y agoAny hints? Anyone?
- Sharlin 13y agoTake advantage of symmetry, especially translation symmetry.
- testiclepizza 13y agoSlow news day, I guess.
- FigBug 13y agoI 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.
- Karunamon 13y agoI'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.
- yankoff 13y agoProject Euler is great. Another one, but more algorithm and CS oriented: hackerrank.com
- wambotron 13y agoHackerrank is great. Thanks for sharing!
- elwell 13y agoHow does it work? Do you submit code or just input your answer as a number?
- henrik_w 13y agoAnother good one for (more general) programming problems is Programming Praxis: http://programmingpraxis.com/ http://programmingpraxis.com/
- bradleyjg 13y agoThese 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.
- gaius 13y agoA 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.
- minimax 13y agoIn the same vein, spending a couple of hours working Project Euler questions before you go into an interview is a great way to warm up for the types of questions you tend to get in interviews but don't see as much during day-to-day programming.
- collyw 13y agoI think the reason it is a poor choice for interview questions, is like you say, we "don't see [questions like these] during day to day programming".
- gknoy 13y agoTrue, but if you are interviewing, this might be an easy way to have a github repo that has an example of your coding style: comments, function and variable names, etc. ... I am kicking myself that I have never done that.
- VLM 13y agoAside from the official rules, its socially frowned upon given the magic power of google. At least that was my experience. Private repo, fine, just as long as google can't find it.
- VLM 13y agoThat's never slowed down interview question fads before ...
- gjm11 13y agoA 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?
- JakeStone 13y agoI 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!
- asgard1024 13y agoI 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 13y ago> Some of them I have no idea how to even start working on Do you have an example of such a problem?
- asgard1024 13y agoI 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.
- cdelsolar 13y agoI became obsessed with this problem recently: http://projecteuler.net/problem=436 http://projecteuler.net/problem=436 and couldn't solve it. I found an article on mathworld that says the number of expected rolls is e so that the sum is over 1. I don't know how to figure out what the value of the roll that gets you over 1 is, it's something like 0.64 from simulation but what does that number mean and why?
- rsmaniak 13y agoI have the same problem, this one for instance http://projecteuler.net/problem=267 http://projecteuler.net/problem=267 I have absolutely no clue how to approach.
- joshdick 13y agoAfter the first hundred or so, you start to need more and more math. If you don't know what to look for off the top of your head (which you probably wouldn't without a math degree), try to google around for math that looks relevant to your problem. I find http://mathworld.wolfram.com/ http://mathworld.wolfram.com/ and http://oeis.org/ http://oeis.org/ to be very helpful for this.
- sricciardi 13y agoI used it to learn the basics of F# and solving algorithms using a functional approach.
- jboggan 13y agoThe 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.
- pmiller2 13y agoWhat company was that? Sound like a great place to work!
- dangoldin 13y agoWhen 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.
- Nicholas_C 13y agoAs a finance person I really like this one. I'll have to check it out when I get home from work. Thanks!
- dangoldin 13y ago
- Sgoettschkes 13y agoLearning 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!
- mixedbit 13y agoI 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.
- doughj3 13y agoProject 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/
- deleted 13y ago[deleted]
- cevn 13y agoHere's one, with a focus on preparing for interview questions: http://oj.leetcode.com/ http://oj.leetcode.com/
- elteto 13y agoThe 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
- datawander 13y agoTo 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 13y agoYou may have inadvertently reversed the arrow of causality there :)
- aezell 13y agoI 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/
- wanda 13y agoWeird, 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 13y agoreally weird. I saw that post and your reply too when I was browsing the 'new' section after posting this.
- blacksmythe 13y agoIf 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/
- habosa 13y agoI 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 13y agoI'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.
- kozikow 13y agoIn 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.
- kylemaxwell 13y agoFor those interested I keep a list of these sorts of things at https://github.com/technoskald/coding-entertainment https://github.com/technoskald/coding-entertainment.
- captn3m0 13y agoTangentially 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
- selectnull 13y agoI 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.
- dmunoz 13y agoA 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.
- careersuicide 13y agoHere'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?
- TallboyOne 13y agomore like this: http://pineapple.io/resources/tagged/challenges http://pineapple.io/resources/tagged/challenges
- yetanotherphd 13y agoThe 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.
- veritas9 13y agoOn CodeEval.com we have over 126+ executable programming challenges in 18 languages :)
- arkinologist13 13y agoYeah! i tried some challenges in CodeEval and they're all cool!
- elwell 13y agoHow does a site this old get so many upvotes? whatever, I guess it's worth bringing back into the collective consciousness.
- lquist 13y agoIf I see a github with 30+ solved Project Euler problems, 99% chance it becomes a hire.