Well, yesterday Seamus conform threw down and did another one of these problems, so I decided to give it a shot as well (without looking at his solution). I was just getting started when Alex oniugnip looked over my shoulder.
"What are you going to use to represent cards and decks?"
"I think those want to be classes."
Famous last words. A day later, I finally finished my ridiculously object-oriented solution. (And it works, too!) Seriously, you guys: I'm getting excited about Python. I started digging in hard because I'm trying to prepare for an interview, but I'm finding that I actually really, really like it. For example, the
for ... in ... construct: give it a list, and it knows you want to iterate over elements. Give it a string, and it knows you want characters. A dictionary? It knows you want keys! A frickin' filehandle? It knows you want lines in the file! See what I mean? It's smart enough to understand you! Or actually, maybe what I'm trying to say that it's smart enough to be exactly dumb enough to understand you, because anything that implements the iteration interface is fine. See? See? Isn't it cool? If this had been how I had learned about polymorphism when I was in school, it wouldn't have made me want to drive nails into my head!