After you visit the ruins in Celestic Town and deliver the Old Charm to Cynthia's grandmother, you can challenge the gym in Hearthome City.
Battle Trainers
Go north and step on the middle of the wooden platform. Then go north and read the sign:
Question: What is 3 plus 5 plus 7?
Answer: ←2 ↑16 →15
If you want to add Drifloon to your Pokédex without having to wait until a Friday, go through the wrong doors in this gym. (Drifloon appears outside of the Valley Windworks on Fridays.)
If you go through the door on the left, you battle Youngster Donny, who has a level 27 Gastly and a level 29 Haunter. You get 696 Pokédollars for winning.
If you go through the middle door, you battle Lass Molly, who has a level 30 Misdreavus. You get 720 Pokédollars for winning.
Go through the door on the right, then go north and walk onto the middle of the
wooden platform. Then go north and read the sign:
Question: What is 12 plus 28?
Answer: ←30 ↑40 →50
If you go through the door on the left, you battle Camper Drew, who has three level 27 Gastly. You get 648 Pokédollars for winning.
If you go through the door on the right, you battle Picnicker Cheyenne, who has a level 28 Drifloon and a level 28 Misdreavus. You get 672 Pokédollars for winning.
Go through the middle door, then go north and walk onto the middle of the
wooden platform. Then go north and read the sign:
Question: What is 3 times 13?
Answer: ←39 ↑93 →33
If you go through the middle door, you battle School Kid Chance, who has a level 30 Haunter. You get 840 Pokédollars for winning.
If you go through the door on the right, you battle School Kid Mackenzie, who has two level 28 Drifloons. You get 784 Pokédollars for winning.
Go through the door on the left, then go north and walk onto the middle of the
wooden platform. Then go north and read the sign:
Question: What is the first room's answer?
Answer: ←2 ↑16 →15
If you go through the door on the left, you battle Ace Trainer Allen, who has a level 26 Gastly, a level 28 Haunter, and a level 30 Gengar. You get 2040 Pokédollars for winning.
If you go through the middle door, you battle Ace Trainer Catherine, who has a level 30 Misdreavus and a level 30 Drifblim. You get 2040 Pokédollars for winning.
Go through the door on the right, and you will find Fantina. Talk to her to begin the battle.
Gym Leader Fantina
Fantina has a level 32 Drifblim, a level 34 Gengar, and a level 36 Mismagius. You get 4608 Pokédollars for winning. You get the Relic Badge, which allows you to use Surf outside of battle. You also get the stickers that Fantina uses, and some TM65s, which teach Shadow Claw.
Leave the Gym
Go south until you leave the Gym. Cynthia will talk to you.
Use the Town Map to fly to Jubilife City, then go west to Route 218.