Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #47166
| Newsgroups | comp.lang.forth |
|---|---|
| Date | 2016-05-15 14:41 -0700 |
| References | <2210aa04-1df4-4328-bf8c-66fbf845609c@googlegroups.com> <f2c2561c-5208-452d-97b7-3aff17789c02@googlegroups.com> <871t566dwf.fsf@jester.gateway.pace.com> <nhamor$q5i$1@dont-email.me> |
| Message-ID | <7bc3a74c-01a4-4db5-936d-e75f2f01e67c@googlegroups.com> (permalink) |
| Subject | Re: fizzbuzz problem in forth |
| From | hughaguilar96@gmail.com |
On Sunday, May 15, 2016 at 1:42:27 PM UTC-7, Gerry wrote: > On 13/05/2016 00:43, Paul Rubin wrote: > > murphy.darin@gmail.com writes: > >> I know it's probaby very sloppy and wasteful, but just finised reading > >> chapter 5 of "Starting forth" and haven't gotten factoring > >> (distilling) down yet, but I will improve! Take care now. > > > > You did fine. That fizzbuzz problem attracts so many solutions not > > because it's difficult, but because it has annoying edges that draw > > people irresistably to look for ways to smooth them down. > > > > http://dave.fayr.am/posts/2012-10-4-finding-fizzbuzz.html > > (not Forth related) expands on that thought. > > > > In 2007 (yes that long ago) I posted a solution that didn't involve > using MOD. Slightly re-worked this was: > > hex > 1249 constant fizzers \ Bits 3i set, i = 0 to 4 > 0421 constant buzzers \ Bits 5i set, i = 0 to 2 > 4000 constant reset-probe \ Bit 14 set > decimal I told you then to use binary for your bit-masks --- bit-masks only make sense in binary --- using hex or any other base is just obfuscation. > : fizzbuzz > cr 0 101 1 > do > ?dup 0= if reset-probe then ( -- probe ) > [ fizzers buzzers or ] literal over and 0= if i . then > fizzers over and if ." fizz" then > buzzers over and if ." buzz" then > 1 rshift cr ( -- probe' ) > loop drop > ; Your solution is pretty good --- you do avoid using MOD which everybody else uses. Your solution doesn't scale up very well though. What if the interview asks you to upgrade to FIZZ-BUZZ-BURP, with BURP being printed every 7th time? Bit masks were reasonable when they were (3*5=15) bits long --- not so reasonable when they are (3*5*7=105) bits long.
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
fizzbuzz problem in forth murphy.darin@gmail.com - 2016-05-12 16:17 -0700
Re: fizzbuzz problem in forth Paul Rubin <no.email@nospam.invalid> - 2016-05-12 16:43 -0700
Re: fizzbuzz problem in forth murphy.darin@gmail.com - 2016-05-12 17:22 -0700
Re: fizzbuzz problem in forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-05-13 12:52 +0000
Re: fizzbuzz problem in forth Paul Rubin <no.email@nospam.invalid> - 2016-05-16 15:09 -0700
Re: fizzbuzz problem in forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-05-17 13:49 +0000
Re: fizzbuzz problem in forth Paul Rubin <no.email@nospam.invalid> - 2016-05-17 11:14 -0700
Re: fizzbuzz problem in forth anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-05-18 12:36 +0000
Re: fizzbuzz problem in forth Paul Rubin <no.email@nospam.invalid> - 2016-05-20 21:55 -0700
Re: fizzbuzz problem in forth julian.fondren@endurance.com - 2016-06-20 20:20 -0700
Re: fizzbuzz problem in forth hughaguilar96@gmail.com - 2016-05-17 12:26 -0700
Re: fizzbuzz problem in forth Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-05-15 21:42 +0100
Re: fizzbuzz problem in forth hughaguilar96@gmail.com - 2016-05-15 14:41 -0700
Re: fizzbuzz problem in forth hughaguilar96@gmail.com - 2016-05-15 15:15 -0700
Re: fizzbuzz problem in forth hughaguilar96@gmail.com - 2016-05-15 17:38 -0700
Re: fizzbuzz problem in forth murphy.darin@gmail.com - 2016-05-15 19:01 -0700
Re: fizzbuzz problem in forth hughaguilar96@gmail.com - 2016-05-15 19:51 -0700
Re: fizzbuzz problem in forth murphy.darin@gmail.com - 2016-05-15 20:48 -0700
Re: fizzbuzz problem in forth hughaguilar96@gmail.com - 2016-05-16 07:51 -0700
Re: fizzbuzz problem in forth "WJ" <w_a_x_man@yahoo.com> - 2016-05-25 08:31 +0000
Re: fizzbuzz problem in forth "WJ" <w_a_x_man@yahoo.com> - 2016-05-27 19:06 +0000
Re: fizzbuzz problem in forth humptydumpty <ouatubi@gmail.com> - 2016-05-18 13:19 -0700
Re: fizzbuzz problem in forth hughaguilar96@gmail.com - 2016-05-18 17:49 -0700
Re: fizzbuzz problem in forth humptydumpty <ouatubi@gmail.com> - 2016-05-18 21:17 -0700
Re: fizzbuzz problem in forth hughaguilar96@gmail.com - 2016-05-19 07:38 -0700
Re: fizzbuzz problem in forth "Kerr Mudd-John" <admin@127.0.0.1> - 2016-06-20 19:24 -0100
Re: fizzbuzz problem in forth endlessboomcapitalism@gmail.com - 2016-06-20 15:03 -0700
Re: fizzbuzz problem in forth Albert van der Horst <albert@cherry.spenarnc.xs4all.nl> - 2016-05-19 13:07 +0000
Re: fizzbuzz problem in forth Paul Rubin <no.email@nospam.invalid> - 2016-05-19 12:22 -0700
Re: fizzbuzz problem in forth Albert van der Horst <albert@cherry.spenarnc.xs4all.nl> - 2016-05-20 23:51 +0000
csiph-web