I know that I can use "had" to construct a conditional perfect:
Had it not rained yesterday, we would have finished painting the walls.
But is it grammatically correct to reverse the order of the clauses, like this?
We would have finished painting the walls, had it not rained yesterday.