Skip to content

Instantly share code, notes, and snippets.

@robinhouston
Created November 15, 2019 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinhouston/86631a1fbaa992840956d9c5580b1eae to your computer and use it in GitHub Desktop.
Save robinhouston/86631a1fbaa992840956d9c5580b1eae to your computer and use it in GitHub Desktop.
import re
for n in range(1, 101):
r = re.match(r'''
(?=(?P<Fizz>
^(
[0369]|
[147][0369]*[258]|
([258]|[147][0369]*[147])([0369]|[258][0369]*[147])*([147]|[258][0369]*[258])
)*$
)?)
(?=(?P<Buzz>.*[05]$)?)''', str(n), re.X)
print("".join([ k * (v is not None) for (k, v) in r.groupdict().items() ]) or n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment