title: Cannot enter while loop. Is it to do with using an unordered map?
body: <p>I am trying to do a coding challenge where we have to shorten and minimise direction instructions. I am using an unordered map prior to implementing the while loop. The rest of the code works as expected but the while loop cannot be reached so I cannot output an appropriate value.</p>
  <pre><code>std::vector&lt;std::string&gt; dirReduc(std::vector &lt;std::string&gt;&amp; arr)
  {
      enum Direction
      {
          NORTH = 1, SOUTH = -1,
          EAST = 1, WEST = -1
      };
      int x=0, y=0;
      std::unordered_map&lt;std::string, Direction&gt; uMapDir = { {&quot;North&quot;,NORTH},{&quot;NORTH&quot;,NORTH},
                                                          {&quot;South&quot;,SOUTH},{&quot;SOUTH&quot;,SOUTH},
                                                          {&quot;East&quot;,EAST},{&quot;EAST&quot;,EAST},
                                                          {&quot;West&quot;,WEST},{&quot;WEST&quot;,WEST} };
      for (std::vector&lt;std::string&gt; ::const_iterator i =arr.begin(); i!=arr.end() ; i ++)
      {
          if ((*i==&quot;North&quot;)||(*i == &quot;NORTH&quot;)||(*i==&quot;South&quot;)|| (*i == &quot;SOUTH&quot;))
          {
              y += uMapDir[*i];
          }
          else
          {
              x += uMapDir[*i];
          }
      }
      std::vector&lt;std::string&gt; outPutArr;
      while ((x!=0)&amp;&amp;(y!=0))
      {
          if (x&lt;0)
          {
              x++;
              outPutArr.push_back(&quot;WEST&quot;);
          }
          else
          {
              x--;
              outPutArr.push_back(&quot;EAST&quot;);
          }
  
          if (y &lt; 0)
          {
              y++;
              outPutArr.push_back(&quot;SOUTH&quot;);
          }
          else
          {
              y--;
              outPutArr.push_back(&quot;NORTH&quot;);
          }
      }
      return outPutArr;
  }
  </code></pre>