Computer Science, asked by laxmi243656, 8 months ago

Consider 9 natural numbers arranged in a 3x3 matrix:


n11 n12 n13


n21 n22 n23


n31 n32 n33

Define numbers "in contact" with a given number to be those that appear closest to it on the same row, column or diagonally across:


Contacts of number n11: n12, n22 and n21


Contacts of number n12: n11, n21, n22, n23, n13


Contacts of number n13: n12, n22, n23


Contacts of number n21: n11, n12, n22, n32, n31


Contacts of number n22: n11, n12, n13, n23, n33, n32, n31, n21


Contacts of number n23: n13, n12, n22, n32, n33


Contacts of number n31: n21, n22, n32


Contacts of number n32: n31, n21, n22, n23, n33


Contacts of number n33: n32, n22, n23

The problem now is that numbers having a common factor (other than 1) should not be "in contact". In other words, a pair of numbers can remain neighbours only if their highest common factor is 1.


The following rules apply to enforce this "distancing":


1. The central number (n22) stays put.


2. The corner numbers (n11, n13, n33, n31) can move in the same row or column or diagonally away from the centre.


3. The numbers "on the walls" (n12, n23, n32, n21) can only move from the walls i.e. n21 can only move "left", n12 can only move "up", n23 can only move "right" and n32 can only move "down".


4. Each number should stay put as far as possible and the "distancing" operation should result in the least number of numbers ending up without any contacts.


5. After satisfying rule 4, if there are multiple options for the final matrix, then the "distancing" operation should result in the smallest (m x n matrix, including the intervening blank space elements, with the least possible value of m*n).


6. If, after satisfying all the rules above, there are multiple distancing options for a set of numbers, the largest number keeps to its original cell.


Constraints

1 <= Element of grid <= 100

Input

First line consists of 9 space separated integers denoting n11, n12, n13, .... n23, n33 respectively.


Output

Print the "contact" less numbers in ascending order of their value separated by space. Output "None" if there are no such numbers.


Time Limit

1
WANT A CODE SOLUTION FOR THIS

Answers

Answered by priyadpriyadarshini3
0

Answer:

9 natural numbers arranged in a 3x3 matrix: n11 n12 n13 n21 n22 n23 n31 n32 n33 numbers "in contact" with a given number to be those that appear closest to it on the same row, column or diagonally across: Contacts of number n11: n12, n22 and n21 Contacts ... Here is what is it about: There is a given array of integers.You choose to fight opponent number 8, then after winning, the max prize kitty you can ... Number Distancing Problem Description Consider 9 natural numbers ... matrix: n11 n12 n13 n21 n22 n23 n31 n32 n33 Define numbers "in contact" with a given number to be those that appear closest to it on the same row, column or ...Consider 9 natural numbers arranged in a 3x3 matrix n11 n12 n13 n21 n22 n23 n31 n32 n33. Define numbers "in contact" with a given number to be those that appear closest to it on the same row, column or diagonally across: Contacts of ... Contacts of number n22: n11, n12, n13, n23, n33, n32, n31, n21. Contacts of ...

Similar questions