title: Incremental Door Pass Riddle - Only Square Positions Open
body: <p>There are hundred doors, all closed to start with, a robot makes 100 passes, such that on every pass it increments by the next starting token. Thus,</p>
  
  <pre><code>1, 2, 3,.....
  2, 4, 6, 8,....
  3, 6, 9, 11,....
  4, 8, 12, 16,....
  .......
  100
  </code></pre>
  
  <p>Every time it visits a door it switches from its current state, thus closes if it was open and opens if it was closed. 
  After 100 passes find the number of doors that are open.</p>
  
  <p>The problem is trivial, here's my solution,</p>
  
  <pre><code>def door_traversal():
      arr = []
      arr = [0 for i in range(101)]
      for i in range(1, 101, 1):
          for j in range(i, 101, i):
              arr[j] = not arr[j]
  
      count = 0
      for i in range(1, 101, 1):
          if arr[i] == 1:
              count += 1
      return count
  </code></pre>
  
  <p>The answer is 10 and on checking how do I get this number 10, it seems all the door indices which are perfect square are open.Thus the open doors are</p>
  
  <pre><code>1,4,9.....
  </code></pre>
  
  <p>What I've been trying to understand is the math behind, this. Any help with that?</p>