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


function eqrf( n as uinteger ) as boolean
    dim as string sn = str(n)
    dim as integer q = 0
    for i as uinteger = 2 to len(sn)
        if asc(mid(sn,i,1)) > asc(mid(sn,i-1,1)) then 
            q += 1 
        elseif asc(mid(sn,i,1)) < asc(mid(sn,i-1,1)) then 
            q -= 1
        end if
    next i
    if q = 0 then return true else return false
end function
 
dim as uinteger c = 0, i = 1
while c < 10000001
    if eqrf(i) then
        c += 1
        if c <= 200 then print i;" ";
        if c = 10000000 then print : print i
    end if
    i += 1
wend