Enigmatic Code

Programming Enigma Puzzles

Enigma 1261: It’s all Greek to us

From New Scientist #2417, 18th October 2003 [link]

In the following addition sum digits have been consistently replaced by letters, with different letters used for different digits: Our alphabet has 26 characters whereas the Greek alphabet has only 24. Appropriately enough, ALPHABET is divisible by both 26 and 24. Also we can tell you that the third Greek letter GAMMA is divisible by 3.

Enigma 1261

Find DELEGATE.

[enigma1261]

Advertisements

4 responses to “Enigma 1261: It’s all Greek to us

  1. Jim Randell 23 January 2015 at 8:42 am

    This puzzle can be solved using the SubstitutedSum() solver from the enigma.py (which is generally faster than using itertools.permutations() to consider all possible permutations of letters to number assignments). This Python program runs in 74ms.

    from enigma import SubstitutedSum, lcm, printf
    
    # divisor for ALPHABET
    X = lcm(24, 26)
    
    # create the puzzle
    p = SubstitutedSum(['ALPHA', 'BETA', 'GAMMA'], 'DELTA')
    
    # solve it
    for s in p.solve():
      # GAMMA is divisible by 3
      GAMMA = int(p.substitute(s, 'GAMMA'))
      if GAMMA % 3 > 0: continue
      # ALPHABET is divisible by 24 and 26 (X = lcm(24, 26))
      ALPHABET = int(p.substitute(s, 'ALPHABET'))
      if ALPHABET % X > 0: continue
      # solution
      DELEGATE = p.substitute(s, 'DELEGATE')
      printf("DELEGATE={DELEGATE} [{s}, GAMMA={GAMMA}, ALPHABET={ALPHABET}]", s=p.substitute(s, p.text))
    

    Solution: DELEGATE = 80601540.

    The correct sum is: 56375 + 9045 + 15225 = 80645.

  2. Naim Uygun 23 January 2015 at 9:35 am
    from itertools import permutations
    #It is obvious that A can not be zero, it must be 5
    a='5'
    for w  in permutations("987643210",9):
        l,p,h,b,e,t,g,m,d =w
    
        gamma=g+a+m+m+a
        if int(gamma)%3 != 0: continue
        
        alpha="".join((a,l,p,h,a))
        beta="".join((b,e,t,a))
    
        total=int(alpha)+int(beta)+int(gamma)
    
        delta="".join((d,e,l,t,a))
           
        if total != int(delta) : continue
        
        alphabet="".join((alpha,b,e,t))
    
        #The LCM(24,26)=312
        if int(alphabet)% 312 != 0 : continue
    
        delegate="".join((d,e,l,e,g,a,t,e))
        
        print("Answer: DELEGATE=",delegate)
        print("ALPHA=",alpha,"BETA=",beta,"GAMMA=",gamma)
        print("DELTA=",delta)
        print("ALPHABET=",alphabet)
        break
       
    
    • geoffrounce 23 January 2015 at 12:14 pm
      a = '5'   # a must be 5 for equation to work
      from itertools import permutations
      for p in permutations('1234567890',2):
          g,m = p
          if g == '0': continue
          gamma = int(g + a + m + m + a)
          if gamma % 3 == 0: 
              dig_left = set('1234567890').difference(set((g,m)))
              for q in permutations(dig_left,7):
                  l,p,h,b,e,d,t = q
                  alpha = int(a + l + p + h + a)
                  if b == '0': continue
                  beta = int(b + e + t + a)
                  if d == '0': continue
                  delta = int(d + e + l + t + a)
                  if alpha + beta + gamma == delta:
                      alphabet = int(a + l + p + h + a + b + e + t)
                      if alphabet % 24 == 0 and alphabet % 26 == 0:
                          delegate = int(d + e + l + e + g + a + t + e)
                          print('ALPHA={},BETA={},GAMMA={},DELTA={}' \
                                .format(alpha,beta,gamma,delta))
                          print('DELEGATE={}'.format(delegate))
      
  3. Jim Randell 25 January 2015 at 10:41 am

    Here’s an alternative solution that starts by looking at possible values for ALPHABET. It runs in 57ms.

    from enigma import lcm, irange, divc, divf, printf
    
    # possible digits (as strings)
    ds = set('0123456789')
    
    # from inspection A is 5
    A = '5'
    
    # ALPHABET must be a multiple of lcm(24, 26)
    m = lcm(24, 26)
    
    # consider possible values for ALPHABET
    for i in irange(divc(int(A) * 10000000, m), divf((int(A) + 1) * 10000000 - 1, m)):
      ALPHABET = str(i * m)
      # check the string matches the pattern
      if ALPHABET[4] != A: continue
      ds1 = ds.difference(ALPHABET)
      if len(ds1) != 3: continue
      (_, L, P, H, _, B, E, T) = ALPHABET
      if B == '0': continue
      # choose D from the remaining digits
      for D in ds1:
        if D == '0': continue
        # calculate GAMMA
        ALPHA = int(ALPHABET[:5])
        BETA = int(B + E + T + A)
        DELTA = int(D + E + L + T + A)
        gamma = int(DELTA) - int(ALPHA) - int(BETA)
        # check GAMMA matches the pattern
        if not(9999 < gamma < 100000 and gamma % 3 == 0): continue
        (G, A1, M, M1, A2) = GAMMA = str(gamma)
        if not(A == A1 == A2 and M == M1): continue
        ds2 = ds1.difference((D, G, M))
        if len(ds2) != 0: continue
    
        DELEGATE = D + E + L + E + G + A + T + E
        printf("DELEGATE={DELEGATE} [ALPHABET={ALPHABET} ALPHA={ALPHA} BETA={BETA} GAMMA={gamma} DELTA={DELTA}]")
    

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: