I had fun solving this, so I offer this golf challenge.
The objective of this golf is to find the largest prime number that can be constructed using the given instructions.
You should accept 3x3 grid of single digits as input. (It's up to you how you want to do that, but specify that in your program.)
You can move along the grid orthogonally (left, right, up or down), and as you move, you keep appending the digits you walk across.
1 2 3 3 5 6 1 8 9
Say we start at
we can form the number 1236589 but cannot form 15.
You have to evaluate every starting position.
If a prime cannot be found, print
-1, else print the prime itself.
Shortest code wins, make sure it runs within 10 secs.
Edit: Use one position exactly once, in the entire number.
Here's a test case
1 2 3 4 5 6 7 8 9