P0001. Upward numbers P32149


Statement
 

pdf   zip

html

We say that a natural number is upward if its digits fulfill the following property: on the right of a 0 can only be a 1, on the right of a 1 can only be a 2, on the right of a 2 can only be a 3, …, on the right of a 8 can only be a 9 and on the right of a 9 can only be a 0. For instance, 34567 and 8901 are upward, but 1223 and 245 are not.

Your task is to write a program that, given a sequence of natural numbers, indicates if this contains two or more consecutive upward numbers.

Your program must include the function

Public test cases
  • Input

    1234 4321 4554 2345 8901 123 6784
    

    Output

    YES
    
  • Input

    
            
                                

    Output

    NO
    
  • Input

    90 0
    

    Output

    YES
    
  • Information
    Author
    Professorat de P1
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++