So, the two piles have 42 and 10 cards each. There are 10 upside-down cards mixed up in them, and you don't know if the pile of 10 cards has no upside-downs, 1 upside-down, or, freakishly, 10 upside down cards.

If, for example, there are 9 upside-downs in the 42, then there will be 1 upside-down in the 10

Turning the 10-pile upisde down will result in 9 upside-downs, matching the pile of 42.

Does it work for all combinations?

Wow, good party trick.