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

Home > Logic
Fill In The Squares (Posted on 2004-12-28) Difficulty: 3 of 5
Place the numbers 1 through 25 in the grid below:
   1 2 3 4 5
A | | | | | |
B | | | | | |
C | | | | | |
D | | | | | |
E | | | | | |
  1. The sum of each column is odd
  2. The sum of each row, except C, is even
  3. The sum of row A is not greater than the sum of any other row
  4. The sum of the diagonal E1 to A5 is less than that of the diagonal A1 to E5
  5. A4 + B4 > C4 + D4 + E4
  6. A1 + B1 = D1 + E1
  7. A1 > E1
  8. A1, A3 and B1 are all prime numbers
  9. (A3 + E3) is a prime number
  10. A5, D1, D3 and E1 are all squares
  11. B2, C2 and D2 are ascending consecutive numbers
  12. B3, C3 and D3 are ascending consecutive numbers
  13. B5 + D5 = A5 + C5
  14. (C1)² + (C5)² = (E3)²
  15. C5 is a two digit number
  16. D5 is a multiple of E5
  17. E1 + E3 = E2 + E4 + E5

See The Solution Submitted by Nosher    
Rating: 4.3333 (9 votes)

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

DEFLNG A-Z
 DIM taken(25)
 DIM primes(10)
 DATA 2,3,5,7,11,13,17,19,23
 CLS
 nPrimes = 9
 FOR i = 1 TO nPrimes
   READ primes(i)
 NEXT
 DIM squares(5)
 FOR i = 1 TO 5
   squares(i) = i * i
 NEXT
 FOR a1p = 1 TO nPrimes
 a1 = primes(a1p)
 taken(a1) = 1
 FOR a3p = 1 TO nPrimes
 a3 = primes(a3p)
 IF taken(a3) = 0 THEN
 taken(a3) = 1
 FOR b1p = 1 TO nPrimes
 b1 = primes(b1p)
 IF taken(b1) = 0 THEN
 taken(b1) = 1
 FOR a5p = 1 TO 5
 a5 = squares(a5p)
 IF taken(a5) = 0 THEN
 taken(a5) = 1
 FOR d1p = 1 TO 5
 d1 = squares(d1p)
 IF taken(d1) = 0 THEN
 taken(d1) = 1
 FOR d3p = 1 TO 5
 d3 = squares(d3p)
 c3 = d3 - 1: b3 = c3 - 1
 IF taken(d3) = 0 AND b3 > 0 THEN
 IF taken(c3) = 0 AND taken(b3) = 0 THEN
 taken(d3) = 1: taken(c3) = 1: taken(b3) = 1
 e1Par = (a3 + b3 + c3 + d3 + 1) MOD 2
 FOR e1p = 1 TO 5
 e1 = squares(e1p)
 IF taken(e1) = 0 AND a1 + b1 = d1 + e1 THEN
 taken(e1) = 1
 FOR c5 = 10 TO 25
 IF taken(c5) = 0 THEN
 taken(c5) = 1
 c1Par = (a1 + b1 + d1 + e1 + 1) MOD 2
 FOR c1 = (2 - c1Par) TO 25 STEP 2
 IF taken(c1) = 0 THEN
 taken(c1) = 1
 e3 = INT(SQR(c1 * c1 + c5 * c5) + .5)
 goodE3 = 0: a3e3 = a3 + e3
 FOR i = 1 TO nPrimes
  IF a3e3 = primes(i) THEN goodE3 = 1
 NEXT i
 IF a3e3 = 29 OR a3e3 = 31 OR a3e3 = 37 OR a3e3 = 41 OR a3e3 = 43 OR a3e3 = 47 THEN goodE3 = 1
 IF e3 * e3 = (c1 * c1 + c5 * c5) AND e3 <= 25 AND goodE3 = 1 THEN
  ' so far know a1, a3, b1, a5, d1, d3, c3, b3, e1, c5, c1, e3
 taken(e3) = 1
 FOR b2 = 1 TO 23
 IF taken(b2) = 0 THEN
 c2 = b2 + 1: d2 = c2 + 1
 IF taken(c2) = 0 AND taken(d2) = 0 THEN
 taken(b2) = 1: taken(c2) = 1: taken(d2) = 1
  ' so far know a1, a3, b1, a5, d1, d3, c3, b3, e1, c5, c1, e3, b2, c2, d2
 c4Par = (c1 + c2 + c3 + c5 + 1) MOD 2
 FOR c4 = (2 - c4Par) TO 25 STEP 2
 IF taken(c4) = 0 THEN
 taken(c4) = 1
 FOR e5 = 1 TO 12
 IF taken(e5) = 0 THEN
 taken(e5) = 1
 FOR d5 = 2 * e5 TO 25 STEP e5
 IF taken(d5) = 0 THEN
 taken(d5) = 1
  ' so far know a1, a3, a5, b1, b2, b3, c1, c2, c3, c4, c5, d1, d2, d3, d5, e1, e3, e5
 d4Par = (d1 + d2 + d3 + d5) MOD 2
 b5Par = (a5 + c5 + d5 + e5 + 1) MOD 2
 FOR d4 = (2 - d4Par) TO 25 STEP 2
 IF taken(d4) = 0 AND (d1 + d2 + d3 + d4 + d5) MOD 2 = 0 THEN
 taken(d4) = 1
 FOR b5 = (2 - b5Par) TO 25 STEP 2
 IF taken(b5) = 0 AND b5 + d5 = a5 + c5 THEN
 taken(b5) = 1

  ' so far know a1, a3, a5, b1, b2, b3, b5, c1, c2, c3, c4, c5, d1, d2, d3, d4, d5, e1, e3, e5
 b4Par = (b1 + b2 + b3 + b5) MOD 2
 FOR b4 = (2 - b4Par) TO 25 STEP (2 - b4Par)
 IF taken(b4) = 0 THEN
 taken(b4) = 1

 IF a1 + b2 + d4 + e5 > e1 + d2 + b4 + a5 AND (b1 + b2 + b3 + b4 + b5) MOD 2 = 0 THEN
 ' so far know a1, a3, a5, b1, b2, b3, b4, b5, c1, c2, c3, c4, c5, d1, d2, d3, d4, d5, e1, e3, e5
 ' don't know a2, a4, e2, e4
 FOR e2 = 1 TO 25
 e4 = e1 + e3 - e2 - e5
 IF e4 > 0 AND e4 <= 25 THEN


 IF e4 <> e2 AND (e1 + e2 + e3 + e4 + e5) MOD 2 = 0 AND taken(e4) = 0 AND taken(e2) = 0 THEN
 taken(e2) = 1
 taken(e4) = 1

 FOR a2 = 1 TO 25
 IF taken(a2) = 0 THEN
 taken(a2) = 1
 FOR a4 = 1 TO 25
 IF taken(a4) = 0 AND a1 > e1 AND a4 + b4 > c4 + d4 + e4 THEN
 taken(a4) = 1

 IF a1 + a2 + a3 + a4 + a5 <= b1 + b2 + b3 + b4 + b5 THEN
 IF a1 + a2 + a3 + a4 + a5 <= c1 + c2 + c3 + c4 + c5 THEN
 IF a1 + a2 + a3 + a4 + a5 <= d1 + d2 + d3 + d4 + d5 THEN
 IF a1 + a2 + a3 + a4 + a5 <= e1 + e2 + e3 + e4 + e5 THEN
 PRINT USING "###"; a1; a2; a3; a4; a5;
 PRINT USING "#####"; a1 + a2 + a3 + a4 + a5
 PRINT USING "###"; b1; b2; b3; b4; b5;
 PRINT USING "#####"; b1 + b2 + b3 + b4 + b5
 PRINT USING "###"; c1; c2; c3; c4; c5;
 PRINT USING "#####"; c1 + c2 + c3 + c4 + c5
 PRINT USING "###"; d1; d2; d3; d4; d5;
 PRINT USING "#####"; d1 + d2 + d3 + d4 + d5
 PRINT USING "###"; e1; e2; e3; e4; e5;
 PRINT USING "#####"; e1 + e2 + e3 + e4 + e5
 FOR i = 1 TO 25: IF taken(i) = 0 THEN PRINT i;
 NEXT: PRINT
 PRINT
 ct = ct + 1
 END IF
 END IF
 END IF
 END IF

 taken(a4) = 0
 END IF
 NEXT
 taken(a2) = 0
 END IF
 NEXT

 taken(e2) = 0
 taken(e4) = 0
 END IF
 END IF
 NEXT e2
 END IF
 taken(b4) = 0
 END IF
 NEXT b4
 taken(b5) = 0
 END IF
 NEXT b5
 taken(d4) = 0
 END IF
 NEXT d4
 taken(d5) = 0
 END IF
 NEXT d5
 taken(e5) = 0
 END IF
 NEXT e5
 taken(c4) = 0
 END IF
 NEXT c4
 taken(b2) = 0: taken(c2) = 0: taken(d2) = 0
 END IF
 END IF
 NEXT b2
 taken(e3) = 0
 END IF
 taken(c1) = 0
 END IF
 NEXT c1
 taken(c5) = 0
 END IF
 NEXT c5
 taken(e1) = 0
 END IF
 NEXT e1p
 taken(d3) = 0: taken(c3) = 0: taken(b3) = 0
 END IF
 END IF
 NEXT d3p
 taken(d1) = 0
 END IF
 NEXT d1p
 taken(a5) = 0
 END IF
 NEXT a5p
 taken(b1) = 0
 END IF
 NEXT b1p
 taken(a3) = 0
 END IF
 NEXT a3p
 taken(a1) = 0
 NEXT a1p
 PRINT ct

finds

  7 11  2 17  1   38
 13 19 23 22  3   80
  9 20 24 14 12   79
 16 21 25 18 10   90
  4  8 15  6  5   38

where the last column is the sum of the numbers in each row.


  Posted by Charlie on 2004-12-28 20:19: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