Skip to content

Instantly share code, notes, and snippets.

@dblume
Created Mar 20, 2021
Embed
What would you like to do?
Find a QR code with as few black dots as possible.
#!/usr/bin/env bash
#
# Spoiler:
# $ ./qrcodes.sh | sort | head
# 416 http://7c.dblu.me
# 416 https://j.dblu.me
# 416 http://wc.dblu.me
# 420 http://2E.dblu.me
# 420 http://73.dblu.me
#
set -eu -o pipefail # See: https://sipb.mit.edu/doc/safe-shell/
f () {
echo $(qrencode -t ASCII $1 | tr -cd '#' | wc -c) $1
}
for X in {a..z} {A..Z} {0..9}
do
f http://dblu.me/$X
f https://dblu.me/$X
f http://dblu.me/$X/
f http://$X.dblu.me
f https://$X.dblu.me
f http://$X.dblu.me/
f http://$X.dlma.com
f http://dlma.com/$X
for Y in {a..z} {A..Z} {0..9}
do
f http://dblu.me/$X$Y
f http://$X$Y.dblu.me
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment