FIZZBUZZ
FIZZBUZZ
I was just reading that 99/100 job applicants for programming jobs apparently cannot write a short "fizzbuzz" program when given 10 minutes to do so in an interview.
I was wondering what the best solution (shortest, least memory or most elegant are all acceptable) would be on a ZX81
The rules are simple -
write out the values 1 to 100 on screen
If the value is divisble by 3 write 'FIZZ' after the number
If the value is divisble by 5 write 'BUZZ' after the number
If the value is divisble by 3 and 5 write 'FIZZBUZZ' after the number
I was wondering what the best solution (shortest, least memory or most elegant are all acceptable) would be on a ZX81
The rules are simple -
write out the values 1 to 100 on screen
If the value is divisble by 3 write 'FIZZ' after the number
If the value is divisble by 5 write 'BUZZ' after the number
If the value is divisble by 3 and 5 write 'FIZZBUZZ' after the number
Rich Mellor
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module
Also Involved in:
Icephorm
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module
Also Involved in:
Icephorm
Re: FIZZBUZZ
Hi!
I think it´s a good drinking game as well
Greetz
Jens
I think it´s a good drinking game as well
Greetz
Jens
eyerything will be okay in the end.
if it´s not okay, it´s not the end.
and: uıɐbɐ ʎɐqǝ uo pɹɐoqʎǝʞ ɐ ʎnq ɹǝʌǝ ɹǝʌǝu ןןıʍ ı
if it´s not okay, it´s not the end.
and: uıɐbɐ ʎɐqǝ uo pɹɐoqʎǝʞ ɐ ʎnq ɹǝʌǝ ɹǝʌǝu ןןıʍ ı
Re: FIZZBUZZ
Here it is:
SiggiMy ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
http://zx81.ddns.net/ZxTeaM
Re: FIZZBUZZ
Another one. Pure BASIC, more complex, but much faster!
MathRe: FIZZBUZZ
Another one, this time in pure forth
Load the program and type FIZZBUZZ to run it.
Load the program and type FIZZBUZZ to run it.
Code: Select all
: FIZZBUZZ
101 1
DO
CR I DUP DUP .
3 MOD 0=
IF ." FIZZ" THEN
5 MOD 0=
IF ." BUZZ " THEN
LOOP
;
- Attachments
-
- fizzbuzz-3.p
- (8.16 KiB) Downloaded 250 times
1 x ZX81, 2 x TK85 , 1 TK82C, 1 TK95, 1 x Alphacom 32 printer, 1 x ZXpand
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
Re: FIZZBUZZ
hi kmurta!
can you tell me something about this forth-version? it´s spanish?
salu2
jens
can you tell me something about this forth-version? it´s spanish?
salu2
jens
eyerything will be okay in the end.
if it´s not okay, it´s not the end.
and: uıɐbɐ ʎɐqǝ uo pɹɐoqʎǝʞ ɐ ʎnq ɹǝʌǝ ɹǝʌǝu ןןıʍ ı
if it´s not okay, it´s not the end.
and: uıɐbɐ ʎɐqǝ uo pɹɐoqʎǝʞ ɐ ʎnq ɹǝʌǝ ɹǝʌǝu ןןıʍ ı
Re: FIZZBUZZ
This small forth was published in the brazilian magazine "Micro Sistemas" and can be downloaded from http://zx81.eu5.org/files/soft/ms/Forth.zip.
It was also incorporated in the emulator VB81 Xur. See more information here http://forth-retro.pagesperso-orange.fr/index-en.htm.
It was also incorporated in the emulator VB81 Xur. See more information here http://forth-retro.pagesperso-orange.fr/index-en.htm.
1 x ZX81, 2 x TK85 , 1 TK82C, 1 TK95, 1 x Alphacom 32 printer, 1 x ZXpand
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
ZeXtender board, Joy81 - Programmable Joystick Controller, Turbo Sound 81
http://zx81.eu5.org
https://toddysoftware.itch.io/
Re: FIZZBUZZ
Hi
Wow, we have a complete rainbow of solutions here !!!
A very good Sinclair Basic version by Siggi
A very good Speed Optimized version by Math
and a very good Forth Version By Kmurta
This is my asm version. I need almost 10 minutes to write and debug it, reusing an routine to write numbers in decimal form
BTW: I think that the Scroll is not necessary, may be you can think the result is not so nice, but I think that the Rules say print on the screen and my version does just it
In one way this is my Think Out of The Box solution dedicated to the Mensa members (Sir Clive included)
Gus
Wow, we have a complete rainbow of solutions here !!!
A very good Sinclair Basic version by Siggi
A very good Speed Optimized version by Math
and a very good Forth Version By Kmurta
This is my asm version. I need almost 10 minutes to write and debug it, reusing an routine to write numbers in decimal form
BTW: I think that the Scroll is not necessary, may be you can think the result is not so nice, but I think that the Rules say print on the screen and my version does just it
In one way this is my Think Out of The Box solution dedicated to the Mensa members (Sir Clive included)
Gus
- Attachments
-
- fizzbuzz-4.rar
- FizzBuzz By Guzz
- (312 Bytes) Downloaded 237 times
Re: FIZZBUZZ
Hi Gus,
You are correct in that there is no rule about having one line per unit, but then surely points are awarded for artistic merit also as programmers need to not only understand the parameters of their remit, but what works well in the hands of a client.
However, your machine code program does break one rule - ie. if a number is divisible by 3 AND 5, then it should display FIZZBUZZ, not FIZZ BUZZ
You are correct in that there is no rule about having one line per unit, but then surely points are awarded for artistic merit also as programmers need to not only understand the parameters of their remit, but what works well in the hands of a client.
However, your machine code program does break one rule - ie. if a number is divisible by 3 AND 5, then it should display FIZZBUZZ, not FIZZ BUZZ
Rich Mellor
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module
Also Involved in:
Icephorm
RWAP Software
RWAP Adventures
SellMyRetro
Retro-Printer Module
Also Involved in:
Icephorm
Re: FIZZBUZZ
Hi Rich,RWAP wrote:Hi Gus,
You are correct in that there is no rule about having one line per unit, but then surely points are awarded for artistic merit also as programmers need to not only understand the parameters of their remit, but what works well in the hands of a client.
mmm in the artistic side of my solution you are missing some fact: I don't say it before, but if you look at the screen very carefully, in the same way that you must look the Magic Eye 3D books you will see some secret part of the Ferranti ULA's
I must admit that you are right here, and now my insolent asm version completes the rainbow...RWAP wrote:
However, your machine code program does break one rule - ie. if a number is divisible by 3 AND 5, then it should display FIZZBUZZ, not FIZZ BUZZ
Gus