All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > General
Capital City Conclusion (Posted on 2014-03-06) Difficulty: 3 of 5
In the alphametic: ABC+DEF= 495, the letters A to F denotes a different digit in {1,2,3,6,7,8}.

What are :
6 * 8 * 1 * 2 * * and 8 1 * 6 2 * * 1, when each of them denotes the capital city of a country? Each asterisk denotes a letter (whether same or different) that is not included in the alphametic.

No Solution Yet Submitted by K Sengupta    
Rating: 3.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 3

DECLARE SUB permute (a$)
CLS
DEFDBL A-Z

DATA "6*8*1*2**","81*62**1"

a$ = "123678": h$ = a$
DO
  a = VAL(MID$(a$, 1, 1))
  b = VAL(MID$(a$, 2, 1))
  c = VAL(MID$(a$, 3, 1))
  d = VAL(MID$(a$, 4, 1))
  e = VAL(MID$(a$, 5, 1))
  f = VAL(MID$(a$, 6, 1))
  abc = 100 * a + 10 * b + c
  defv = 100 * d + 10 * e + f
  IF abc + defv = 495 THEN
    PRINT abc; " "; defv,
    RESTORE
    FOR wh = 1 TO 2
      READ tmplt$: cap$ = ""
      FOR i = 1 TO LEN(tmplt$)
        c$ = MID$(tmplt$, i, 1)
        IF c$ = "*" THEN
           PRINT c$;
           cap$ = cap$ + "*"
        ELSE
           IF a = VAL(c$) THEN PRINT "a"; : cap$ = cap$ + "a"
           IF b = VAL(c$) THEN PRINT "b"; : cap$ = cap$ + "b"
           IF c = VAL(c$) THEN PRINT "c"; : cap$ = cap$ + "c"
           IF d = VAL(c$) THEN PRINT "d"; : cap$ = cap$ + "d"
           IF e = VAL(c$) THEN PRINT "e"; : cap$ = cap$ + "e"
           IF f = VAL(c$) THEN PRINT "f"; : cap$ = cap$ + "f"
        END IF
      NEXT
      OPEN "natlcaps.txt" FOR INPUT AS #1
      DO
        LINE INPUT #1, l$
        ix = INSTR(l$, ",")
        IF ix THEN
          l$ = LTRIM$(RTRIM$(LEFT$(l$, ix - 1)))
          good = 0
          IF LEN(l$) = LEN(cap$) THEN
            good = 1
            FOR i = 1 TO LEN(cap$)
              IF MID$(cap$, i, 1) <> "*" THEN
                IF MID$(cap$, i, 1) <> LCASE$(MID$(l$, i, 1)) THEN good = 0: EXIT FOR
              END IF
            NEXT
            IF good THEN
              PRINT "    "; l$; "      ";
            END IF
          END IF
        END IF
      LOOP UNTIL EOF(1) OR good = 1
      CLOSE 1
      PRINT "    ";
    NEXT
    PRINT
  END IF
 
  permute a$
LOOP UNTIL a$ = h$

finds

ABC   DEF       substitutions:
127   368    e*f*a*b**                       fa*eb**a
128   367    e*c*a*b**                       ca*eb**a
167   328    b*f*a*e**                       fa*be**a
168   327    b*c*a*e**    Bucharest          ca*be**a    Canberra
327   168    e*f*d*b**                       fd*eb**d
328   167    e*c*d*b**                       cd*eb**d
367   128    b*f*d*e**                       fd*be**d
368   127    b*c*d*e**                       cd*be**d

so ABC = 168 and DEF = 327 and the capital cities are

Bucharest and Canberra.


  Posted by Charlie on 2014-03-06 22:35:41
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (9)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information