Sign in to follow this  
Followers 0
asik

Perimeter searching a Matrix

1 post in this topic

I'm wondering if anyone can shine a light as to how I might be able to do this.

The idea is, I have an 8x8 matrix of numbers (1-7). The matrix must be searched for identical numbers next to eachother (either horizontally or vertically). When a pair is found, the area around each number (not diagonally) must be searched for the same number (ie. a pair of 2's needs to find another 2). This number has to be switched with an adjacent number to create a row of 3 or more identical numbers.

To be valid, this number must not be touching either side (top and bottom for horizontal pairs, left and right sides for vertical pairs).

So, an example matrix:

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

Two Valid 7s:

4, 1, 2, 3, 6
7, 6, 7, 7, 2
6, 2, 4, 6, 7

Invalid 2:

7, 6, 7
6, 2, 4
7, 2, 2
5, 7, 1

Somebody up to the challenge? I'm still working on this myself, but I'm having a hell of a time with it.

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0