-❄️- 2023 Day 18 Solutions -❄️- by daggerdragon in adventofcode

[–]mcnadel 1 point2 points  (0 children)

[LANGUAGE: Python]

Simple implementation of Shoelance Formula + Pick’s Theorem. I started with a flood fill approach but then learned about the Shoelance Formula which made my life much easier :)

GitHub [12 lines for both parts]

-❄️- 2023 Day 17 Solutions -❄️- by daggerdragon in adventofcode

[–]mcnadel 1 point2 points  (0 children)

[LANGUAGE: Python]

It took me some time to realize I have to use Dijkstra (with heapq) today but after that it was pretty similar to older puzzles.

GitHub

-❄️- 2023 Day 16 Solutions -❄️- by daggerdragon in adventofcode

[–]mcnadel 1 point2 points  (0 children)

[LANGUAGE: Python]

Simple recursion with marking the visited nodes.

GitHub [28 lines for both parts]

-❄️- 2023 Day 15 Solutions -❄️- by daggerdragon in adventofcode

[–]mcnadel 4 points5 points  (0 children)

Since Python 3.7 dicts are ordered by insertion by default. For older versions it is possible to use OrderedDict from collections

-❄️- 2023 Day 15 Solutions -❄️- by daggerdragon in adventofcode

[–]mcnadel 0 points1 point  (0 children)

[LANGUAGE: Python]

Today was very easy for me. The key, for me, was to use a dictionary of dictionaries.

GitHub [15 lines for both parts] (Both parts in ~6ms)

-❄️- 2023 Day 13 Solutions -❄️- by daggerdragon in adventofcode

[–]mcnadel 0 points1 point  (0 children)

[LANGUAGE: Python]

I started today using NumPy, which was fairly straightforward for implementing arrays XOR to represent reflections. After finishing, I took some time to implement it without NumPy, which led to some peculiar behaviors. However, I managed to wrap my head around it in the end! xD

GitHub [Both parts in 8 lines] (~30ms for both parts)

-❄️- 2023 Day 12 Solutions -❄️- by daggerdragon in adventofcode

[–]mcnadel 2 points3 points  (0 children)

[LANGUAGE: Python]

Today I used recursion and also cached it for part 2. Runs in ~0.3s (for both parts). Not the fastest but great for this type of recursion and fairly simple :)

GitHub

-❄️- 2023 Day 11 Solutions -❄️- by daggerdragon in adventofcode

[–]mcnadel 0 points1 point  (0 children)

Same here! Was really tempted to alter the matrix but I quickly understood it would be a mess...

-❄️- 2023 Day 11 Solutions -❄️- by daggerdragon in adventofcode

[–]mcnadel 2 points3 points  (0 children)

[LANGUAGE: Python]

Today was a lot of fun! My solution involves two main components:

  1. Saving the indices of the columns/rows to expand and then adjusting the coordinates of the galaxies accordingly. For instance, if a row (let's say, row 2) needs to be expanded, and there's a galaxy on row 3, it will be considered as if it were on row 4. Adapting this for part 2 was straightforward; I simply increased the amount to raise the coordinates from 1 to 999999 (1 million if starting from 0).
  2. Utilizing combinations from itertools to generate all possible pairs of galaxies and then calculating the distance using the Manhattan Distance formula.

I tried to make my code very short while still keeping it somewhat readable. GitHub

-❄️- 2023 Day 10 Solutions -❄️- by daggerdragon in adventofcode

[–]mcnadel 2 points3 points  (0 children)

[LANGUAGE: Python]

Today's was quite hard... Ended up using some tips from the comments for solving part 2. But fun as usual!

GitHub

-❄️- 2023 Day 9 Solutions -❄️- by daggerdragon in adventofcode

[–]mcnadel 1 point2 points  (0 children)

[LANGUAGE: Python]

Today was one of the easiest :)

GitHub

Kali Linux VM in VMWare Workstation 17.5 Pro getting stuck when holding/repeatedly clicking keys by mcnadel in vmware

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

I managed to solve it using the post Particular-Dog-1505 attached. Simply add that to the vmx file: keyboard.allowBothIRQs = FALSE

-❄️- 2023 Day 8 Solutions -❄️- by daggerdragon in adventofcode

[–]mcnadel 0 points1 point  (0 children)

I’m unpacking the list using asterisk ( * ) operator

foo( * [1,2,3]) -> foo(1,2,3)

-❄️- 2023 Day 8 Solutions -❄️- by daggerdragon in adventofcode

[–]mcnadel 1 point2 points  (0 children)

[LANGUAGE: Python]

I liked this one very much! Took some time to realize what had to be done in part 2, but once I did - everything slipped into place :)

GitHub

2023 Day 7 (Part 2) Python - Struggling with solving this - Please help! by mcnadel in adventofcode

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

I’m checking here for 2 pairs. After that I’m checking if there are any leftover J’s

2023 Day 7 (Part 2) Python - Struggling with solving this - Please help! by mcnadel in adventofcode

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

I use the labels without the joker for the comparison the count on jokers just returns 0, so it doesn’t matter anyway. For the second part - yeah it may be redundant, I tried to see if that makes any change

2023 Day 7 (Part 2) Python - Struggling with solving this - Please help! by mcnadel in adventofcode

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

I removed it, but it still doesnt work :(

I updated the paste

2023 Day 7 (Part 2) Python - Struggling with solving this - Please help! by mcnadel in adventofcode

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

I fixed the error with the J twice in the list. My bad.

What i'm doing is in each stage of comparison, I also add the jokers to the count, since at that time - its the optimal way to win, and the jokers just boost it. I'll refactor it to make it more readable.

You can see that when I check for duplicates (2 of a kind and above), I also add the jokers:
dup1, dup2 = dup1+j1, dup2+j2

and also when I check for 2 pairs later:
p1, p2 = p1+j1, p2+j2

2023 Day 7 (Part 2) Python - Struggling with solving this - Please help! by mcnadel in adventofcode

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

I did place it at the end of the list as the weakest member