Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Example string
View Source
var Example2 string
Functions ¶
This section is empty.
Types ¶
type Day10 ¶
type Day10 struct {
// contains filtered or unexported fields
}
func (*Day10) ParseExample ¶
func (d *Day10) ParseExample()
func (*Day10) ParseExample2 ¶
func (d *Day10) ParseExample2()
func (*Day10) Part2 ¶
Part2 calculates the enclosed tiles using the shoelace formula and Pick's theorem. Pick's theorem can be rearranged to give
interiorPoints = area - perimeter/2 + 1
The perimeter is equal to the number of pipes in the loop, as each pipe is one unit apart. The area can be calculated using the shoelace formula
area = abs(sum(x_i*y_{i+1} - x_{i+1}*y_i)))/2
Credit to all the users on the reddit solutions thread for the idea
Click to show internal directories.
Click to hide internal directories.