New code for matrix rotation and binary tree flattening problems