Friday, June 28, 2013

Achievement Unlocked: You da you da best!

GUYS I DID IT. I finally finished that stupid problem. It took me like a few hours of kindof working on it at work, but with the help of PythonFiddle and a nice little notepad I've been scribbling on, everything is now so simple.

Things got SUPER EASY when I decided to make a dictionary corresponding to the days in every month when it was a leap year, and the days in every month when it was not a leap year:


yeardic = {"1True":31, "2True":29, "3True":31, "4True":30, "5True":31, "6True":30, "7True":31, "8True":31, "9True":30, "10True":31, "11True":30, "12True":31,"1False":31, "2False":28, "3False":31, "4False":30, "5False":31, "6False":30, "7False":31, "8False":31, "9False":30, "10False":31, "11False":30, "12False":31}


I know it looks kinda... gross... but it works! Before I only had 1:31, 2:29, 3:31, etc etc and I was trying to do some weird workarounds to determine when a leap year was happening and when to add +1 to my total accumulated days... silly me.

This new way is BOSS. Anyway here's a pastebin of the code if anyone wants to yell at me about how stupid it is: http://pastebin.com/wkNKPSUZ

Woo-hoo! Time to move on to the next unit.

No comments:

Post a Comment