title: Project Euler Problem #11
body: <p>Source: <a href="http://projecteuler.net/index.php?section=problems&amp;id=11" rel="nofollow noreferrer">http://projecteuler.net/index.php?section=problems&amp;id=11</a></p>
  
  <p>Quick overview:  Take a 20x20 grid of numbers and compute the largest product of 4 pairs of numbers in either horizontal, vertical, or diagonal.</p>
  
  <p>My current approach is to divide the 20x20 grid up into single rows and single columns and go from there with a much more manageable grid. The code I'm using to divide the rows into rows is</p>
  
  <pre><code>void fillRows
      ( string::const_iterator&amp; fieldIter, 
        list&lt;int&gt;&amp; rowElements, 
        vector&lt;list&lt;int&gt;&gt;&amp; rows )
  {
      // fieldIter is already initialized.
      int count(0);
      for( ; fieldIter &lt; field.end(); ++fieldIter )
      {
          if(isdigit(field[*fieldIter]))
          {           
              rowElements.push_back(toInt(field[*fieldIter]));
              ++count;
          }
          if(count == 40)
          {
              rows.push_back(rowElements);
              count = 0;
              rowElements.clear();
          }
      }
  }
  </code></pre>
  
  <p>Short explanation: 
  I have the field set as <code>static const std::string field</code> and I am filling a vector with lists of rows. Why a list? Because the queue doesn't have a clear function. Also practice using STL container lists and not ones I write myself.</p>
  
  <p>However, this thing isn't working. Oftentimes I see it omitting a character( function toInt parses the const char as int ) and I end up with 18 rows, two rows short of the 20x20 grid. The length of the rows seem good.</p>
  
  <p><code>Rows: 18</code></p>
  
  <p><code>RowElements[0]: 40</code> (instead of pairs I saved each number individually. Will fix that later) </p>
  
  <p>What am I doing wrong? </p>