Skip to content

Instantly share code, notes, and snippets.

@zxjinn
Created December 18, 2012 20:58
Show Gist options
  • Save zxjinn/4331917 to your computer and use it in GitHub Desktop.
Save zxjinn/4331917 to your computer and use it in GitHub Desktop.
quick and dirty way to brute force palindromes in the gregorian calendar using the format MM/DD/YYYY
#!/bin/bash
# quick and dirty way to brute force palindromes in the gregorian calendar
# using the format MM/DD/YYYY
MAX=5000000000000
i=0
while [ $i -ne $MAX ]
do
i=$[$i+1]
MONTHZ=$(date +%m --date "-${i} days")
DAYZ=$(date +%d --date "-${i} days")
YEARZ=$(date +%Y --date "-${i} days")
FIRSTZ=$(echo ${MONTHZ}${DAYZ}|rev)
LASTZ=$YEARZ
if [ $FIRSTZ -eq $LASTZ ]; then
echo $(date +%m"/"%d"/"%Y --date "-${i} days")
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment