Skip to main content
added 62 characters in body
Source Link

Lets define a non-empty, unsorted and finite matrix with unique numbers as follow: $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$

Lets define 4 matrix moves as:

  • ↑* (up): Moves a column up
  • ↓* (down): Moves a column down
  • →* (right): Moves a row to the right
  • ←* (left): Moves a row to the left

The asterisk(*) represents the column/row that is affected by the move (It can be 0-indexed or 1-indexed. Up to you. Please state which one in your answer).


The challenge is, using above moves, sort the matrix in a ascendant order (being the top left corner the lowest and the bottom right corner the highest).

Example

Input: $$N=\begin{Bmatrix}4&2&3\\1&5&6 \end{Bmatrix}$$ Possible Output: ↑0 or ↓0. (Notice any of those moves can sort the matrix so both answer are correct)


Input: $$N=\begin{Bmatrix}2&3&1\\4&5&6 \end{Bmatrix}$$ Possible Output: →0


Input (Example test case): $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$ Possible Output: ↑0↑1←1↑2


Input: $$N = \begin{Bmatrix} 5&9&6\\ 8&2&4\\ 1&7&3 \end{Bmatrix}$$ Possible Output: ↑0↑2→0→2↑0→2↑1↑2←1


Input: $$N = \begin{Bmatrix} 1 & 27 & 28 & 29 & 6 \\10 & 2 & 3 & 4 & 5 \\17 & 7 & 8 & 13 & 9 \\15 & 11 & 12 & 18 & 14 \\26 & 16 & 21 & 19 & 20 \\30 & 22 & 23 & 24 & 25 \end{Bmatrix}$$ Possible Output: ↑2↑1←3→0←3↓0←0←2→3↑3↑4


Input: $$N = \begin{Bmatrix} 1 \end{Bmatrix} $$ Output: or any move


Input: $$N = \begin{Bmatrix} 1&2\\3&4 \end{Bmatrix} $$ Output:


