Last active
December 21, 2018 13:35
-
-
Save martin-kokos/4a031f5009e115fda2d84e83b1c0449d to your computer and use it in GitHub Desktop.
Advent countdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime as dt | |
from time import sleep as s | |
curr_date = dt.datetime.now().replace(month=11,day=27) | |
class Candles(list): | |
def __repr__(self): | |
items = ['\N{CANDLE}' if i else '_' for i in self] | |
return '[{items}]'.format(items=', '.join(items)) | |
candles = Candles([False]*4) | |
v = dt.datetime.now().replace(month=12,day=24) | |
n = v - dt.timedelta(v.isoweekday()%7) | |
while not all(candles): | |
left = (n - curr_date).days | |
if not left/7 % 1 and left/7 < 4: | |
candles[int((4-left/7)-1)] = True | |
print(f'{curr_date:%Y-%m-%d} {candles}', end='\n\n') | |
curr_date += dt.timedelta(1); s(0.1) | |
else: | |
print('Merry Christmas!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment