xavdid's recent activity

  1. Comment on Day 19: Aplenty in ~comp.advent_of_code

    xavdid
    Link
    Step-by-step explanation | full code This one was a lot of fun! I separated out the workflow parsing (using operator.gt/lt and simple string indexing), the part parsing (using a regex that found...

    Step-by-step explanation | full code

    This one was a lot of fun! I separated out the workflow parsing (using operator.gt/lt and simple string indexing), the part parsing (using a regex that found tuples), and the recursing (to get answers) so you can look at each individually.

    I had some trouble visualizing part 2 at first, so there's some good diagrams in there if you're having trouble as well!

    Solution wise, A workflow is parsed into a dynamically-defined function which gets the next workflow(s) based on the input. For part 1, that's:

    Python code
    def build_workflow(raw_filters: str, default: str) -> Callable[[Part], str]:
        def _get_next_destination(part: Part):
            for raw_filter in raw_filters.split(","):
                category, op, value, destination = extract_filter_components(raw_filter)
                if op(part[category], value):
                    return destination
    
            return default
    
        return _get_next_destination
    

    For part 2 I passed around a Part as a dict[str, range], so its workflow runner was:

    Python code
    def build_counting_workflow(
        raw_filters: str, default: str
    ) -> Callable[[RangedPart], list[tuple[str, RangedPart]]]:
        def _get_next_destinations(part: RangedPart):
            ranges: list[tuple[str, RangedPart]] = []
    
            for raw_filter in raw_filters.split(","):
                category, op, value, dest = extract_filter_components(raw_filter)
    
                if op == gt:
                    keep, send = bisect_range(part[category], value + 1)
                else:
                    send, keep = bisect_range(part[category], value)
    
                ranges.append((dest, {**part, category: send}))
                part = {**part, category: keep}
    
            # whatever is left also goes
            return ranges + [(default, part)]
    
        return _get_next_destinations
    

    Very fun today, and nothing too cursed!

    2 votes
  2. Comment on Day 26 in ~comp.advent_of_code

    xavdid
    Link
    There are 2 truly difficult problems in computer science: naming things, cache invalidation, and off-by-one errors. 😁

    There are 2 truly difficult problems in computer science: naming things, cache invalidation, and off-by-one errors. 😁

    3 votes
  3. Comment on Day 16: The Floor Will Be Lava in ~comp.advent_of_code

    xavdid
    Link
    Step-by-step explanation | full Python code Very pleased with today. Ended up with a State that could generate the next State based on its location and direction. Put those in a queue and bail if...

    Step-by-step explanation | full Python code

    Very pleased with today. Ended up with a State that could generate the next State based on its location and direction. Put those in a queue and bail if the next state is out of bounds or has already been seen. I liked the architecture today, which focused on separation of concerns. Also, got to use some features of pattern matching, which is always exciting.

    Also, spent a bunch of time at the end of the post discussion performance optimizations. Got the (both parts) runtime from ~ 4.6 seconds down to ~ 1.1 with 3 1-line changes!

    1 vote
  4. Comment on Day 2: Cube Conundrum in ~comp.advent_of_code

    xavdid
    Link Parent
    Ah, that's awesome! I always use sum but never knew there was a multiplication version!

    Ah, that's awesome! I always use sum but never knew there was a multiplication version!

    1 vote
  5. Comment on Looking for games like wordle in ~games

    xavdid
    Link Parent
    Cinerdle is a favorite of mine! Not too hard, but not too easy. I do love film trivia.

    Cinerdle is a favorite of mine! Not too hard, but not too easy. I do love film trivia.

  6. Comment on Day 2: Cube Conundrum in ~comp.advent_of_code

    xavdid
    Link Parent
    Nice! I've been really digging just as a program. Is powerful, but stays out of my way.

    Nice! I've been really digging just as a program. Is powerful, but stays out of my way.

    1 vote
  7. Comment on Day 2: Cube Conundrum in ~comp.advent_of_code

    xavdid
    Link
    Step-by-step Python explanation: https://advent-of-code.xavd.id/writeups/2023/day/2/ Pretty straightforward today - Python's re.findall and a regex got me all the pairs of count + color and a...

    Step-by-step Python explanation: https://advent-of-code.xavd.id/writeups/2023/day/2/

    Pretty straightforward today - Python's re.findall and a regex got me all the pairs of count + color and a defaultdict made it easy to calculate the min number required. Oddly, this felt more like a day 1 than yesterday did 😅

    2 votes
  8. Comment on Day 1: Trebuchet?! in ~comp.advent_of_code

    xavdid
    Link
    AoC is routinely my favorite event of the year. Day 1 had some fun edge cases, but nothing too crazy. If anyone gets stuck (not necessarily today, but at some point in here), I'll be posting...

    AoC is routinely my favorite event of the year. Day 1 had some fun edge cases, but nothing too crazy.

    If anyone gets stuck (not necessarily today, but at some point in here), I'll be posting explanations of each puzzle and my Python solution on my website: https://advent-of-code.xavd.id/writeups/2023/day/1/

    Should be a fun year!

    2 votes
  9. Comment on What programming/technical projects have you been working on? in ~comp

    xavdid
    Link
    For the past few years of Advent of Code, I've written step-by-step explanations for how each puzzle is solved. This has been an important step in my learning, plus it's fun. Previously, these...

    For the past few years of Advent of Code, I've written step-by-step explanations for how each puzzle is solved. This has been an important step in my learning, plus it's fun.

    Previously, these writeups have been available as GitHub READMEs, which is fine. But, in an effort to really showcase them, I'm making a little static site to host them. This has a few advantages:

    • I can get a little fancier with my syntax highlighting (e.g. line numbers or highlighting new rows)
    • They'll be easier to find rather than buried in a repo
    • I can add things like an RSS feed

    I'm building it with Astro and am very impressed so far!

    10 votes
  10. Comment on As the Halloween season begins, what are your favorite spooky reads? in ~books

    xavdid
    Link Parent
    TIL! That's very cool.

    TIL! That's very cool.

  11. Comment on As the Halloween season begins, what are your favorite spooky reads? in ~books

    xavdid
    Link Parent
    Definitely witchy- they're running around doing magic and stuff. I actually don't remember loving the movie, but I think it would fit the season.

    Definitely witchy- they're running around doing magic and stuff. I actually don't remember loving the movie, but I think it would fit the season.

  12. Comment on As the Halloween season begins, what are your favorite spooky reads? in ~books

    xavdid
    Link Parent
    Nice! Seems appropriate. I've seen the Eastwick movie, but didn't realize it was a book.

    Nice! Seems appropriate. I've seen the Eastwick movie, but didn't realize it was a book.

  13. Comment on As the Halloween season begins, what are your favorite spooky reads? in ~books

    xavdid
    Link Parent
    Oh fun! I like frame stories like that - I'll check it out.

    Oh fun! I like frame stories like that - I'll check it out.

    1 vote
  14. Comment on As the Halloween season begins, what are your favorite spooky reads? in ~books

    xavdid
    Link Parent
    Hey, can't be the classics. Thank you!

    Hey, can't be the classics. Thank you!

    2 votes
  15. Comment on As the Halloween season begins, what are your favorite spooky reads? in ~books

    xavdid
    Link Parent
    Awesome, I'll check this out!

    Awesome, I'll check this out!

    2 votes
  16. As the Halloween season begins, what are your favorite spooky reads?

    I like to try and read seasonally-appropriate books during October and I'm curious what your favorites are. To qualify as "seasonally-appropriate", the book should have at least one of: ghost /...

    I like to try and read seasonally-appropriate books during October and I'm curious what your favorites are. To qualify as "seasonally-appropriate", the book should have at least one of:

    • ghost / vampire / werewolf / zombie / witch / haunting / etc
    • Take place in the autumn / around Halloween itself
    • be overall creepy or unsettling
    • mysteries are generally acceptable, but it should be different from an any-time-of-year mystery
    25 votes
  17. Comment on What do you think about other users' usernames? in ~tildes

    xavdid
    Link Parent
    Oh interesting, I'll check that out! I think it's never a good substitute for a service-level thing (which is tied to my account and doesn't need to be explicitly synced), this is probably a good...

    Oh interesting, I'll check that out!

    I think it's never a good substitute for a service-level thing (which is tied to my account and doesn't need to be explicitly synced), this is probably a good stopgap.

    3 votes
  18. Comment on What do you think about other users' usernames? in ~tildes

    xavdid
    Link
    I mostly don't. Many forums have so many users that you're unlikely to come across the same user enough times to develop any sort of relationship. A feature I wish more sites had (tildes included)...

    I mostly don't. Many forums have so many users that you're unlikely to come across the same user enough times to develop any sort of relationship.

    A feature I wish more sites had (tildes included) that I like from Reddit is to be able to mark a user as a "friend". All this does is light up their username in a thread if they've commented. It's great to see someone you "know" pop up in a random thread and it does help develop that sense of community.

    18 votes
  19. Comment on What online subscriptions do you pay for? in ~tech

    xavdid
    Link Parent
    The problem with this is that it ruins it for everyone. Sure, people from wealthier countries can get super cheap games / YT / whatever this way. But once enough people do it,...

    The problem with this is that it ruins it for everyone. Sure, people from wealthier countries can get super cheap games / YT / whatever this way. But once enough people do it, Nintendo/Steam/Google notices and drops the cheaper pricing, effectively locking the country (Turkey, Argentina, etc) out of the service. If you can't pay then pirate, but don't ruin it for people who literally can't afford it.

  20. Comment on What are some good, non-microtransaction riddled mobile games? in ~games

    xavdid
    Link
    One I haven't seen mentioned is Blackbox. It's iOS only and costs a few bucks to unlock the entire game. The first few levels are free. There are no ads at all. It's a puzzle game about exploring...

    One I haven't seen mentioned is Blackbox. It's iOS only and costs a few bucks to unlock the entire game. The first few levels are free. There are no ads at all.

    It's a puzzle game about exploring your phone, but you never have to touch the screen. Each puzzle has to do with some system function or hardware sensor- basically treating it as a little black box.

    The puzzles are awesome and the art is delightful. There's also a lot of Easter eggs to find!