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

Home > Numbers
Fill the Grid (Posted on 2004-01-21) Difficulty: 5 of 5
In the 4x4 grid below, 32 consecutive two digit numbers (45 to 76) have been packed in it.
1 3 5 9
2 5 4 8
0 7 6 2
1 6 3 9
*****
The challenge: Pack as many consecutive 3 digit numbers as possible into a 9x9 grid. The numbers may be read from any direction. No leading zeros.

See The Solution Submitted by Brian Smith    
Rating: 3.6250 (8 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
My algorithm | Comment 17 of 29 |
Firstly to Brian - I wrote the program in Delphi 6, if you want the source code I'll happily email it to you :)

And now for everyone else that's interested...

I used a genetic algorithm to find my solutions. I start with a population of 500 random "genes". Each gene is a string of 81 digits (enough to fill the 9x9 grid). I test the genes and find the longest run of consecutive numbers in each, and store this as the "fitness" score for each gene. When all the tests are done, a new genepool is generated. For each new gene, two genes are selected using roulette wheel sampling and "bred" by mixing them together at random. There is a probability of about 0.001 that a gene will mutate and contain a digit that is different from both parents. The old genepool is replaced with the new genepool and the process begins again.

So basically the algorithm is:

Test, breed, mutate, repeat.

...But this is the same for pretty much any GA.

Sorry for the poor explanation - I'm not very good at explaining things like that :P

Peace,
Rawlyn.
  Posted by Rawlyn on 2004-02-04 18:48:41
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 (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