Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Advent of Code 2023 is nigh. Parent comment
However the 'naive' solution still feels quite nice. Some python, at the risk of sharing spoilers:
fixes = { "seven":"7", "two":"2", "one":"1", "nine":"9", "eight":"8", "three":"3", "four":"4", "five":"5", "six":"6" } cands = set(fixes.keys()) | set(fixes.values()) total = 0 for line in Path("input/1.txt").read_text().splitlines(): matches = list(filter(lambda k: k in line, cands)) first, *_ = sorted(matches, key=line.index) *_, last = sorted(matches, key=line.rindex) total += int(fixes.get(first, first) + fixes.get(last, last)) print(total)
There are no comments on this comment yet.
However the 'naive' solution still feels quite nice. Some python, at the risk of sharing spoilers: