From cb3bcc0e018f5ed1ae088c8e0108d12f645962fd Mon Sep 17 00:00:00 2001 From: Andrew Conlin Date: Sun, 13 Apr 2025 17:17:02 +0100 Subject: [PATCH] [2025-04-13] Add The Hobbit chapters --- year-progress.py | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/year-progress.py b/year-progress.py index 088148c..06648fb 100644 --- a/year-progress.py +++ b/year-progress.py @@ -115,8 +115,46 @@ def abbeyRoad(yearPercent): else: return "Her Majesty" -def theHobbit(): - pass +def theHobbit(yearPercent): + hobbitPage = math.floor(yearPercent * 273) + if hobbitPage < 24: + return "having an unexpected party" + elif hobbitPage < 40: + return "roasting mutton" + elif hobbitPage < 49: + return "having a short rest" + elif hobbitPage < 62: + return "going over hill and under hill" + elif hobbitPage < 82: + return "performing riddles in the dark" + elif hobbitPage < 102: + return "out of the frying pan, but into the fire" + elif hobbitPage < 127: + return "in some queer lodgings" + elif hobbitPage < 157: + return "fighting flies and spiders" + elif hobbitPage < 171: + return "taking barrels out of bond" + elif hobbitPage < 183: + return "getting a warm welcome" + elif hobbitPage < 192: + return "on the doorstep" + elif hobbitPage < 211: + return "getting inside information" + elif hobbitPage < 222: + return "not at home" + elif hobbitPage < 231: + return "oblivious to fire hitting water" + elif hobbitPage < 241: + return "watching the gathering of the clouds" + elif hobbitPage < 247: + return "a thief in the night" + elif hobbitPage < 258: + return "oblivious to the clouds bursting" + elif hobbitPage < 266: + return "on the return journey" + else: + return "at the last stage" def transatlanticFlight(yearPercent): lat1 = 51.470020 @@ -132,9 +170,9 @@ def getHomoSapiens(yearPercent): totalYears = 4.3e9 yearsUntilHumans = totalYears*(1-yearPercent) - 300e3 if yearsUntilHumans >= 0: - return f"Homo Sapiens would evolve in ~{math.floor(yearsUntilHumans)} years." + return f"Homo Sapiens would evolve in ~{math.floor(yearsUntilHumans)} years" else: - return f"Homo Sapiens have been around for ~{-math.floor(yearsUntilHumans)} years." + return f"Homo Sapiens have been around for ~{-math.floor(yearsUntilHumans)} years" def getTemplate(timestamp): now = datetime.datetime.fromtimestamp(timestamp) @@ -149,7 +187,7 @@ def getTemplate(timestamp): workDay, workTime = workWeek(yearPercent) marathonMile = round(26.2 - math.floor(yearPercent*26.2),2) abbeyRoadSong = abbeyRoad(yearPercent) - hobbitChapter = "having an unexpected party" + hobbitChapter = theHobbit(yearPercent) lat, long = transatlanticFlight(yearPercent) homoSapiens = getHomoSapiens(yearPercent)