Solve a Rubik's cube: Difference between revisions

Content added Content deleted
(Added Go)
(→‎{{header|Go}}: Added code to check there were no errors whilst scanning the file. Changed previous error handling code to use log.Fatal().)
Line 34:
"bufio"
"fmt"
"log"
"os"
"strings"
Line 159 ⟶ 160:
//--- Load dataset (file name should be passed as a command line argument).
if len(os.Args) != 2 {
fmtlog.PrintlnFatal("Thethe file name should be passed as a command line argument")
return
}
file, err := os.Open(os.Args[1])
if err != nil {
fmtlog.PrintlnFatal("Unableerr) to open file.")
return
}
defer file.Close()
Line 294 ⟶ 293:
fmt.Printf(" (moves %d)\n", totalMoves)
aggregateMoves += totalMoves
}
if err := scanner.Err(); err != nil {
log.Fatal(err)
}
endTime := time.Now()