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

Home > Logic
Clockwork (Posted on 2013-06-24) Difficulty: 3 of 5
Diagram A

A B C D E F G H I
J 1 K 2 L 3 M 4 N
O P Q R S T U V W
Diagram B

O J I N W F C D E
P 1 K 2 L 3 V 4 H
S R A B Q T G M U

Diagram A contains the first 23 letters of the alphabet and the numbers one to four. Imagine that the eight letters surrounding each number can rotate around that number clockwise or anticlockwise. To arrive at Diagram B, each of the numbers have been rotated twice, except number 1, which has only been rotated once.

Work out the order in which they were rotated to arrive at diagram B and, if they were rotated 90o or 180o, clockwise or anticlockwise.

No Solution Yet 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 1

DECLARE SUB permute (a$)
DECLARE SUB try (po!)
DECLARE SUB subst (s$, ctr!)
CLEAR , , 25000

DATA abcdefghi
DATA j1k2l3m4n
DATA opqrstuvw
READ r10$
READ r20$
READ r30$

DIM SHARED ord$, r1$, r2$, r3$, hist$(7), goal$
goal$ = "ojinwfcdep1k2l3v4hsrabqtgmu"

ord$ = "1223344": h$ = ord$

DO
  r1$ = r10$: r2$ = r20$: r3$ = r30$
  try 1
  permute ord$
LOOP UNTIL ord$ = h$

SUB subst (s$, ctr)
    MID$(r1$, ctr * 2 - 1, 3) = MID$(s$, 1, 3)
    MID$(r2$, ctr * 2 + 1, 1) = MID$(s$, 4, 1)
    MID$(r3$, ctr * 2 + 1, 1) = MID$(s$, 5, 1)
    MID$(r3$, ctr * 2, 1) = MID$(s$, 6, 1)
    MID$(r3$, ctr * 2 - 1, 1) = MID$(s$, 7, 1)
    MID$(r2$, ctr * 2 - 1, 1) = MID$(s$, 8, 1)
END SUB

SUB try (po)
  ctr = VAL(MID$(ord$, po, 1))
  s$ = MID$(r1$, ctr * 2 - 1, 3) + MID$(r2$, ctr * 2 + 1, 1) + MID$(r3$, ctr * 2 + 1, 1) + MID$(r3$, ctr * 2, 1) + MID$(r3$, ctr * 2 - 1, 1) + MID$(r2$, ctr * 2 - 1, 1)
  FOR rotv = 1 TO 3
    ss$ = s$
    s$ = MID$(s$, 9 - 2 * rotv) + LEFT$(s$, 8 - 2 * rotv)
    subst s$, ctr
    hist$(po) = MID$(ord$, po, 1) + STR$(rotv)
    IF po = 7 THEN
       ct = 0
       FOR i = 1 TO 9
         IF MID$(r1$, i, 1) = MID$(goal$, i, 1) THEN ct = ct + 1
         IF MID$(r2$, i, 1) = MID$(goal$, i + 9, 1) THEN ct = ct + 1
         IF MID$(r3$, i, 1) = MID$(goal$, i + 18, 1) THEN ct = ct + 1
       NEXT
       IF ct = 27 THEN
        FOR i = 1 TO 7
          PRINT hist$(i); "  ";
        NEXT
        PRINT
       END IF
    ELSE
      try po + 1
    END IF

    s$ = ss$
    subst ss$, ctr
  NEXT
END SUB

finds nine possible sequences:

2 1  1 1  3 2  4 2  3 2  2 3  4 3
2 1  1 1  3 2  4 2  3 2  4 3  2 3
2 1  3 2  1 1  4 2  3 2  2 3  4 3
2 1  3 2  1 1  4 2  3 2  4 3  2 3
2 1  3 2  4 2  1 1  3 2  2 3  4 3
2 1  3 2  4 2  1 1  3 2  4 3  2 3
2 1  3 2  4 2  3 2  1 1  2 3  4 3
2 1  3 2  4 2  3 2  1 1  4 3  2 3
2 1  3 2  4 2  3 2  4 3  1 1  2 3

Each pair of numbers identifies first the pivot around which the rotation takes place, and second, the number of 90° clockwise rotations which equal the rotation given, so that 1 = 90° clockwise, 2 = 180° and 3 = 90° counterclockwise.

In English, the simplest way of saying it is:

Other than the rotation about 1, the sequence is:

About 2 90° clockwise
About 3 180°
About 4 180°
About 3 180°
About 4 90° counterclockwise
About 2 90° counterclockwise

but the last two can be interchanged, except as noted below.

The single rotation about position 1 is 90° clockwise and can occur anywhere except first or last. It must be before the 90° counterclockwise rotation about 2, so if the rotation about 1 occurs next to last, the interchange of the last two steps listed above cannot take place. That's why there are nine solutions rather than ten.


  Posted by Charlie on 2013-06-24 17:35:28
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
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 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information