title: minimum number of moves required to convert a given into a lucky number
body: <p>You are given a number, at a time either you can increase a number by 1 or decrease by 1 it is considered as one move find the minimum number of moves required to convert a given into a lucky number. A number is called lucky if all the digits in it are even.</p>
  <p>I have writtern the code but I am not sure if it is correct. Can anybody please confirm me?</p>
  <pre><code>#include&lt;bits/stdc++.h&gt;
  using namespace std;
  
  int count(int n)
  {
      int count = 0;
      while (n != 0)
      {
          n = n / 10;
          ++count;
      }
      return count;
  }
  
  int firstDigit(int n)
  {
      // Remove last digit from number
      // till only one digit is left
      while (n &gt;= 10)
          n /= 10;
       
      // return the first digit
      return n;
  }
  
  int main()
  {
      int n;
      cin &gt;&gt; n;
  
      int i,j,ans=0;
  
      int x = count(n);
  
      while(x--)
      {
          if(firstDigit(n)%2 != 0)
          {
              if(firstDigit(n) == 9)
              {
                  ans = ans + pow(10,x);
                  n = n-pow(10,x);
              }
  
              else
              {
                  ans = ans + pow(10,x);
                  n = n + pow(10,x);
              }
          }
          
          else
          n = n - pow(10,x);
  
      }
  
      cout &lt;&lt; ans &lt;&lt; endl;
  
  }
  </code></pre>
  <p>Edit:</p>
  <p>I found it is giving wrong answer at 100. Can you please help me in finding out the mistake</p>