title: Issue with the "Even Digits" problem from Round A of 2018 in Google Kickstart
body: <p>I am currently practicing on Google Kickstart competition and I am currently working on the <a href="https://codingcompetitions.withgoogle.com/kickstart/round/0000000000050edf/00000000000510ed" rel="nofollow noreferrer">Even Digits problem from Round A of 2018</a>.</p>
  
  <p>I have created the following algorithm and when I test it, it works just great. But the problem is that when I submit it to the platform and press the "Attempt" button, it shows that <strong>my output is not correct</strong>.</p>
  
  <p>I retried testing it using larger and more complex numbers but I just <em>cannot find what is the case</em>.</p>
  
  <blockquote>
    <p><strong>Problem Description:</strong></p>
    
    <p> Supervin has a unique calculator. This calculator only has a display, a plus button, and a minus button. Currently, the integer <strong>N</strong> is displayed on the calculator display.<br>
     Pressing the plus button increases the current number displayed on the calculator display by 1. Similarly, pressing the minus button decreases the current number displayed on the calculator display by 1. The calculator does not display any leading zeros. For example, if <em>100</em> is displayed on the calculator display, pressing the minus button once will cause the calculator to display <em>99</em>.<br>
     Supervin does not like odd digits, because he thinks they are "odd". Therefore, he wants to display an integer with only even digits in its decimal representation, using only the calculator buttons. Since the calculator is a bit old and the buttons are hard to press, he wants to use a minimal number of button presses.<br>
     Please help Supervin to determine the minimum number of button presses to make the calculator display an integer with no odd digits.<br>
    <strong>Input</strong><br>
    The first line of the input gives the number of test cases, <strong>T</strong>. <strong>T</strong> test cases follow. 
    Each begins with one line containing an integer <strong>N</strong>: 
    the integer initially displayed on Supervin's calculator.</p>
  </blockquote>
  
  <p><strong>Here is my code:</strong></p>
  
  <pre class="lang-cs prettyprint-override"><code>public static void Main(string[] args)
  {
    var SCount = Console.ReadLine();
    long Count = Convert.ToInt64(SCount);
  
    for (long i = 0; i &lt; Count; i++)
    {
      var val = Console.ReadLine();
      long l = Convert.ToInt64(val);
  
      Console.WriteLine("Case #{0}: {1}", i + 1, Slover4(l));
    }
  }
  
  public static long Slover4(double N)
  {
    char[] odds = { '1', '3', '5', '7', '9' };
  
    double presses_p = 0;
    double PN = N;
    double presses_n = 0;
    double NN = N;
  
    double pdegits = -1;
    for (int i = PN.ToString().Length - 1; i &gt;= 0; i--)
    {
      pdegits += 1;
  
      //2110
      //2018 EVEN EVEN (ODD EVEN)  ----&gt;
      //11   ODD OOD               &lt;----
      //1    ODD                   ----&gt;
      //42   EVEN EVEN             XXXXX 6969 1 | 6970 30 | 7000 -200 | 6800
  
      #region Positives
      if (i &gt; 0 &amp;&amp; odds.Contains(PN.ToString()[i]) &amp;&amp;
          odds.Contains(PN.ToString()[i - 1])) // ODD - ODD 
      {
        var val = int.Parse(string.Concat(PN.ToString()[i - 1], PN.ToString()[i]));
        var lv = int.Parse(PN.ToString()[i].ToString());
        //15 17  19
        //5  3   1
        presses_p += (5 - (lv - 5)) * Math.Pow(10, pdegits);
        PN += (5 - (lv - 5)) * Math.Pow(10, pdegits);
      }
      else if (i != 0 &amp;&amp;
               !odds.Contains(PN.ToString()[i - 1]) &amp;&amp;
               odds.Contains(PN.ToString()[i])) // EVEN - ODD 
      {
        presses_p += Math.Pow(10, pdegits);
        PN += Math.Pow(10, pdegits);
      }
      else if (i != 0 &amp;&amp; 
               odds.Contains(PN.ToString()[i - 1])) // ODD - EVEN
      {
        var val = int.Parse(string.Concat(PN.ToString()[i - 1], PN.ToString()[i]));
        var lv = int.Parse(PN.ToString()[i].ToString());
  
        //10 12 14 16 18
        //10  8  6  4  2  -&gt;
  
        //10 12 14|
        //2 4  6 |
        presses_p += (10 - lv) * Math.Pow(10, pdegits);
        PN += (10 - lv) * Math.Pow(10, pdegits);
      }
      else if (i == 0 &amp;&amp; 
               odds.Contains(PN.ToString()[i])) // ODD Only
      {
        presses_p += Math.Pow(10, pdegits);
        PN += Math.Pow(10, pdegits);
      }
      #endregion
  
      #region Negatives 
  
      if (i &gt; 0 &amp;&amp; 
          odds.Contains(NN.ToString()[i]) &amp;&amp; 
          odds.Contains(NN.ToString()[i - 1])) // ODD - ODD 
      {
        var val = int.Parse(string.Concat(NN.ToString()[i - 1], NN.ToString()[i]));
        var lv = int.Parse(NN.ToString()[i].ToString());
        //11 13 15 17 19
        //3  5  7  9  11
        presses_n += (3 + (lv - 1)) * Math.Pow(10, pdegits);
        NN -= (3 + (lv - 1)) * Math.Pow(10, pdegits);
      }
      else if (i != 0 &amp;&amp;
               !odds.Contains(NN.ToString()[i - 1]) &amp;&amp;
               odds.Contains(NN.ToString()[i])) // EVEN - ODD 
      {
        presses_n += Math.Pow(10, pdegits);
        NN -= Math.Pow(10, pdegits);
      }
      else if (i != 0 &amp;&amp;
               odds.Contains(NN.ToString()[i - 1])) // ODD - EVEN
      {
        var val = int.Parse(string.Concat(NN.ToString()[i - 1], NN.ToString()[i]));
        var lv = int.Parse(NN.ToString()[i].ToString());
  
        //10 12 14 16 18     
        //2  4  6  8  10  &lt;-
  
        presses_n += (2 + lv) * Math.Pow(10, pdegits);
        NN -= (2 + lv) * Math.Pow(10, pdegits);
      }
      else if (i == 0 &amp;&amp;
               odds.Contains(NN.ToString()[i])) // ODD Only
      {
        presses_n += Math.Pow(10, pdegits);
        NN -= Math.Pow(10, pdegits);
      }
      #endregion
    }
  
    //$"P:{presses_p} - N - {presses_n}";
    return presses_p &lt; presses_n ? (long)presses_p : (long)presses_n;
  }
  </code></pre>