Democrats would need to flip 24 seats to retake the U.S. House in 2018. But at least two-thirds of that tally may be permanently out of reach, thanks to a dirty geographical trick played by Republican lawmakers in 2010.

That's according to a new Brennan Center analysis of gerrymandering — the process lawmakers use to draw legislative districts for their own partisan advantage.

A bit of background before we delve into the nitty-gritty. Every 10 years, congressional districts are redrawn following the Census. On paper, this is done to ensure the people's House is representative of the country's people — states gain or lose districts based on population changes, and district boundaries shift to reflect our ever-changing demographics.

The process of re-drawing district lines to give an advantage to one party over another is called "gerrymandering". Here's how it works. (Daron Taylor/The Washington Post)

In most states, this redistricting process is handled by the state legislature. This is where the trouble begins: legislatures are composed of partisan lawmakers who have partisan interests — like keeping themselves in power. Over the past several decades, lawmakers have become adept at drawing district boundaries to benefit their parties.

There are any number of ways to do this. If you want to create a 100 percent safe seat for a friend, for instance, you draw a district with a safe partisan majority. You can also decide to concentrate all of your political opponents in one or two districts, diluting their power everywhere else. Or, you could spread them out thinly everywhere, making it hard for them to achieve a majority anywhere.

Gerrymandering is notoriously hard to measure, because it's partly a question of intent — a state's districts may be lopsided in favor of one party or another, but how do you prove that's not just an accident?

Enter the Brennan Center. For their report, Brennan's researchers used a number of different statistical tests to measure the outcomes of congressional elections in 2012, 2014 and 2016.

They looked at whether "wasted" votes — votes for losing candidates, or votes for winners in excess of 50.1 percent — were skewed toward one party or another.

They looked at historic trends to determine whether recent congressional election results deviated from historic results in expected ways.

And they looked at differences between the parties' average vote share in a state's districts and their median share — gerrymandering tends to skew a party's median vote share away from its average.

Brennan restricted the analysis to states with six or more districts because in smaller states, gerrymandering isn't as much of a problem. To give an extreme example, states with just one representative, like Wyoming, can't be gerrymandered at all, because the single district covers the entire state. The more districts you have, the more district boundaries you tweak to your desire.

Each of Brennan's three analyses returned more or less the same result: "In the 26 states that account for 85 percent of congressional districts, Republicans derive a net benefit of at least 16-17 congressional seats in the current Congress from partisan bias," the researchers found.

Most of that bias is concentrated in just seven Republican-controlled states: Michigan, North Carolina and Pennsylvania exhibit the most extreme partisan skew, while bias toward Republicans is also strongly evident in Florida, Ohio, Texas and Virginia.

Take a look at the chart from Brennan below, which estimates the net seat benefit to Republicans or Democrats in the 26 states they analyzed via the "wasted" votes method.

Brennan Center

The dark red bars represent states where Republicans drew district maps. And in a number of those states, they effectively gave themselves an advantage of two or more seats simply by putting Democrats in places where their votes counted less.

Republicans were particularly successful in Pennsylvania, where they owe 3+ seats to creative redistricting.

Democrats aren't innocent in this whole affair either, but two factors severely limited their ability to redistrict themselves to a majority: for starters, more statehouses are now controlled by Republicans. Post-2010, there are simply fewer opportunities for Democrats to gerrymander.

Second, Brennan's analysis suggests that Democrats did attempt some gerrymanders in places such as Maryland and Massachusetts. But there are fewer people in those states than in places such as Pennsylvania or Texas, meaning that even the most aggressive gerrymander (looking at you, Maryland) might net at best a seat or so.

Republicans maintain some representational advantage from other neutral factors, too, like Democrats' propensity to cluster in densely populated areas, and from a Voting Rights Act requirement that mandates majority-minority districts in some Southern states.

But even after accounting for these factors, the Brennan analysis suggests that a minimum of 16 to 17 seats are in Republican hands because of partisan gerrymandering alone. There's one huge piece of damning evidence in support of this notion: "All of the states we found to have extreme partisan bias had maps drawn solely by one party," they found. Specifically, the Republican party.

There are any number of ways out of the quandary. For starters, a number of redistricting cases are currently before the courts. A number of the more egregious gerrymanders of the 2010 era have already been thrown out.

But litigation is just a Band-Aid. True reform would mean taking the redistricting process out of the hands of partisan lawmakers and putting it under the purview of something like an independent commission. That's already the case in certain states.

More radical reforms would involve handing the redistricting process over to algorithms that draw maps without any human input at all. But the political will for that level of change is currently nonexistent.

At the moment, Democrats' best hope would appear to be former attorney general Eric H. Holder Jr.'s National Democratic Redistricting Commission, which aims to help Democrats be just as effective at gerrymandering as their Republican counterparts.