title: Trying to implement a pointer that can go both clockwise and counter clockwise in a circular array
body: <p>I have failed a coding interview because of this question. Can someone please help me crack this down?</p>
  <p><a href="https://i.stack.imgur.com/FTVcQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FTVcQ.png" alt="enter image description here" /></a></p>
  <p>This is my code (Python):</p>
  <pre><code>import string
  
  alphabet = string.ascii_lowercase # String 'abcdefghijklmnopqrstuvwxyz'
  current_position = 0 # Letter 'A', the first item in our alphabet list
  distances = []
  
  word = 'Croves'.lower()
  
  for letter in word:
      destination = alphabet.index(letter) # Index of the letter in the alphabet array where the pointer should move
      
      distance_clockwise = abs(destination - current_position)
      distance_counter = abs(len(alphabet) - destination + current_position)
                             
      distance = distance_counter if distance_clockwise &gt; distance_counter else distance_clockwise
      
      distances.append(distance) # No of movements from current position to destination
      current_position = destination # Repositioning the pointer
      
      print(letter, distance) # Debuging...
  print(sum(distances))
  </code></pre>
  <p>According to my test case, the string 'Croves' should have the following distances:</p>
  <ol>
  <li>From A (pointer initial position) to C (first letter), 2 movements</li>
  <li>From C to R, 11 movements</li>
  <li>From R to O, 3 movements</li>
  <li>From O to V, 7 movements</li>
  <li>From V to E, 9 movements</li>
  <li>From E to S, 12 movements</li>
  <li>The total number of movements should be 44</li>
  </ol>
  <p>But my code output is:</p>
  <ol>
  <li>From A (pointer initial position) to C (first letter), 2 movements</li>
  <li>From C to R, 11 movements</li>
  <li>From R to O, 3 movements</li>
  <li>From O to V, 7 movements</li>
  <li><strong>From V to E, 17 movements</strong></li>
  <li>From E to S, 12 movements</li>
  <li>The total number of movements is 52</li>
  </ol>
  <p>There's a bug when the pointer needs to move through the letter 'A' that I don't know how to solve it.</p>
  <p>Thank you!</p>