Notes

  • There can be different correct outputs (there don't need to be necessarily the same as the test cases or the shortest one)
  • You can assume it will be always a way to order the matrix
  • Edges connects (like pacman :v)
  • There wont be a matrix with more than 9 columns or/and rows
  • Assume matrix contains only positive non-zero unique integers
  • You can use any 4 distinct values other than numbers to represent the moves (in case of that, please state that in your answer)
  • Column/row can be 0 or 1 indexed
  • Winning criteria

Extra test cases are always welcome

Lets define a non-empty, unsorted and finite matrix with unique numbers as follow: $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$

Lets define 4 matrix moves as:

  • ↑* (up): Moves a column up
  • ↓* (down): Moves a column down
  • →* (right): Moves a row to the right
  • ←* (left): Moves a row to the left

The asterisk(*) represents the column/row that is affected by the move (It can be 0-indexed or 1-indexed. Up to you. Please state which one in your answer).


The challenge is, using above moves, sort the matrix in a ascendant order (being the top left corner the lowest and the bottom right corner the highest).

Example

Input: $$N=\begin{Bmatrix}4&2&3\\1&5&6 \end{Bmatrix}$$ Possible Output: ↑0 or ↓0. (Notice any of those moves can sort the matrix so both answer are correct)


Input: $$N=\begin{Bmatrix}2&3&1\\4&5&6 \end{Bmatrix}$$ Possible Output: →0


Input (Example test case): $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$ Possible Output: ↑0↑1←1↑2


Input: $$N = \begin{Bmatrix} 5&9&6\\ 8&2&4\\ 1&7&3 \end{Bmatrix}$$ Possible Output: ↑0↑2→0→2↑0→2↑1↑2←1


Input: $$N = \begin{Bmatrix} 1 & 27 & 28 & 29 & 6 \\10 & 2 & 3 & 4 & 5 \\17 & 7 & 8 & 13 & 9 \\15 & 11 & 12 & 18 & 14 \\26 & 16 & 21 & 19 & 20 \\30 & 22 & 23 & 24 & 25 \end{Bmatrix}$$ Possible Output: ↑2↑1←3→0←3↓0←0←2→3↑3↑4


Input: $$N = \begin{Bmatrix} 1 \end{Bmatrix} $$ Output: or any move


Input: $$N = \begin{Bmatrix} 1&2\\3&4 \end{Bmatrix} $$ Output:


Notes

  • There can be different correct outputs (there don't need to be necessarily the same as the test cases or the shortest one)
  • Edges connects (like pacman :v)
  • There wont be a matrix with more than 9 columns or/and rows
  • Assume matrix contains only positive non-zero unique integers
  • You can use any 4 distinct values other than numbers to represent the moves (in case of that, please state that in your answer)
  • Column/row can be 0 or 1 indexed
  • Winning criteria

Extra test cases are always welcome

Lets define a non-empty, unsorted and finite matrix with unique numbers as follow: $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$

Lets define 4 matrix moves as:

  • ↑* (up): Moves a column up
  • ↓* (down): Moves a column down
  • →* (right): Moves a row to the right
  • ←* (left): Moves a row to the left

The asterisk(*) represents the column/row that is affected by the move (It can be 0-indexed or 1-indexed. Up to you. Please state which one in your answer).


The challenge is, using above moves, sort the matrix in a ascendant order (being the top left corner the lowest and the bottom right corner the highest).

Example

Input: $$N=\begin{Bmatrix}4&2&3\\1&5&6 \end{Bmatrix}$$ Possible Output: ↑0 or ↓0. (Notice any of those moves can sort the matrix so both answer are correct)


Input: $$N=\begin{Bmatrix}2&3&1\\4&5&6 \end{Bmatrix}$$ Possible Output: →0


Input (Example test case): $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$ Possible Output: ↑0↑1←1↑2


Input: $$N = \begin{Bmatrix} 5&9&6\\ 8&2&4\\ 1&7&3 \end{Bmatrix}$$ Possible Output: ↑0↑2→0→2↑0→2↑1↑2←1


Input: $$N = \begin{Bmatrix} 1 & 27 & 28 & 29 & 6 \\10 & 2 & 3 & 4 & 5 \\17 & 7 & 8 & 13 & 9 \\15 & 11 & 12 & 18 & 14 \\26 & 16 & 21 & 19 & 20 \\30 & 22 & 23 & 24 & 25 \end{Bmatrix}$$ Possible Output: ↑2↑1←3→0←3↓0←0←2→3↑3↑4


Input: $$N = \begin{Bmatrix} 1 \end{Bmatrix} $$ Output: or any move


Input: $$N = \begin{Bmatrix} 1&2\\3&4 \end{Bmatrix} $$ Output:


Notes

  • There can be different correct outputs (there don't need to be necessarily the same as the test cases or the shortest one)
  • You can assume it will be always a way to order the matrix
  • Edges connects (like pacman :v)
  • There wont be a matrix with more than 9 columns or/and rows
  • Assume matrix contains only positive non-zero unique integers
  • You can use any 4 distinct values other than numbers to represent the moves (in case of that, please state that in your answer)
  • Column/row can be 0 or 1 indexed
  • Winning criteria

Extra test cases are always welcome

Tweeted twitter.com/StackCodeGolf/status/1086005446484344833
added 20 characters in body
Source Link

Lets define a non-empty, unsorted and finite matrix with unique numbers as follow: $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$

Lets define 4 matrix moves as:

  • ↑* (up): Moves a column up
  • ↓* (down): Moves a column down
  • →* (right): Moves a row to the right
  • ←* (left): Moves a row to the left

The asterisk(*) represents the column/row that is affected by the move (It can be 0-indexed or 1-indexed. Up to you. Please state which one in your answer).


The challenge is, using above moves, sort the matrix in a ascendant order (being the top left corner the lowest and the bottom right corner the highest).

Example

Input: $$N=\begin{Bmatrix}4&2&3\\1&5&6 \end{Bmatrix}$$ OutputPossible Output: ↑0 or ↓0. (Notice any of those moves can sort the matrix so both answer are correct)


Input: $$N=\begin{Bmatrix}2&3&1\\4&5&6 \end{Bmatrix}$$ OutputPossible Output: →0


Input (Example test case): $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$ OutputPossible Output: ↑0↑1←1↑2


Input: $$N = \begin{Bmatrix} 5&9&6\\ 8&2&4\\ 1&7&3 \end{Bmatrix}$$ Possible Output: ↑0↑2→0→2↑0→2↑1↑2←1


Input: $$N = \begin{Bmatrix} 1 & 27 & 28 & 29 & 6 \\10 & 2 & 3 & 4 & 5 \\17 & 7 & 8 & 13 & 9 \\15 & 11 & 12 & 18 & 14 \\26 & 16 & 21 & 19 & 20 \\30 & 22 & 23 & 24 & 25 \end{Bmatrix}$$ Possible Output: ↑2↑1←3→0←3↓0←0←2→3↑3↑4


Input: $$N = \begin{Bmatrix} 1 \end{Bmatrix} $$ Output: or any move


Input: $$N = \begin{Bmatrix} 1&2\\3&4 \end{Bmatrix} $$ Output:


Notes

  • There can be different correct outputs (there don't need to be necessarily the same as the test cases or the shortest one)
  • Edges connects (like pacman :v)
  • There wont be a matrix with more than 9 columns or/and rows
  • Assume matrix contains only positive non-zero unique integers
  • You can use any 4 distinct values other than numbers to represent the moves (in case of that, please state that in your answer)
  • Column/row can be 0 or 1 indexed
  • Winning criteria

Extra test cases are always welcome

Lets define a non-empty, unsorted and finite matrix with unique numbers as follow: $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$

Lets define 4 matrix moves as:

  • ↑* (up): Moves a column up
  • ↓* (down): Moves a column down
  • →* (right): Moves a row to the right
  • ←* (left): Moves a row to the left

The asterisk(*) represents the column/row that is affected by the move (It can be 0-indexed or 1-indexed. Up to you. Please state which one in your answer).


The challenge is, using above moves, sort the matrix in a ascendant order (being the top left corner the lowest and the bottom right corner the highest).

Example

Input: $$N=\begin{Bmatrix}4&2&3\\1&5&6 \end{Bmatrix}$$ Output: ↑0 or ↓0. (Notice any of those moves can sort the matrix so both answer are correct)


Input: $$N=\begin{Bmatrix}2&3&1\\4&5&6 \end{Bmatrix}$$ Output: →0


Input (Example test case): $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$ Output: ↑0↑1←1↑2


Input: $$N = \begin{Bmatrix} 5&9&6\\ 8&2&4\\ 1&7&3 \end{Bmatrix}$$ Possible Output: ↑0↑2→0→2↑0→2↑1↑2←1


Input: $$N = \begin{Bmatrix} 1 & 27 & 28 & 29 & 6 \\10 & 2 & 3 & 4 & 5 \\17 & 7 & 8 & 13 & 9 \\15 & 11 & 12 & 18 & 14 \\26 & 16 & 21 & 19 & 20 \\30 & 22 & 23 & 24 & 25 \end{Bmatrix}$$ Possible Output: ↑2↑1←3→0←3↓0←0←2→3↑3↑4


Input: $$N = \begin{Bmatrix} 1 \end{Bmatrix} $$ Output: or any move


Input: $$N = \begin{Bmatrix} 1&2\\3&4 \end{Bmatrix} $$ Output:


Notes

  • There can be different correct outputs (there don't need to be necessarily the same as the test cases)
  • Edges connects (like pacman :v)
  • There wont be a matrix with more than 9 columns or/and rows
  • Assume matrix contains only positive non-zero unique integers
  • You can use any 4 distinct values other than numbers to represent the moves (in case of that, please state that in your answer)
  • Column/row can be 0 or 1 indexed
  • Winning criteria

Extra test cases are always welcome

Lets define a non-empty, unsorted and finite matrix with unique numbers as follow: $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$

Lets define 4 matrix moves as:

  • ↑* (up): Moves a column up
  • ↓* (down): Moves a column down
  • →* (right): Moves a row to the right
  • ←* (left): Moves a row to the left

The asterisk(*) represents the column/row that is affected by the move (It can be 0-indexed or 1-indexed. Up to you. Please state which one in your answer).


The challenge is, using above moves, sort the matrix in a ascendant order (being the top left corner the lowest and the bottom right corner the highest).

Example

Input: $$N=\begin{Bmatrix}4&2&3\\1&5&6 \end{Bmatrix}$$ Possible Output: ↑0 or ↓0. (Notice any of those moves can sort the matrix so both answer are correct)


Input: $$N=\begin{Bmatrix}2&3&1\\4&5&6 \end{Bmatrix}$$ Possible Output: →0


Input (Example test case): $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$ Possible Output: ↑0↑1←1↑2


Input: $$N = \begin{Bmatrix} 5&9&6\\ 8&2&4\\ 1&7&3 \end{Bmatrix}$$ Possible Output: ↑0↑2→0→2↑0→2↑1↑2←1


Input: $$N = \begin{Bmatrix} 1 & 27 & 28 & 29 & 6 \\10 & 2 & 3 & 4 & 5 \\17 & 7 & 8 & 13 & 9 \\15 & 11 & 12 & 18 & 14 \\26 & 16 & 21 & 19 & 20 \\30 & 22 & 23 & 24 & 25 \end{Bmatrix}$$ Possible Output: ↑2↑1←3→0←3↓0←0←2→3↑3↑4


Input: $$N = \begin{Bmatrix} 1 \end{Bmatrix} $$ Output: or any move


Input: $$N = \begin{Bmatrix} 1&2\\3&4 \end{Bmatrix} $$ Output:


Notes

  • There can be different correct outputs (there don't need to be necessarily the same as the test cases or the shortest one)
  • Edges connects (like pacman :v)
  • There wont be a matrix with more than 9 columns or/and rows
  • Assume matrix contains only positive non-zero unique integers
  • You can use any 4 distinct values other than numbers to represent the moves (in case of that, please state that in your answer)
  • Column/row can be 0 or 1 indexed
  • Winning criteria

Extra test cases are always welcome

Source Link

Matrix rotation sort

Lets define a non-empty, unsorted and finite matrix with unique numbers as follow: $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$

Lets define 4 matrix moves as:

  • ↑* (up): Moves a column up
  • ↓* (down): Moves a column down
  • →* (right): Moves a row to the right
  • ←* (left): Moves a row to the left

The asterisk(*) represents the column/row that is affected by the move (It can be 0-indexed or 1-indexed. Up to you. Please state which one in your answer).


The challenge is, using above moves, sort the matrix in a ascendant order (being the top left corner the lowest and the bottom right corner the highest).

Example

Input: $$N=\begin{Bmatrix}4&2&3\\1&5&6 \end{Bmatrix}$$ Output: ↑0 or ↓0. (Notice any of those moves can sort the matrix so both answer are correct)


Input: $$N=\begin{Bmatrix}2&3&1\\4&5&6 \end{Bmatrix}$$ Output: →0


Input (Example test case): $$N = \begin{Bmatrix} 4&5&7\\1&3&6 \end{Bmatrix}$$ Output: ↑0↑1←1↑2


Input: $$N = \begin{Bmatrix} 5&9&6\\ 8&2&4\\ 1&7&3 \end{Bmatrix}$$ Possible Output: ↑0↑2→0→2↑0→2↑1↑2←1


Input: $$N = \begin{Bmatrix} 1 & 27 & 28 & 29 & 6 \\10 & 2 & 3 & 4 & 5 \\17 & 7 & 8 & 13 & 9 \\15 & 11 & 12 & 18 & 14 \\26 & 16 & 21 & 19 & 20 \\30 & 22 & 23 & 24 & 25 \end{Bmatrix}$$ Possible Output: ↑2↑1←3→0←3↓0←0←2→3↑3↑4


Input: $$N = \begin{Bmatrix} 1 \end{Bmatrix} $$ Output: or any move


Input: $$N = \begin{Bmatrix} 1&2\\3&4 \end{Bmatrix} $$ Output:


Notes

  • There can be different correct outputs (there don't need to be necessarily the same as the test cases)
  • Edges connects (like pacman :v)
  • There wont be a matrix with more than 9 columns or/and rows
  • Assume matrix contains only positive non-zero unique integers
  • You can use any 4 distinct values other than numbers to represent the moves (in case of that, please state that in your answer)
  • Column/row can be 0 or 1 indexed
  • Winning criteria

Extra test cases are always welcome