• Lucid Dreaming - Dream Views




    Results 1 to 6 of 6

    Thread: Halp! (Python)

    Threaded View

    1. #1
      Ehh..Well..Uhm...HUGS!
      Join Date
      Dec 2008
      Gender
      Location
      Netherlands
      Posts
      842
      Likes
      0

      Halp! (Python)

      Hi guys.
      So here's the story, I'm trying to solve this problem with a python script. (I feel like I'm advertising, I've already posted links to Euler three times now)

      So here's my brute-force, inefficient script:
      Spoiler for Brute Force:

      I've ran in once, and it wasn't the right answer, but the script should be right. I've checked with printing all the stuff, and that checks out.

      So after a night's sleep I decided to optimize:
      Spoiler for So-called optimized:

      I hope you can see what I did there. If I've already got one coin of 100p, my maximum for getting 200p while adding 50p coins is 2, or 4-2*g, thus making the making the maximum value for f smaller.

      Thing is, this just returns "Total: 1". What's wrong with my code?

      P.S: Everything is, actually indented properly. Python editor does it automatically after a colon.
      Finally, I'm NOT asking you to give me the answer, that would ruin the fun.

      EDIT: I've ran the brute force, just with m instead of four. It wasn't the right answer. Trying again without m. (That means it'll make about a bazillion loops). 2*4*10*20*40*100*200=1.28e9 to be exact. Dang.

      *edited*
      added code tags to preserve indentation (bloody python....)
      Ynot
      Last edited by Ynot; 06-21-2009 at 06:42 PM.
      http://i96.photobucket.com/albums/l199/ablativus/spidermansig2.png

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •