Enigmatic Code

Programming Enigma Puzzles

Enigma 1607: England 1, Germany 4

From New Scientist #2772, 7th August 2010 [link]

At the football World Cup in South Africa, the England team lost to Germany 1-4 and so was eliminated from the tournament.

In the equations below, each of the integers 1 to 9 has been replaced consistently by a different letter, in such a way that:

(E×N×G×L×A×N×D) / (G×E×R×M×A×N×Y) = 1 / 4

and

(E+N+G+L+A+N+D) – (G+E+R+M+A+N+Y) = 1 – 4.

What is the numerical value of A+N+G+L+E+D?

[enigma1607]

Advertisements

2 responses to “Enigma 1607: England 1, Germany 4

  1. jimrandell 4 January 2012 at 4:16 pm

    The following Python program runs in 32ms.

    from itertools import combinations
    from enigma import multiply, irange, printf
    
    # eliminating common terms we get:
    # R+M+Y - L+N+D = 3
    # 4xLxNxD = RxMxY
    
    d1 = set(irange(1, 9))
    for LND in combinations(d1, 3):
      pLND = multiply(LND)
      sLND = sum(LND)
    
      d2 = d1.difference(LND)
      for RMY in combinations(d2, 3):
        pRMY = multiply(RMY)
        sRMY = sum(RMY)
    
        if sRMY - sLND != 3: continue
        if 4 * pLND != pRMY: continue
    
        AGE = d2.difference(RMY)
        sANGLED = sum(AGE) + sLND
    
        printf("LND={LND} pLND={pLND} sLND={sLND} RMY={RMY} pRMY={pRMY} sRMY={sRMY} AGE={AGE} sANGLED={sANGLED}")
    

    Solution: A+N+G+L+E+D = 28.

  2. geoffrounce 19 November 2017 at 8:22 pm
    % A Solution in MiniZinc
    include "globals.mzn";
    
    var 1..9:E;  var 1..9:N;  var 1..9:G;  var 1..9:L;  var 1..9:A;
    var 1..9:D;  var 1..9:R;  var 1..9:M;  var 1..9:Y;
    
    var 20..60: angled = (A+N+G+L+E+D);
    
    constraint all_different( [E,N,G,L,A,D,R,M,Y] );
    
    constraint 4 * (E*N*G*L*A*N*D) = (G*E*R*M*A*N*Y);
    
    constraint (E+N+G+L+A+N+D) + 3 =  (G+E+R+M+A+N+Y);
    
    solve satisfy;
    
    output[ "A+N+G+L+E+D = " ++ show(angled)    
    ++ "\n" ++ "E+N+G+L+A+N+D = " ++ show (E+N+G+L+A+N+D)    
    ++ "\n" ++ "G+E+R+M+A+N+Y = " ++ show (G+E+R+M+A+N+Y)   
    ++ "\n" ++ "E*N*G*L*A*N*D = " ++ show (E*N*G*L*A*N*D)    
    ++ "\n" ++ "G*E*R*M*A*N*Y = " ++ show (G*E*R*M*A*N*Y) ];       
    
    % A+N+G+L+E+D = 28
    % E+N+G+L+A+N+D = 29
    % G+E+R+M+A+N+Y = 32
    % E*N*G*L*A*N*D = 2520
    % G*E*R*M*A*N*Y = 10080
    % ----------
    % Finished in 64msec
         
    

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: