In representative democracies, legislative redistricting, which redraws district boundaries after Census, plays a fundamental role in ensuring equal representation. Redistricting also influences who is elected and hence what policies are eventually enacted. Because the stakes are high, redistricting has been subject to intense political battles. Parties often engage in gerrymandering by manipulating district boundaries to amplify the voting power of some groups while diluting that of others. Drawing upon my own involvement in actual redistricting court cases in the United States, I will discuss how computational algorithms, combined with granular data, can be used to detect gerrymandering. I will also use these algorithms to evaluate the partisan bias of Japanese redistricting where politicians play less prominent roles than the United States.