Skip to content

Instantly share code, notes, and snippets.

@grejppi
Created January 28, 2014 16:28
Show Gist options
  • Save grejppi/8671037 to your computer and use it in GitHub Desktop.
Save grejppi/8671037 to your computer and use it in GitHub Desktop.
Yet another 99 Bottles of Beer
print((lambda a,b,c:'\n'.join([a('\n'.join([' on the wall, '.join([b(0)]*2),'{0}, {1} on the wall.\n']).format('Take one down and pass it around' if n else 'Go to the store and buy some more', b(2).format()).format(*sum([[c(nn%100),'s' if nn!=1 else ''] for nn in (n,n-1)],[]))) for n in reversed(range(100))]))(lambda s: s[0].upper()+s[1:], lambda n:'{{n}} bottle{{s}} of beer'.replace('n',str(n)).replace('s',str(n+1)),lambda n:('-'.join if not False in (n%10, n>19) else lambda no:no[0 if n>19 else 1])([(lambda e,nn:['ten' if n==10 else 'no more','one' if n!=11 else 'eleven','tw'+('o' if n!=12 and e else ('e'+('lve' if n==12 else 'n'))),'th'+('ree' if n!=13 and e else 'ir'),'fo'+('u' if e else '')+'r','fi'+('ve' if n!=15 and e else 'f'),'six','seven','eigh'+('t' if n!=18 and e else ''),'nine'][nn]+(('ty' if n>19 else '') if not e else ('teen' if 20>n>12 else '')))(*e) for e in enumerate(((n-(n%10))//10,n%10))])))
# Skype friendly version
exec(r"print((lambda a,b,c:'\n'.join([a('\n'.join([' on the wall, '.join([b(0)]*2),'{0}, {1} on the wall.\n']).format('Take one down and pass it around' if n else 'Go to the store and buy some more', b(2).format()).format(*sum([[c(nn%100),'s' if nn!=1 else ''] for nn in (n,n-1)],[]))) for n in reversed(range(100))]))(lambda s: s[0].upper()+s[1(inlove), lambda n:'{{n}} bottle{{s}} of beer'.replace('n',str(n)).replace('s',str(n+1)),lambda n:('-'.join if not False in (n%10, n>19) else lambda no:no[0 if n>19 else 1])([(lambda e,nn:['ten' if n==10 else 'no more','one' if n!=11 else 'eleven','tw'+('o' if n!=12 and e else ('e'+('lve' if n==12 else 'n'))),'th'+('ree' if n!=13 and e else 'ir'),'fo'+('u' if e else '')+'r','fi'+('ve' if n!=15 and e else 'f'),'six','seven','eigh'+('t' if n!=18 and e else ''),'nine'][nn]+(('ty' if n>19 else '') if not e else ('teen' if 20>n>12 else '')))(*e) for e in enumerate(((n-(n%10))//10,n%10))])))".replace('(inlove)', ']:'[::-1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment