unixy scripts to help you solve that famous word puzzle game
whatToDo: Make script to give advice for gurgle players
Zach DeCook 2022-04-27
commit 5c9e712
-rwxr-xr-xwhatToDo.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/whatToDo.sh b/whatToDo.sh
new file mode 100755
index 0000000..2c3816c
--- /dev/null
+++ b/whatToDo.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+LIST="$(cat -)"
+if test "$(echo "$LIST" | wc -l)" -lt 15; 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