Enigmatic Code

Programming Enigma Puzzles

Enigma 1358: Five fives

From New Scientist #2517, 17th September 2005

You might think there is something wrong with the addition sum shown below, but in fact each of the five numbers shown in the sum is in a different base.

Enigma 1358

All five numbers are even and the given total at the bottom is less than 100,000.

What is that total?



3 responses to “Enigma 1358: Five fives

  1. Jim Randell 4 January 2014 at 9:08 am

    This is a relatively straightforward puzzle, but I think it would act as a good introductory puzzle for someone just starting to do Enigmas.

    This Python program runs in 33ms.

    from itertools import count, combinations
    from enigma import concat, printf
    # find 11101 in various bases
    # (we only need to consider odd bases as the numbers are even)
    ns = list()
    for b in count(3, step=2):
      n = int('11101', base=b)
      if not(n < 100000): break
      printf("[b={b} n={n}]")
    # find 4 of the numbers that sum to a fifth
    for s in combinations(ns[:-1], 4):
      n = sum(s)
      if n in ns:
        printf("{s} = {n}", s=concat(*s, sep=' + '))

    Solution: The total of the sum is 88724 (in base 10, in the puzzle it is written in base 17).

    • Naim Uygun 4 January 2014 at 12:07 pm
      # the bases are 5,7,13,15,17
      # 776 + 2794 + 30928 + 54226 = 88724
      from itertools import combinations
      for a,b,c,d,e in combinations(range(2,20),5):
        if max(a,b,c,d,e)==e :
           n5= int('11101', base=e)
           if  n5 < 100000 :
              n1=int('11101', base=a)
              n2=int('11101', base=b)
              n3=int('11101', base=c)
              n4=int('11101', base=d)
              if t==n5:
                  print("The bases are ",a,b,c,d,e)
      input("THE END")
      • Brian Gladman 7 January 2014 at 11:11 pm

        Hi Naim,

        I thought that you might be interested to know that your line

        if max(a, b, c, d, e) == e:

        is not neccsary because combinations are returned in (lexicographic) order whenever the input is in this order. In your use this means that the test is not necessary since e will always be the largest of a, b, c, d and e.


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: