Nov 11, 2009
Fighting the Flu with Python
Over the last few days I have been having flu like symptoms. This has left me either stuck in bed or very lethargic at work. Not wanting to completely waste my time I’ve been actively engaged in learning Python. Thus far I’ve gotten a few of the basics down and have been able to hack my way through a few scripts. I know I’m no where near being a master Python programer, but I am well on my way.
The Tower of Hanoi
Here is my version of the classic computer science problem about recursion.
#!/usr/bin/python # Towers fo Hanoi # # An example program about recursion def hanoi(n, a = "A", b = "B", c = "C"): """ Move n discs from A to C using B as middle """ if n == 0: return hanoi(n-1,a,c,b) print a, '->', c hanoi(n-1,b,a,c) def get_disk_number(): """ Get the number of disk to be used with hanoi function """ disk_number = raw_input("Enter number of disk: ") n = int(disk_number) return n def main(): """ Main function of program """ n = get_disk_number() hanoi(n) if __name__ == "__main__": main()
My Next Project
I think for my next project I’m going to try and make a command line Twitter client. I know a the world doesn’t need a command line Twitter client, but I think this would be a good exercise in Python anyways. This is a coarse based on weather I survive the flu or not. Check back soon to find out more.







[...] more here: Fighting the Flu with Python Leave a [...]