package main import ( "bufio" "os" log "github.com/sirupsen/logrus" ) // readlines reads lines from stdin. // returns input as an array of strings func readlines() []string { lines := []string{} scanner := bufio.NewScanner(os.Stdin) for scanner.Scan() { lines = append(lines, scanner.Text()) } if err := scanner.Err(); err != nil { log.Fatal(err) } return lines } // inLastMoves checks if next coords exists in past moves func inLastMoves(last []coords, b coords) bool { for _, co := range last { if co.X == b.X && co.Y == b.Y { return true } } return false } // comparePoints returns true if coordinates for two points match func comparePoints(a, b point) bool { return a.X == b.X && a.Y == b.Y } // contains returns true if a slice of elements contains a given element func contains[T comparable](elems []T, v T) bool { for _, s := range elems { if v == s { return true } } return false }