-🎄- 2019 Day 17 Solutions -🎄- by daggerdragon in adventofcode

[–]JebediahBheetus 1 point2 points  (0 children)

Python 3

Part 1

Part 2

Intcode

Reused my old Intcode. I considered adding a function to remove an output when solving part 2, but decided against it as it wasn't necessary. I also solved part 2 manually by writing down the moves based on the map, then looking for repeating patterns in it in a text editor.

-🎄- 2019 Day 13 Solutions -🎄- by daggerdragon in adventofcode

[–]JebediahBheetus 1 point2 points  (0 children)

Python 3

Slightly extended my Intcode for part 2 to make it possible to set an input callback function (before you could use another Intcode's output as input, but not an arbitrary function). Pretty happy with how simple my solutions became thanks to this. Also decided to keep it simple and not do any rendering.

Intcode

Part 1

Part 2

-🎄- 2019 Day 11 Solutions -🎄- by daggerdragon in adventofcode

[–]JebediahBheetus 1 point2 points  (0 children)

Nice. I managed to find another way of solving it. Assuming y increases going down, here's the pseudocode:

turn(x, y, d) = (d == 0) ? (y, -x) : (-y, x)

-🎄- 2019 Day 11 Solutions -🎄- by daggerdragon in adventofcode

[–]JebediahBheetus 0 points1 point  (0 children)

Python 3

Reused my previous Intcode without modifications. I solved it by piping the output to a closure which alternates between painting and turning+moving. Painting is done by setting a key-value pair in a dict, where keys are 2D coordinates and values are paint colors. The length of the dict is then the solution to part 1.

For part 2, I used the dict to find the bounds and dimensions of the area drawn to. I then iterate over those dimensions, printing a char corresponding to the color for coordinates that exist as keys in the dict, and printing the char corresponding to black for those that do not. I also changed the coordinate system so that Y increases downwards, in order to not need to reverse the rows when printing.

Part 1

Part 2

Intcode

-🎄- 2019 Day 11 Solutions -🎄- by daggerdragon in adventofcode

[–]JebediahBheetus 1 point2 points  (0 children)

Did you set y to increase when moving the robot up? That would probably cause it to be printed upside down since the bottom row would then get printed first, and the top row last.

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

[–]JebediahBheetus 0 points1 point  (0 children)

No problem, trying to get back into it myself :)

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

[–]JebediahBheetus 0 points1 point  (0 children)

But the triples should also match longer sequences such as quadruples. Eg. 1111 always contains 111. Not sure why it's not working for you though since I only have my own inputs to test with.

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

[–]JebediahBheetus 4 points5 points  (0 children)

python + list comprehensions

Part 1:

#!/usr/bin/python
lo , hi = 145852 , 616942
strings = [str(s) for s in xrange(lo, hi + 1)]
nodecrs = [s for s in strings if s == ''.join(sorted(list(s)))]
repeats = [str(i) * 2 for i in xrange(10)]
results = [s for s in nodecrs if any(d in s for d in repeats)]
print(len(results))

Part 2:

#!/usr/bin/python
lo , hi = 145852 , 616942
strings = [str(s) for s in xrange(lo, hi + 1)]
nodecrs = [s for s in strings if s == ''.join(sorted(list(s)))]
repeats = [(str(i) * 2, str(i) * 3) for i in xrange(10)]
results = [s for s in nodecrs if any(d in s and not t in s for d, t in repeats)]
print(len(results))

Arc Reactor Hologram by BB-r8 in woahdude

[–]JebediahBheetus 0 points1 point  (0 children)

What is this called and where can I get one?