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

Home > Numbers
Self-Descriptor (Posted on 2002-07-10) Difficulty: 3 of 5
Find a number ABCDEFGHIJ such that A is the count of how many 0's are in the number, B is the number of 1's, and so on.

(Taken from http://einstein.et.tudelft.nl/~arlet/puzzles/logic.html)

See The Solution Submitted by levik    
Rating: 3.8750 (8 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 12 of 14 |

It takes several runs of this program, manually halting it when a pattern emerges:

DIM ct(1, 9)
RANDOMIZE TIMER
FOR i = 0 TO 9
 ct(0, i) = INT(RND(1) * 10)
NEXT

DO
 FOR i = 0 TO 9
  ct(1, i) = 0
 NEXT
 FOR i = 0 TO 9
  ct(1, ct(0, i)) = ct(1, ct(0, i)) + 1
 NEXT
 FOR i = 0 TO 9
   ct(0, i) = ct(1, i)
   PRINT ct(0, i);
 NEXT
 PRINT
LOOP

Each successive line shows the count of the number of the given digit in the preceding line.

So when the following pattern is reached,

6  3  0  0  0  0  0  1  0  0
7  1  0  1  0  0  1  0  0  0
6  3  0  0  0  0  0  1  0  0
7  1  0  1  0  0  1  0  0  0
6  3  0  0  0  0  0  1  0  0
7  1  0  1  0  0  1  0  0  0
6  3  0  0  0  0  0  1  0  0
7  1  0  1  0  0  1  0  0  0
6  3  0  0  0  0  0  1  0  0
7  1  0  1  0  0  1  0  0  0
6  3  0  0  0  0  0  1  0  0
7  1  0  1  0  0  1  0  0  0
6  3  0  0  0  0  0  1  0  0

a solution hasn't been found, and it needs to try again. The RANDOMIZE TIMER causes a different seed to start. Eventually a run will produce the desired answer:

6  2  1  0  0  0  1  0  0  0
6  2  1  0  0  0  1  0  0  0
6  2  1  0  0  0  1  0  0  0
6  2  1  0  0  0  1  0  0  0
6  2  1  0  0  0  1  0  0  0
6  2  1  0  0  0  1  0  0  0
6  2  1  0  0  0  1  0  0  0
6  2  1  0  0  0  1  0  0  0
6  2  1  0  0  0  1  0  0  0
6  2  1  0  0  0  1  0  0  0
6  2  1  0  0  0  1  0  0  0
6  2  1  0  0  0  1  0  0  0
6  2  1  0  0  0  1  0  0  0
6  2  1  0  0  0  1  0  0  0

The above two seem to be the only two patterns achieved; I don't know if any other loop is possible.


  Posted by Charlie on 2009-03-30 11:23:32
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 (6)
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