| | |
A Pythonian Look at the Family Tree Conundrum
The other day I was looking at my family tree. There are my parents Antonio and Lucy Vegaseat, then my grandparents Alfonso and Ludmilla Vegaseat on my father's side and Roland and Helga Gruenspan on my mother's side. Then come my great grandparents, by now there are eight of those. It was time for a small Python program to figure out how many great great great ... grandparents I had.
# The family tree conundrum ... # you have two parents, your parents each have two parents, that makes it # four grandparents for you, then there must be eight great grandparents # and so on. A light hearted look at a serious problem. # tested with Python24 vegaseat 24jul2005 generations = 3 number_of_parents = 2 ** generations print "after 3 generation we have %d great grandparents" % number_of_parents # going back 40 generations for generations in range(4, 41): number_of_parents = 2 ** generations print "In %d generation we have %d (g)parents" % (generations, number_of_parents) print """Going back in your family tree for 40 generations, or around a thousand years, there should be over one trillion great-great-great-...-grandparents you could lay claim to being related with. Hmmm, that alone is more people then ever lived! We demand an explanation from our government!"""
0
•
•
•
•
I do not know Python much, but I was taught that you start with Adam and Eve, not one trillion old people!
Similar Threads
- how to make a dynamic family tree using php (PHP)
- create family tree at runtime (C#)
- Family Tree scheme function (Legacy and Other Languages)
- network conundrum (IT Professionals' Lounge)
- audio email conundrum (OS X)
| Thread Tools | Search this Thread |
address aliased anydbm app bash beginner bits calling casino changecolor cipher clear conversion coordinates corners count cturtle curves definedlines development dictionary digital dynamic events examples excel external feet file float format function gui handling hints homework iframe images import input java keycontrol line linux list lists loan loop matching mouse multiple number numbers output parsing path port prime programming projects py py2exe pygame pymailer python random rational raw_input recursion recursive scrolledtext searchingfile shebang signal singleton split string strings tails terminal text threading time tlapse tooltip tuple tutorial type ubuntu unicode url urllib urllib2 valueerror variable web-scrape whileloop word wxpython xlwt



