Skip to content

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 a function that takes a single integer greater than or equal to 100 and less than 1015 as its right argument and returns a 1 if the integer is a zigzag number, 0 otherwise.

💡 Hint: Your solution might make use of N-wise Reduction X f/ Y.

Examples:

      (your_function) 123 
0

      (your_function) 132
1

      (your_function) 31115
0

      (your_function) 3141514131415
1
your_function ←

Solutions

Video Thumbnail YouTube

Chat transcript Code on GitHub