Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #10665

Re: Euler problem 303

From anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups comp.lang.forth
Subject Re: Euler problem 303
Date 2012-03-31 13:08 +0000
Organization Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID <2012Mar31.150845@mips.complang.tuwien.ac.at> (permalink)
References <2012Mar30.170245@mips.complang.tuwien.ac.at> <7xr4w9uylg.fsf@ruckus.brouhaha.com>

Show all headers | View raw


Paul Rubin <no.email@nospam.invalid> writes:
>anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
>> One other interesting thing is that it generates (decimal) numbers
>> containing only 0, 1, 2 by converting numbers into strings using base
>> 3, then converting the strings to numbers using base 10.  
>
>    : tn ( n -- n ) 3 /mod dup if recurse 10 * + else drop then ;

: desired-form ( u1 -- ud2 )
    \ u2 is the u1th cool number
    3 base ! 0 <# #s #>
    decimal 0 0 2swap >number 2drop ;

The same basic functionality, but produces doubles (which are needed);
it's probably also significantly slower, mainly because it also works
with doubles in the #S part, where it is not necessary (for this problem).

- anton
-- 
M. Anton Ertl  http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
     New standard: http://www.forth200x.org/forth200x.html
   EuroForth 2011: http://www.euroforth.org/ef11/

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Euler problem 303 anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-30 15:02 +0000
  Re: Euler problem 303 Paul Rubin <no.email@nospam.invalid> - 2012-03-30 22:30 -0700
    Re: Euler problem 303 anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-31 13:08 +0000
      Re: Euler problem 303 Paul Rubin <no.email@nospam.invalid> - 2012-04-01 00:51 -0700
        Re: Euler problem 303 Paul Rubin <no.email@nospam.invalid> - 2012-04-01 01:46 -0700
          Re: Euler problem 303 mhx@iae.nl (Marcel Hendrix) - 2012-04-01 12:00 +0200
            Re: Euler problem 303 Paul Rubin <no.email@nospam.invalid> - 2012-04-01 12:57 -0700
              Re: Euler problem 303 Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-04-01 23:34 +0000
                Re: Euler problem 303 Paul Rubin <no.email@nospam.invalid> - 2012-04-01 17:19 -0700
          Re: Euler problem 303 anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-04-02 10:53 +0000
  Re: Euler problem 303 Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-31 11:41 +0000
    Re: Euler problem 303 anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2012-03-31 13:30 +0000
      Re: Euler problem 303 Albert van der Horst <albert@spenarnc.xs4all.nl> - 2012-03-31 18:27 +0000

csiph-web