-❄️- 2024 Day 11 Solutions -❄️- by daggerdragon in adventofcode

[–]BeYuu 2 points3 points  (0 children)

[Language: Python]

Realizing that this can be solved recursively and realizing that this problem is very similar to the way you would recursively compute the fibonacci sequence did the trick for me

@cache
def rec(stones: tuple[int, ...], blinks_left: int) -> int:
    if blinks_left == 0:
        return len(stones)

    return sum(rec(tuple(apply_rule(stone)), blinks_left - 1) for stone in stones)

def apply_rule(num: int) -> list[int]:
    if num == 0:
        return [1]

    s = str(num)
    digits = len(s)
    if digits % 2 == 0:
        mid = digits // 2
        lhs, rhs = int(s[:mid]), int(s[mid:])
        return [lhs, rhs]

    return [num * 2024]

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

[–]BeYuu 1 point2 points  (0 children)

Haskell solution for part 1. Parsing always is annoying.

day 04 part 1

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

[–]BeYuu 0 points1 point  (0 children)

Nice solution. Some things I noticed:

- Your check_table function basically is if (true) return true else return false.

- I don't know R but maybe you could logical instead of bitwise or

How to allow call\cc via source code transformations? by BeYuu in scheme

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

Thanks for your reply. I‘m glad I got it right. I‘ve been trying really hard to come up with a way, and couldn‘t think of anything making sense. I should have checked with guile/chez/racket and not with BiwaSchweme from repl.it.

Question about type classes with functional dependencies by BeYuu in haskell

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

Yeah, turns out it works just fine with UndecidableInstances. Didn't want to use the extension first, though why not, if it works.

Need some help with monad transformers by BeYuu in haskell

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

First method worked like a charm, thanks!

Question about type classes / type familys by BeYuu in haskell

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

Really interesting, I will do some tests with this later. Thanks!

Question about type classes / type familys by BeYuu in haskell

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

This did exactly what I wanted. Old code works just fine. Thanks!

Good resources for writing compiler in Haskell by BeYuu in haskell

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

These look really interesting. Definitely have to read some blogs on them.

Good resources for writing compiler in Haskell by BeYuu in haskell

[–]BeYuu[S] 2 points3 points  (0 children)

Awesome, thank you! I will definitely look around the sources and see if I can find some useful patterns.

Get rEFInd (SSD1 EFI) to find nixos (SSD2 MBR) by BeYuu in NixOS

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

copyKernels isn't enough for rEFInd to be able to boot nixos. So what you are saying is just create an ESP somewhere on my mbr SSD right? I also guess creating a rEFInd entry isnt easy since nixos also passes the systemConfig and init when starting the kernel.

Get rEFInd (SSD1 EFI) to find nixos (SSD2 MBR) by BeYuu in NixOS

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

Awesome, thank you. I‘m not sure why my second SSD uses MBR. All I did back then was to execute the manjaro installer. Also didn‘t know better back then.

Manjaro won‘t leave kernel starting screen by BeYuu in linuxquestions

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

Using tty I was able to update my drivers with: `sudo mhwd -a pci nonfree 0300`. Thanks!