The Founder and The Ghost

All submissions for this problem are available.
“Do you understand what’s going on in here, TARS?” The way out of the tesseract is a lower dimensional puzzle which consists of $k$Squares, consisting of a $k*k*1$ grid of cubies, where the solved configuration consists of six monochromatic faces. From any $k$Square configuration, there are $2k$ possible moves to transform the configuration into a new configuration. Each move changes the position and orientation of exactly one row or column of cubies from a input configuration in the following way: to move row (or column) $i$ of a configuration, reverse the order of the cubies within that row (or column), and flip the orientation of each cubie in the row (or column) upsidedown. We will represent a $k$Square configuration via a length$k$ array of length$k$ arrays, where the $y^{th}$ inner array corresponds to the $y^{th}$ row of the configuration, and the $x^{th}$ element of row $y$ corresponds to the cubie positioned at row $y$ and column $x$. We represent each cubie as an integer between $1$ and $k^2$ inclusive, where integer $i$ represents the cubie that exists in row $y = floor(i1/k)$ and column $x = iky1$ in the solved configuration. In addition, we use positive $i$ when the cubie in the configuration has the same orientation as in the solved configuration, and negative $i$ when the cubie is upsidedown. For example, the two configurations shown above have the following representations:  $C_1=((1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12),(13, 14, 15, 16))$  $C_2 =(( 1, 2, 15, 4),( 5, 6, 11, 8), ( 9, 10, 7, 12),(13, 14, 3, 16))$  here, $C_2$ = move($C_1$, ("$col$", $2$)) Joseph Cooper now needs your help! Find the shortest sequence of moves to solve the $k$Square. The input will be a $k$square configuration, and it should return a list of moves where: $(1)$ each move is of the form $(s, i)$ for some $s$ in { "$row$","$col$"} and $i$ in ${ 0,....., k1}$, and $(2)$ applying the sequence of moves in order to the input configuration results in the solved configuration. If there are multiple sequences of moves always choose to apply a “$col$” move before a “$row$” move, and between moves of the same type (“$row$” or “$col$”) choose the move with a smaller index. ###Input format  The first line contains $k$, the side of the $k$square.  The following $k$ lines contains $k$ integers, such that the $i^{th}$ integer in the $j^{th}$ line $a_{ij}$ corresponds to the cubie positioned at row $i$ and column $j$. ###Constraints  $1\leq k \leq10$  $k^2 \leq a_{ij} \leq k^2$ ###Output Format  Print $n$, the number of moves in the shortest sequence.  In the following $n$ lines print the moves, where the $i_{th}$ line contains a move of the form $(s,i)$ as a string $s$ followed by a space followed by integer $i$. ###Sample Input 2 1 4 3 2 ###Sample Output 1 col 1Author:  shriram_c253 
Tags  shriram_c253 
Date Added:  19122019 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 