Write a Go program: The program's first argument is the word to search for in the puzzle.
Question:
Write a Go program: The program's first argument is the word to search for in the puzzle. The second argument is either the file path to the puzzle or "-" which means the program will read the puzzle from standard input. The puzzle is a UTF-8 encoded text file with one line per row in the puzzle. The puzzle is rectangular so all rows must have the same number of columns. If they do not then write "inconsistent line length" to standard error and exit with exit code 3.
2. Output the matches one per line in the following format. (R, C) D where R is the row (1-based), C is the column (1-based), and D is the unicode direction arrow from the set →←↓↑↘↗↙↖. The matches must be output in lexicographic order on the vector RCD.
3. Be sure to close of file descriptor. You will loose a point for each file descriptor not closed.
4. Do not use any library other than the Go standard library.
5. The source code must compile with the most recent version of the Go compiler.
6. The program must not panic under any circumstances.
7. Make sure your code is "gofmt'd". See gofmt or better use goimports or better yet configure IDE to do this formatting on file save.
Hints:
The bufio, fmt, and strings packages might be useful for this assignment.
example output
$ cat puzzle1.txt
abcdefg
hiŮklmn
pqœstuv
$ cat puzzle2.txt
cxxxefg
bxfxhi0
cxxxc10
$ go run ./cmd/wordsearch de puzzle1.txt
(1, 4) →
$ go run ./cmd/wordsearch œke puzzle1.txt ← Note: make sure this command run and print “output”
(3, 3) ↗
$ go run ./cmd/wordsearch cx puzzle2.txt
(1, 1) →
(1, 1) ↘
(3, 1) →
(3, 1) ↗
(3, 5) ←
(3, 5) ↖
$ go run ./cmd/wordsearch i puzzle2.txt
(2, 6) ←
(2, 6) ↑
(2, 6) →
(2, 6) ↓
(2, 6) ↖
(2, 6) ↗
(2, 6) ↘
(2, 6) ↙
Microsoft Visual C# An Introduction to Object-Oriented Programming
ISBN: 978-1337102100
7th edition
Authors: Joyce Farrell