mirror of
				https://github.com/onyx-and-iris/aoc2024.git
				synced 2025-11-04 06:51:47 +00:00 
			
		
		
		
	dry it up a little
This commit is contained in:
		
							parent
							
								
									401bd4201b
								
							
						
					
					
						commit
						dcf3479d88
					
				@ -101,33 +101,31 @@ func isCorner(graph *graph, current, p, q point) bool {
 | 
			
		||||
func numInnerCorner(graph *graph, current point, ns [4]point) int {
 | 
			
		||||
	var corners int
 | 
			
		||||
 | 
			
		||||
	if !graph.isOutOfBounds(ns[N]) && !graph.isOutOfBounds(ns[E]) {
 | 
			
		||||
		if graph.sameKind(ns[N], current) && graph.sameKind(ns[E], current) &&
 | 
			
		||||
			!graph.sameKind(point{current.x + 1, current.y - 1}, current) {
 | 
			
		||||
			corners++
 | 
			
		||||
		}
 | 
			
		||||
	if isInnerCorner(graph, current, ns[N], ns[E], point{current.x + 1, current.y - 1}) {
 | 
			
		||||
		corners++
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !graph.isOutOfBounds(ns[N]) && !graph.isOutOfBounds(ns[W]) {
 | 
			
		||||
		if graph.sameKind(ns[N], current) && graph.sameKind(ns[W], current) &&
 | 
			
		||||
			!graph.sameKind(point{current.x - 1, current.y - 1}, current) {
 | 
			
		||||
			corners++
 | 
			
		||||
		}
 | 
			
		||||
	if isInnerCorner(graph, current, ns[N], ns[W], point{current.x - 1, current.y - 1}) {
 | 
			
		||||
		corners++
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !graph.isOutOfBounds(ns[S]) && !graph.isOutOfBounds(ns[E]) {
 | 
			
		||||
		if graph.sameKind(ns[S], current) && graph.sameKind(ns[E], current) &&
 | 
			
		||||
			!graph.sameKind(point{current.x + 1, current.y + 1}, current) {
 | 
			
		||||
			corners++
 | 
			
		||||
		}
 | 
			
		||||
	if isInnerCorner(graph, current, ns[S], ns[E], point{current.x + 1, current.y + 1}) {
 | 
			
		||||
		corners++
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !graph.isOutOfBounds(ns[S]) && !graph.isOutOfBounds(ns[W]) {
 | 
			
		||||
		if graph.sameKind(ns[S], current) && graph.sameKind(ns[W], current) &&
 | 
			
		||||
			!graph.sameKind(point{current.x - 1, current.y + 1}, current) {
 | 
			
		||||
			corners++
 | 
			
		||||
		}
 | 
			
		||||
	if isInnerCorner(graph, current, ns[S], ns[W], point{current.x - 1, current.y + 1}) {
 | 
			
		||||
		corners++
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return corners
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func isInnerCorner(graph *graph, current, p, q, diagonal point) bool {
 | 
			
		||||
	if !graph.isOutOfBounds(p) && !graph.isOutOfBounds(q) {
 | 
			
		||||
		if graph.sameKind(p, current) && graph.sameKind(q, current) &&
 | 
			
		||||
			!graph.sameKind(diagonal, current) {
 | 
			
		||||
			return true
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user