Hitting the Books: How to fight gerrymandering with math