Created
November 21, 2013 17:13
-
-
Save dbburgess/7585698 to your computer and use it in GitHub Desktop.
In the event you only trim your fingernails "every morning that the date is a prime number and the day of the week is named after a Norse deity," then this is a simple script to help you decide whether you should trim them or not.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
# Check whether number is prime | |
# Source: http://www.cs.armstrong.edu/liang/py/html/PrimeNumberFunction.html | |
def isPrime(number): | |
divisor = 2 | |
while divisor <= number / 2: | |
if number % divisor == 0: | |
# If true, number is not prime | |
return False # number is not a prime | |
divisor += 1 | |
return True # number is prime | |
# Days of the week that are named after a Norse deity: | |
# Tuesday, Thursday, and Friday. | |
# Source: http://en.wikipedia.org/wiki/Names_of_the_days_of_the_week#Germanic_tradition | |
# 0 being Monday... | |
daysOfTheWeek = [1, 3, 4] | |
# Check (and print) whether or not we should trim our nails today. | |
# This is based on if the day is named after a Norse deity, | |
# or the date (day of the month) is a prime number. | |
def checkNailTrimmingForDate(day): | |
dayIsPrime = isPrime(day.day) | |
dayIsNorseBased = (day.weekday() in daysOfTheWeek) | |
# Print the date leading our conclusion. | |
print(day.strftime('%A') + ', the ' + str(day.day)), | |
# Print the four possible results. | |
if dayIsPrime: | |
if dayIsNorseBased: | |
print('is the day! You better be trimming on it.') | |
else: | |
print('is a prime, but not named after a Norse deity. No nail trimming for you.') | |
else: | |
if dayIsNorseBased: | |
print('is named after a Norse deity, but it isn\'t a prime number. Restrain thy trimming, lest ye be struck down.') | |
else: | |
print('is not a prime number, nor is it named after a Norse deity...No need to trim your fingernails.') | |
# Check if we should trim our nails today. | |
today = datetime.datetime.today() | |
checkNailTrimmingForDate(today) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mr. Burgess, you're a hero.