refactored code to properly do columnar transposition

also handles uneven cases

should be fairly fast now,
not too many perms