Enigmatic Code

Programming Enigma Puzzles

Enigma 372: Letter by letter

From New Scientist #1521, 14th August 1986 [link]

In this division sum, each letter stands for a different digit.

enigma-372

Rewrite the sum with letters replaced by digits.

[enigma372]

Advertisements

9 responses to “Enigma 372: Letter by letter

  1. Jim Randell 25 November 2016 at 8:13 am

    We can solve this puzzle using the SubstitutedDivision() solver in the enigma.py library. Here’s the run file:

    #!/usr/bin/env python -m enigma -r
    
    # solver to use
    SubstitutedDivision
    
    # the division sum
    "bjjhd / fef = aeg"
    
    # the intermediate subtraction sums
    "bjj - fef = abh"
    "abhh - afhc = cjb"
    "cjbd - cjbd = 0"
    

    Or we can use the SubstitutedExpression solver (also in the enigma.by library). Here’s the run file for that:

    #!/usr/bin/env python -m enigma -r
    
    # solver to use
    SubstitutedExpression
    
    --symbols="abcdefghj"
    
    # the division sum
    "fef * aeg = bjjhd"
    
    # the multiples
    "a * fef = fef"
    "e * fef = afhc"
    "g * fef = cjbd"
    
    # the intermediate subtraction sums
    "bjj - fef = abh"
    "abhh - afhc = cjb"
    

    Either way we get the same answer in about the same time (96ms for SubstitutedDivision, 92ms for SubstitutedExpression).

    Solution: The sum with numbers substituted for letters is 50078 ÷ 343 = 146:

    enigma-372-solution

  2. Hugh Casement 25 November 2016 at 8:31 am

    Once again I’m moved to say how little imagination is shown by those who set such puzzles with a random jumble of letters.  My favourite in this case is MUM × GIN = BOOZY.  Anyone who finds that sexist or otherwise offensive is welcome to suggest an alternative.

    • Brian Gladman 1 December 2016 at 7:54 pm

      My complaint about this, Hugh, is not that it is sexist but that it’s not alphametic (good try though!).

      • Hugh Casement 2 December 2016 at 7:52 am

        Oh, I wonder what went wrong there!  Perhaps my division was faulty.

        • Hugh Casement 2 December 2016 at 8:05 am

          Does this work?  Last two lines TOBY, top line JUG ?

          • Brian Gladman 2 December 2016 at 8:36 am

            I am not sure of the change you want to make here, Hugh. I just noticed that mapping MUM x GIN = BOOZY onto 343 x 146 = 50078 makes both U and I equal to 4, which means it is not a (normal) alphametic. I haven’t looked for meaningful words that make this sum correct.

            • Hugh Casement 3 December 2016 at 8:22 am

              I’m evidently not very good at expressing myself.  Divide MUM into BOOZY to get the quotient JUG.  G × MUM = TOBY, subtracted in the last step to give no remainder.
              For equality, no doubt something could be found to fit DAD as divisor.

              I now see where the GIN came from.  My pen sputtered when I copied down the puzzle, so that aeg came out as acg.  My word-matching program then did its best, and I didn’t check the arithmetic.  Sorry sorry.

        • Jim Randell 2 December 2016 at 8:05 am

          The middle letters of MUM and GIN would have to be the same, so “MUM × GUN = BOOZY” which isn’t as satisfying. Maybe “PIP × GIN = BOOZY”.

  3. geoffrounce 13 October 2017 at 10:11 am
    % A Solution in MiniZinc
    include "globals.mzn";
    %
    %               aeg
    %         -----------
    %     fef ) bjjhd
    %           fef
    %           ------
    %           abhh
    %           afhc
    %           -----
    %            cjbd
    %            cjbd
    %            ----
     
    var 0..9:a;  var 0..9:e;  var 0..9:g;  var 0..9:f;
    var 0..9:b;  var 0..9:j;  var 0..9:h;  var 0..9:d;   
    var 0..9:c;   
     
    constraint alldifferent([a,e,g,f,b,j,h,d,c])
    /\ a > 0 /\ f > 0 /\ b > 0 /\ c > 0;
    
    var 100..999 : fef = 100*f + 10*e + f;
    var 100..999 : aeg = 100*a + 10*e + g;
    var 100..999 : abh = 100*a + 10*b + h;
    var 100..999 : bjj = 100*b + 10*j + j;
    var 100..999 : cjb = 100*c + 10*j + b;
    
    var 1000..9999 : abhh = 1000*a + 100*b + 10*h + h;
    var 1000..9999 : afhc = 1000*a + 100*f + 10*h + c;
    var 1000..9999 : cjbd = 1000*c + 100*j + 10*b + d;
    var 10000..99999 : bjjhd = 10000*b + 1100*j + 10*h + d;
    
    constraint aeg * fef == bjjhd;
    constraint a * fef == fef;
    constraint e * fef == afhc;
    constraint g * fef == cjbd;
    
    constraint bjj - fef == abh;
    constraint abhh - afhc == cjb;
    
    solve satisfy;
    
    output [ "Sum is " ++ show(bjjhd) ++ " / " ++ show(fef) ++ " = " ++ show(aeg) ] ++
    ["\nabhh = " ++ show(abhh) ++ ", "  ++ "afhc = " ++ show(afhc) ++ ", " ++ "cjbd = " ++ show(cjbd) ];
    
    % Sum is 50078 / 343 = 146
    % abhh = 1577, afhc = 1372, cjbd = 2058
    % Finished in 76msec
    
    

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: