Enigmatic Code

Programming Enigma Puzzles

Enigma 1568: Odd puzzle

From New Scientist #2731, 24th October 2009 [link]

In this multiplication sum the digits have been replaced by letters and dots. Different letters stand for different digits, the same letter stands for the same digit, each dot can be any digit, and leading digits cannot be zero.

What is the six-figure odd PUZZLE?

 

[enigma1568]

Advertisements

2 responses to “Enigma 1568: Odd puzzle

  1. jimrandell 21 February 2012 at 5:04 pm

    The following Python program runs in 55ms.

    from enigma import is_pairwise_distinct, printf
    
    # consider the product that makes ODD
    for A in range(100, 1000):
      for B1 in range(1, 10):
        ODD = str(A * B1)
        if len(ODD) != 3: continue
        (O, D, D2) = list(ODD)
        if D != D2: continue
        # then B2 and B3 also make 3 digit products
        Bs = list(Bx for Bx in range(0, 10) if len(str(A * Bx)) == 3)
        for B2 in Bs:
          for B3 in Bs:
            B = int(''.join(map(str, (B1, B2, B3))))
            PUZZLE = str(A * B)
            if len(PUZZLE) != 6: continue
    
            (P,U, Z, Z2, L, E) = list(PUZZLE)
            if Z != Z2: continue
            if not(int(E) % 2): continue
            if not is_pairwise_distinct(P, U, Z, L, E): continue
    
            printf("PUZZLE = {PUZZLE} ({A} x {B}) [ODD = {ODD}]")
    

    Solution: PUZZLE = 102235.

  2. Jim Randell 23 August 2016 at 10:16 am

    Here’s a solution using the general Alphametic solver (SubstitutedExpression()) from the enigma.py library. We introduce new (lower case) symbols that are not required to be distinct from the other symbols to represent the multiplicands of the sum.

    The whole thing runs in 111ms. Here is the command and its output:

    % python -m enigma SubstitutedExpression \
      --symbols="DELOPUZabcdef" --distinct="DELOPUZ" \
      --answer="PUZZLE" \
      "abc * def = PUZZLE" \
      "99 < abc * f < 1000" \
      "99 < abc * e < 1000" \
      "abc * d = ODD" \
      "E % 2 = 1"
    (abc * def = PUZZLE) (99 < abc * f < 1000) (99 < abc * e < 1000) (abc * d = ODD) (E % 2 = 1)
    (161 * 635 = 102235) (99 < 161 * 5 < 1000) (99 < 161 * 3 < 1000) (161 * 6 = 966) (5 % 2 = 1) / D=6 E=5 L=3 O=9 P=1 U=0 Z=2 a=1 b=6 c=1 d=6 e=3 f=5 / 102235
    PUZZLE = 102235 [1 solution]
    

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: