The Project Euler thread

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • benguino
    Kawaii Desu Ne?
    • Dec 2007
    • 4185

    #256
    Re: The Project Euler thread

    Decided to start doing this again. Going to start from the beginning because I know when I first started my solutions were crap. I used my favorite programming language for this one:


    Some actual code:

    Code:
    /*
    * We use the fact that 3+6+9+12+... = 3(1+2+3+..) from which we can
    * use the n(n+1)/2 formula for the sum of the first n positve integers
    */
           int a = 999/3; //number of multiples of 3 less than 1000
           int b = 999/5; //number of multiples of 5 less than 1000
           int c = 999/15; //number of multiples of 15 less than 1000
           System.out.println(3*(a)*(a+1)/2+5*(b)*(b+1)/2-15*(c)*(c+1)/2);

    AMA: http://ask.fm/benguino

    Not happening now! Don't click to join!



    Originally posted by Spenner
    (^)> peck peck says the heels
    Originally posted by Xx{Midnight}xX
    And god made ben, and realized he was doomed to miss. And said it was good.
    Originally posted by Zakvvv666
    awww :< crushing my dreams; was looking foward to you attempting to shoot yourself point blank and missing

    Comment

    • benguino
      Kawaii Desu Ne?
      • Dec 2007
      • 4185

      #257
      Re: The Project Euler thread

      Ok, screw the whole going in order thing, I'm just going to do problems I haven't done yet haha. This was a nice paper-n-pencil-n-calculator one as well :) Level 1 get.
      AMA: http://ask.fm/benguino

      Not happening now! Don't click to join!



      Originally posted by Spenner
      (^)> peck peck says the heels
      Originally posted by Xx{Midnight}xX
      And god made ben, and realized he was doomed to miss. And said it was good.
      Originally posted by Zakvvv666
      awww :< crushing my dreams; was looking foward to you attempting to shoot yourself point blank and missing

      Comment

      • rushyrulz
        Digital Dancing!
        FFR Simfile Author
        FFR Music Producer
        • Feb 2006
        • 12985

        #258
        Re: The Project Euler thread

        I tend to just brute force everything :/







        Comment

        • stargroup100
          behanjc & me are <3'ers
          FFR Simfile Author
          FFR Music Producer
          • Jul 2006
          • 2051

          #259
          Re: The Project Euler thread

          Originally posted by rushyrulz
          I tend to just brute force everything :/
          *solution to problem nine*
          if you haven't done these kinds of problems with pencil/paper you should try it

          the first time you realize how to do it it's quite enlightening and exciting
          Rhythm Simulation Guide
          Comments, criticism, suggestions, contributions, etc. are all welcome.

          Piano Etude Demon Fire sheet music

          Comment

          • leonid
            I am leonid
            FFR Simfile Author
            FFR Music Producer
            • Oct 2008
            • 8080

            #260
            Re: The Project Euler thread

            pencil&paper will only get you so far



            Proud member of Team No

            Comment

            • Reincarnate
              x'); DROP TABLE FFR;--
              • Nov 2010
              • 6332

              #261
              Re: The Project Euler thread

              Not every problem can be done with pencil and paper.

              Comment

              • leonid
                I am leonid
                FFR Simfile Author
                FFR Music Producer
                • Oct 2008
                • 8080

                #262
                Re: The Project Euler thread



                Rubix sent me to solve this

                A bit of paperwork and then lots of wolframalpha



                Proud member of Team No

                Comment

                • Reincarnate
                  x'); DROP TABLE FFR;--
                  • Nov 2010
                  • 6332

                  #263
                  Re: The Project Euler thread

                  Nicely done

                  Comment

                  • stargroup100
                    behanjc & me are <3'ers
                    FFR Simfile Author
                    FFR Music Producer
                    • Jul 2006
                    • 2051

                    #264
                    Re: The Project Euler thread

                    sorry I should've been more clear

                    I was referring to problem nine specifically, involving pythagorean triples
                    Rhythm Simulation Guide
                    Comments, criticism, suggestions, contributions, etc. are all welcome.

                    Piano Etude Demon Fire sheet music

                    Comment

                    • rushyrulz
                      Digital Dancing!
                      FFR Simfile Author
                      FFR Music Producer
                      • Feb 2006
                      • 12985

                      #265
                      Re: The Project Euler thread

                      brute forcing 12 and it's not going so well. I'm almost an hour in and still no solution.
                      Code:
                      The sequence of triangle numbers is generated by adding the natural numbers. 
                      So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:
                      
                      1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
                      
                      Let us list the factors of the first seven triangle numbers:
                      
                       1: 1
                       3: 1,3
                       6: 1,2,3,6
                      10: 1,2,5,10
                      15: 1,3,5,15
                      21: 1,3,7,21
                      28: 1,2,4,7,14,28
                      We can see that 28 is the first triangle number to have over five divisors.
                      
                      What is the value of the first triangle number to have over five hundred divisors?
                      In hindsight, I probably would have used a much more efficient factor breakdown algorithm had I known it would take this long.
                      Last edited by rushyrulz; 05-21-2014, 05:34 PM.


                      Comment

                      • Reincarnate
                        x'); DROP TABLE FFR;--
                        • Nov 2010
                        • 6332

                        #266
                        Re: The Project Euler thread

                        using brute force = not very interesting

                        usually more fun to try for the faster approaches

                        Comment

                        • rushyrulz
                          Digital Dancing!
                          FFR Simfile Author
                          FFR Music Producer
                          • Feb 2006
                          • 12985

                          #267
                          Re: The Project Euler thread

                          I'm sure there's a very elegant mathematical solution for all of these, but I'm just trying to get as far as I can :P


                          Comment

                          • stargroup100
                            behanjc & me are <3'ers
                            FFR Simfile Author
                            FFR Music Producer
                            • Jul 2006
                            • 2051

                            #268
                            Re: The Project Euler thread

                            I did the first 30 (excluding 12) and even a couple of the 300+ ones before I figured out 12. I don't know why but that one was hard for me
                            Rhythm Simulation Guide
                            Comments, criticism, suggestions, contributions, etc. are all welcome.

                            Piano Etude Demon Fire sheet music

                            Comment

                            • rushyrulz
                              Digital Dancing!
                              FFR Simfile Author
                              FFR Music Producer
                              • Feb 2006
                              • 12985

                              #269
                              Re: The Project Euler thread

                              Probably since there are so many different things you need to account for in 12. Not only do you need a gigantic 500+ factor number, but it also needs to be a summation of n number which is tricky to check for.


                              Comment

                              • Guest15937
                                One-handed elite
                                • May 2008
                                • 1464

                                #270
                                Re: The Project Euler thread

                                My brute force of 12 took 15 seconds to run.
                                The renegade has betrayed me.

                                Comment

                                Working...