Page 1 of 1

Project Euler

Posted: Fri Feb 06, 2015 5:55 am
by Jirato
So, a younger friend of mine is just starting to learn computer sciences and programming. I was watching him livestream an interesting problem the other day and was offering some advice. He told me it was actually some sort of math/programming puzzle called Project Euler.

It starts out really really simple, basic low-level stuff that anyone just getting into programming should be able to figure out, but I'm guessing it gets heaps more difficult as you work through the problems.

Here's a blurb from their website. https://projecteuler.net/about
About Project Euler
Leonhard Euler (1707-1783)
What is Project Euler?

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

The motivation for starting Project Euler, and its continuation, is to provide a platform for the inquiring mind to delve into unfamiliar areas and learn new concepts in a fun and recreational context.

Who are the problems aimed at?

The intended audience include students for whom the basic curriculum is not feeding their hunger to learn, adults whose background was not primarily mathematics but had an interest in things mathematical, and professionals who want to keep their problem solving and mathematics on the cutting edge.

Can anyone solve the problems?

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'm going to be working on these problems in my free time along side with my young friend, so that I can help mentor him and stuff. But if anyone else wants to come along for the ride, I think it'll be fun. So, feel free to share your progress or any issues you're having here, though try to avoid posting direct solutions to the puzzles, that would ruin the fun!

If you do register an account, feel free to go to the friend's page and add my friend key: 738974_80b0c3b10960a012ebfdfe7b9a5688b0

We've already solved the first problem (Which took him about 3 hours, to give a general idea of where he's at, programming wise, took me a couple minutes). I've solved the second problem in a non-recursive way but am going to wait for my friend to start tackling it to work on it using a recursive function so that he can learn about recursion.

Re: Project Euler

Posted: Fri Feb 06, 2015 6:15 am
by Kunren
Really disappoints me that my highschool offers no computer science classes, since that's what I want to try to major in once I hit college. I suppose nothing's stopping me from trying to teach myself.. I'd just hate accidentally messing up my laptop. Well I guess Google could help.

Re: Project Euler

Posted: Fri Feb 06, 2015 6:38 am
by Sneaky
I made an account, and I was on the first problem and I have the concept in my head, and I'm fairly certain I can code it, though I'm not sure how it's listed or what language I'm suppose to right it in, or is it suppose to be formula based? I'm not sure, the other problem is that each problem requires a captcha image to be solved, which I unfortunately can't do without sighted assistance. I think I can send an email and rquest an audio version to be added in, but I don't think this is going to result in a change unfortunately.

Re: Project Euler

Posted: Fri Feb 06, 2015 8:35 am
by blindndangerous
Sneaky, you can't use web visum to solve them?

Re: Project Euler

Posted: Fri Feb 06, 2015 9:13 am
by Jirato
You can use any language you want. It's all about the output, how you get there is up to you. Every program/script you make for those problems should ultimately print or return a single value which is your answer.

But yeah... captchas are a problem.

Re: Project Euler

Posted: Sun Feb 08, 2015 6:06 am
by Jirato
Anyone? Anyone?

I solved problems 3 and 4 the other night. 3 took me forever to figure out how to write a sieve of Eratosthenes... For the first half hour I just tried to brute force it, but checking every single natural number in the world to determine if it's prime is actually very very inefficient (plus you run into memory issues). Finally I had someone offer some advice for making an efficient/working sieve. I learned a few new things that I didn't know before such as...

Array initialization in the form of

Code: Select all

arr = [value] * length
Setting multiple elements of an array at the same time such as:

Code: Select all

arr[0] = arr[1] = value
Python's enumerate function (don't know how I lived without that!)

The fact that python's range function has a third "step" argument... which I think I might have used once or twice before but totally forgot about. ><

After spending so many hours on 3, 4 was a piece of cake. I did it kinda the inefficient way by converting the integer into a string and using string manipulation to determine if it was a palindrome or not, but what can I say? I develop text based games, string manipulation is kinda my thing.

Re: Project Euler

Posted: Mon Feb 09, 2015 9:40 am
by qinweiqi
I've solved through 9 at the moment. I'm using R, a great language for statistical analysis. R is really good at vector operations (performing functions on vectors). It is less optimized for loops and only ok at recursion. It has been interesting realizing how much choice of language sets the difficulty of the problem. So, for example, problems 1, 6, and 8 were practically trivial in R, while problems 2, 7, and 10 have been as much about writing code as waiting for loops to run. Initially I took a slower approach to finding primes (a loop where we check if previous prime + 2 is prime and continue to increment by 2). I've since also adopted a sieve because R is really good at subsetting and my code is currently grinding away at problem 10. This time I'm saving my list of primes to use as a starter for the next deranged primes problem.

Edit to add:
Jirato wrote:After spending so many hours on 3, 4 was a piece of cake. I did it kinda the inefficient way by converting the integer into a string and using string manipulation to determine if it was a palindrome or not, but what can I say? I develop text based games, string manipulation is kinda my thing.
I forgot that I wanted to comment on this part too! Dealing with strings in R is typically a nuisance, so I decided to start on the palindrome side (use arithmetic to turn 999 to 999999, 998 to 998899 etc.) and then check factors. I like to think about what the hardest part to deal with in terms of code is and then see if I can avoid that problem altogether =)