Here is the code i write while reading the book 'collective intelligence'