zigzag conversion CPP/Python accepted