From 5c9e7124f968cc381843dba285d4081231a9325d Mon Sep 17 00:00:00 2001 From: Zach DeCook Date: Wed, 27 Apr 2022 23:38:09 -0400 Subject: whatToDo: Make script to give advice for gurgle players --- whatToDo.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 whatToDo.sh 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 -- cgit 1.4.1