Skip to content

Commit

Permalink
Outputting the board after each go.
Browse files Browse the repository at this point in the history
  • Loading branch information
archy-bold committed Jan 4, 2022
1 parent 9425c76 commit 9b34e7c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ import (
"strings"
)

const NUM_LETTERS = 5
const (
NUM_LETTERS = 5
NUM_ATTEMPTS = 6

COLOUR_RESET = "\033[0m"
COLOUR_GREEN = "\033[32m"
COLOUR_YELLOW = "\033[33m"
)

var letters = map[string]bool{"a": true, "b": true, "c": true, "d": true, "e": true, "f": true, "g": true, "h": true, "i": true, "j": true, "k": true, "l": true, "m": true, "n": true, "o": true, "p": true, "q": true, "r": true, "s": true, "t": true, "u": true, "v": true, "w": true, "x": true, "y": true, "z": true}
var validWords = []string{}
Expand All @@ -18,6 +25,7 @@ var histogram = map[string]int{}
var rankedWords PairList
var answersCorrect []string
var answersIncorrect [][]string
var board []string

func main() {
// Read the valid words
Expand Down Expand Up @@ -64,15 +72,22 @@ func main() {
fmt.Print("Enter the result, where x is incorrect, o is wrong position, y is correct eg yxxox: ")
input, _ := reader.ReadString('\n')
parts := strings.Split(strings.TrimSpace((input)), "")
boardRow := ""
for i, chr := range parts {
if chr == "x" {
letters[wordParts[i]] = false
} else if chr == "y" {
boardRow += COLOUR_GREEN
answersCorrect[i] = wordParts[i]
} else if chr == "o" {
boardRow += COLOUR_YELLOW
answersIncorrect[i] = append(answersIncorrect[i], wordParts[i])
}
boardRow += wordParts[i] + COLOUR_RESET
}
board = append(board, boardRow)

outputBoard()
}
}

Expand Down Expand Up @@ -171,3 +186,13 @@ func rankWords() {
// Sort the
sort.Sort(sort.Reverse(rankedWords))
}

func outputBoard() {
fmt.Println("")
fmt.Println(strings.Repeat("-", NUM_LETTERS+2))
for _, row := range board {
fmt.Printf("|%s|\n", row)
}
fmt.Println(strings.Repeat("-", NUM_LETTERS+2))
fmt.Println("")
}
Binary file modified wordle-solver
Binary file not shown.

0 comments on commit 9b34e7c

Please sign in to comment.