Scripting puzzle / challenge.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Scripting puzzle / challenge.

Stephen Barncard via use-livecode
It's been a while since we had a puzzle challenge on here ....

I came across this article

and it seemed to me like an interesting puzzle. The article is
interesting, but (IMHO) pretty flawed; don't be put off by how complex
he makes it seem :-).

Problem is simple:

given a rectangular grid of squares, each square has a color and the
task is to find the largest contiguous block of any single colour.

We'll keep the problem size moderate - up to 100x100 squares in the
grid, up to 8 colours. Any 2 squares are adjacent only if they share an
edge - i.e. corner touches don't count.

The input format is a file : each line is a row of the grid, each
character is a square within that row, and the value of the char
represents the colour of that square. (or simply generate the data
internally in the same format).

So an example would be


which has a block of 18 'g' squares, so the result would be something like

2,2 3,2 4,2 5,2 6,2 7,2 2,3 7,3 2,4 7,4 2,5 7,5 2,6 3,6 4,6 5,6 7,6

I'll post my solution in a day or two - but if you are impatient you can
download from
     - text file, script for the solution function only (< 100 lines) 
     - stack file, including display of the results, etc.

and some sample data at ..../color_1.txt   .../color_2.txt and

-- Alex.
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences: