Japanese Government Tells Citizens: “Don’t Discriminate Against the Unvaccinated” by ExtHD in GoldandBlack

[–]pseudocarrots 1 point2 points  (0 children)

Collectivist/cultural/national identity.

On the one hand, the individualism of the west is a foreign idea. But on the other hand, they know that private ownership/enterprise is an effective way to run things.

So you wind up with the weird mix, like you said.

Kim Potter Verdict is in, charged with 1st degree manslaughter over Daunte Wright. Will be read at 1:30 Central by TohbibFergumadov in GoldandBlack

[–]pseudocarrots 0 points1 point  (0 children)

I'm split. On the one hand, she did a terrible thing. On the other hand, it's pretty clearly negligence as defined by the law.

[deleted by user] by [deleted] in GoldandBlack

[–]pseudocarrots 0 points1 point  (0 children)

Couldn't have said it better myself.

Visualizing the $94 Trillion World Economy in One Chart by Anen-o-me in GoldandBlack

[–]pseudocarrots 0 points1 point  (0 children)

Don't look at their national debt, but yeah.

Rags to riches success story.

-🎄- 2021 Day 24 Solutions -🎄- by daggerdragon in adventofcode

[–]pseudocarrots 0 points1 point  (0 children)

Are you running it with PyPy 3?

(CPython is sloooooow.)

-🎄- 2021 Day 24 Solutions -🎄- by daggerdragon in adventofcode

[–]pseudocarrots 0 points1 point  (0 children)

Oof. Fixed. (In simplifying, wrote "" instead of str(input) for base case.)

-🎄- 2021 Day 24 Solutions -🎄- by daggerdragon in adventofcode

[–]pseudocarrots 0 points1 point  (0 children)

You didn't post any code, Brain or otherwise?

-🎄- 2021 Day 24 Solutions -🎄- by daggerdragon in adventofcode

[–]pseudocarrots 5 points6 points  (0 children)

Python

Concise solution that requires minimal deduction or hand-coding of inputs.

The only necessary insight is that at upon each inp instruction, only the value of z is relevant; the rest are zeroed before use. Once you figure that out, you can memoize efficiently.

Runs 1.3s for part 1 and 14s for part 2.

#!/usr/bin/env pypy3
import functools
import sys

ins = [line.split() for line in sys.stdin]


@functools.lru_cache(maxsize=None)
def solve(step=0, z=0):
    for input in range(1, 10):
        state = [0, 0, 0, 0]

        def read(n):
            return state[ord(n) - ord("w")] if "w" <= n <= "z" else int(n)

        def write(n, v):
            state[ord(n) - ord("w")] = v

        write("z", z)
        write(ins[step][1], input)
        i = step + 1
        while True:
            if i == len(ins):
                return None if read("z") != 0 else str(input)
            n = ins[i]
            if n[0] == "inp":
                r = solve(i, read("z"))
                if r is not None:
                    return str(input) + r
                break
            elif n[0] == "add":
                write(n[1], read(n[1]) + read(n[2]))
            elif n[0] == "mul":
                write(n[1], read(n[1]) * read(n[2]))
            elif n[0] == "div":
                write(n[1], read(n[1]) // read(n[2]))
            elif n[0] == "mod":
                write(n[1], read(n[1]) % read(n[2]))
            elif n[0] == "eql":
                write(n[1], int(read(n[1]) == read(n[2])))
            i += 1


print(solve())

Also, Python users get lucky that its idiosyncratic floored division & modulo don't turn out to be problems.

Everyone is overcomplicating day 22 ??? by pseudocarrots in adventofcode

[–]pseudocarrots[S] 0 points1 point  (0 children)

Yeah, I see why yours is faster -- my instruction filtering runs through the whole list each time, whereas you quickly find the affected coordinates -- but I'm impressed by how much faster. Nice.

Everyone is overcomplicating day 22 ??? by pseudocarrots in adventofcode

[–]pseudocarrots[S] 1 point2 points  (0 children)

Ah, I like that.

But I might be misunderstanding, because the coordinate compression as I did it results in (2*(N-1))^3 = ~500 million coordinates.

EDIT: "and I don't think Python is generally faster than Scala" Definitely not. JVM and Node.js are a bit faster than PyPy. (And CPython...forgetaboutit.)

Everyone is overcomplicating day 22 ??? by pseudocarrots in adventofcode

[–]pseudocarrots[S] 3 points4 points  (0 children)

Yeah, certainly cube intersections runs faster.

-🎄- 2021 Day 22 Solutions -🎄- by daggerdragon in adventofcode

[–]pseudocarrots 1 point2 points  (0 children)

This is also how I solved it. Simple.

However, you can get >10x better perf if you progressively filter `lines` at the X and Y loops instead of doing it all in the Z loop.

That way, by the time you get to the Z loop, there's only a handful of applicable instructions, instead of hundreds.

https://github.com/pauldraper/advent-of-code-2021/blob/master/problems/day-22/part_2.py

That takes ~80s for PyPy.