Whenever they zig, you gotta zag def is_zigzag(n): A positive integer n is called a zigzag number (also called an “alternating number” in some combinatorics material) if the series of differences...



Whenever they zig, you gotta zag

def is_zigzag(n):


A positive integer n is called a zigzag number (also called an “alternating number” in some combinatorics material) if the series of differences between its consecutive digits strictly alternates between positive and negative steps. The step from the first digit to the second may be either positive or negative. The function should determine whether n is a zigzag number.


In the negative examples in the table below, the part of the number that violates the zigzag property is highlighted in red.


Expected result<br>n<br>7<br>True<br>25391<br>True<br>90817263545463728185<br>True<br>16329<br>False<br>104175101096715<br>False<br>49573912009<br>False<br>

Extracted text: Expected result n 7 True 25391 True 90817263545463728185 True 16329 False 104175101096715 False 49573912009 False

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here