99 Bottles of Beer: Unterschied zwischen den Versionen
+ SPL |
Enki (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
Zeile 30: | Zeile 30: | ||
"of beer on the wall.\n${i ? "" : "\n"}"); | "of beer on the wall.\n${i ? "" : "\n"}"); | ||
} | } | ||
#!/usr/bin/env python | |||
# 99 bottles of beer in Python by Ricardo Garcia. Public Domain code. | |||
# Fully compliant version, pretty indentation, fits in 80x24. | |||
plural = lambda n: n != 1 and "s" or "" | |||
number = lambda n: n == 0 and "No" or str(n) | |||
next = lambda n: (n - 1) % 100 | |||
pu_line = lambda n: n == 0 and "Go to the store and buy some more" or \ | |||
"Take one down, pass it around" | |||
verses = lambda n: "%s bottle%s of beer on the wall!\n" \ | |||
"%s bottle%s of beer!\n" \ | |||
"%s\n" \ | |||
"%s bottle%s of beer on the wall!\n" % \ | |||
( number(n), plural(n), | |||
number(n), plural(n), | |||
pu_line(n), | |||
number(next(n)), plural(next(n)) ) | |||
print "\n".join([verses(x) for x in range(99, -1, -1)]) |