UPSB v4

Off-topic / Help me I lack computing power

  1. ChainBreak
    Date: Sat, Jul 6 2013 22:23:11

    I need help for doing a calculation that my computer would take ages for. If you happen to have Python 3 on your computer and a decent processor + RAM I would kindly ask you to help me out. http://www.mediafire.com/view/4aa88qe6yja1kao/Euler10.py As you can see it's a .py file so no need to worry about it being a virus. If you're still suspicious you can check the Virustotal here: https://www.virustotal.com/de/file/bdc42fdc7a0f86f4b6e4a737249e967198ba89ed699ef4bb9b1937b88572003d/analysis/1373149197/ Just press F5 when viewing the script and type euler10alt() into the shell and tell me what the shell outputs. Please help q_q

  2. BozoHimSelf
    Date: Sun, Jul 7 2013 11:15:01

    It's pretty unrelated to the whole task you're asking for, but I'm a newbie programmer myself. And I'm wondering what Python 3 is, and really what it is used for?

  3. ChainBreak
    Date: Sun, Jul 7 2013 11:44:32

    Python is a programming language and Python 3 is the newest version of the standart interpreter IDLE.

  4. Xienix
    Date: Sun, Jul 7 2013 12:19:25

    ...@ChainBreak nothing happend so far what now? (i have no idea what am diong : P ) [SPOILER="picture..."][/SPOILER]

  5. Pixels
    Date: Sun, Jul 7 2013 12:44:21

    i would help you if i can get python to run on my mac. still trying to figure out why it doesnt >______<

  6. ChainBreak
    Date: Sun, Jul 7 2013 13:28:05

    Xienix wrote: ...@ChainBreak nothing happend so far what now? (i have no idea what am diong : P ) [SPOILER="picture..."]http://i.imgur.com/PdgtlFb.png[/SPOILER]
    It can take some time for the calculation to complete. If you can please try to keep it running. It's a rather long calculation and the result exceeds 32 bits so it can take some time. My computer took almost 2 hours to calculate untill 500 000 and the calculation needs to be done untill 2 000 000. Also the calculation always takes longer with higher numbers =\

  7. Xienix
    Date: Sun, Jul 7 2013 13:49:55

    ChainBreak wrote: It can take some time for the calculation to complete. If you can please try to keep it running. It's a rather long calculation and the result exceeds 32 bits so it can take some time. My computer took almost 2 hours to calculate untill 500 000 and the calculation needs to be done untill 2 000 000. Also the calculation always takes longer with higher numbers =\
    let's start over again then :P

  8. ChainBreak
    Date: Sun, Jul 7 2013 15:44:14

    Xienix wrote: let's start over again then :P
    Thanks a lot Xienix T_T

  9. webspider
    Date: Sun, Jul 7 2013 17:18:22

    Your algorithm fucking sucks. Project Euler is about coming up with efficient solutions that take one or two minutes maximum on a weak CPU. Also, use some pastebin (preferably not pastebin.com because it's cancer) instead of mediafire >_>

  10. Awesome
    Date: Sun, Jul 7 2013 17:20:07

    http://answers.yahoo.com/question/index?qid=20090521080827AAlCb3J ?

  11. nateiskewl
    Date: Sun, Jul 7 2013 17:47:31

    Dude, just make a list of integers 2 through 2 million, run it through the sieve of Eratosthenes, and use sum() on the list you get.

  12. ChainBreak
    Date: Sun, Jul 7 2013 17:49:06

    nateiskewl wrote: Dude, just make a list of integers 2 through 2 million, run it through the sieve of Eratosthenes, and use sum() on the list you get.
    That's what is in the code.

  13. ChainBreak
    Date: Sun, Jul 7 2013 17:52:42

    webspider wrote: Your algorithm fucking sucks. Project Euler is about coming up with efficient solutions that take one or two minutes maximum on a weak CPU. Also, use some pastebin (preferably not pastebin.com because it's cancer) instead of mediafire >_>
    I didn't learn a lot about making code more efficient yet. All I learned is writing the program for a problem. My teacher in school thouht it unnecessary since we had a server that did the calculations. Since I dont have access to the server atm it's difficult for me to write efficient code since I dont know what is faster compared to what.

  14. nateiskewl
    Date: Sun, Jul 7 2013 17:56:49

    ChainBreak wrote: That's what is in the code.
    Are you sure there isn't something slowing it down a bunch? When I did this problem, that method took like 20 seconds on a pretty average computer. EDIT: I just took a look at my code and it runs in like 2 seconds. What I did was create a list of 2000000 booleans set to True and then use the sieve on the indices, setting all of the booleans that the sieve eliminates to False.

  15. webspider
    Date: Sun, Jul 7 2013 18:31:34

    True, togglng a list of booleans is a lot more efficient than adding larger and larger numbers every time to a sum. If you have no idea how efficient an algorithm is, learn about o-notation, find out what the typical algorithms are and use introspection and timing to actually measure shit instead of assuming weird things and optimizing blindly.

  16. Xienix
    Date: Sun, Jul 7 2013 18:33:08

    @ChainBreak nothing happend after 4/5 hours...should i quit?

  17. ChainBreak
    Date: Sun, Jul 7 2013 19:00:48

    could you take a look at this: http://de.pastebin.ca/2420152 I used this code to create a list of True s, but when I want to use it the shell tells me that it's not a list, but a function.

  18. ChainBreak
    Date: Sun, Jul 7 2013 19:01:32

    Xienix wrote: @ChainBreak nothing happend after 4/5 hours...should i quit?
    Yeah I'll try to rewrite the code. But thanks for your help <3

  19. Xienix
    Date: Sun, Jul 7 2013 19:13:00

    ChainBreak wrote: Yeah I'll try to rewrite the code. But thanks for your help <3
    you're welcome :)

  20. MightAsWellGG
    Date: Tue, Jul 9 2013 13:23:35

    Are you learning Python in your school? Is it your first language? Also, I think you're the same age as me but I dunno. Are you 16? I might be able to help even though I don't know python lel; the problem is that I'm in Korea atm and this computer isn't mine to install a bunch of shit

  21. ChainBreak
    Date: Tue, Jul 9 2013 18:19:59

    MightAsWellGG wrote: Are you learning Python in your school? Is it your first language? Also, I think you're the same age as me but I dunno. Are you 16? I might be able to help even though I don't know python lel; the problem is that I'm in Korea atm and this computer isn't mine to install a bunch of shit
    I learned in school, but only 1/2 a year was dedicated to upper level programming. The rest was theory, low level programming, hardware and that stuff. It's my first language and atm I'm trying to get back into programming a bit to be able to peform better at uni. I don't have that much time atm though, because I work fulltime untill september.

  22. ChainBreak
    Date: Sat, Jul 13 2013 21:00:53

    I'm almost done with the fine-tuning! The link: http://www.python-forum.de/pastebin.php?mode=view&s=371 Still need to fix some minor stuff, but the calculation now takes 22 secs. Thanks to @webspider for recommending the Python forum. Though I only started working on it today since I lacked time because of work. u_u'