Skip to content

Instantly share code, notes, and snippets.

@riceissa
Last active March 29, 2020 04:56
Show Gist options
  • Save riceissa/e42019ea299e98559052d83194cc4e97 to your computer and use it in GitHub Desktop.
Save riceissa/e42019ea299e98559052d83194cc4e97 to your computer and use it in GitHub Desktop.
breeder's index
#!/usr/bin/env python3
import requests
import math
from bs4 import BeautifulSoup
import pdb
def breeder_index(sons, daughters, wives):
return (1.1 * sons + math.log(1 + daughters)) / (1 + 0.3 * wives) - (1/4 if wives > 0 else 0)
url = "https://wiki.issarice.com/wiki/List_of_men_by_number_of_sons,_daughters,_and_wives"
r = requests.get(url)
soup = BeautifulSoup(r.content, "lxml")
table = soup.find("table")
data = []
for row in table.find_all("tr")[1:]:
d = {}
for n, cell in enumerate(row.find_all("td")):
text = cell.text.strip().strip("?")
if n == 0:
d["name"] = text
elif n == 1 and text:
d["sons"] = int(text)
elif n == 2 and text:
d["daughters"] = int(text)
elif n == 3 and text:
d["children"] = int(text)
elif n == 4 and text:
d["wives"] = int(text)
if "sons" in d and "daughters" in d:
assert d["sons"] + d["daughters"] == d["children"], d["name"]
if "sons" in d and "daughters" in d and "wives" in d:
d["index"] = breeder_index(d["sons"], d["daughters"], d["wives"])
else:
d["index"] = -10
data.append(d)
fmt_string = "{0:25} {1:4} {2:9} {3:8} {4:5} {5:5}"
print(fmt_string.format("Name", "Sons", "Daughters", "Children", "Wives", "Index"))
for d in sorted(data, key=lambda x: x["index"], reverse=True):
print(fmt_string.format(
d.get("name", ""),
d.get("sons", ""),
d.get("daughters", ""),
d.get("children", ""),
d.get("wives", ""),
round(d.get("index"), 2),
))
@riceissa
Copy link
Author

riceissa commented Mar 28, 2020

Original version's output:

