unixy scripts to help you solve that famous word puzzle game
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/bin/sh
LIST="$(cat -)"
if test "$(echo "$LIST" | wc -l)" -lt 13; then
# Get the answer on your next guess
echo "$LIST"
else
# Letters you want to guess
LETTERS="$(echo "$LIST" | sed 's/\(.\)/\1\n/g' | sort | uniq -c | sort -n)"
echo "$LETTERS"
grep5="$(echo "$LETTERS" | tac | awk '(p){printf("| grep " $2); p--;} ($2 == ""){p=5;}')"
grep4="$(echo "$LETTERS" | tac | awk '(p){printf("| grep " $2); p--;} ($2 == ""){p=4;}')"
grep3="$(echo "$LETTERS" | tac | awk '(p){printf("| grep " $2); p--;} ($2 == ""){p=3;}')"
g5="$(sh -c "grep ^.....$ \"$1\" $grep5")"
if sh -c "grep ^.....$ \"$1\" $grep5"; then
echo
elif sh -c "grep ^.....$ \"$1\" $grep4"; then
echo
elif sh -c "grep ^.....$ \"$1\" $grep3"; then
echo
fi
fi
|