Posts: 6610
Threads: 73
Joined: May 31, 2014
Reputation:
56
Project Euler
June 26, 2016 at 12:41 am
For you lovers of programming and mathematics, here's a cool site for you with fun exercises to complete and progress tracked (if you sign up to the site first)::
https://projecteuler.net/
Up to Problem 20 now. Who here can beat me?
Posts: 15351
Threads: 118
Joined: January 13, 2014
Reputation:
116
RE: Project Euler
June 26, 2016 at 4:35 am
Oooh... I like.
I solved the first two pretty quickly.
Using C++.
"There remain four irreducible objections to religious faith: that it wholly misrepresents the origins of man and the cosmos, that because of this original error it manages to combine the maximum servility with the maximum of solipsism, that it is both the result and the cause of dangerous sexual repression, and that it is ultimately grounded on wish-thinking." ~Christopher Hitchens, god is not Great
PM me your email address to join the Slack chat! I'll give you a taco(or five) if you join! --->There's an app and everything!<---
Posts: 6610
Threads: 73
Joined: May 31, 2014
Reputation:
56
RE: Project Euler
June 26, 2016 at 4:39 am
(This post was last modified: June 26, 2016 at 4:39 am by GrandizerII.)
(June 26, 2016 at 4:35 am)SteelCurtain Wrote: Oooh... I like.
I solved the first two pretty quickly.
Using C++.
I'm using Python: the programming language for lazy people like me who don't want to type parentheses or braces more than they should.
Posts: 15351
Threads: 118
Joined: January 13, 2014
Reputation:
116
RE: Project Euler
June 26, 2016 at 4:40 am
I thought about using Python, but the C++ online shell has a shorter URL...
http://cpp.sh
"There remain four irreducible objections to religious faith: that it wholly misrepresents the origins of man and the cosmos, that because of this original error it manages to combine the maximum servility with the maximum of solipsism, that it is both the result and the cause of dangerous sexual repression, and that it is ultimately grounded on wish-thinking." ~Christopher Hitchens, god is not Great
PM me your email address to join the Slack chat! I'll give you a taco(or five) if you join! --->There's an app and everything!<---
Posts: 6610
Threads: 73
Joined: May 31, 2014
Reputation:
56
RE: Project Euler
June 26, 2016 at 9:02 am
(June 26, 2016 at 4:40 am)SteelCurtain Wrote: I thought about using Python, but the C++ online shell has a shorter URL... ![Tongue Tongue](https://atheistforums.org/images/smilies/tongue.gif)
cpp.sh
This looks really neat.
I'm using:
https://repl.it/
Up to Problem 23, but need to take a break now. I'll figure out tomorrow a way to solve that problem without crashing the browser.
Posts: 15351
Threads: 118
Joined: January 13, 2014
Reputation:
116
RE: Project Euler
June 28, 2016 at 4:58 am
Seriously, these are fun and challenging.
Usually, my code is pretty hacky because I don't care about anything but the result, but I love these challenges.
"There remain four irreducible objections to religious faith: that it wholly misrepresents the origins of man and the cosmos, that because of this original error it manages to combine the maximum servility with the maximum of solipsism, that it is both the result and the cause of dangerous sexual repression, and that it is ultimately grounded on wish-thinking." ~Christopher Hitchens, god is not Great
PM me your email address to join the Slack chat! I'll give you a taco(or five) if you join! --->There's an app and everything!<---
Posts: 6610
Threads: 73
Joined: May 31, 2014
Reputation:
56
RE: Project Euler
June 28, 2016 at 11:50 am
(June 28, 2016 at 4:58 am)SteelCurtain Wrote: Seriously, these are fun and challenging.
Usually, my code is pretty hacky because I don't care about anything but the result, but I love these challenges.
Where you up to, Steel?
If by hacky, you mean running fragments of code, extracting the intermediate answers, and then using those answers as part of the data for the final code, then yep, that's what I did for a couple of them thus far.
Posts: 15351
Threads: 118
Joined: January 13, 2014
Reputation:
116
RE: Project Euler
July 3, 2016 at 1:52 am
I'm working on #12 right now.
I'm on a slow shitty computer at work using Python and IDLE now. The summation of primes problem was too much for the online shells, they time out after like 5 seconds, the stingy bastards. Hard to sum all of the primes below 2,000,000 in 5 seconds with an online shell.
Now I am finding all of the divisors in triangle numbers, finding the first triangle number with more than 500 divisors. The code was easy, but it's been running for quite a time. I've tried to make it as economical as possible, but I don't care to think too hard about it.
That's what I mean by hacky: maybe not the most efficient code, and that's why this is good practice. I am trying to loop as few times as possible when having nested loops running two million times.
"There remain four irreducible objections to religious faith: that it wholly misrepresents the origins of man and the cosmos, that because of this original error it manages to combine the maximum servility with the maximum of solipsism, that it is both the result and the cause of dangerous sexual repression, and that it is ultimately grounded on wish-thinking." ~Christopher Hitchens, god is not Great
PM me your email address to join the Slack chat! I'll give you a taco(or five) if you join! --->There's an app and everything!<---
Posts: 6610
Threads: 73
Joined: May 31, 2014
Reputation:
56
RE: Project Euler
July 3, 2016 at 2:46 am
(July 3, 2016 at 1:52 am)SteelCurtain Wrote: I'm working on #12 right now.
I'm on a slow shitty computer at work using Python and IDLE now. The summation of primes problem was too much for the online shells, they time out after like 5 seconds, the stingy bastards. Hard to sum all of the primes below 2,000,000 in 5 seconds with an online shell.
Now I am finding all of the divisors in triangle numbers, finding the first triangle number with more than 500 divisors. The code was easy, but it's been running for quite a time. I've tried to make it as economical as possible, but I don't care to think too hard about it. ![Smile Smile](https://atheistforums.org/images/smilies/smile.gif)
That's what I mean by hacky: maybe not the most efficient code, and that's why this is good practice. I am trying to loop as few times as possible when having nested loops running two million times.
Can I give you a hint on how to deal with primes in the case of very large numbers?
Posts: 15351
Threads: 118
Joined: January 13, 2014
Reputation:
116
RE: Project Euler
July 3, 2016 at 6:20 am
Sure!
To be clear, I didn't actually loop through every number. I skipped evens, and I didn't check for factors after 1/3 of the number I was checking.
"There remain four irreducible objections to religious faith: that it wholly misrepresents the origins of man and the cosmos, that because of this original error it manages to combine the maximum servility with the maximum of solipsism, that it is both the result and the cause of dangerous sexual repression, and that it is ultimately grounded on wish-thinking." ~Christopher Hitchens, god is not Great
PM me your email address to join the Slack chat! I'll give you a taco(or five) if you join! --->There's an app and everything!<---
|