The Project Euler thread

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • emerald000
    the Mathemagician~
    • Nov 2005
    • 1320

    #16
    Re: THE project euler thread

    Let's take f(95). Its 100 digits are: (note my program counts backwards)

    7, 2, 5, 5, 6, 0, 8, 3, 0, 6, 9, 0, 2, 1, 7, 8, 4, 8, 6, 5, 3, 9, 4, 2, 0, 6, 4, 2, 7, 7, 1, 8, 0, 0, 2, 7, 5, 0, 0, 0, 5, 7, 1, 9, 9, 1, 3, 0, 1, 9, 4, 7, 3, 3, 0, 0, 9, 3, 8, 5, 2, 5, 2, 9, 9, 2, 0, 0, 6, 9, 9, 8, 9, 9, 1, 3, 1, 4, 8, 3, 8, 6, 0, 9, 3, 6, 9, 8, 0, 8, 4, 4, 3, 4, 9, 7, 6, 4, 7, 9


    which gives a sum of 459. The 101st decimal is a 6, so if rounded up the 7, you would get to your answer of 460.

    And yes the problem isn't clear, but thanks to the example, you can understand they mean to have 100 significant digits.

    Comment

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

      #17
      Re: THE project euler thread

      hmm maybe I will get back into this

      seeing leonid ahead of me is making my competitive core act up (by that I mean he could kick my ass at this shit but idgaf)


      heh solved problem 68 in excel
      Last edited by Reincarnate; 11-8-2011, 09:49 AM.

      Comment

      • iironiic
        D6 FFR Legacy Player
        FFR Simfile Author
        • Jan 2009
        • 4342

        #18
        Re: THE project euler thread

        Originally posted by emerald000
        Let's take f(95). Its 100 digits are: (note my program counts backwards)

        7, 2, 5, 5, 6, 0, 8, 3, 0, 6, 9, 0, 2, 1, 7, 8, 4, 8, 6, 5, 3, 9, 4, 2, 0, 6, 4, 2, 7, 7, 1, 8, 0, 0, 2, 7, 5, 0, 0, 0, 5, 7, 1, 9, 9, 1, 3, 0, 1, 9, 4, 7, 3, 3, 0, 0, 9, 3, 8, 5, 2, 5, 2, 9, 9, 2, 0, 0, 6, 9, 9, 8, 9, 9, 1, 3, 1, 4, 8, 3, 8, 6, 0, 9, 3, 6, 9, 8, 0, 8, 4, 4, 3, 4, 9, 7, 6, 4, 7, 9


        which gives a sum of 459. The 101st decimal is a 6, so if rounded up the 7, you would get to your answer of 460.

        And yes the problem isn't clear, but thanks to the example, you can understand they mean to have 100 significant digits.
        Thanks! I just got 80 and 69 now! :)

        Comment

        • fido123
          FFR Player
          • Sep 2005
          • 4245

          #19
          Re: THE project euler thread

          I think I'm going to get started with this. Wanted to work on my programming skills. On my reading week and nobody else I know is so why not. Probably going to work in C or Perl.

          Comment

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

            #20
            Re: THE project euler thread

            Problem 96 is solving 50 sudoku problems. I'm very tempted to cheat



            Proud member of Team No

            Comment

            • danny53x
              AKA Yotipo
              • Jan 2007
              • 1008

              #21
              Re: THE project euler thread

              How do I learn this stuff and become a cool programmer like you guys ; _;

              Comment

              • TC_Halogen
                Rhythm game specialist.
                FFR Simfile Author
                FFR Music Producer
                • Feb 2008
                • 19376

                #22
                Re: THE project euler thread

                I'm interested in playing this but I have very little coding experience, haha.

                Comment

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

                  #23
                  Re: THE project euler thread

                  Good way to learn imo

                  Comment

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

                    #24
                    Re: THE project euler thread

                    Originally posted by danny53x
                    How do I learn this stuff and become a cool programmer like you guys ; _;
                    Project Euler is a set of problems that encourages the use of clever math to simplify programming problems. If you're not inherently good at math, this is gonna be really hard for you no matter how someone teaches you. (Except for the first few problems, which are pretty easy.)

                    If, on the other hand, you just want to learn programming, this is one way of starting out. At least it gives you a goal.

                    Man, I need to find more time to do this.
                    Rhythm Simulation Guide
                    Comments, criticism, suggestions, contributions, etc. are all welcome.

                    Piano Etude Demon Fire sheet music

                    Comment

                    • foilman8805
                      smoke wheat hail satin
                      FFR Simfile Author
                      • Sep 2006
                      • 5704

                      #25
                      Re: THE project euler thread

                      Thanks OP for giving me something to do with my brain while I'm in between jobs. This is awesome. I'll be programming in MATLAB/Octave. I just did the first two problems as a bit of a warm up and it was a lot of fun.

                      Problem 1
                      Code:
                      %% Euler Project - Problem 1 
                      
                      % Find the sum of all multiples of 3 or 5 below 1000. 
                      
                      sum = 0;
                      
                      for i=3:999
                          if rem(i,3) == 0 || rem(i,5) == 0
                              sum = sum + i;
                          end
                      end
                      
                      sum


                      Problem 2
                      Had to first write a function to calculate the numbers in the Fibonacci sequence given any input:
                      Code:
                      function fib = fibonacci(x)
                      
                      if x == 0
                          fib = 0;
                      elseif x == 1
                          fib = 1;
                      else
                          fib = fibonacci(x-1) + fibonacci(x-2);
                      end

                      I then implemented that function in the script file below to find the solution:
                      Code:
                      %% Euler Project - Problem 2
                      
                      % By considering the terms in the Fibonacci sequence whose values do not
                      % exceed four million, find the sum of the even-valued terms.
                      
                      % First need to find at what term the Fibonacci sequence goes over 
                      % 4 million. I created a supplimentary function file called fibonacci.m 
                      % that calculates the values of the Fibonacci sequence given an input.
                      % i.e. fibonacci(10) will output 89. 
                      
                      i = 0;
                      fib = 0;
                      
                      while fib <= 4000000
                          i = i + 1;
                          fib(i) = fibonacci(i);
                      end
                      
                      % The loop above identifies that there are 33 values in the Fibonacci sequence
                      % that don't exceed 4,000,000. Now we will add up each even term. 
                      
                      for j = 1:33
                          if rem(fib(j),2) == 0
                              sumfib(j,1) = fib(j);
                          else
                              sumfib(j,1) = 0;
                          end
                      end
                          
                      answer = sum(sumfib)
                      Last edited by foilman8805; 10-23-2011, 02:14 AM.

                      Comment

                      • foilman8805
                        smoke wheat hail satin
                        FFR Simfile Author
                        • Sep 2006
                        • 5704

                        #26
                        Re: THE project euler thread

                        Interesting, I actually had to augment the source code in MATLAB in order to do Problem 3.

                        For some reason MATLAB arbitrarily sets a limit on prime factoring numbers larger than 2^32. Opened up the factor.m and changed it to 2^50, so this solution pretty much became a one-liner.

                        Problem 3
                        Code:
                        %% Euler Project - Problem 3
                        
                        % The prime factors of 13195 are 5, 7, 13 and 29.
                        
                        % What is the largest prime factor of the number 600851475143?
                        
                        pf = factor(600851475143);
                        
                        lpf = max(pf)

                        Comment

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

                          #27
                          Re: THE project euler thread

                          hit a wall with this problem :|

                          Comment

                          • Reshiram
                            The Vast White Note
                            FFR Simfile Author
                            • May 2011
                            • 1224

                            #28
                            Re: THE project euler thread

                            I'm not gonna use programs. :3

                            Problem 1:

                            Take the smallest multiple of 3, add the largest, and multiply by 166.5.
                            Take the smallest multiple of 5, add the largest, and multiply by 99.5.
                            Subtract the sum of the common multiples.

                            Comment

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

                              #29
                              Re: THE project euler thread

                              Upon first glance, that problem looks pretty trivial. But since Rubix is having trouble with it, it must be far from that. LOL

                              I'll take a crack at it.
                              Rhythm Simulation Guide
                              Comments, criticism, suggestions, contributions, etc. are all welcome.

                              Piano Etude Demon Fire sheet music

                              Comment

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

                                #30
                                Re: THE project euler thread

                                After taking a look at the problem, here's what I have so far. (I'm sure you already figured out this much, it's all the obvious stuff.)

                                Problem 355:

                                For Co(n), let the maximal sum subset be denoted as S.
                                Each prime factor below n must be found in the factorization of exactly one term in S. As such, we can start off the problem with a base case by creating a subset of all the primes below n (and 1) and then raising each of these primes to the highest power possible to maximize the sum.

                                However, it is possible that a term has the form (p^a)(q^b), where p and q are primes, if (p^a)(q^b) > p^c + q^d. (where a,b,c,d are the highest possible powers such that each term is less than n)

                                So the problem becomes reduced to figuring out how to find all of the optimizations for the sum. Chances are, there's some pattern that can use the fact that they give you the values of Co(30) and Co(100).


                                I'll edit with more content once I figure out more. BRB FOOD LOL
                                Last edited by stargroup100; 10-23-2011, 12:33 PM.
                                Rhythm Simulation Guide
                                Comments, criticism, suggestions, contributions, etc. are all welcome.

                                Piano Etude Demon Fire sheet music

                                Comment

                                Working...