Never used or liked Lisp, so I did challenge 1 with Lisp:
Code:
(defun drink (n)
(loop for i from n downto 1 do
(if (>= i 2)
(format t "~a bottles of beer on the wall, ~a bottles of beer.~%~
Take one down and pass it around, ~a ~a of beer on the wall.~%~%" i i (- i 1) (format nil "bottle~p" (- i 1)))
(format t "~a bottle of beer on the wall, ~a bottle of beer.~%~
Take one down and pass it around, no more bottles of beer on the wall~%~%~
No more bottles of beer on the wall, no more bottles of beer.~%~
Go to the store and buy some more, ~a bottles of beer on the wall." i i n))))
I tried a recursive version but it looked bad compared to the above.
Bookmarks