When a number is written in base 10,   adjacent digits may "rise" or "fall" as the number is read   (usually from left to right).



Definition

Given the decimal digits of the number are written as a series   d:

   A   rise   is an index   i   such that    d(i)  <  d(i+1)
   A   fall    is an index   i   such that    d(i)  >  d(i+1)


Examples

   The number   726,169   has   3   rises and   2   falls,   so it isn't in the sequence.
   The number     83,548   has   2   rises and   2   falls,   so it   is   in the sequence.


Task

   Print the first   200   numbers in the sequence 
   Show that the   10 millionth   (10,000,000th)   number in the sequence is   41,909,002


See also

   OEIS Sequence  A296712   describes numbers whose digit sequence in base 10 have equal "rises" and "falls".


Related tasks

   Esthetic numbers


with javascript_semantics
atom t1 = time()+1
integer count = 0, n = 0
printf(1,"The first 200 numbers are:\n")
while true do
    n += 1
    integer rmf = 0,
            l = remainder(n,10),
            r = floor(n/10)
    while r do
        integer p = remainder(r,10)
        rmf += compare(l,p)
        l = p
        r = floor(r/10)
    end while
    if rmf=0 then
        count += 1
        if count<=200 then
            printf(1,"%3d ",n)
            if remainder(count,20)=0 then
                printf(1,"\n")
            end if
        end if
        if count == 1e7 then
            if platform()!=JS then progress("") end if
            printf(1,"\nThe %,dth number is %,d\n",{count,n})
            exit
        end if
        if time()>t1 and platform()!=JS then
            progress("%,d:%,d\r",{count,n})
            t1 = time()+1
        end if
    end if
end while
