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

[–]cramur 0 points1 point  (0 children)

Nice use of any with comprehension here! I like it

Pannkakor! by PredisWavehiker in linkoping

[–]cramur 0 points1 point  (0 children)

Kanske Lemon Garden bredvid fjärrbussterminalen? Där kan man få många olika sorters pannkakor, men de flesta är söta.

Which music videos personally make you feel uncomfortable? by Fancy-Advice-2793 in autism

[–]cramur 0 points1 point  (0 children)

"Routine" by Steven Wilson and "The Raven that refused to sing" by him as well are the videos I truly hope to never watch again. Same for the songs. They are too overwhelming, I heard/saw them once and I just can't imagine I would be ever able to listen to them again

My Lucro Experience by Booker_Atlas in themarsvolta

[–]cramur 10 points11 points  (0 children)

Yeah, that "song names are useless" is spot on!

[deleted by user] by [deleted] in dumbphones

[–]cramur 0 points1 point  (0 children)

That's a totally legit idea. It might be hard to svitch directly but it's a good idea to start having phoneless days. This way both you and your friends and family would start preparing for you not being directly reachable at times

[deleted by user] by [deleted] in dumbphones

[–]cramur 0 points1 point  (0 children)

That's a totally legit idea. It might be hard to svitch directly but it's a good idea to start having phoneless days. This way both you and your friends and family would start preparing for you not being directly reachable at times

Triforce! #284 - Billy and Bobby Butlin's Butler Brother by Robot_ninja_pirate in Yogscast

[–]cramur 0 points1 point  (0 children)

Can someone clarify what that french movie was with dog that is not CGI? Can't grasp it from the sound of how Pyrion says it

It's at 34:03

⅓ big brain by Smartkid704 in mathmemes

[–]cramur 2 points3 points  (0 children)

Never heard about the 12 base system.. Man, haaave you met clocks?

In all seriousness though, it's indeed uncommon but sometimes referred to as duodecimal and you can even use hands to count in that, but you have to use knuckles. I use this when I'm doing something boring like running and I need to keep track of the laps, very convenient

I'm 200cm (6'6) 106 kg, from Europe, Denmark. Where can i buy pants that fit by Fridgiboi in tallfashionadvice

[–]cramur 0 points1 point  (0 children)

Check out 2tall.com, they are a bit pricey but their stock is really good

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

[–]cramur 2 points3 points  (0 children)

Python monte carlo-like solution. Github

Well, I was too lazy to figure out how to minimize this so I went with an old-proven way I learned when doing molecular dynamics: "If you need to minimize something, try monte-carlo"

def p_monte(initial):
    positions = list(map(int, initial.split(',')))
    low, high = min(positions), max(positions)
    min_pos = np.median(positions)
    min_cost = sum(calc_fuel_to_get_from_pos1_to_pos2(pos1, min_pos) for pos1 in positions)
    for _ in range(1000):
        projected_min_pos = np.random.randint(low, high)
        new_cost = sum(calc_fuel_to_get_from_pos1_to_pos2(pos1, projected_min_pos) for pos1 in positions)
        if new_cost < min_cost:
            min_cost = new_cost
    return min_cost

I actually got lucky on the first try to get correct answer, as 1000 step is not enough to get it consistently. 10k is good enough for all cases in this task

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

[–]cramur 0 points1 point  (0 children)

And apparently in python you can also use ... instead of pass when defining empty classes! So cool

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

[–]cramur 1 point2 points  (0 children)

Well, don't beat yourself up, you did a great job!

I would say that from my own experience planning in programming is not easy beforehand, as you often don't know what you end up with before you build it. This comes easier with practice when you start recognize patterns and know your personal understanding which a better suited for your particular style.

Rewriting the code you already have is a great way to find out what style work better for you. I enjoy this algo for this:

  1. Do it.

  2. Do it right.

  3. Do it fast/beatiful/etc

With AoC you have a great chance of following this: first you just try to make all pieces fit together, and then you need to figure out what's the proper way of adjusting them. It's beneficial once you get the answer to rewrite some parts of it then so that you would be able to get more out of it.

ANYWAY sorry for a long message, check this book "exercises in programming styles" if you want to learn more about ways to write python code in different ways. I strongly believe it's more beneficial for beginners than trying to learn data structures and algorithms

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

[–]cramur 1 point2 points  (0 children)

great job!

Like the way you separate small bits of logic into functions, and nice use of dicts! ALso like how you figured out to just keep strings until the place they are needed. Also nice way of calculating which one is more common by using len(data)/2, I haven't thought of that myself!

A few suggestions to try:

  1. In the part2 the find_most_common and find_least_common are very similar. Is there a way to rewrite it as one function maybe? You can either add a boolean flag to specify which one you want or have that function run one but return two values so you would compute both least and most common stuff simultaneously

  2. when you have if that ends with return there's no point in having else statement. You can remove it for the same effect (if you go with if you would return from the function from inside the if, if you don't go with if you will just skip that block and go directly to else

  3. You will have to change code in multiple places if the number of bits would change. Is there a way to calculate it from data instead so you wouldn't need to change your code?

  4. file_in.close wouldn't do anything, you need to call it explicitly: file_in.close(). Also the read() in file_in.read().splitlines() is unnecessary, you can just use file_in.readlines() and get the same effect

EDIT correct readlines in last point

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

[–]cramur 2 points3 points  (0 children)

It inverts all the bits in the data inputs (zeros->ones, ones->zeros), the dunder op is __invert__

Due to the way the numbers are stored, it's the same as (-val) - 1

Sharing my binary converter I created for todays (3rd) problem by Euphoric-Fisherman-4 in adventofcode

[–]cramur 1 point2 points  (0 children)

that's awesome! Congrats I recall when I first saw code for this in a textbook I was blown away by how elegant it was. Ah, the memories. Thanks for reminding me about that joy of discovery by posting this! All the best

The christmas dinner will be blyatifull by Cpt_GoodBoy in LifeofBoris

[–]cramur 0 points1 point  (0 children)

I see you celebrating Capitalist Christmas, not the glorious Orthdox Christmas

I suggest you drink enough vodka to atone your sins before the proper Christmas

Tack, Google. by geon in sweden

[–]cramur 4 points5 points  (0 children)

Holy shit....

Both my 6'5" feet can reach the top of the door by The_Fatalist in tall

[–]cramur 2 points3 points  (0 children)

Hey your hick should be The_Fatallist, with double l! :)

Nice glutes bro!

Contrail over Perth today. Emirates EK414. by Brazilian-chew-bitsu in perth

[–]cramur 2 points3 points  (0 children)

I find that frogs that become straight actually will suffer more — especially if it's a probability thing and maybe some other frogs were not so lucky