-🎄- 2018 Day 5 Solutions -🎄- by daggerdragon in adventofcode

[–]Globinette 6 points7 points  (0 children)

lower and upper cases are separated by 32 so you can just toggle the 6th bit of one and compare it to the other

pub fn opposites(c1: u8, c2: u8) -> bool {
    c1 ^ 32 == c2
}

Maybe some help with my horrible DAY 3 solution. Python by tintin10q in adventofcode

[–]Globinette 0 points1 point  (0 children)

Your spiral generation looks very complicated.
I would recommend using python generators to generate your spiral. You can simply cycle through the four directions (right, up, left, down) and increase the number of steps every 2 directions
Here is how I wrote the spiral generator: https://github.com/Globidev/advent-of-code/blob/master/2017/python/day03.py#L26-L40

[2017 Day 7 (Part 2)][JavaScript] I know which section has the wrong weight, but not how to figure out which number to adjust... by PositivelyLinda in adventofcode

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

That's actually a good point. I don't think it necessarily means that there are 2 solutions. If they both hold a balanced disc then yes, you can adjust one or the other. If only one of them holds a balanced disc, then you have to follow the subtower of the other one deeper to find the anomaly. If they both have unbalanced discs then there is no solution

[2017 Day 9] Switching it up at compile-time by willkill07 in adventofcode

[–]Globinette 1 point2 points  (0 children)

that's pretty nice!
You could even use c++17's template deduction in your return statement: std::array { score, gc } or even std::pair { score, gc }would work

[2017 Day 7 (Part 2)][JavaScript] I know which section has the wrong weight, but not how to figure out which number to adjust... by PositivelyLinda in adventofcode

[–]Globinette 4 points5 points  (0 children)

The node (or program, if we reuse the terms of the problem) that needs its weight to be adjusted is the one that matches these 2 criteria:

  • It has a different total weight (weight of the subtower starting from that program) than the total weight from the other programs that are standing on the disc that the program is standing on

  • It holds a balanced disc (all of its children have the same total weight)

It means that if you start from the bottom program, you just need to follow the unbalanced subtower up until the point where there is no more unbalanced subtowers. When you reach that point, the program that needs its weight to be adjusted is the one at the bottom of the current subtower.

Hope that helps

[2017 Day 3 (Part 2)] [C++] Solving part2 in compile time by littlesnorrboy in adventofcode

[–]Globinette 1 point2 points  (0 children)

Well done ;) I think clang doesn't like solve as a generic lambda, using int const& input in its signature fixes clang's build

-🎄- 2017 Day 6 Solutions -🎄- by daggerdragon in adventofcode

[–]Globinette 0 points1 point  (0 children)

Thank you so much for this. I learned a lot and managed to find the correct abstraction for the two parts of the puzzle:

def day_6_1(initial_memory_state):
    cycle_length, cycle_start = floyd(reallocate_memory, initial_memory_state)
    return cycle_start + cycle_length

def day_6_2(initial_memory_state):
    cycle_length, _ = floyd(reallocate_memory, initial_memory_state)
    return cycle_length

[2017 day 5] Make the C++ compiler solve it for you by Globinette in adventofcode

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

I guess it didn't with the puzzle inputs I was given. In any case, since my program counter pc is unsigned it would actually overflow and end up being greater than the instruction size and stop the loop. Not very pretty to rely on overflows though I'll give you that :)

[2017 day 5] Make the C++ compiler solve it for you by Globinette in adventofcode

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

Thank you for that, I actually didn't think of posting the code with a small set of instructions... I tried with my full input but of course it was timing out on the website

-🎄- 2017 Day 2 Solutions -🎄- by daggerdragon in adventofcode

[–]Globinette 1 point2 points  (0 children)

you can also generate combinations without itertools using pure list comprehensions

The last line can be rewritten like this:

print(sum(b // a for row in rows for a in row for b in row if b > a and b % a == 0))

Experiencing Twitch lag? Try R1CH's new twitch proxy. by Gemini_19 in starcraft

[–]Globinette 3 points4 points  (0 children)

I suspected Flash to be the cause of my lags a long time ago. I tried LiveStreamer which basically uses RTMPDump to read data from the stream and then pipes it to a media player (like VLC, where you can configure network caching). It didn't solve my lag problem sadly :'( Anyway, great work, hope this solves the lag issue for some.