uf-toys

toys and experiments with uf forth
git clone git://git.alexwennerberg.com/uf-toys
Log | Files | Refs | README

01b.f (367B) - raw


      1 variable last
      2 variable total
      3 : to-num ( a u -- n ) 0 -rot 0 do dup r@ + c@ h# 30 - rot 10 * + swap loop drop ;
      4 : read-num ( -- n ) pad pad 10 accept to-num ;
      5 : 3dup 2 pick 2 pick 2 pick ;
      6 : read-first-3 3 0 do read-num loop ;
      7 : solve read-first-3 2000 3 do
      8 3dup + + dup \ sum
      9 last @ swap < 0<> negate total +!  last ! 
     10 rot drop read-num loop total @ ;
     11 solve . cr bye