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

Home > Numbers
5x5 Grid Alphamagic (Posted on 2009-09-27) Difficulty: 3 of 5
Substitute each of the capital letters in bold by a different digit from 0 to 9, such that each of the columns, each of the rows and each of the two main diagonals of this 5x5 grid have the same sum, where none of the numbers in the 25 cells contains a leading zero.

TI    KT    NS    OB    UL
CN   IO    CC    UK    TB
IU    OL    UI    SC    CS
OK   UB    TL    KO    IT
NC   TK    KU    NN   OI

See The Solution Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 2
76  37  58  19  40
25  61  22  43  79
64  10  46  82  28
13  49  70  31  67
52  73  34  55  16
230 (sum of each row, col, diag)

DATA "TI   KT   NS   OB   UL"
DATA "CN   IO   CC   UK   TB"
DATA "IU   OL   UI   SC   CS"
DATA "OK   UB   TL   KO   IT"
DATA "NC   TK   KU   NN   OI"

FOR i = 1 TO 5
 READ puzRow$(i)
 FOR j = 1 TO LEN(puzRow$(i))
   c$ = MID$(puzRow$(i), j, 1)
   IF c$ >= "A" AND c$ <= "Z" THEN
     ix = INSTR(ltrs$, c$)
     IF ix = 0 THEN ltrs$ = ltrs$ + c$
   END IF
 NEXT
NEXT

PRINT LEN(ltrs$)

l = 0
FOR t = 1 TO 9
 IF used(t) = 0 THEN
  used(t) = 1
FOR k = 1 TO 9
 IF used(k) = 0 THEN
  used(k) = 1
  PRINT t; k; "   ";
FOR n = 1 TO 9
 IF used(n) = 0 THEN
  used(n) = 1
FOR s = 1 TO 9
 IF used(s) = 0 THEN
  used(s) = 1
FOR o = 1 TO 9
 IF used(o) = 0 THEN
  used(o) = 1
FOR u = 1 TO 9
 IF used(u) = 0 THEN
  used(u) = 1
FOR c = 1 TO 9
 IF used(c) = 0 THEN
  used(c) = 1
FOR i = 1 TO 9
 IF used(i) = 0 THEN
  used(i) = 1
FOR b = 1 TO 9
 IF used(b) = 0 THEN
  used(b) = 1

  FOR row = 1 TO 5
   FOR col = 1 TO 5
     c10$ = LCASE$(MID$(puzRow$(row), (col - 1) * 5 + 1, 1))
     SELECT CASE c10$
     CASE "t"
      v = 10 * t
     CASE "k"
      v = 10 * k
     CASE "n"
      v = 10 * n
     CASE "b"
      v = 10 * b
     CASE "o"
      v = 10 * o
     CASE "u"
      v = 10 * u
     CASE "c"
      v = 10 * c
     CASE "i"
      v = 10 * i
     CASE "s"
      v = 10 * s
     END SELECT
     c1$ = LCASE$(MID$(puzRow$(row), (col - 1) * 5 + 2, 1))
     SELECT CASE c1$
     CASE "t"
      v = v + t
     CASE "k"
      v = v + k
     CASE "n"
      v = v + n
     CASE "b"
      v = v + b
     CASE "o"
      v = v + o
     CASE "u"
      v = v + u
     CASE "c"
      v = v + c
     CASE "i"
      v = v + i
     CASE "s"
      v = v + s
     END SELECT
     gr(row, col) = v
   NEXT
  NEXT
    totl = 0
    FOR col = 1 TO 5
     totl = totl + gr(1, col)
    NEXT
    totGoal = totl
  good = 1
  FOR row = 1 TO 5
    totl = 0
    FOR col = 1 TO 5
     totl = totl + gr(row, col)
    NEXT
    IF totl <> totGoal THEN good = 0: EXIT FOR
  NEXT
  IF good THEN
    FOR col = 1 TO 5
      totl = 0
      FOR row = 1 TO 5
       totl = totl + gr(row, col)
      NEXT
      IF totl <> totGoal THEN good = 0: EXIT FOR
    NEXT
  END IF
  IF good THEN
    totl = 0
    FOR col = 1 TO 5
      row = col
      totl = totl + gr(row, col)
    NEXT
    IF totl <> totGoal THEN good = 0: EXIT FOR
  END IF
  IF good THEN
    totl = 0
    FOR col = 1 TO 5
      row = 6 - col
      totl = totl + gr(row, col)
    NEXT
    IF totl <> totGoal THEN good = 0: EXIT FOR
  END IF
  IF good THEN
    PRINT
    FOR row = 1 TO 5
     FOR col = 1 TO 5
      PRINT gr(row, col);
     NEXT
     PRINT
    NEXT
    PRINT totGoal
    PRINT
    PRINT
  END IF


  used(b) = 0
 END IF
NEXT
  used(i) = 0
 END IF
NEXT
  used(c) = 0
 END IF
NEXT
  used(u) = 0
 END IF
NEXT
  used(o) = 0
 END IF
NEXT
  used(s) = 0
 END IF
NEXT
  used(n) = 0
 END IF
NEXT
  used(k) = 0
 END IF
NEXT
  used(t) = 0
 END IF
NEXT

END

 


  Posted by Charlie on 2009-09-27 22:07:02
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 (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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