Solve reversal distance (inline::cpp trick)
Perl is really slow