unixy scripts to help you solve that famous word puzzle game
gurg: helper for easier faceting
Zach DeCook 2022-04-28
parent 3282fad · commit 85d01bc
-rwxr-xr-xgurg.sh14
-rwxr-xr-xhas.sh6
2 files changed, 19 insertions, 1 deletions
diff --git a/gurg.sh b/gurg.sh
new file mode 100755
index 0000000..7c012e2
--- /dev/null
+++ b/gurg.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# $1: guessed word
+# $2: .Abc. - A green, b, c yellow
+
+n2="$(echo $2 | tr [:upper:] .)"
+has="./has.sh '${n2:0:1}' 1 |./has.sh '${n2:1:1}' 2 |./has.sh '${n2:2:1}' 3 |./has.sh '${n2:3:1}' 4 |./has.sh '${n2:4:1}' 5"
+alias lc="tr [:upper:] [:lower:]"
+l2="$(echo "$2" | lc)"
+
+cat - |
+grep -v "[$(echo $1|tr -d "$l2")]" |
+grep -i "$(echo $2|tr [:lower:] .)" |
+sh -c "$has"
diff --git a/has.sh b/has.sh
index 1a19a5f..f4c94bc 100755
--- a/has.sh
+++ b/has.sh
@@ -1,3 +1,7 @@
#!/bin/sh
# Has "$1", not in the "$2"th position
-cat - | grep "$1" | grep -v "$(echo "12345" | tr "$2" "$1" | tr [:digit:] .)"
+if test "$1" = "."; then
+ cat -
+else
+ cat - | grep "$1" | grep -v "$(echo "12345" | tr "$2" "$1" | tr [:digit:] .)"
+fi