title: Find Position Given Number Among Numbers Made 4 7
signature: function findPositionGivenNumberAmongNumbersMade47($n) {
test_code: <?php
  
  
  // SOLUTION CODE 
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function validateSolution($actual, $expected){
      return serialize($actual) == serialize($expected);
  }
  
  function driver($n, $expected){
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME($n), $expected)){
          return "PASSED";
        }
        return "FAILED";
      }
      catch (Exception $exception_obj) {
        return get_class($exception_obj);
      }
  }
  
  function main(){
      printf("TEST-0...%s\n",driver(
        "7", 
        2));
      
      printf("TEST-1...%s\n",driver(
        "305745689", 
        5));
      
      printf("TEST-2...%s\n",driver(
        "444", 
        7));
      
      printf("TEST-3...%s\n",driver(
        "4", 
        1));
      
      printf("TEST-4...%s\n",driver(
        "2074", 
        5));
      
      printf("TEST-5...%s\n",driver(
        "27", 
        2));
      
      printf("TEST-6...%s\n",driver(
        "447", 
        8));
      
      printf("TEST-7...%s\n",driver(
        "255", 
        0));
      
      printf("TEST-8...%s\n",driver(
        "10000111111011", 
        0));
      
      printf("TEST-9...%s\n",driver(
        "fAKcSDRTNz", 
        0));
      
  }
  
  main();
  ?>
source_py: def find_position_given_number_among_numbers_made_4_7(n):
      i = 0
      j = len(n)
      pos = 0
      while (i < j):
          if (n[i] == '4'):
              pos = ((pos * 2) + 1)
          if (n[i] == '7'):
              pos = ((pos * 2) + 2)
          i = (i + 1)
      return pos
source_cpp: int find_position_given_number_among_numbers_made_4_7(string n) {
    int i = 0, pos = 0;
    while ( n [ i ] != '\0' ) {
      switch ( n [ i ] ) {
        case '4' : pos = pos * 2 + 1;
        break;
        case '7' : pos = pos * 2 + 2;
        break;
      }
      i ++;
    }
    return pos;
  }