2020-8: Zigzag Numbers

A zigzag number is an integer in which the difference in magnitude of each pair of consecutive digits alternates from positive to negative or negative to positive.

Write code that takes a single integer greater than or equal to 100 and less than 1015 as its argument and returns a 1 if the integer is a zigzag number, 0 otherwise.

Examples

Implementation

You can also run the tests via ⌘/shift + enter