Enigmatic Code

Programming Enigma Puzzles

Enigma 536: A strange encounter

From New Scientist #1688, 28th October 1989 [link] [link]

At a Halloween party I met a strangely beautiful red-haired woman who was gazing with longing into a bonfire. To my inquiries she replied: “(My telephone number) 2 = AABCCD and the exchange is 04617. I was born in the year given by: (AE) F = EDGE”

I realised that it was one of those ‘letters-for-digits-and-digits-for-letters’ puzzles, but I must have looked confused for she added: “The other letters are HIS.” So saying she vanished into thin air.

Given that in the above relations the same letter stands for the same digit and the same digit stands for the same letter; that different digits stand for different letters and vice versa; and that 04617 stands for the place where she now resides:

Can you solve the mystery and write down the digits 0 to 9 in the alphabetical order of the letters that represent them?

[enigma536]

2 responses to “Enigma 536: A strange encounter

  1. Jim Randell 10 February 2020 at 7:47 am

    This Python program uses the [[ SubstitutedExpression() ]] solver from the enigma.py library to deal with the alphametic expressions.

    It runs in 116ms.

    Run: [ @repl.it ]

    from enigma import SubstitutedExpression, join, printf
    
    # create the alphametic puzzle
    p = SubstitutedExpression(
      [ "is_square(AABCCD)", "is_power(EDGE, F) = AE" ],
      answer="(is_square(AABCCD), (A, B, C, D, E, F, G, H, I, S))",
    )
    
    # solve the puzzle
    for (s, (number, digits)) in p.solve(verbose=0):
      # make a map of digits to symbols
      d2s = dict((str(v), k) for (k, v) in s.items())
      # output solution
      exch = join(d2s[x] for x in "04617")
      printf("exchange = {exch}, number = {number}; digits = {digits}")
    

    There are 6 ways to fill out the letters (corresponding to the different ways to assign the unused digits to the letters H, I, S), but one of them gives a satisfactory solution to the puzzle.

    Solution: The digits are: A=4, B=3, C=5, D=6, E=1, F=2, G=8, H=0, I=9, S=7.

    Using this assignment of digits to letters we find that the telephone number is: HADES 666. And the mystery woman was born in the year 1681.

  2. GeoffR 10 February 2020 at 11:19 am

    Solution is the fourth answer in the multiple output below:

    % A Solution in MiniZinc
    include "globals.mzn";
    
    var 0..9:A; var 0..9:B; var 0..9:C; var 0..9:D;
    var 0..9:E; var 0..9:F; var 0..9:G; var 0..9:H;
    var 0..9:I; var 0..9:S;
    
    constraint all_different ([A,B,C,D,E,F,G,H,I,S]);
    
    var 10..99: AE = 10*A + E;
    constraint A > 0;
    
    var 1000..9999: EDGE = 1000*E + 100*D + 10*G + E;
    constraint E > 0;
    
    var 100000..999999: AABCCD = 110000*A + 1000*B + 110*C + D;
    
    var 317..1000: TNUM;
    constraint TNUM * TNUM == AABCCD;
    
    % square root(AE) of EDGE(4 digits) must be between 32 and 99, so F == 2
    constraint F == 2 /\ AE * AE == EDGE;
    
    solve satisfy;
    
    output [ "Tel No. = " ++ show(TNUM)]
    ++ [ ", YEAR = " ++ show(EDGE)]
    ++ ["\n[A,B,C,D,E,F,G,H,I,S] =" ++ show([A,B,C,D,E,F,G,H,I,S])];
    
    % Tel No. = 666, YEAR = 1681
    % [A,B,C,D,E,F,G,H,I,S] =[4, 3, 5, 6, 1, 2, 8, 9, 7, 0]
    % ----------
    % Tel No. = 666, YEAR = 1681
    % [A,B,C,D,E,F,G,H,I,S] =[4, 3, 5, 6, 1, 2, 8, 7, 9, 0]
    % ----------
    % Tel No. = 666, YEAR = 1681
    % [A,B,C,D,E,F,G,H,I,S] =[4, 3, 5, 6, 1, 2, 8, 9, 0, 7]
    % ----------
    % Tel No. = 666, YEAR = 1681  
    % [A, B, C, D, E, F, G, H, I, S] =
    % [4, 3, 5, 6, 1, 2, 8, 0, 9, 7] << ANSWER - 04617 gives HADES  ***
    % ----------
    % Tel No. = 666, YEAR = 1681
    % [A,B,C,D,E,F,G,H,I,S] =[4, 3, 5, 6, 1, 2, 8, 7, 0, 9]
    % ----------
    % Tel No. = 666, YEAR = 1681
    % [A,B,C,D,E,F,G,H,I,S] =[4, 3, 5, 6, 1, 2, 8, 0, 7, 9]
    % ----------
    % ==========
    % Finished in 306msec
    
    

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: