-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwordleSolver.sh
More file actions
executable file
·126 lines (109 loc) · 4.54 KB
/
Copy pathwordleSolver.sh
File metadata and controls
executable file
·126 lines (109 loc) · 4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Benjamin Belandres
# Wordle Solver
GOOD_WORDS=`cat wordleWords`
# Finding the word to test
IS_RUNNING=true
echo "\n\n\n\n\n\n\n\n\n\n\n
██╗ ██╗ ██████╗ ██████╗ ██████╗ ██╗ ███████╗
██║ ██║██╔═══██╗██╔══██╗██╔══██╗██║ ██╔════╝
██║ █╗ ██║██║ ██║██████╔╝██║ ██║██║ █████╗
██║███╗██║██║ ██║██╔══██╗██║ ██║██║ ██╔══╝
╚███╔███╔╝╚██████╔╝██║ ██║██████╔╝███████╗███████╗
╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚══════╝╚══════╝
███████╗ ██████╗ ██╗ ██╗ ██╗███████╗██████╗
██╔════╝██╔═══██╗██║ ██║ ██║██╔════╝██╔══██╗
███████╗██║ ██║██║ ██║ ██║█████╗ ██████╔╝
╚════██║██║ ██║██║ ╚██╗ ██╔╝██╔══╝ ██╔══██╗
███████║╚██████╔╝███████╗╚████╔╝ ███████╗██║ ██║
╚══════╝ ╚═════╝ ╚══════╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝
"
echo "<n>ormal <l>egacy"
read INPUT
INPUT=$(echo "$INPUT" | tr '[:upper:]' '[:lower:]')
if [ "$INPUT" = "l" ]; then
while $IS_RUNNING
do
# Getting input
echo -n "Enter color of letter: "
read INPUT
INPUT=$(echo "$INPUT" | tr '[:upper:]' '[:lower:]')
case "$INPUT" in
"green" | "g")
echo -n "Enter the letter: "
read LETTER
LETTER=$(echo "$LETTER" | tr '[:lower:]' '[:upper:]')
echo -n "Enter the letter's position (from 0): "
read POSITION
LEN=$((4 - $POSITION))
GOOD_WORDS=`echo "$GOOD_WORDS" | grep -P "(\w{$POSITION})$LETTER(\w{$LEN})"` ;;
"yellow" | "y")
echo -n "Enter the letter: "
read LETTER
LETTER=$(echo "$LETTER" | tr '[:lower:]' '[:upper:]')
echo -n "Enter the letter's position (from 0): "
read POSITION
LEN=$((4 - $POSITION))
GOOD_WORDS=`echo "$GOOD_WORDS" | grep "$LETTER"`
GOOD_WORDS=`echo "$GOOD_WORDS" | grep -P -v "(\w{$POSITION})$LETTER(\w{$LEN})"` ;;
"black" | "b")
echo -n "Enter the letter: "
read LETTER
LETTER=$(echo "$LETTER" | tr '[:lower:]' '[:upper:]')
GOOD_WORDS=`echo "$GOOD_WORDS" | grep -v "$LETTER"` ;;
"d")
echo "$GOOD_WORDS" ;;
"q")
IS_RUNNING=false
break ;;
"help" | "h")
echo "d recommends a word to guess\nq stops the program\n" ;;
*)
echo "This ain't it chief: $INPUT" ;;
esac
done
else
ITERATIONS=$((0))
LETTER_POSITION=$((0))
while $IS_RUNNING
do
# Printing suggested words after the input is done
LETTER_POSITION=$(($ITERATIONS % 5))
if [ $LETTER_POSITION -eq 0 ] && [ $ITERATIONS != 0 ]; then
echo "$GOOD_WORDS"
fi
# Getting input
echo -n "Enter color of letter in position $LETTER_POSITION: "
read INPUT
INPUT=$(echo "$INPUT" | tr '[:upper:]' '[:lower:]')
case "$INPUT" in
"green" | "g")
echo -n "Enter the letter: "
read LETTER
LETTER=$(echo "$LETTER" | tr '[:lower:]' '[:upper:]')
LEN=$((4 - $LETTER_POSITION))
GOOD_WORDS=`echo "$GOOD_WORDS" | grep -P "(\w{$LETTER_POSITION})$LETTER(\w{$LEN})"`
ITERATIONS=$(($ITERATIONS + 1)) ;;
"yellow" | "y")
echo -n "Enter the letter: "
read LETTER
LETTER=$(echo "$LETTER" | tr '[:lower:]' '[:upper:]')
LEN=$((4 - $LETTER_POSITION))
GOOD_WORDS=`echo "$GOOD_WORDS" | grep "$LETTER"`
GOOD_WORDS=`echo "$GOOD_WORDS" | grep -P -v "(\w{$LETTER_POSITION})$LETTER(\w{$LEN})"`
ITERATIONS=$(($ITERATIONS + 1)) ;;
"black" | "b")
echo -n "Enter the letter: "
read LETTER
LETTER=$(echo "$LETTER" | tr '[:lower:]' '[:upper:]')
GOOD_WORDS=`echo "$GOOD_WORDS" | grep -v "$LETTER"`
ITERATIONS=$(($ITERATIONS + 1)) ;;
"q")
IS_RUNNING=false
break ;;
"help" | "h")
echo "q stops the program\n" ;;
*)
echo "This ain't it chief: $INPUT" ;;
esac
done
fi