### Author Topic: Fizz Buzz Plus  (Read 552 times)

#### B+

• Hero Member
• Posts: 846
##### Fizz Buzz Plus
« on: 07. May 2019, 15:25:40 »
http://wiki.c2.com/?FizzBuzzTest

Code: [Select]
`check\$ = "0203050711": say\$ = "BizzFizzBuzzFuzzWow"FOR i = 1 TO 100    Flag = 1    FOR j = 0 TO 4        IF i MOD VAL(MID\$(check\$, j * 2 + 1, 2)) = 0 THEN PRINT MID\$(say\$, j * 4 + 1, 4);: Flag = 0    NEXT    IF Flag THEN PRINT i ELSE PRINTNEXT`
« Last Edit: 07. May 2019, 15:36:25 by B+ »

#### jj2007

• Full Member
• Posts: 168
• MasmBasic rocks
##### Re: Fizz Buzz Plus
« Reply #1 on: 08. May 2019, 16:40:24 »

#### Tomaaz

• Guest
##### Re: Fizz Buzz Plus
« Reply #2 on: 10. May 2019, 01:29:05 »
Newlisp (a single line version):

Code: [Select]
`(print (map (fn (x) (if (zero? (% x 15)) "FizzBuzz" (zero? (% x 3)) "Fizz" (zero? (% x 5)) "Buzz" x)) (sequence 1 100)))`

#### B+

• Hero Member
• Posts: 846
##### Re: Fizz Buzz Plus
« Reply #3 on: 10. May 2019, 15:28:50 »
Nice one liner!

but no plus?

#### Tomaaz

• Guest
##### Re: Fizz Buzz Plus
« Reply #4 on: 10. May 2019, 19:01:16 »
Code: [Select]
`(define (sprawdz x)    (set 'slowa '(2 bizz 3 fizz 5 buzz 7 fuzz 11 wow))    (set 'k 0)    (dolist (y (filter integer? slowa))        (if (zero? (% x y)) (begin (print (slowa (+ (* \$idx 2) 1))) (inc k))))        (if (zero? k) (println x) (print "\n")))(map sprawdz (sequence 1 100))`

#### Aurel

• Regular Member
• Hero Member
• Posts: 596
##### Re: Fizz Buzz Plus
« Reply #5 on: 10. May 2019, 19:56:24 »
..just for translation

slowa = slova = letters

** NOT RESPOND - HIGH RISK **************
http://basicpro.mipropia.com/smf/index.php
**************************************
USE:
http://basicpro.spacefor.site/smf/index.php

#### Tomaaz

• Guest
##### Re: Fizz Buzz Plus
« Reply #6 on: 10. May 2019, 20:01:45 »
slowa = slova = letters

Wrong. Slowa == words.

#### Aurel

• Regular Member
• Hero Member
• Posts: 596
##### Re: Fizz Buzz Plus
« Reply #7 on: 11. May 2019, 00:29:03 »
interesting ..same word but different meaning
** NOT RESPOND - HIGH RISK **************
http://basicpro.mipropia.com/smf/index.php
**************************************
USE:
http://basicpro.spacefor.site/smf/index.php

#### B+

• Hero Member
• Posts: 846
##### Re: Fizz Buzz Plus
« Reply #8 on: 13. May 2019, 15:24:27 »
Using JB's WORD\$():
Code: [Select]
`FOR i = 1 TO 100    b\$ = ""    FOR w = 1 TO 5        IF i mod val(word\$("2 3 5 7 11", w)) = 0 THEN b\$ = b\$ + word\$("Bizz Fizz Buzz Fuzz Wow", w)    NEXT    IF b\$ = "" THEN PRINT i ELSE PRINT b\$NEXT`
Output:
Code: [Select]
`1BizzFizzBizzBuzzBizzFizzFuzzBizzFizzBizzBuzzWowBizzFizz13BizzFuzzFizzBuzzBizz17BizzFizz19BizzBuzzFizzFuzzBizzWow23BizzFizzBuzzBizzFizzBizzFuzz29BizzFizzBuzz31BizzFizzWowBizzBuzzFuzzBizzFizz37BizzFizzBizzBuzz41BizzFizzFuzz43BizzWowFizzBuzzBizz47BizzFizzFuzzBizzBuzzFizzBizz53BizzFizzBuzzWowBizzFuzzFizzBizz59BizzFizzBuzz61BizzFizzFuzzBizzBuzzBizzFizzWow67BizzFizzBizzBuzzFuzz71BizzFizz73BizzFizzBuzzBizzFuzzWowBizzFizz79BizzBuzzFizzBizz83BizzFizzFuzzBuzzBizzFizzBizzWow89BizzFizzBuzzFuzzBizzFizzBizzBuzzBizzFizz97BizzFuzzFizzWowBizzBuzz`

#### jbk

• Newcomer
• Posts: 36
##### Re: Fizz Buzz Plus
« Reply #9 on: 13. May 2019, 19:17:21 »
hi B+
how did you come up with the algorithm?
your last program also runs in LB5

#### B+

• Hero Member
• Posts: 846
##### Re: Fizz Buzz Plus
« Reply #10 on: 13. May 2019, 23:28:21 »
Hi jbk,

I imagine one would be hard pressed to find a Basic that the first program wouldn't work, specially if line numbers were added.

The algo came from trying to generalize the case of 3 and 5 to more numbers and more fun words to say for each divisor of i.