0

help me

All submissions for this problem are available. Johnny has some difficulty memorizing the small prime numbers. So, his computer science teacher has asked him to play with the following puzzle game frequently. The puzzle is a 3x3 board consisting of numbers from 1 to 9. The objective of the puzzle is to swap the tiles until the following final state is reached: 1 2 3 4 5 6 7 8 9 At each step, Johnny may swap two adjacent tiles if their sum is a prime number. Two tiles are considered adjacent if they have a common edge. Help Johnny to find the shortest number of steps needed to reach the goal state. Input: 2 7 3 2 4 1 5 6 8 9 9 8 5 2 4 1 3 7 6 Output: 6 -1

22nd Jun 2018, 6:36 PM
Hardik Aghara
Hardik Aghara - avatar
2 Answers
+ 1
When typed 2, from what moved to what and why?
23rd Jun 2018, 11:44 AM
Seb TheS
Seb TheS - avatar
+ 1
i spot homework
24th Jun 2018, 12:23 PM
hinanawi
hinanawi - avatar