Enigmatic Code

Programming Enigma Puzzles

Enigma 308: Digital darts

From New Scientist #1456, 16th May 1985 [link]

In this puzzle, digits are replaced by letters. Each letter stands for a different digit, and the same letter stands for the same digit throughout.

I’ve just been practising for tomorrow’s darts tournament. I was trying for a grand total of 201, starting and finishing with a double. In my first go, I got a double A, treble BC and a single D, leaving a total of BGJ to get. In my next go, I got treble BE, treble F and double BG, leaving HB to get. My final go gave me a double H, treble I and a neat double BA to finish.

The total for my last three darts was less than the total for the previous three, which was less than the total for the first three: I hope that this deterioration does not continue tomorrow!

What, in order, are the digits for ABCDEFGHIJ?

[enigma308]

Advertisements

2 responses to “Enigma 308: Digital darts

  1. Jim Randell 6 September 2015 at 8:06 am

    This Python program runs in 39ms.

    from itertools import permutations
    from enigma import irange, split, printf
    
    # digits
    digits = set(irange(0, 9))
    
    # B must be 1
    B = 1
    
    # A and D cannot be zero
    for (A, D) in permutations(digits.difference([0, B]), 2):
      for C in digits.difference([A, B, D]):
    
        # 1st throw
        t1 = 2 * A + 30 * B + 3 * C + D
        BGJ = 201 - t1
        (B1, G, J) = split(BGJ, int)
        if B1 != B: continue
    
        # remaining digits
        ds1 = digits.difference([A, B, C, D, G, J])
        if len(ds1) != 4: continue
    
        # choose E and F (F is non-zero)
        for (E, F) in permutations(ds1, 2):
          if F == 0: continue
    
          # 2nd throw
          t2 = 50 * B + 3 * E + 3 * F + 2 * G
          HB = BGJ - t2
          (H, B1) = split(HB, int)
          if B1 != B: continue
    
          # remaining digits (H is non-zero)
          ds2 = ds1.difference([E, F, H])
          if H == 0 or len(ds2) != 1: continue
    
          # the remaining digit is I (non-zero)
          for I in ds2:
            if I == 0: continue
    
            # 3rd throw
            t3 = 2 * H + 3 * I + 20 * B + 2 * A
            if t3 != HB: continue
    
            # check the ordering constraint
            if not(t3 < t2 < t1): continue
    
            printf("A={A} B={B} C={C} D={D} E={E} F={F} G={G} H={H} I={I} J={J} [t1={t1} t2={t2} t3={t3}]")
    

    Solution: A=7, B=1, C=8, D=9, E=0, F=3, G=2, H=6, I=5, J=4.

    The total scores in the three throws are: 77, 63, 61.

    • geoffrounce 6 September 2015 at 7:15 pm

      I used MiniZinc for solving this enigma.

      include "globals.mzn"; 
      
      var 0..9: A;  var 0..9 :B;  var 0..9: C;
      var 0..9: D;  var 0..9: E;  var 0..9: F;
      var 0..9: G;  var 0..9: H;  var 0..9: I;
      var 0..9: J;  
      
      var 10..202: total1;
      var 10..202: total2;
      var 10..202: total3;
      
      % we can exclude A,B,D,F,H,I as 0
      % as these digits occur at the start of numbers
      
      constraint 
           A != 0 /\ B != 0 /\ D != 0 /\
           F != 0 /\ H != 0 /\ I != 0;
      
      constraint
          alldifferent([A,B,C,D,E,F,G,H,I,J]) /\
      
          total1 = 2*A + 3*(10*B + C) + D /\
      
          % remaining total after 1st throw
          100*B + 10*G + J = 201 - total1 /\        
         
          total2 = 3*(10*B + E) + 3*F + 2*(10*B + G) /\
      
          % remaining total after 2nd throw
          10*H + B = 100*B + 10*G + J - total2 /\   
         
          total3  = 2*H + 3*I + 2*(10*B + A) /\
          10*H + B = total3 ;
      
      constraint
          total3 < total2 /\ total2 < total1 ;
      
      output ["A,B,C,D,E,F,G,H,I,J = " 
      ++ show([A,B,C,D,E,F,G,H,I,J]) ++ "\n"];
      
      solve satisfy;
      
      % A,B,C,D,E,F,G,H,I,J = [7, 1, 8, 9, 0, 3, 2, 6, 5, 4]
      %                        A  B  C  D  E  F  G  H  I  J
      
      % check totals
      % total1 = 14 + 54 + 9 = 77 (ie 2A + 3BC + D)
      % total2 = 30 + 9 + 24 = 63 (ie 3BE + 3F + 2BG) 
      % total3 = 12 + 15 + 34 = 61 (ie 2H + 3I + 2BA)
      % TOTAL = 77 + 63 + 61 = 201
      
      

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: