Johnny is a boy who likes to open and close lockers. He loves it so much that one day, when school was out, he snuck in just to play with the lockers.

Each locker can either be open or closed. If a locker is closed when Johnny gets to it, he opens it, and vice versa.

The lockers are numbered sequentially, starting at 1.

Starting at the first locker, Johnny runs down the row, opening each locker.

Then he runs all the way back to the beginning and runs down the row again, this time skipping to every other locker. (2,4,6, etc)

Then he runs all the way back and runs through again, this time skipping two lockers for every locker he opens or closes. (3,6,9, etc)

He continues this until he has finished running past the last locker (i.e. when the number of lockers he skips is greater than the number of lockers he has).

------

The equation could be stated as follows: 

> Johnny runs down the row of lockers `n` times, starting at the first locker each run and skipping `i` lockers as he runs, where `n` is the number of lockers there are in total and `i` is the current run.
    
The goal of this kata is to determine which lockers are open at the end of Johnny's running. 

The program accepts an integer giving the total number of lockers, and should output an array filled with the locker numbers of those which are open at the end of his run.

Difficulty: introductory

Starter code:

def locker_run(lockers):
	

Solutions:
from math import floor
#Pretty sure this is the fastest implementation; only one square root, and sqrt(n) multiplications.
#Plus, no booleans, because they're super slow.
locker_run = lambda l: [i * i for i in range(1, int(floor(l ** .5)) + 1)]

def locker_run(lockers):
    return [n*n for n in range(1,int(lockers**.5+1))]

def locker_run(lockers):
    a=[1]
    while len(a)<int(lockers**.5):
        if 1<lockers<9 or (len(a)<2 and lockers>=9):
            a.append(4)
        else:
            a.append(a[-1]*2-a[-2]+2)
    return a

def locker_run(lockers):
    return [n * n for n in range(1, int(1 + lockers**0.5))]

def locker_run(lockers):
    return [i for i in range(1, lockers + 1) if i ** 0.5 % 1 == 0]

def locker_run(lockers):
    i = 0
    box = [0] * lockers
    while i < lockers:
        for x in range(i, lockers, i + 1):
            box[x] += 1
        i += 1
    return [c + 1 for c in range(len(box)) if box[c] % 2 != 0]

def locker_run(lockers):
    #..
    return [x*x for x in range(1,lockers+1) if x*x <= lockers]