In the book, Tom Sawyer finds being forced to whitewash Aunt Polly's fence far worse than a whipping. This is because he cleverly manipulates his friends into doing the work for him by making it seem like a desirable and coveted activity.
While a whipping is unpleasant, Tom's ingenuity and the power of perception make the fence-painting far more torturous, as it represents boredom and a loss of his freedom.