Trains the technique from
LeetCode 319Bulb SwitcherThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A greenhouse roof carries vent_count vents in one long row, numbered 1 through vent_count. Every vent starts shut.
The controller then runs vent_count sweeps over the row. On sweep k it visits each vent whose number is a multiple of k and flips that vent: a shut vent opens and an open vent shuts. Sweep 1 therefore touches every vent, sweep 2 touches vents 2, 4, 6 and so on, up to sweep vent_count, which touches only the last vent.
Return how many vents are open after the final sweep. If vent_count is 0 the roof has no vents and no sweeps are run.
Example 1
Sweep 1 opens all eight vents, sweep 2 flips the even-numbered ones, and each later sweep flips its own multiples. Two vents are open once sweep 8 has run.
Example 2
Five of the twenty-seven vents are open after the twenty-seventh sweep.
Example 3
Seven of the forty-nine vents are open once every sweep has run.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def count_open_vents(vent_count: int) -> int:public int countOpenVents(int ventCount)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.