r/adventofcode • • Dec 12 '18

SOLUTION MEGATHREAD -🎄- 2018 Day 12 Solutions -🎄-

--- Day 12: Subterranean Sustainability ---


Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or whatever).

Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.


Advent of Code: The Party Game!

Click here for rules

Please prefix your card submission with something like [Card] to make scanning the megathread easier. THANK YOU!

Card prompt: Day 12

Transcript:

On the twelfth day of AoC / My compiler spewed at me / Twelve ___


This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.

edit: Leaderboard capped, thread unlocked at 00:27:42!

20 Upvotes

257 comments sorted by

View all comments

Show parent comment

2

u/abnew123 Dec 12 '18

if the first character in your string is the number 0 pot, the sum is 877 yes.

1

u/[deleted] Dec 12 '18

Apparently not:

That's not the right answer. If you're stuck, there are some general tips on the about page, or you can ask for hints on the subreddit. Because you have guessed incorrectly 9 times on this puzzle, please wait 10 minutes before trying again. (You guessed 877.)

How do I know which is my number 0 pot? In the example it is the 4th pot from the left, but it is not explained why.

0

u/[deleted] Dec 12 '18

[deleted] — view deleted comment

1

u/[deleted] Dec 12 '18

I need to expand? In which scenario would that happen? At least it is not in the example

4

u/ThezeeZ Dec 12 '18

In the example, in generation 3, a plant grows in pot -1

1

u/[deleted] Dec 12 '18

I see :-) THX

3

u/abnew123 Dec 12 '18

The pots don't move. So your starting 0 pot is still the 0 pot. Like, if "#..#" was your string, and # is your starting 0 pot, you can represent your pots as whatever you want (".#..#", "..#..#", ".#..#....."), but that first # is still your pot 0. At the end, whatever pot corresponds to the initial first # is still pot 0.

2

u/[deleted] Dec 12 '18

So I have to track the left-most pot from the starting string and this position will be my 0? Is that correct?

2

u/branfili Dec 12 '18

Yes

It's easier if you make a list of characters 500 long, and insert your string starting at char 250

Then just print (sol - count('#')*250) (minus offset)

2

u/[deleted] Dec 12 '18

Yeah :-) Or some kind of defaultdict that automatically "expands". You basically only have to store the indices of "#" pots and assume everything else is ".". I think this is the cleanest solution, but now I am too lazy and tired. Might try that tomorrow

2

u/abnew123 Dec 12 '18

yeah. If you set say index 100 in a list to your left most pot in the starting string, that at the end index 100 will still be the left most pot. Obviously no need to use index 100 specifically, it just happened to be the one I used.

2

u/branfili Dec 12 '18

on the start, the first pot is 0

if you've expanded to the left then you have some negative pots

1

u/[deleted] Dec 12 '18

My initial state was:

##.#..#.#..#.####.#########.#...#.#.#......##.#.#...##.....#...#...#.##.#...##...#.####.##..#.#..#.

So i did not expand to the left, right?