Avatar for wence

wence

Member since May 2009 • Last active May 2022
  • 6 conversations
  • 364 comments

Person, occasional wit.

Most recent activity

  • in Bikes & Bits
    Avatar for wence

    FWIW, I had no problems fitting new 25c and 25c gp5000s to the R (18mm internal) hooked rims.

    My approach is not to try and use my thumbs to push the tyre bead over the rim but to sort of roll it on. Also after reading these horror stories tried getting them off and after releasing the bead from the rim on both sides (this was the hardest part) only needed one lever

  • in Rides & Races
    Avatar for wence

    a meme

  • in Rides & Races
    Avatar for wence

    been on the whole time. check if your stream is set to "ambient sound"

  • in Miscellaneous and Meaningless
    Avatar for wence

    And that's a wrap (modulo finishing some of the days in rust):

    $ python main.py 
    Day        Part 1         Part 2           Time [ms]
    ----------------------------------------­------------
    Day 01     1374           1418                  2.01
    Day 02     1660158        1604592846            1.52
    Day 03     3895776        7928162               4.52
    Day 04     14093          17388                 3.80
    Day 05     6397           22335               177.87
    Day 06     393019         1757714216975         0.79
    Day 07     355989         102245489             1.30
    Day 08     473            1097568               5.64
    Day 09     600            987840               55.01
    Day 10     321237         2360030859            2.38
    Day 11     1637           242                  28.11
    Day 12     5252           147784                2.81
    Day 13     724            CPJBERUL              2.63
    Day 14     2233           2884513602164         3.94
    Day 15     523            2876                772.99
    Day 16     852            19348959966392        5.14
    Day 17     14535          2270                  8.71
    Day 18     4435           4802                599.87
    Day 19     396            11828               547.72
    Day 20     5475           17548                65.86
    Day 21     503478         716241959649754      50.66
    Day 22     603661         1237264238382479     82.99
    Day 23     19167          47665               153.68
    Day 24     29599469991739 17153114691118        0.24
    Day 25     516                                319.61
    ----------------------------------------­------------
                                                 2926.96
    

    Just snuck in under 3 seconds total solve time.

  • in Miscellaneous and Meaningless
    Avatar for wence

    Yep. Hopefully binary search or something is all you need but I'm skeptical.

    See if you can spot a pattern in the calculations done on the input values. I have something which I suspect is right, but failed to collect the right information in my recursive call.

    D23 done, A* too slow so I went with recursion and memoising which was shockingly fast by comparison

    My basic approach using Dijkstra was ~4s, I did some mild perusal of other people's solutions and with an appropriate cost-function for A* got down to ~150ms.

  • in Miscellaneous and Meaningless
    Avatar for wence

    Today looks annoying as well

    There must be a trick, because just naively trying the 9^14 combinations isn’t very feasible.

  • in Miscellaneous and Meaningless
    Avatar for wence

    Nearly caught up (still day 19 to do), but here was my part2 for today (~55ms)

    from functools import cache
    def part2(inp):
        p1, p2 = inp
        p1 -= 1
        p2 -= 1
    
        moves = list(Counter(map(sum, product(*repeat(range(1, 4), 3)))).items())
    
        @cache
        def winners(A, B, s1, s2):
            if s1 >= 21:
                return (1, 0)
            if s2 >= 21:
                return (0, 1)
            winA = 0
            winB = 0
            for move, freq in moves:
                newA = (A + move) % 10
                news1 = s1 + newA + 1
                x, y = winners(B, newA, s2, news1)
                winA += y * freq
                winB += x * freq
            return (winA, winB)
    
        return max(winners(p1, p2, 0, 0))
    
  • Avatar for wence

    It definitely took me longer to parse the exercise than write the code...

    https://gist.github.com/wence-/500e1bc46­33192ac6fee67433aedd974#file-day16-py

  • Avatar for wence

    That's the naive implementation, if you use a heap, then insertion is O(log n)

Actions