Avatar

__init__

__init__@programming.dev
Joined
0 posts • 13 comments
Direct message

Yeah, this was especially irritating in a python project that uses poetry, cause every single one would cause a merge conflict. We stopped using it altogether because of that. Will have to give this a try.

permalink
report
parent
reply

Spontaneous trailer harness combustion, spontaneous oil pump combustion, what’s next?

permalink
report
parent
reply

Before I had it all automated, I used to use a browser extension which would send them to the web ui without having to actually open deluge at all. I think it was called deluge siphon.

permalink
report
reply

They got me good with this one time. It looked like a newsletter from like Seattle times or something, I was like I didn’t sign up for this shit and immediately clicked the unsubscribe link, boom enrolled in training. Well played, guys.

permalink
report
parent
reply

It’s javascript. We’ll have gone through 275,760 new datetime libraries before then, it’ll be fine.

permalink
report
parent
reply

Nobody doing python? It is my first time participating so I think I’ll try it out my strongest language first. I think if I were to try something else it would be Go, to brush up, or Typescript, which I’ve been wanting to learn but haven’t really had an application for, yet.

permalink
report
reply

(python) Much easier than day 3.

code
import pathlib

base_dir = pathlib.Path(__file__).parent
filename = base_dir / "day4_input.txt"

with open(base_dir / filename) as f:
    lines = f.read().splitlines()

score = 0

extra_cards = [0 for _ in lines]
n_cards = [1 for _ in lines]

for i, line in enumerate(lines):
    _, numbers = line.split(":")
    winning, have = numbers.split(" | ")

    winning_numbers = {int(n) for n in winning.split()}
    have_numbers = {int(n) for n in have.split()}

    have_winning_numbers = winning_numbers & have_numbers
    n_matches = len(have_winning_numbers)

    if n_matches:
        score += 2 ** (n_matches - 1)

    j = i + 1
    for _ in range(n_matches):
        if j >= len(lines):
            break
        n_cards[j] += n_cards[i]
        j += 1

answer_p1 = score
print(f"{answer_p1=}")

answer_p2 = sum(n_cards)
print(f"{answer_p2=}")
permalink
report
reply

Nice. I’m a long time fan of poetry, but I’m trying out a couple new tools too. Been wanting to check out ruff to replace flake8. And mypy, cause I’ve never worked on a project that used a type checker, though there hasn’t really been much for it to do on the solutions I’ve hammered out so far.

permalink
report
parent
reply

Python

Easy one today

code
import pathlib

base_dir = pathlib.Path(__file__).parent
filename = base_dir / "day9_input.txt"

with open(base_dir / filename) as f:
    lines = f.read().splitlines()

histories = [[int(n) for n in line.split()] for line in lines]

answer_p1 = 0
answer_p2 = 0

for history in histories:
    deltas: list[list[int]] = []
    last_line: list[int] = history

    while any(last_line):
        deltas.append(last_line)
        last_line = [last_line[i] - last_line[i - 1] for i in range(1, len(last_line))]

    first_value = 0
    last_value = 0
    for delta_list in reversed(deltas):
        last_value = delta_list[-1] + last_value
        first_value = delta_list[0] - first_value

    answer_p1 += last_value
    answer_p2 += first_value

print(f"{answer_p1=}")
print(f"{answer_p2=}")
permalink
report
reply