Project Euler is a great tool to learn a new programming language. I used it, along with 'Programming Clojure' to learn Clojure. You can see all my problems on GitHub. http://github.com/semmons99/clojure-euler
Haskell is actually very good for solving these types of problems. It supports infinite lists and lazy evaluation which help quite a bit.
I find that the best thing about Project Euler is being able to look at how other people have solved the problems - a great way to improve your own code.
I can't decide whether to put my solutions up. They're in Arc, so they might be useful for people learning the language, as there aren't many Arc-specific programs out there.
So why are you hesitating? If your programming is good you will only help other people and may get some useful exposure in the community in the process.
If your programming is bad, (hypothetically) you will likely get people to give you good pointers so that you are better next time.
Either way, I see no reason not to, and the fact you are using Arc just increases the importance of helping people to follow along behind you.
One good reason to hesitate is that Project Euler is supposed to be a set of problems that people solve for themselves. Therefore the admins request that people not post solutions, and occasionally will tweak parameters if certain problems are too easy to find with a Google search.
It is a losing battle to be sure, but they put a lot of work into it and I prefer it when people respect their request to not facilitate cheating.
People who are going through Project Euler to practice will never search for those and would likely forget the fine details quickly, so having the answers out there somewhere won't matter to them. People who want to cheat at Project Euler already have plenty of ways (and besides, what would they gain? At least from my minimal participication, it does not really look like a contest and there are no prizes).
On the other hand, people who want to learn Arc might be very greatful to have a good set of code out there.
Some companies in the financial industry use PE problems for interviews. People memorize brainteasers for these interviews, so I imagine people might also want to memorize PE solutions.
I couldn't disagree with you more. People solving the problems have a choice. If they don't want to look it up, more power to them. Otherwise, leave the decision to the learner.
I always hated it when teachers would hold on to the solutions to the exercises in the textbook.
They have places to talk about solutions where only people who already solved the question can see them - it's just that they close the discussions relatively quickly - 100 comments or some time limit? And you can't really discuss solutions on their regular forum, because that's likely a (deletable) spoiler. So to openly discuss & share, you really have to go elsewhere.
btilly's reason is correct -- It's because Project Euler is about solving the problems for yourself, not just blindly copying and pasting. Although I'm starting to lean towards thinking that if people want to cheat, they will, and so if I can help someone (even myself) by posting the code, I should do so.
And yes, getting pointers on my Arc code would be helpful. So maybe I'll put everything up on github.
Btilly is entirely correct of course, but there is a huge caveat to what he says.
That being that people who want to cheat have any number of ways of doing it from finding someone else who posted it publicly, to asking privately, to (in the extreme case) actually paying someone to figure out the answer and give it to them.
And, as I mentioned in a previous post, the people who do not want to cheat, won't. They won't do those searches. If they stumble over it and know what it is they won't read it. If they stumble over it and read it before they know what it is, they will almost certainly forget the details quickly.
So by posting your Arc code publicly, you would neither (significantly) help someone wanting to cheat nor hurt someone not wanting to cheat. But you will help people who want to learn Arc.
It sounds like someone wants to cheat on Project Euler.
No, I'm joking. If that was the only issue, I'd just post them. Somewhere on the Project Euler site -- I can't find it now -- they ask for the solutions not to be posted anywhere. That's my main hangup at this point.
IMHO Project Euler teaches bad programming by asking you to solve specific cases instead of general problems. I've found at least one problem where the straightforward correct answer failed in the general case, and the generic solution was significantly more complicated.
I'm not sure what you mean by "straightforward correct answer".
I just used a big integer library, calculated the answer, and then took the first 10 digits. That should work out fine in any reasonable general case that you're likely to be thinking of.
What I found in example solutions, and is indeed accepted by the site, is truncating each number to 10 digits and then summing. You can do this with just double-precision FP so it's likely to be the most common solution in languages that don't have bignums baked in.
There are also a number of problems where it is possible to narrow down the answer fairly easily, then submit a limited number of guesses until you get the right answer without having really shown that it is right.
There are also a number of problems where it is possible to narrow down the answer fairly easily, then submit a limited number of guesses until you get the right answer without having really shown that it is right.
To some degree, they need to rely on the users to care enough not to "cheat." There is no way to completely avoid people doing things like this.
That was actually the problem that first got me interested in math. The whole "roll several dice, take the top n" was a common trick we used in D&D games, and I wanted to know what the odds were of getting different outcomes, and how it varied by number of dice. I actually worked out the 4 dice version by hand before trying to get smarter about it. And eventually did.
So when I saw Project Euler I dusted off the problem, and tried to set up a variant that was about the right level of difficulty for a Project Euler problem. :-)
A really tricky dice problem is calculating Risk odds, once an attack needs to go through several countries, potentially from multiple starting points. The whole distribution of possible outcomes must be considered, to best figure out the trade-offs in attacking. :-)
Why can’t you just figure out how many ways to sum 10 12-sided dice to 70, and then for each solution, multiply that by the number of ways the other dice could all be ≤ the smallest one (times changes in ordering). Seems like it'd take no more than 20 or 30 minutes to code up.
Go ahead and try it out. I've only solved 87 problems, but I enjoyed it very much. My experience was that many problems were very deceptive. At first you think, it is really easy, and after awhile it becomes evident that the problem is much harder than initially thought. I appreciated that every problem seems to teach you something new, even if the problem seems very similar to a previous one, there is usually a twist.