Enigmatic Code

Programming Enigma Puzzles

Enigma 385: A multiletteral problem

From New Scientist #1534, 13th November 1986 [link]

In the following multiplication sum letters have been substituted for most of the digits.

enigma-385

Write out the whole multiplication sum.

[enigma385]

Advertisements

2 responses to “Enigma 385: A multiletteral problem

  1. Jim Randell 24 February 2017 at 7:48 am

    We can use the general alphametic solver (SubstitutedExpression()) in the enigma.py library to tackle this problem.

    Here is the run file. It executes in 158ms.

    # consider the multiplication sum:
    #
    #     A B C D
    #         f p
    #   ---------
    #   g k b f p
    #   p g b f
    #   ---------
    #   y m f p p
    #   ---------
    
    # solver to use
    SubstitutedExpression
    
    # solver parameters
    --symbols="bfgkmpyABCD"
    --distinct="bfgkmpy"
    
    # expressions to solve
    "ABCD * fp = ymfpp"
    "ABCD * p = gkbfp"
    "ABCD * f = pgbf"
    

    Solution: The correct sum is: 2031 × 48 = 97488.

    enigma-385-solution

  2. geoffrounce 8 January 2018 at 8:51 am
    % 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:b; var 0..9:f; var 0..9:g; var 0..9:k; 
    var 0..9:m; var 0..9:p; var 0..9:y;  
    
    constraint alldifferent([b,f,g,k,m,p,y]);
    constraint A>0 /\ f>0 /\ p>0 /\ y>0 /\g>0 ;
    
    var 1000..9999: ABCD = 1000*A + 100*B + 10*C + D;
    var 10..99: fp = 10*f + p;
    var 10000..99999: ymfpp = 10000*y + 1000*m + 100*f + 11*p;
    var 10000..99999: gkbfp = 10000*g + 1000*k + 100*b + 10*f + p;
    var 1000..9999: pgbf = 1000*p + 100*g + 10*b + f;
    
    constraint ABCD * fp = ymfpp /\ ABCD * p = gkbfp /\ ABCD * f = pgbf;
    
    solve satisfy;
    output [ show(ABCD) ++ " X " ++ show(fp) ++ " = " ++ show(ymfpp) ];
    
    % 2031 X 48 = 97488
    % -----------------
    % Finished in 71msec
    

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: