Skip to content

Instantly share code, notes, and snippets.

@flatcap
Created May 24, 2015 13:37
Show Gist options
  • Save flatcap/a81cf8b9bbae91159c42 to your computer and use it in GitHub Desktop.
Save flatcap/a81cf8b9bbae91159c42 to your computer and use it in GitHub Desktop.
Sunday Times Teaser 2748 (2015-05-24)
arithmetic progression
digits replaced by letters
progression includes term 10000
progression starts
I, GO, UP, AND
what's the value of POUND?
#!/bin/bash
for initial in {0..9}; do
for stride in {33..50}; do
for count in {0..300}; do
echo -n "$((initial+(stride*count))) "
done
echo
done
done > o1
grep -w 10000 o1 > o2
grep -o "^[0-9] [0-9][0-9] [0-9][0-9] [0-9][0-9][0-9] " o2 > o3
sed '/\([0-9]\).*\1/d' o3 > o4
echo I GO UP AND
cat o4
# I G O1 U2 P3 A N4 D5
POUND=$(sed 's/. .\(.\) \(.\)\(.\) .\(.\)\(.\)/\3\1\2\4\5/' o4)
echo
echo POUND = $POUND
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment