The Project Euler thread

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Zageron
    Zageron E. Tazaterra
    FFR Administrator
    • Apr 2007
    • 6592

    #421
    Re: The Project Euler thread

    Haha

    Comment

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

      #422
      Re: The Project Euler thread

      Site is up, limited form

      Comment

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

        #423
        Re: The Project Euler thread

        ETA



        Proud member of Team No

        Comment

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

          #424
          Re: The Project Euler thread

          who knows

          Comment

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

            #425
            Re: The Project Euler thread

            So recently I've gotten more motivation to do smartsy stuff so I picked this up again. (unfortunately we can't have our accounts back yet, if ever)

            In any case, I'm currently working on 65. What I don't understand is how someone would go about finding a solution more rigorously.


            I tried to find a recursive method to quickly find the fraction I needed, and used a large integer "class"/object to hold the numerator and denominator.

            In (x+k+1)/(2x+2k+1), we start with k = 66, x = 1/2.
            (2*(1/2)+2*66+1)/(1/2+66+1) = x_1
            (2*(x_1)+2*64+1)/(x_1+64+1) = x_2
            (2*(x_2)+2*62+1)/(x_2+62+1) = x_3
            (2*(x_3)+2*60+1)/(x_3+60+1) = x_4
            ...
            (2*(x_32)+2*4+1)/(x_32+4+1) = x_33
            (8+3x_33)/(3+x_33) will give us our final fraction.

            Code:
            	var num = 1;
            	var denom = 1;
            	var tempnum;
            	
            	for (var k = 6; k >= 4; k=k-2) {
            		tempnum = num + (k*denom) + denom;
            		denom = (2*num) + (2*k*denom) + denom;
            		num = tempnum;
            	}
            	console.log('The fraction is ' + num + '/' + denom);
            
            	tempnum = (8*denom) + (3*num);
            	denom = (3*denom) + num;
            	num = tempnum;
            	
            	console.log('The fraction is ' + num + '/' + denom);
            I'm pretty sure this gives me the final fraction, but I can't tell whether or not this needs to be simplified, and if so, I still won't get the right answer.


            On the other hand, there's an easily recognizable pattern in the numerator: n_k = a_k * n_[k-1] + n_[k-2]

            This easily gives me the correct answer, but I can't show why this pattern holds true.

            What do?
            Rhythm Simulation Guide
            Comments, criticism, suggestions, contributions, etc. are all welcome.

            Piano Etude Demon Fire sheet music

            Comment

            • AutotelicBrown
              Under the scarlet moon
              FFR Simfile Author
              • Jan 2014
              • 923

              #426
              Re: The Project Euler thread

              If that pattern works, shouldn't you use dynamic programming?
              Last edited by AutotelicBrown; 08-8-2014, 06:28 AM.
              Play my files

              Comment

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

                #427
                Re: The Project Euler thread

                Originally posted by AutotelicBrown
                If that pattern works, shouldn't you use dynamic programming?
                That pattern is so simple it only needs like a couple lines of code. But still, what concerns me at the moment is the reasoning for this pattern, an mathematical explanation for how it works, rather than the code/solution, which already works.
                Rhythm Simulation Guide
                Comments, criticism, suggestions, contributions, etc. are all welcome.

                Piano Etude Demon Fire sheet music

                Comment

                • AutotelicBrown
                  Under the scarlet moon
                  FFR Simfile Author
                  • Jan 2014
                  • 923

                  #428
                  Re: The Project Euler thread

                  Yeah, I noticed that was the point a bit later. Anyway, I'm taking a look into it, I'll let you know if I get something.
                  Play my files

                  Comment

                  • Zapmeister
                    FFR Player
                    • Sep 2012
                    • 466

                    #429
                    Re: The Project Euler thread

                    Originally posted by stargroup100
                    On the other hand, there's an easily recognizable pattern in the numerator: n_k = a_k * n_[k-1] + n_[k-2]

                    This easily gives me the correct answer, but I can't show why this pattern holds true.
                    finding the convergents of a continued fraction using a recurrence relation is a standard result you'd find in any number theory textbook or set of lecture notes. the result you get is that both the numerator and denominator obey this recurrence.

                    to prove it, we define sequences of numbers using this relation and show that they have the properties we want using induction.

                    so for a given continued fraction [a0; (a1, a2, a3...)] (using the notation in the question) we define

                    p0 = a0
                    p1 = a0*a1 + 1
                    q0 = 1
                    q1 = a1
                    p_n = a_n*p_(n-1) + p_(n-2) and q_n = a_n*q_(n-1) + q_(n-2)

                    we want to prove

                    p_n / q_n = [a0; (a1, a2, ..., a_n)]

                    we use induction. n=0 and n=1 are boring

                    assume true for n=k then

                    [a0; (a1, a2, ..., a_(k+1))] = [a0; (a1, a2, ..., a_k + 1/a_(k+1))]

                    =
                    ( a_k + 1/a_(k+1) )*p_(k-1) + p_(k-2)
                    -------------------------------------
                    ( a_k + 1/a_(k+1) )*q_(k-1) + q_(k-2)

                    =
                    a_k*p_(k-1) + p_(k-2) + p_(k-1)/a_(k+1)
                    ----------------------------------------
                    a_k*q_(k-1) + q_(k-2) + q_(k-1)/a_(k+1)

                    =
                    p_k + p_(k-1)/a_(k+1)
                    ----------------------
                    q_k + q_(k-1)/a_(k+1)

                    =
                    a_(k+1)*p_k + p_(k-1)
                    ----------------------
                    a_(k+1)*q_k + q_(k-1)

                    = p_(k+1)/q_(k+1)

                    which completes the induction

                    finally we need to prove that these fractions p_n/q_n are irreducible

                    to do this we prove that:

                    p_n*q_(n-1) - q_n*p_(n-1) = (-1)^(n+1)

                    and you do an induction sort of like the previous one. from this it follows instantly that p_n and q_n are coprime, so these recurrences give you the fractions in lowest terms.

                    edit: does anybody know when the fuck i'll be able to log into project euler again because (1) i want to see which problems i've solved and (2) most importantly i want that dark website background back like i've always been used to using, which i can only access while logged in
                    Last edited by Zapmeister; 08-16-2014, 06:19 PM.

                    Theorem: If you have a large enough number of monkeys, and a large enough number of computer keyboards, one of them will sight-read AAA death piano on stealth. And the ffr community will forever worship it. Proof Example

                    ask me anything here

                    mashed FCs: 329

                    r1: 5
                    r2: 4
                    r3: 6
                    r4: 8
                    r5: 3
                    r6: 5
                    r7: 15
                    final position: 4th

                    Comment

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

                      #430
                      Re: The Project Euler thread

                      Originally posted by Zapmeister
                      solution
                      oh my god i feel so stupid fml
                      Rhythm Simulation Guide
                      Comments, criticism, suggestions, contributions, etc. are all welcome.

                      Piano Etude Demon Fire sheet music

                      Comment

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

                        #431
                        Re: The Project Euler thread

                        aaaaaaaaaaaaaaaaaaand live

                        Comment

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

                          #432
                          Re: The Project Euler thread

                          \o/



                          Proud member of Team No

                          Comment

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

                            #433
                            Re: The Project Euler thread

                            thread revive







                            Comment

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

                              #434
                              Re: The Project Euler thread

                              This thread needs more action

                              New problem up in 2.5 hours
                              Last edited by Reincarnate; 03-7-2015, 06:36 PM.

                              Comment

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

                                #435
                                Re: The Project Euler thread



                                I'm too stupid I don't have a sufficient math foundation to do stuff over 50 probably.
                                Last edited by rushyrulz; 03-7-2015, 07:58 PM.


                                Comment

                                Working...