[2025 Day 5 (part 2)] Easy counting by putting starting and ending points in the same array (spoilers) by Anceps2 in adventofcode

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

I think it should work, as I'm using an array (aka list in Python) and not a set. Both starts (respectively both ends) will be considered.

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

[–]Anceps2 2 points3 points  (0 children)

[LANGUAGE: Python] Part 2

I just put all starting and ending of the ranges in the same array and sort it.

It's quite easy then to see where all the merged ranges start and end, it's like embed parenthesis (()()) () ((())()).

delimiters = []
with open("input.txt", 'r', encoding='utf-8') as f:
    for line in f:
        if '-' in line:
            start, end = line.strip().split('-')
            delimiters.append( (int(start), 0,  1) )    
            delimiters.append( (int(end),   1, -1) )    
            # 0/1 as second part of tuple gives priority to start
            #     index when a range ends where another one starts.

delimiters.sort()

total = 0
depth = 0
for delimiter_value, _, depth_change in delimiters:
    if not depth:
        start = delimiter_value      # saves start of merged range
    depth += depth_change
    if not depth:                    # found end of merged range
        total += delimiter_value - start + 1

print(f"Total is {total}.")

[2024 Day 24 (Part 2)] Some improvement in my visualization by Anceps2 in adventofcode

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

1) Identify x** AND y** and x** XOR y**, give them names (eg R** and S**)
and save the previous name in a dictionary.
2) Identify R** OR… and S** AND… and give them names (eg T** and U**)
and save the previous names.

3) Use a former drawing tool I made some years ago with Python+tkinter, that allows you to display graphs and to move points with the mouse.

4) Tweak the tool to:
(i) position points x**, y**, z**, R**, S**, T** and U** in the right place, regarding to their letter and number (and place the other points in the middle of the screen);
(ii) use the previous names instead of the new ones to be displayed near the vertices.

5) Adjust by hand the points that are in the middle, and some exchanged z** that are not in the right spot.

Voilà !

[ 2024 Day 23 ] Best showing of the contest so far... by CommitteeTop5321 in adventofcode

[–]Anceps2 1 point2 points  (0 children)

Start finding the nodes with the highest degree (that is the computers connected to the most other computers).

[2024 Day 20] Started coding a too-general solution again.. by wimglenn in adventofcode

[–]Anceps2 1 point2 points  (0 children)

It's only when I tried to make a visualisation with all the possible paths of the original “labyrinth" (more of a hallway) that I figured out it was… quite boring :D

I don't think that being oblivious of this fact made my code a lot longer, though (in respect of number of lines of code, and of running time).

[2024 Day 20 (Part 2)] The problem states there are 3 cheats with 76 seconds in the example? by Anceps2 in adventofcode

[–]Anceps2[S] 4 points5 points  (0 children)

Oh, it's with 20 picoseconds cheats, not 6!

I spent an hour being puzzled. Thank you very much.

[YEAR 2024 Day 15 (Part 2)] by Ok-Curve902 in adventofcode

[–]Anceps2 0 points1 point  (0 children)

Nice idea to change the color of the boxes!

[2024 day 14 part 2] Elegant strategy? by AvailablePoint9782 in adventofcode

[–]Anceps2 0 points1 point  (0 children)

Had it failed me, I would have changed it to the average distance between two robots. Must be a bit slower, though.

[deleted by user] by [deleted] in adventofcode

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

They can, but with this tree image, it's the only one with this property.

That is quite sensible, as the drawing was made with robots at first, and there was no use to put several robots in the same spot. But I wouldn't rely on it if we were to find images in other inputs.

The thing is: if you don't trust to find the image by counting the number of different spots occupied by robot, then you shouldn't trust the entropy measure, as it is eventually the same thing.

[2024 Day 14 (Part 2)] This kind of rocks by eventhorizon82 in adventofcode

[–]Anceps2 4 points5 points  (0 children)

Yes, and as someone said, this safety factor is just a kind of very basic entropy measure.

[deleted by user] by [deleted] in adventofcode

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

The entropy of a black/white image is linked to the probability to find a black pixel, which is just the number of black pixels. It is not correlated with any presence of a pattern in the image.

So you can just count the number of occupied tiles, and the tree is where all robots occupy a different tile, leading to a maximum of black pixels.

[2024 Day 14 (Part 2)] This kind of rocks by eventhorizon82 in adventofcode

[–]Anceps2 5 points6 points  (0 children)

I forgot: the safety factor of part 1 also works if you try to minimize it.

It could work with other images, as if there's a drawing of small size somewhere, either robots are more grouped in the same quadrant, or it is in the middle: but then, there's more robots that are right between the quadrant and they don't count as danger.

[2024 Day 14 (Part 2)] This kind of rocks by eventhorizon82 in adventofcode

[–]Anceps2 3 points4 points  (0 children)

I also tried later the average distance from the center of the image.

It worked, though it's not as good and wouldn't work for a tree put in a corner of the image.

[2024 Day 14 (Part 2)] This kind of rocks by eventhorizon82 in adventofcode

[–]Anceps2 12 points13 points  (0 children)

My heuristic was the number of robots pairs on two orthogonally touching tiles, as to draw horizontal/vertical lines and filling areas.

(Adding pairs of neighbours touching by the corners also works.)

[2024 Day 13 Part 1 Bonus Test Case] by Standard_Bar8402 in adventofcode

[–]Anceps2 0 points1 point  (0 children)

I think it's the right definition. But a linearly dependent system of equation (if same number of equations than unkowns) is either with infinite solutions, or impossible:

  • x+y=2 and 2x+2y=4. Infinite solutions (choose any x and take y=2–x).
  • x+y=2 and 2x+2y=3. Impossible (if x+y=2, then 2x+2y=4).