solve zigzag-conversion