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 upto 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. Eg.
1 2 3
3 5 6
1 8 9
Say we start at 1
,
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 10secs.
Have Fun!
Edit: Use one position exactly once, in the entire number.