Enigmatic Code

Programming Enigma Puzzles

Enigma 1153: Luconacci numbers

From New Scientist #2309, 22nd September 2001 [link]

In the Fibonacci sequence the first two terms are 1 and 1, and each subsequent term is the sum of the previous two terms; so the sequence starts 1, 1, 2, 3, 5. Less well known is the Lucas sequence, whose first two terms are 1 and 3, and each subsequent term is the sum of the previous two terms; so the sequence starts 1, 3, 4, 7, 11. In the Tribonacci sequence (so named by Mark Feinberg) the first three terms are 1, 1 and 2, as in the Fibonacci sequence, and each subsequent term is the sum of the previous three terms; so it starts 1, 1, 2, 4, 7.

Harry, Tom and I were looking to find a 2-digit Fibonacci number, a 2-digit Lucas number and a 2-digit Tribonacci number that used six different digits. We each found a different solution; our three Fibonacci numbers were all different from each other; our three Lucas numbers were all different from each other; and our three Tribonacci numbers were all different from each other. None of the numbers in my solution appeared in either Harry’s or Tom’s solution.

List in ascending order the numbers in my solution.

[enigma1153]

Advertisements

One response to “Enigma 1153: Luconacci numbers

  1. Jim Randell 22 August 2016 at 8:47 am

    This Python program runs in 37ms.

    from itertools import product, combinations
    from enigma import join, printf
    
    # collect n-digit numbers from an (increasing) generator as strings
    def numbers(g, n=2):
      for x in g:
        t = str(x)
        m = len(t)
        if m < n: continue
        if m > n: break
        yield t
    
    # generator for fibonacci-type sequences
    def fib(*s):
      s = list(s)
      while True:
        s.append(sum(s))
        yield s.pop(0)
    
    # 2-digit fibonacci numbers
    fibs = list(numbers(fib(1, 1)))
    
    # 2-digit lucas numbers
    lucs = list(numbers(fib(1, 3)))
    
    # 2-digits tribonacci numbers
    tribs = list(numbers(fib(1, 1, 2)))
    
    # find triples consisting of 6-different digits
    ts = list()
    for (n1, n2, n3) in product(fibs, lucs, tribs):
      if len(set(n1 + n2 + n3)) == 6:
        printf("[fib={n1}, luc={n2}, trib={n3}]")
        ts.append((n1, n2, n3))
    
    # choose numbers for D, H, T
    for D in ts:
      for (H, T) in combinations(ts, 2):
        # the numbers in each category are all different
        if any(len(set(s)) < 3 for s in zip(D, H, T)): continue
        # D is disjoint from H and T
        if set(D).intersection(H + T): continue
        # output solution
        printf("D=({D}) [H/T=({H})/({T})]", D=join(D, sep=', '), H=join(H, sep=', '), T=join(T, sep=', '))
    

    Solution: The numbers in your solution are 29, 34, 81.

    The Fibonacci number is 34. The Lucas number is 29. The Tribonacci number is 81.

    Harry and Tom’s (Fibonacci, Lucas, Tribonacci) numbers are (13, 76, 24) and (89, 47, 13), but we don’t know who chose which set, but one of them chose 13 as a Fibonacci number, and one of them chose 13 as a Tribonacci number.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: