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

Home > General
Magic circle (Posted on 2006-12-16) Difficulty: 3 of 5
Joe placed 10 numbered counters in a circle:


                  0

        1                   2




  8                               7





  4                               5




        6                   3

                  9
                  

He asked Penny to pick a number and then count clockwise from that numbered position on the circle that many further counters. For example, if she picked 7, the new counter would be 1 (located 7 clockwise from the 7). Repeating the process with the number on each new counter she would finish up at zero.

There was one particular number that, if she started there, she would go through all the other counters before getting to zero. What was that number?

Penny also found that, if she rearranged the counters in the circle in a certain order, leaving the topmost three (1, 0 and 2) in place (and maybe some others), that if she started with that same numbered counter from part 1, that she would also go through all the other counters before getting to zero. What was the clockwise order of the numbers in this new arrangement, starting with the zero at the top?

  Submitted by Charlie    
No Rating
Solution: (Hide)
Part 1:

Trial and error, via

cir$ = "0275396481"
FOR strt = 2 TO 10
  PRINT strt,
  REDIM visited(9)
  ptr = strt
  DO
    m = VAL(MID$(cir$, ptr, 1))
    visited(m) = 1: PRINT m;
    ptr = ptr + m: IF ptr > 10 THEN ptr = ptr - 10
  LOOP UNTIL ptr = 1
  PRINT
  good = 1
  FOR i = 1 TO 9
   IF visited(i) = 0 THEN good = 0: EXIT FOR
  NEXT
 ' IF good THEN PRINT VAL(MID$(cir$, strt, 1))
NEXT

shows the following sequences, from starting at the different positions:

2 2 5 8 6 7 1
3 7 1
4 5 8 6 7 1
5 3 4 2 5 8 6 7 1
6 9 3 4 2 5 8 6 7 1
7 6 7 1
8 4 2 5 8 6 7 1
9 8 6 7 1
10 1

So starting with the number in the 6th position (9) will go through all the numbers before being stopped by the zero.

Part 2 also uses trial and error via:

DECLARE SUB permute (a$)
c2$ = "3456789"
s$ = c2$
DO
    cir$ = "02" + c2$ + "1"
    g$ = ""
    strt = INSTR(cir$, "9")
      REDIM visited(9)
      ptr = strt: ct = 0
      DO
        m = VAL(MID$(cir$, ptr, 1))
        visited(m) = 1: ' : PRINT m;
        ptr = ptr + m: IF ptr > 10 THEN ptr = ptr - 10
        ct = ct + 1
      LOOP UNTIL ptr = 1 OR ct = 15
      good = 1
      FOR i = 1 TO 9
       IF visited(i) = 0 THEN good = 0: EXIT FOR
      NEXT
     IF good THEN
      g$ = cir$: stv = strt
     END IF
    IF g$ > "" THEN PRINT g$, stv
    permute c2$
LOOP UNTIL c2$ = s$

The permute subroutine is found elsewhere on this site.

Here we had to count iterations, as, for a given setup, we're not assured of a termination at zero--the counting process can continue in an infinite loop.

The program finds

0264793581
0275396481

the second line being the original sequence, and the first line being the sought answer for part 2.

Puzzle from New Scientist, 11 November 2006, Enigma 1417 by Bob Walker.

Comments: ( You must be logged in to post comments.)
  Subject Author Date
Puzzle Answer K Sengupta2023-09-20 03:22:52
solution to part 1Dave2006-12-21 09:23:22
re(2): SolutionPenny2006-12-19 09:23:30
re: SolutionCharlie2006-12-19 08:50:26
SolutionSolutionPenny2006-12-18 18:47:36
Creation of MagicGamer2006-12-17 00:41:36
first partDennis2006-12-16 10:41:42
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