c++ - Permutations of a large number of rows -


an array of int (between 0 , 30) has n rows , 4 columns.

it has head , tail, start , end.

all rows 2 have permutated between head , tail. rows identified head , tail can moved, distance between 2 must, top bottom, remain same.

example:

enter image description here

in picture, sequence { 2, 4, 7, 9 } head, { 7, 1, 9, 4 } tail. thus, elements between these 2 can shuffled row row (not column column).

(it must noted "row#" refers row contains respective sequences, not absolute rows our perspective. "row3" in picture situated @ second row).

theoretically, if right, there 3! possible permutations.

but these elements can not randomly shuffled. specific configuration sought.

first contraint: each int of second column (here: colb) must identical int situated @ x mod n rows below in first column (cola). (x arbitrary: know there solution given x).

second constraint: each int of third column (colc) must identical int below it, mod n (then, nc = 1d), in fourth column (cold).

an example of configuration (x = 3 here): enter image description here

take number 4, row1, colb. identical number situated @ ((row 4)+3) % 5, cola (in blue). , case numbers of colb.

take number 7, row1, colc. identical number situated @ ((row 7)+1) % 5, cold (in yellow).

this configuration (x = 3 too):

enter image description here

head , tail have been moved, distance top bottom (we start head of course) between 2 remains same.

take number 2, row3 (the fourth row then), colb. identical number situated @ ((row 2)+3) % 5 = second row, cola.

as see, simple, trivial solve in situation.

now imagine n = 300. 300-2 rows must permutated in order meet constraints. 298! permutations possible. seems unsolvable.

do know if algorithm can solve problem n = 300 rows repetitive ints in reasonable time (that is, < age of universe)?

thanks!


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -