0 out of 464 challenges solved

Check Undulating Number

An **undulating number** is a number that alternates between two digits, starting with one digit and then switching to another, and repeating this pattern. For example, `1212121` is undulating, but `1991` is not.

Write a function `is_undulating(n)` that checks whether a given number `n` is undulating or not. The function should return `True` if the number is undulating, and `False` otherwise.

#### Examples
```python [main.nopy]
is_undulating(1212121)  # True
is_undulating(1991)     # False
is_undulating(121)      # True
is_undulating(1)        # False
```

#### Constraints
- The input `n` will be a positive integer.
- A number with fewer than three digits cannot be undulating.
def is_undulating(n):
    """
    Check if the given number is undulating.

    Args:
        n (int): The number to check.

    Returns:
        bool: True if the number is undulating, False otherwise.
    """
    # Convert the number to a string for easier manipulation
    n = str(n)
    # Implement the logic to check for undulating pattern
    pass