code.go 640 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package main
  2. import (
  3. "bufio"
  4. "fmt"
  5. "log"
  6. "os"
  7. )
  8. type Point struct {
  9. y, x int
  10. }
  11. func (p *Point) move(maze []string) bool {
  12. switch maze[p.y][p.x] {
  13. }
  14. }
  15. func readInput(file *os.File) []string {
  16. scanner := bufio.NewScanner(file)
  17. var maze []string
  18. for scanner.Scan() {
  19. line := scanner.Text()
  20. if line == "" {
  21. break
  22. }
  23. maze = append(maze, line)
  24. }
  25. return maze
  26. }
  27. func main() {
  28. if len(os.Args) < 2 {
  29. log.Fatal("You need to specify a file!")
  30. }
  31. filePath := os.Args[1]
  32. file, err := os.Open(filePath)
  33. if err != nil {
  34. log.Fatalf("Failed to open %s!\n", filePath)
  35. }
  36. maze := readInput(file)
  37. fmt.Println(maze)
  38. }