hey thanks!
I didn't check any other solutions before finishing (currently wondering way day 13 is too low), but I thought that trying to traverse fences would be a pain and since I have everything separated by regions and not traversing the array, counting corners never came to mind.
But the thought that I had was that for each region, all points will be a straight line in the V or H orientations, so if I can go up and down and count when last != next - 1
, then that'll tell me that that is a contiguous piece of fence.
The idea isn't too hard, for tracking the XAxis it's
region.GroupBy(YAxis) // row
.Select(group =>
group.Sort(g => g.XAxis) // column
.Window(a,b => a != b - 1 ? 1 : 0).Sum()
.Sum()
Except that I used a different splitting method and that came to me later.
I had to borrow some of y'alls code to finish part 2. My approach and all the attempts I did at trying to get the slopes of lines and such couldn't get it high enough.
I thought to move from the prize along it's furthest away axis until I got to the intersection of the slope of the two buttons.
I thought that maybe that wasn't the cheapest way, so I fiddled around with the order of button A and B, but still couldn't get it high enough.
It looks like this group was mostly doing the cross product of the prize to the two buttons. I'm too dumb to realize how that would work. I thought you'd want to move along the furthest away axis first, but maybe it doesn't matter.
If anyone can see if I did anything obviously wrong, I'd appreciate it. I normally don't like to take code without fixing whatever it is I was doing since it always bites me in the butt later, but here I am.
F#
expand for source