Thread: 2d Array and a SegFault

  1. #16
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    You're probably better at math than I am. I heard of this technique a long time ago; I don't remember where. I didn't know what it was called so I just googled "how to solve a sequence" and the page I linked above was the first result.

    It does seem kind of magical. The math behind it is probably quite interesting. Try googling "method of common differences". If you find an explanation, let me know.

    As for why it generates the FITs, I don't know. I just tried the technique on paper for the n-cubed example and it worked, so I implemented it for the question and got the right answer.

    And note that for "project euler" (and similar) type of questions, there's often some kind of trick to simplify the algorithm. If you find yourself resorting to 3rd-party libraries or 300 lines of code or an hour of running time then you've probably missed it. At first problem 101 seemed extremely difficult until I remembered that trick.

  2. #17
    Registered User
    Join Date
    Feb 2016
    Posts
    18
    Well I've found my new project! I'm determined to figure out how this produces FITs.

    My (eventual) solution can be described here: Polynomial interpolation - Wikipedia, the free encyclopedia

    In 101, the term "optimum polynomial generating function" can be replaced by "interpolated polynomial". We then solve the system of linear equations to find the coefficients of the polynomial. If the polynomial, p(x), is n-th degree, p(n+2) should produce a FIT, that is if we haven't interpolated our actual generating function.

    FYI, my project euler friend key: 991422_dRFnAZHkfV29mg6TvcBDKseBtFFUn1g8
    Last edited by John...; 08-31-2016 at 12:45 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SegFault Help!
    By Giorgos Prapas in forum C Programming
    Replies: 4
    Last Post: 12-14-2015, 01:01 PM
  2. Segfault... Why?
    By jonheese in forum C Programming
    Replies: 14
    Last Post: 11-21-2011, 06:02 PM
  3. Segfault
    By astral in forum C Programming
    Replies: 8
    Last Post: 06-18-2011, 11:20 PM
  4. Reading a txt file into an array: unexpected segfault
    By pistacchio in forum C Programming
    Replies: 3
    Last Post: 05-05-2009, 04:27 PM
  5. segfault with gcc, but not with TC
    By koodoo in forum C Programming
    Replies: 15
    Last Post: 04-23-2007, 09:08 AM

Tags for this Thread