Name                      Sons Daughters Children Wives Index
Charles Darwin               5         3        8     1  2.94
Johann Sebastian Bach        6         5       11     2  2.35
Bryan Caplan                 3         1        4     1   1.6
Elon Musk                    5         0        5     2  1.42
William Thurston             3         2        5     2  1.12
Tim Gowers                   3         2        5     2  1.12
Carl Sagan                   4         1        5     3  0.92
John Horton Conway           3         4        7     3   0.9
Edward Witten                1         2        3     1   0.8
Alonzo Church                1         2        3     1   0.8
Marvin Minsky                1         2        3     1   0.8
Judea Pearl                  1         2        3     1   0.8
Vladimir Arnold              2         0        2     1  0.75
Robin Hanson                 2         0        2     1  0.75
James Watson                 2         0        2     1  0.75
Freeman Dyson                1         5        6     2  0.68
Claude Shannon               2         1        3     2  0.65
Goro Shimura                 1         1        2     1   0.6
Donald Knuth                 1         1        2     1   0.6
Daniel Dennett               1         1        2     1   0.6
Eric Weinstein               1         1        2     1   0.6
Terence Tao                  1         1        2     1   0.6
Alfred Tarski                1         1        2     1   0.6
J. Robert Oppenheimer        1         1        2     1   0.6
Noam Chomsky                 1         2        3     2  0.45
Francis Crick                1         2        3     2  0.45
Andrew Wiles                 0         3        3     1  0.44
Linus Torvalds               0         3        3     1  0.44
Charles Spearman             0         3        3     1  0.44
John Lennon                  2         0        2     2  0.42
Isaac Asimov                 1         1        2     2  0.31
Joe Rogan                    0         2        2     1   0.3
Sam Harris                   0         2        2     1   0.3
Peter Norvig                 0         2        2     1   0.3
Dominic Cummings             1         0        1     1  0.25
Nick Bostrom                 1         0        1     1  0.25
David Hilbert                1         0        1     1  0.25
Emil Post                    0         1        1     1   0.1
Wei Dai                      0         1        1     1   0.1
Michael Nielsen              0         0        0     0   0.0
Richard S. Sutton            0         0        0     0   0.0
Richard Stallman             0         0        0     0   0.0
Gwern Branwen                0         0        0     0   0.0
Terry A. Davis               0         0        0     0   0.0
Richard Feynman              1         0        1     3   0.0
George Carlin                0         1        1     2 -0.02
Richard Dawkins              0         1        1     3 -0.08
Steven Pinker                0         0        0     3 -0.25
Haruki Murakami              0         0        0     1 -0.25
Raymond Smullyan             0         0        0     2 -0.25
Derek Parfit                 0         0        0     1 -0.25
Murray Rothbard              0         0        0     1 -0.25
David Chalmers               0         0        0     1 -0.25
Eliezer Yudkowsky            0         0        0     1 -0.25
Carl Shulman                 0         0        0     1 -0.25
Kurt Gödel                   0         0        0     1 -0.25
Ray Solomonoff               0         0        0     1 -0.25
Gottlob Frege                0         0        0     1 -0.25
Gary Becker                                               -10
Ronald Coase                                              -10
Herbert Simon                                             -10
Grant Sanderson                                           -10
Hayao Miyazaki                                            -10
Satoshi Kon                                               -10
Hideaki Anno                                          1   -10
Paul McCartney                                            -10
Bob Dylan                                                 -10
Thom Yorke                                                -10
Steve Hsu                                                 -10
Cédric Villani                                            -10
Ted Kaczynski                                             -10
Kenzaburo Oe                                              -10
Grigori Perelman                                          -10
Misha Gromov                                              -10
Peter Smith                                               -10
Michael Sipser                                            -10
Scott Aaronson                                            -10
Eric Drexler                                              -10
Paolo Aluffi                                              -10
Keith Frankish                                            -10
Michael Huemer                                            -10
Franz Kafka                                               -10
Brian Kernighan                                           -10
Dennis Ritchie                                            -10
(add other bell labs people)                                 -10
E. T. Jaynes                                              -10
Robert Aumann                                   5     2   -10
Andrew Ng                                                 -10
Geoffrey Hinton                                           -10
Yann LeCun                                                -10
Sheldon Axler                                             -10
Serge Lang                                                -10
Milton Friedman                                           -10
David Friedman                                            -10
John Stillwell                                            -10
Geoffrey Miller                                           -10
Richard Wrangham                                          -10
Tooby and Cosmides                                        -10
James Joyce                                               -10
David Foster Wallace                                      -10
Joseph Henrich                                            -10
Paul Graham                                               -10
Mark Zuckerberg                                           -10
Bill Gates                                                -10
Max Tegmark                                               -10
Juergen Schmidhuber                                       -10
Marcus Hutter                                             -10
Charles Pierce                                            -10
Arthur Jensen                                             -10
Fisher (are there two?)                                   -10
George Boole                                              -10
George Boolos                                             -10
John von Neumann                                          -10
Paul Dirac                                                -10
Enrico Fermi                                              -10
George Pólya                                              -10
John McCarthy                                             -10
Stuart Russell                                        1   -10
Bertrand Russell                                          -10
Wittgenstein                                              -10
Albert Einstein                                           -10
Georg Cantor                                    6     1   -10
Richard Dedekind                                          -10
Weierstrass                                               -10
Bolzano                                                   -10
Michael Spivak                                            -10
Paul Halmos                                               -10
Leo Szilard                                               -10
Hans Bethe                                                -10
Niels Bohr                                                -10

@riceissa
Copy link
Author

New output:

