Tuesday, January 2, 2007

fly away home


yay! i wrote my first 'real' Python program: it produced all the anagram combinations (720) of the word 'zombie' (none of which were actual English words, but i just wanted to figure out a way of doing it in Python). i did it a quick & dirty way:

w = 'zombie'

count = 0

for a in [0, 1, 2, 3, 4, 5]:
for b in [0, 1, 2, 3, 4, 5]:
for c in [0, 1, 2, 3, 4, 5]:
for d in [0, 1, 2, 3, 4, 5]:
for e in [0, 1, 2, 3, 4, 5]:
for f in [0, 1, 2, 3, 4, 5]:
if ((not w[a]==w[b]) and (not w[a]==w[c]) and (not w[a]==w[d])
and (not w[a]==w[e]) and (not w[a]==w[f]) and
(not w[b]==w[c]) and (not w[b]==w[d]) and
(not w[b]==w[e]) and (not w[b]==w[f]) and
(not w[c]==w[d]) and (not w[c]==w[e]) and
(not w[c]==w[f]) and (not w[d]==w[e]) and
(not w[d]==w[f]) and (not w[e]==w[f])):
print w[a] + w[b] + w[c] + w[d] + w[e] + w[f]
count += 1
print count

although there's probably a more elegant way to do it with Lists instead of strings, this way works. blah, blah, blah. anyway, that was yesterday. (and sorry that all the indents disappear in the blog text of the program -- makes it hard to read.)

(and why anagrams of 'zombie'? i was looking for a last name for Karen, and there's the whole big zombie thing in the philosophy of consciousness that i wanted to acknowledge, even though Karen *won't* be a zombie. maybe Karen Zimboe. but i thought of that before writing the program.)

today, my digital brother delivered a great gift -- his old Playstation 2 (he got a 3) -- and i hope this doesn't signal the demise of my non-video-game-playing activities. (it won't; but it *will* be a lot of fun.) i've ordered the Atari Anthology, Capcom Classics Collection, and Burnout 3; and those should keep me busy for a while. Baldur's Gate is on my list, but it's harder to find. any other suggestions?

the full moon is tomorrow night, but i forgot to recharge my camera batteries in time for tonight's moonrise, which will be before sunset -- tomorrow's may be after dark, and then it's difficult not to overexpose the bright moon. wish me luck.

No comments: