Enigmatic Code

Programming Enigma Puzzles

Puzzle 8: Division (letters for digits)

From New Scientist #1059, 7th July 1977 [link]

In the following division sum each letter stands for a different digit:

Re-write the sum with the letters replaced by digits.

[puzzle8]

2 responses to “Puzzle 8: Division (letters for digits)

  1. Jim Randell 11 December 2019 at 8:25 am

    The [[ SubstitutedDivision() ]] solver from the enigma.py library can be used to solve this puzzle.

    The following run file executes in 146ms.

    Run: [ @repl.it ]

    #!/usr/bin/env python -m enigma -r
    
    SubstitutedDivision
    
    "HMMXM / YH = ATP"
    
    "HMM - HXD = K"
    ""
    "KXM - HPX = KX"
    

    Solution: The correct division sum is: 32212 ÷ 53 = 607 (remainder 41).

  2. GeoffR 11 December 2019 at 9:08 pm
    % A Solution in MiniZinc
    
    %           A T P            6 0 7
    %       ---------       ----------
    %  Y H )H M M X M    5 3)3 2 2 1 2
    %       H X D            3 1 8
    %       -----            -----
    %           K X M            4 1 2
    %           H P X            3 7 1
    %           -----            -----
    %             K X              4 1
    %           -----            -----
    
    include "globals.mzn";
    
    var 1..9:Y; var 1..9:H; var 1..9:A; var 0..9:T;
    var 0..9:P; var 0..9:M; var 0..9:X; var 0..9:D;
    var 1..9:K;
    
    var 10..99: YH = 10*Y + H;
    var 10..99: KX = 10*K + X;
    
    var 100..999: ATP = 100*A + 10*T + P;
    var 100..999: HXD = 100*H + 10*X + D;
    var 100..999: KXM = 100*K + 10*X + M;
    var 100..999: HPX = 100*H + 10*P + X;
    var 100..999: HMM = 100*H + 10*M + M;
    
    var 10000..99999: HMMXM = 10000*H + 1000*M + 100*M + 10*X + M;
    
    % Partial products and subtractions
    constraint YH * ATP == HMMXM - KX;
    constraint A * YH == HXD /\ HMM - HXD == K;
    constraint P * YH == HPX /\ KXM - HPX == KX;
    
    solve satisfy;
    
    % Y = 5;  H = 3;  A = 6;
    % T = 0;  P = 7;  M = 2;
    % X = 1;  D = 8;  K = 4;
    % ----------
    % ==========
    % Finished in 333msec
    
    
    
    

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: