#!/usr/bin/env python3 """CodeShell.kr — Offset (Misc, 50p) solver. misc-offset.csv gives a local timestamp, a UTC offset and a mark letter per row. Normalising every row to UTC and sorting by real time recovers the word. Usage: uv run python solvers/offset.py """
import csv from datetime import datetime, timedelta from pathlib import Path
CSV = "assets/challenge-files/misc-offset.csv"
defmain(): rows = [] for r in csv.DictReader(open(CSV)): local = datetime.strptime(r["local_time"], "%Y-%m-%d %H:%M") sign = 1if r["utc_offset"][0] == "+"else -1 hh, mm = (int(x) for x in r["utc_offset"][1:].split(":")) utc = local - sign * timedelta(hours=hh, minutes=mm) rows.append((utc, r["mark"], r["local_time"], r["utc_offset"]))
for utc, mark, local, off insorted(rows): print(f"{utc}{local}{off}{mark}") print("answer:", "".join(m for _, m, _, _ insorted(rows)))