rearranging code for coding challenges