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

#### B+

• Guest
##### Fizz Buzz Plus
« on: May 07, 2019, 01:25:40 PM »
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: May 07, 2019, 01:36:25 PM by B+ »

#### jj2007

• Guest
##### Re: Fizz Buzz Plus
« Reply #1 on: May 08, 2019, 02:40:24 PM »

#### Tomaaz

• Guest
##### Re: Fizz Buzz Plus
« Reply #2 on: May 09, 2019, 11:29:05 PM »
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+

• Guest
##### Re: Fizz Buzz Plus
« Reply #3 on: May 10, 2019, 01:28:50 PM »
Nice one liner!

but no plus?

#### Tomaaz

• Guest
##### Re: Fizz Buzz Plus
« Reply #4 on: May 10, 2019, 05:01:16 PM »
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

• Guest
##### Re: Fizz Buzz Plus
« Reply #5 on: May 10, 2019, 05:56:24 PM »
..just for translation

slowa = slova = letters

#### Tomaaz

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

Wrong. Slowa == words.

#### Aurel

• Guest
##### Re: Fizz Buzz Plus
« Reply #7 on: May 10, 2019, 10:29:03 PM »
interesting ..same word but different meaning

#### B+

• Guest
##### Re: Fizz Buzz Plus
« Reply #8 on: May 13, 2019, 01:24:27 PM »
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

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

#### B+

• Guest
##### Re: Fizz Buzz Plus
« Reply #10 on: May 13, 2019, 09:28:21 PM »
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.