Sunday, November 8, 2009

Project Euler

Lately my spare time has been eaten by an MMORPG: Project Euler. Even though I have played few RPGs, I’m sure Project Euler is one of the most difficult and challenging.

Actually, it’s really not an RPG. Rather than reward the clicking of buttons, the only way to gain levels in Project Euler is to submit answers to puzzles. Each involves a little bit of computer science and a little bit of mathematics.

Along the way, I wrote a library to make it easier to do arbitrary precision arithmetic in C. For example, to solve problem 97, I could write:

  mpz_t z;
mpz_init(z);
mpx_eval("mpz a; a = (28433 * 2^7830457 + 1) % 10^10;", z);
gmp_printf("%Zd\n", z);

Strangely, Project Euler only lets you try at most 25 problems over n days, where n is your current level (except at level 0, when it is 1). Perhaps I should be grateful, as bumping into this limit gives me time to post code!

1 comment:

FreeArtMan said...

Yepp whery good MMORPG. I also trying there my skills. There is many news thing that I have lerned whyle play it. Also gmp library I have found while played Project Euler