Here is a very simple solution to the 100 doors challenge
You are in a hotel with 100 doors. Initially every door is closed. On the first round, you change the state of every door (if it is open, close it. If it is closed, open it). On the second round, you change the state of every second door. On the third round, every third door etc... Find the state of all 100 hundred doors after n rounds
"""Check which doors are open and which are closed after n rounds"""
def check_doors_round(n):
"""Check which door is open after n rounds"""
doors = [False] * 100
for step in range(n):
for (index, door) in enumerate(doors):
if (index+1) % (step+1) == 0:
doors[index] = not door
print(doors)
if __name__ == "__main__":
check_doors_round(100)