mirror of
				https://github.com/onyx-and-iris/aoc2024.git
				synced 2025-11-04 06:51:47 +00:00 
			
		
		
		
	remove unused functions and fields
This commit is contained in:
		
							parent
							
								
									fa02cb3bc7
								
							
						
					
					
						commit
						c89f5611ed
					
				@ -1,14 +1,12 @@
 | 
			
		||||
package two
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"slices"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type point struct {
 | 
			
		||||
	x         int
 | 
			
		||||
	y         int
 | 
			
		||||
	direction int
 | 
			
		||||
	x int
 | 
			
		||||
	y int
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type graph struct {
 | 
			
		||||
@ -31,11 +29,3 @@ func (g *graph) isOutOfBounds(p point) bool {
 | 
			
		||||
func (g *graph) valueAt(p point) rune {
 | 
			
		||||
	return rune(g.data[p.y][p.x])
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (g *graph) debug(path []point) string {
 | 
			
		||||
	temp := slices.Clone(g.data)
 | 
			
		||||
	for _, pos := range path {
 | 
			
		||||
		temp[pos.y] = replaceAtIndex(temp[pos.y], '+', pos.x)
 | 
			
		||||
	}
 | 
			
		||||
	return strings.Join(temp, "\n")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -2,9 +2,9 @@ package two
 | 
			
		||||
 | 
			
		||||
func neighbours(p point) [4]point {
 | 
			
		||||
	return [4]point{
 | 
			
		||||
		{p.x, p.y - 1, N},
 | 
			
		||||
		{p.x + 1, p.y, E},
 | 
			
		||||
		{p.x, p.y + 1, S},
 | 
			
		||||
		{p.x - 1, p.y, W},
 | 
			
		||||
		{p.x, p.y - 1},
 | 
			
		||||
		{p.x + 1, p.y},
 | 
			
		||||
		{p.x, p.y + 1},
 | 
			
		||||
		{p.x - 1, p.y},
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -34,15 +34,11 @@ func Solve(buf []byte) (int, error) {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			for dir, n := range neighbours(current) {
 | 
			
		||||
			for _, n := range neighbours(current) {
 | 
			
		||||
				if graph.isOutOfBounds(n) {
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if n.direction == None {
 | 
			
		||||
					n.direction = dir
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if graph.valueAt(n)-graph.valueAt(current) == 1 {
 | 
			
		||||
					log.Tracef("pushing %v with value %s back onto the queue\n", n, string(graph.valueAt(n)))
 | 
			
		||||
					queue.Enqueue(n)
 | 
			
		||||
 | 
			
		||||
@ -22,7 +22,7 @@ func parseLines(r io.Reader) (*graph, error) {
 | 
			
		||||
		for _, m := range reStartPos.FindAllStringIndex(line, -1) {
 | 
			
		||||
			graph.startPositions = append(
 | 
			
		||||
				graph.startPositions,
 | 
			
		||||
				point{x: m[0], y: linecount, direction: None},
 | 
			
		||||
				point{x: m[0], y: linecount},
 | 
			
		||||
			)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -37,9 +37,3 @@ func parseLines(r io.Reader) (*graph, error) {
 | 
			
		||||
 | 
			
		||||
	return graph, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func replaceAtIndex(s string, r rune, i int) string {
 | 
			
		||||
	out := []rune(s)
 | 
			
		||||
	out[i] = r
 | 
			
		||||
	return string(out)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user