Name                      Sons Daughters Children Wives Index
Charles Darwin               5         3        8     1  5.05
Johann Sebastian Bach        6         5       11     2  4.99
Elon Musk                    5         0        5     2  3.19
Bryan Caplan                 3         1        4     1  2.82
William Thurston             3         2        5     2   2.5
Tim Gowers                   3         2        5     2   2.5
Carl Sagan                   4         1        5     3  2.43
John Horton Conway           3         4        7     3  2.33
Claude Shannon               2         1        3     2  1.56
Freeman Dyson                1         5        6     2  1.56
Vladimir Arnold              2         0        2     1  1.44
Robin Hanson                 2         0        2     1  1.44
James Watson                 2         0        2     1  1.44
Edward Witten                1         2        3     1  1.44
Alonzo Church                1         2        3     1  1.44
Marvin Minsky                1         2        3     1  1.44
Judea Pearl                  1         2        3     1  1.44
Goro Shimura                 1         1        2     1  1.13
Donald Knuth                 1         1        2     1  1.13
Daniel Dennett               1         1        2     1  1.13
Eric Weinstein               1         1        2     1  1.13
Terence Tao                  1         1        2     1  1.13
Alfred Tarski                1         1        2     1  1.13
J. Robert Oppenheimer        1         1        2     1  1.13
John Lennon                  2         0        2     2  1.12
Noam Chomsky                 1         2        3     2  1.12
Francis Crick                1         2        3     2  1.12
Isaac Asimov                 1         1        2     2  0.87
Andrew Wiles                 0         3        3     1  0.82
Linus Torvalds               0         3        3     1  0.82
Charles Spearman             0         3        3     1  0.82
Dominic Cummings             1         0        1     1   0.6
Nick Bostrom                 1         0        1     1   0.6
David Hilbert                1         0        1     1   0.6
Joe Rogan                    0         2        2     1   0.6
Sam Harris                   0         2        2     1   0.6
Peter Norvig                 0         2        2     1   0.6
Richard Feynman              1         0        1     3  0.33
Emil Post                    0         1        1     1  0.28
Wei Dai                      0         1        1     1  0.28
George Carlin                0         1        1     2  0.18
Richard Dawkins              0         1        1     3  0.11
Michael Nielsen              0         0        0     0   0.0
Richard S. Sutton            0         0        0     0   0.0
Richard Stallman             0         0        0     0   0.0
Gwern Branwen                0         0        0     0   0.0
Terry A. Davis               0         0        0     0   0.0
Steven Pinker                0         0        0     3 -0.25
Haruki Murakami              0         0        0     1 -0.25
Raymond Smullyan             0         0        0     2 -0.25
Derek Parfit                 0         0        0     1 -0.25
Murray Rothbard              0         0        0     1 -0.25
David Chalmers               0         0        0     1 -0.25
Eliezer Yudkowsky            0         0        0     1 -0.25
Carl Shulman                 0         0        0     1 -0.25
Kurt Gödel                   0         0        0     1 -0.25
Ray Solomonoff               0         0        0     1 -0.25
Gottlob Frege                0         0        0     1 -0.25
Gary Becker                                               -10
Ronald Coase                                              -10
Herbert Simon                                             -10
Grant Sanderson                                           -10
Hayao Miyazaki                                            -10
Satoshi Kon                                               -10
Hideaki Anno                                          1   -10
Paul McCartney                                            -10
Bob Dylan                                                 -10
Thom Yorke                                                -10
Steve Hsu                                                 -10
Cédric Villani                                            -10
Ted Kaczynski                                             -10
Kenzaburo Oe                                              -10
Grigori Perelman                                          -10
Misha Gromov                                              -10
Peter Smith                                               -10
Michael Sipser                                            -10
Scott Aaronson                                            -10
Eric Drexler                                              -10
Paolo Aluffi                                              -10
Keith Frankish                                            -10
Michael Huemer                                            -10
Franz Kafka                                               -10
Brian Kernighan                                           -10
Dennis Ritchie                                            -10
(add other bell labs people)                                 -10
E. T. Jaynes                                              -10
Robert Aumann                                   5     2   -10
Andrew Ng                                                 -10
Geoffrey Hinton                                           -10
Yann LeCun                                                -10
Sheldon Axler                                             -10
Serge Lang                                                -10
Milton Friedman                                           -10
David Friedman                                            -10
John Stillwell                                            -10
Geoffrey Miller                                           -10
Richard Wrangham                                          -10
Tooby and Cosmides                                        -10
James Joyce                                               -10
David Foster Wallace                                      -10
Joseph Henrich                                            -10
Paul Graham                                               -10
Mark Zuckerberg                                           -10
Bill Gates                                                -10
Max Tegmark                                               -10
Juergen Schmidhuber                                       -10
Marcus Hutter                                             -10
Charles Pierce                                            -10
Arthur Jensen                                             -10
Fisher (are there two?)                                   -10
George Boole                                              -10
George Boolos                                             -10
John von Neumann                                          -10
Paul Dirac                                                -10
Enrico Fermi                                              -10
George Pólya                                              -10
John McCarthy                                             -10
Stuart Russell                                        1   -10
Bertrand Russell                                          -10
Wittgenstein                                              -10
Albert Einstein                                           -10
Georg Cantor                                    6     1   -10
Richard Dedekind                                          -10
Weierstrass                                               -10
Bolzano                                                   -10
Michael Spivak                                            -10
Paul Halmos                                               -10
Leo Szilard                                               -10
Hans Bethe                                                -10
Niels Bohr                                                -10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment