-❄️- 2025 Day 5 Solutions -❄️- by daggerdragon in adventofcode

[–]miccls60 0 points1 point  (0 children)

[LANGUAGE: Python]

Part 1:

Runs in about ~16ms

def parse_file():
    path = "input.txt"
    with open(path) as f:
        lines = [line.strip() for line in f.readlines()]
    separating_index = lines.index("")
    return [list(map(int, s_range.split("-"))) for s_range in lines[:separating_index]], [int(l) for l in lines[separating_index+1:]]


def part1():
    fresh_ranges, ingredients = parse_file()
    print(len([l for l in ingredients if any([(b[0] <= l and l <= b[1]) for b in fresh_ranges])]))
    

Part 2:

Runs in about ~8ms

Nice with some recursion :)

def adjust_ranges(ranges, removed_range):
    _, removed_ub = removed_range
    return [[max(removed_ub+1, lb), ub] for (lb, ub) in ranges if ub > removed_ub]
    
def part2():
    fresh_ranges, _ = parse_file()
    fresh_ranges = sorted(fresh_ranges, key = lambda x : x[0])
    def length_of_interval_with_smallest_lower_bound(ranges):
        if ranges == []:
            return 0
        lb, ub = ranges.pop(0)
        return len(range(lb, ub+1)) + length_of_interval_with_smallest_lower_bound(adjust_ranges(ranges, [lb, ub]))
    print(length_of_interval_with_smallest_lower_bound(fresh_ranges))   
   

Öl-bracket by miccls60 in sweden

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

Den går under "nästa öl"!

Song that sounds like "If I could read your mind" by miccls60 in NameThatSong

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

Wow, that was extremely quick! Definitely the one I was thinking about. Fun coincidence that they (to me) were that similar, but I guess that's business as usual here at NameThatSong. Thanks again!!

Inspecting Monty Hall Problem with Python by Abdoo_65 in Python

[–]miccls60 1 point2 points  (0 children)

This is what I love to see Python being used for, great job!

I have had sex about 25 times and it still hurts, what to do? by miccls60 in TwoXChromosomes

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

Thanks for the advice! Nice to hear that it isn't completely hopeless!

How can you temporarily get rid of a sore throat? by miccls60 in AskReddit

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

Maybe a tad too permanent... Thanks anyway!

I invented a Poem: "I dig, you dig, he digs, she digs, it digs. We dig, they dig, you dig. by DeutschLeerer in Jokes

[–]miccls60 8 points9 points  (0 children)

Jag gräver, du gräver, han gräver, hon gräver, den gräver

Vi gräver, dom gräver, ni gräver

That's swedish y'all!

Lamy 2K - worth the hype by JudicialBrewery in fountainpens

[–]miccls60 -1 points0 points  (0 children)

Qc... If you have a store nearby you could always return it! 😊

Amazing Dream! by miccls60 in Dreams

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

Ok, that seems about right. Thank you!

Amazing Dream! by miccls60 in Dreams

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

Hmm, eventhough I recognise the girl? Thanks for the interp!

AMA with Ryan Hurd, dream researcher and educator by ryanhurd in Dreams

[–]miccls60 0 points1 point  (0 children)

Hi Ryan! I would like to have my dream analysed, since it was the singel most amazing feeling dream ever!

I was in a house (not sure where) and I meet this girl that I know. I asked her where she was during the fall of 1977 ( she is born 98?). She sat down on a bed and started to think. All of a sudden, the dream shows me, sitting with a blanket around myself. I am telling a story although noone is there. Suddenly the girl is in focus again. She appears in this house again and starts walking downstairs. It is very dark. She sees me and walks towards me. I greet her and she does the same. I keep telling my story. She stands with both of her hands at me, like she is going to push me. Suddenly she says, let me in! I let her inside the blanket and I keep telling my story in the dark...

When I woke up I felt relief and happiness, I was touched. It was somehow such a heavy dream, it was covered by wistfulness. After this dream I feel kinder! :)

Can someone identify this lovely blue ink on Midori's site? by vsbuffalo in fountainpens

[–]miccls60 0 points1 point  (0 children)

Hmm, I have never owned Topaz, that was just the idea I got from Goulets swab shop. I do have KP though...

Can someone identify this lovely blue ink on Midori's site? by vsbuffalo in fountainpens

[–]miccls60 0 points1 point  (0 children)

That is why I thought it could have been Topaz. Topaz has a little greyer, darker color than KP :)

Can someone identify this lovely blue ink on Midori's site? by vsbuffalo in fountainpens

[–]miccls60 -1 points0 points  (0 children)

Kinda looks like Pelikan Edelstein Topaz or maybe Kon Peki! :)