Skip to content

Instantly share code, notes, and snippets.

@oertels
Created January 23, 2012 19:53
Show Gist options
  • Save oertels/1665212 to your computer and use it in GitHub Desktop.
Save oertels/1665212 to your computer and use it in GitHub Desktop.
Cigarettes
from datetime import timedelta, datetime
cigarettes_at = (
datetime(2012,01,5,16,0,30),
datetime(2012,01,12,12,3,30),
datetime(2012,01,22,18,12,30),
datetime(2012,01,23,18,12,30),
)
print "Not smoking since: %s" % max(cigarettes_at)
print "Longest streak: %s" % max((x-y) for (x, y) in zip(cigarettes_at[1:], cigarettes_at[:-1]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment