algol,n<
begin
   comment

   https://projecteuler.net/problem=112

   Answer:  1587000
   Time:    25518.52s = 7h 5m 18.52s

   No buffer, no f̲o̲r̲:

   Time classic:        30380.22
   Time turbo:          28390.72 6.5pct

   Buffer, no f̲o̲r̲:

   Time classic:        30569.63
   Time turbo:          28580.12 6.5pct

   No buffer, f̲o̲r̲:

   Time classic:        25329.12
   Time turbo:          24158.28 4.6pct

   Buffer, f̲o̲r̲:

   Time classic:        25518.52
   Time turbo:          24347.68 4.6pct

   ;
   real clock;
   real procedure clock count;
   code clock count;
   1, 37;
     zl        , grf p−1   ; RF ≔ clock count; stack[p−1] ≔ RF;
   e;
   boolean procedure bouncy(n);
   value n;
   integer n;
   begin
      integer d,lastd;
      boolean up,down;
      bouncy ≔ up ≔ down ≔ false;
      lastd ≔ n mod 10;
      n ≔ n÷10;
      for n ≔ n while n>0 do
      begin
         d ≔ n mod 10;
         if d>lastd ∨ (d=lastd ∧ up) then
            up ≔ true
         else
         if d<lastd ∨ (d=lastd ∧ down) then
            down ≔ true;
         if up ∧ down then
         begin
            bouncy ≔ true;
            goto finish
         end bouncy;
         n ≔ n÷10;
         lastd ≔ d
      end for;
finish:
   end bouncy;
   integer i,bcount;
   clock count;
   bcount ≔ 0;
   for i ≔ 1 step 1 until 999999999 do
   begin
      if bouncy(i) then bcount ≔ bcount+1;
      if bcount×100/i⩾99 then goto found
   end;
   writetext(«bad»);
found:
   clock ≔ clock count;
   writecr;
   writeinteger(«p»,bcount);
   writecr;
   writeinteger(«p»,i);
   writecr;
   write(«dddddddd.dd»,clock)
end;
t<