Another friend of mine commenting on the same FizzBuzz thread supplied
the following Python code. It certainly is concise:
for i in xrange(1,101):
print(str(i), "Fizz", "Buzz", "FizzBuzz")[(i%3==0)|(i%5==0)<<1]
Another friend of mine commenting on the same FizzBuzz thread supplied
the following Python code. It certainly is concise:
for i in xrange(1,101):
print(str(i), "Fizz", "Buzz", "FizzBuzz")[(i%3==0)|(i%5==0)<<1]
Gauche Scheme
(use srfi-42) ;; do-ec looping macro.
(define (z? n) (if (= 0 n) 1 0))
(define % mod)
(do-ec (: i 1 101)
(print (~ `(,i Fizz Buzz FizzBuzz)
(+ (z? (% i 3)) (* (z? (% i 5)) 2)))))
After removing unnecessary blanks, it's shorter than the
Python version.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 54 |
| Nodes: | 6 (1 / 5) |
| Uptime: | 21:46:16 |
| Calls: | 742 |
| Files: | 1,218 |
| D/L today: |
6 files (8,794K bytes) |
| Messages: | 186,234 |
| Posted today: | 1 |