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

Home > Shapes
Square Patterns (Posted on 2007-04-20) Difficulty: 3 of 5
Consider a 2x2 board in which each square can be black or white. Obviously there are 16 different 2x2 patterns, counting reflections and rotations.
A 5x5 board has 16 different 2x2 subsquares. Can the squares of a 5x5 board be colored so that each 2x2 subsquare has a different pattern?

See The Solution Submitted by Brian Smith    
Rating: 2.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution 50 unique solutions Comment 3 of 3 |
wwBww  wwBBw  wwBBw  wwBBw  wwBBw  wwBBw  wwBBw  wwBBw  wwBBw  wwBBw
BBwwB  BBwwB  BBwwB  BBwwB  BBwwB  BBwwB  BBwwB  BBwBB  BBBwB  BBBwB
BBBwB  BBwww  BBwwB  BBwwB  BBwBB  BBBww  BBBwB  BBwBw  wBBww  wBBwB
BwwBB  wBBwB  wBBww  BwwBB  BwwwB  wBwwB  wBwww  wwwwB  BwwwB  Bwwww
BwwwB  BBwwB  BBwwB  BBwwB  BBwwB  BBwwB  BBwwB  BwwBB  BBwwB  BBwwB
wwBBB  wwBBB  wBwwB  wBBww  wBBww  wBBww  wBBww  wBBww  BwwwB  BwwBB
BBwwB  BBwBw  BBwwB  BBwwB  BBwwB  BBwBB  BBBwB  BBBwB  BBBwB  wBBwB
BBwww  BBwww  BBBww  BBwwB  BBwwB  BBwwB  BwwBw  BwBBw  BBwBB  BBBww
BwBwB  wwBwB  BwwBB  wwBBw  wBBww  wwwBw  wwwBB  wwwwB  wBwww  BwwwB
wwBBB  wwBBB  wwBwB  BwwBB  BwwBB  BwwBB  BBwwB  BBwwB  BwwwB  BBwwB
BwwBB  BwwBB  BwwBB  BwwBB  BwBww  BwBww  BwBwB  BwBBB  BwBBB  BBwww
wBBwB  BBwwB  BBwwB  BBBwB  BBwwB  BBwBB  BBwww  BBwBw  BBwBw  BBwwB
BBBwB  BBwwB  BBwwB  BBwwB  BBwwB  BBwwB  BBwwB  BBwwB  BBwwB  wwBBB
Bwwww  wwBBw  BwwBB  wwBww  wwBBB  wwwBB  wwBBB  wwwwB  wwwwB  BwBwB
BBwwB  wBBww  wBBww  wBBww  BwwBw  BwwBw  BwBwB  BwBBB  BBwBB  BBwww
BBwwB  BBwwB  BBwwB  BBwwB  BBwwB  BBwwB  BBwwB  BBwwB  BBwwB  BBwwB
BBwww  BBwww  BBwww  BBwwB  BBwwB  BBwwB  BBwwB  BBwwB  BBwBw  BBwBB
wBBwB  wBBBw  BwBwB  wwBBw  wBBww  wBBww  BwwBB  BwwBB  BwBBB  BwwwB
BBwwB  wBwwB  wwBBB  BwwBB  BwwBB  BBwwB  wBBww  BBwwB  wwwwB  BBwwB
wwBBw  BwwBB  BBwwB  wwBBw  wwBBw  wwBBw  wwBBw  wwBBw  BBwwB  wwBBw
BBwwB  BBwwB  BBwwB  BBwwB  BBwwB  BBwBw  BBwBB  BBwBB  BBwBB  BBwBB
BBBww  BBBwB  BBBwB  BBBwB  BBBBw  BBwwB  BBwww  BBwwB  BBwwB  BBBwB
wBwwB  wBwww  wBwBB  BwwBB  wwBwB  wwwwB  BwwwB  wwwwB  wwwwB  BwwwB
BBwwB  BBwwB  Bwwww  BwwwB  BwwwB  BwBBB  wBBwB  BwBBw  BBwBw  wBwww
wwBBw  wwBBw  BwwBB  wwBBw  BwwBB  BBwBw  BwBBB  BBBwB  BwBBB  BBwBB

None of the above is trivially related to any other, as

1. All have more Black than white squares.
2. The all-black square of 4 is in the upper left quadrant.
3. Each of those meeting those two criteria was checked to be sure it was not a diagonal reflection of a previous solution.

Thus, what originally were 800 solutions became 50.

I've bolded the solution that's the diagonal reflection of Penny's solution.

DECLARE SUB build (row!, col!)
CLEAR , , 9999

DIM SHARED used(15), board(5, 5), wCt, hist(111, 5, 5)
DIM SHARED blkCt, row15, col15

CLS

build 1, 1

PRINT wCt

END

SUB build (row, col)
 board(row, col) = 0
 GOSUB tryIt
 board(row, col) = 1
 blkCt = blkCt + 1
 GOSUB tryIt
 blkCt = blkCt - 1
 EXIT SUB

tryIt:
   idx = -1
   IF row > 1 AND col > 1 THEN
     idx = 8 * board(row - 1, col - 1) + 4 * board(row - 1, col) + 2 * board(row, col - 1) + board(row, col)
     IF used(idx) THEN RETURN
     used(idx) = 1
     IF idx = 15 THEN row15 = row: col15 = col
   END IF
   r = row: c = col + 1
   IF c > 5 THEN
     c = 1: r = r + 1
   END IF
   IF r < 6 THEN
     build r, c
   ELSE
     IF blkCt > 12 AND row15 <= 3 AND col15 <= 3 THEN
       good = 1
       FOR h = 1 TO wCt
         match = 1
         FOR r1 = 1 TO 5
          FOR c1 = 1 TO 5
            IF board(r1, c1) <> hist(h, c1, r1) THEN match = 0: EXIT FOR
          NEXT
          IF match = 0 THEN EXIT FOR
         NEXT
         IF match THEN good = 0: EXIT FOR
       NEXT h
       IF good THEN
         pRow = wCt 10
         pCol = wCt MOD 10
         pRow = pRow * 6: pCol = pCol * 7
         wCt = wCt + 1
         FOR r1 = 1 TO 5
          FOR c1 = 1 TO 5
            LOCATE pRow + r1, pCol + c1
            IF board(r1, c1) THEN PRINT "B"; :  ELSE PRINT "w";
            hist(wCt, r1, c1) = board(r1, c1)
          NEXT
          PRINT
         NEXT
         PRINT
       END IF
     END IF
   END IF
   IF idx >= 0 THEN used(idx) = 0
RETURN
END SUB

 

Edited on April 20, 2007, 11:19 pm
  Posted by Charlie on 2007-04-20 22:30:52

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 (7)
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