title: Find Position Given Number Among Numbers Made 4 7
signature: findPositionGivenNumberAmongNumbersMade47(n) {
test_code: import 'dart:convert';
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual.toString() == expected.toString();
  }
  
  String driver(n, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }catch(exception_object){
          return exception_object.runtimeType.toString();
      }
  }
  
  int main() {
  
      print("TEST-0...${driver(
          "7", 
          2)
      }");
  
      print("TEST-1...${driver(
          "305745689", 
          5)
      }");
  
      print("TEST-2...${driver(
          "444", 
          7)
      }");
  
      print("TEST-3...${driver(
          "4", 
          1)
      }");
  
      print("TEST-4...${driver(
          "2074", 
          5)
      }");
  
      print("TEST-5...${driver(
          "27", 
          2)
      }");
  
      print("TEST-6...${driver(
          "447", 
          8)
      }");
  
      print("TEST-7...${driver(
          "255", 
          0)
      }");
  
      print("TEST-8...${driver(
          "10000111111011", 
          0)
      }");
  
      print("TEST-9...${driver(
          "fAKcSDRTNz", 
          0)
      }");
  
      return 0;
  }
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;
  }