summaryrefslogtreecommitdiffstats
path: root/8/solution.sh
diff options
context:
space:
mode:
Diffstat (limited to '8/solution.sh')
-rw-r--r--8/solution.sh5
1 files changed, 5 insertions, 0 deletions
diff --git a/8/solution.sh b/8/solution.sh
new file mode 100644
index 0000000..5b227ec
--- /dev/null
+++ b/8/solution.sh
@@ -0,0 +1,5 @@
+rawlen=$(while read -r; do printf "${REPLY:1:-1}"; done <$1 | wc -c)
+reallen=$(<$1 tr -d '\n' | wc -c)
+echo $((reallen - rawlen))
+quotedlen=$(sed 's/["\\]/\\&/g;s/.*/"&"/' $1 | tr -d '\n' | wc -c)
+echo $((quotedlen - reallen))