Homer is arrested for drunk driving, and Marge persuades him to swear off beer for a month, which gives Homer a whole new outlook on life. Meanwhile, after Bart ruins Lisa's science fair project, she comes up with a new experiment: To determine which is smarter, Bart or a hamster.
The episode opens at the school science fair, with Bart presenting a Go-Go Ray: He zaps all the teachers, causing them to dance uncontrollably. Principal Skinner declares "First Prize" over and over, while Bart's dream fades out to Lisa saying into Bart's ear "First prize...first prize..." She explains she was "just screwing with [his] mind."
At breakfast, Lisa shows the family her science fair project: a genetically engineered tomato she hopes will cure world hunger. Bart's actual project is the effect of cigarettes on canines, mainly Santa's Little Helper, but Marge orders Bart to thwart it. Meanwhile, Homer plans to duck out of work and go on a tour of the Duff Brewery with Barney. At the brewery the two partake in free samples, Barney much more than Homer. Homer, who has hardly had anything refuses to let Barney drive home after the tour since he drank plenty to pass out, but Lou, Eddie and Chief Wiggum, who have been waiting outside the factory for anyone on the tour to drive off pull him over and despite passing a sobriety test flawlessly (touching his nose with his fingers alternately while balancing on one foot and saying the alphabet) he is arrested when Barney tells the cops to use the breathalyzer. His license is suspended, and he must attend traffic school and Alcoholics Anonymous meetings. In the meantime Barney, who is obviously drunk, is allowed to drive off after running over Wiggum.
After school three days before the science fair, Lisa leaves her super tomato under Bart's care for a moment, whose juvenile mind takes over when he sees the opportunity to hurl it at a bent-over Skinner forgetting that it was Lisa's project. Lisa appeals to Marge for help, who suggests she run a hamster through a maze. She takes the idea to heart, but instead of just testing the intelligence of a rodent, she pits a hamster against an unknowing Bart to find out which is smarter. Lisa tests both the hamster and Bart first in acquiring out of reach food, then in the electroshock theory. After two tests, the hamster leads 2-0.
At Homer's first AA meeting, Reverend Lovejoy says that after finishing AA he will never drink a beer again, Homer screams and runs off. In bed, Marge gives Homer a magazine quiz about his drinking. Hearing his answers, she asks him to give up beer for a month, to which he finally agrees. Homer reminisces about the time he first drank beer, passing out listening to Queen, and is taunted by ubiquitous sights of beer, but later comes to realize the fact that watching baseball sober is boring, and that beer commercials falsely state that beer transforms angry feminists into attractive women in bikinis who cling to ordinary men.
Meanwhile Bart finds Lisa's project notes and hides them. He plans to lead her on a treasure hunt to get them back but she finds them after just a minute. At the science fair, Marge says she isn't too sure about the idea of Lisa using her brother as a test subject, but Lisa insists that it is all scientific theory (immediately after her monologue reveals Lisa's true intentions of getting back at Bart). Unfortunately for Lisa, her project and chance for humiliating Bart are both ruined by Bart's project: "Can hamsters fly planes?" Lisa tries to protest that the project does not have a scientific merit, but everyone just ignores her. A cute hamster flying a miniature plane wins over Skinner, who hands Bart the winning ribbon for real, much to Lisa's disappointment.
At the AA meeting, Homer confesses that his desperation led him to "sneak into the football stadium and suck the dirt underneath the bleachers", getting him kicked out. However, as time goes by Homer also exhibits more positive changes, such as his belly getting smaller and has saved over a hundred dollars. After 30 days, Marge is proud of Homer for upholding his end of his deal, while thirsty Homer rushes back to Moe's, money in hand. Marge argues that just because Homer honored his alcohol-free month does not mean he has to jump off the wagon the moment it is over. Homer goes anyway, and is about to drink up when he sees what effect alcohol has had on the barflies, tells Moe to save his drink and heads home. The episode finishes with Homer and Marge riding Lisa's bike into the sunset.