Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.forth    |    Forth programmers eat a lot of Bratwurst    |    117,927 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 116,521 of 117,927    |
|    B. Pym to Anton Ertl    |
|    Re: Best Euler #13 solution?    |
|    02 Jun 24 23:15:35    |
   
   From: No_spamming@noWhere_7073.org   
      
   On 5/3/2024, Anton Ertl wrote:   
      
   > s" euler13.input" slurp-file 2constant input   
   >   
   > : sumcolumn ( ucarry1 c-addr -- ucarry2 )   
   > 5100 bounds ?do   
   > i c@ +   
   > 51 +loop   
   > '0' 100 * - 0 # drop ;   
   >   
   > : sum ( -- c-addr2 u2 )   
   > 0 <<#   
   > input drop 50 1 mem-do   
   > i sumcolumn   
   > loop   
   > 0 #s #> ;   
   >   
   > sum drop 10 type cr   
   >   
   > This outputs "5537376230".   
      
   SP-Forth   
      
   REQUIRE BOUNDS ~ygrek/lib/neilbawd/toolbelt.f   
   REQUIRE STR@ ~ac/lib/str5.f \ slurp file: FILE   
   REQUIRE .R lib/include/core-ext.f   
   REQUIRE { lib/ext/locals.f \ local variables   
   REQUIRE CASE-INS lib/ext/caseins.f \ case-insensitivity   
      
   : eu13 { a n }   
    0 0 49 do   
    a i + 5100 bounds do i c@ 48 - + 51 +loop   
    10 /mod   
    -1 +loop   
    9 0 do 1 .R loop ;   
      
   s" eu13.dat" FILE eu13   
      
    ===>   
   5537376230   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca