Gobbel2000

joined 2 years ago
[–] Gobbel2000@feddit.de 23 points 1 year ago (2 children)

Being active is probably most important.

Maybe it would be possible to get a link into a "This Week in Rust"?

[–] Gobbel2000@feddit.de 1 points 1 year ago (3 children)

Where are these circles coming from!?

[–] Gobbel2000@feddit.de 4 points 1 year ago

That commonwealth is called the EU today and, along with NATO, is the reason why these countries are in a comparitively safer position. It would be much riskier for Russia to invade there.

[–] Gobbel2000@feddit.de 324 points 1 year ago (10 children)

lemmy.made.me.look.at.this.each.time.i.open.a.terminal

Hostnames can be up to 64 characters long in Linux.

[–] Gobbel2000@feddit.de 3 points 1 year ago

I use Colemak where most punctuation is at the same place as in the US English layout, which programming languages seem to be optimized toward. For the layout I prefer ISO for the larger Enter key.

[–] Gobbel2000@feddit.de 75 points 1 year ago (2 children)

That's sad that Mozilla has to take it into their own hands to provide a proper alternative to Snap Firefox.

[–] Gobbel2000@feddit.de 20 points 1 year ago

"Würstel Bianchi" als Übersetzung von Weißwürsten finde ich gut.

[–] Gobbel2000@feddit.de 2 points 2 years ago

Rust

I simply check each starting position individually for Part 2, I don't know if there are more clever solutions. Initially that approach ran in 180ms which is a lot more than any of the previous puzzles needed, so I tried if I could optimize it.

Initially I was using two hash sets, one for counting unique energized fields, and one for detecting cycles which also included the direction in the hash. Going from the default rust hasher to FxHash sped it up to 100ms. Seeing that, I thought that this point could be further improved upon, and ended up replacing both hash sets with boolean arrays, since their size is neatly bounded by the input field size. Now it runs in merely 30ms, meaning a 6x speedup just by getting rid of the hashing.

[–] Gobbel2000@feddit.de 1 points 2 years ago (1 children)

You can create an array filled with all the same values in Rust, but only if all values have the same memory representation because they will be copied. That just doesn't work with Vec's, because they must all have their own unique pointer. And to have uninitialized values at first (think NULL-pointers for every Vec) while creating each Vec, something like this is apparently needed.

The appropriate way would certainly have been to store the map as a Vec> instead of an array, but I just wanted to see if could.

[–] Gobbel2000@feddit.de 5 points 2 years ago (4 children)

Rust

Part 1 was super simple with wrapping_add and wrapping_mul on a u8. Building an actual hash map in Part 2 was nice.

[–] Gobbel2000@feddit.de 6 points 2 years ago

Rust

The trick for part 2 is obviously to check when the pattern repeats itself and then jump ahead to 1000000000.

My code allocates an entire new grid for every tilt, some in-place procedure would probably be more efficient in terms of memory, but this seems good enough.

[–] Gobbel2000@feddit.de 4 points 2 years ago

Rust

Part 2 turned out easier than I thought initially. My code assumes that there is only 1 mirror in each field which means I don't have to remember where the smudge is, I just have to find a mirror line where the two halves differ at exactly one spot.

view more: ‹ prev next ›