title: Program Binary Decimal Conversion 1
signature: programBinaryDecimalConversion1(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(
          "uEmIAgF", 
          0)
      }");
  
      print("TEST-1...${driver(
          "753310137", 
          20)
      }");
  
      print("TEST-2...${driver(
          "010011010", 
          154)
      }");
  
      print("TEST-3...${driver(
          "kNi", 
          0)
      }");
  
      print("TEST-4...${driver(
          "04562016903312", 
          130)
      }");
  
      print("TEST-5...${driver(
          "000111101", 
          61)
      }");
  
      print("TEST-6...${driver(
          "bk", 
          0)
      }");
  
      print("TEST-7...${driver(
          "9", 
          0)
      }");
  
      print("TEST-8...${driver(
          "1", 
          1)
      }");
  
      print("TEST-9...${driver(
          "XxT nXLlk", 
          0)
      }");
  
      return 0;
  }
source_py: def program_binary_decimal_conversion_1(n):
      num = n
      dec_value = 0
      base1 = 1
      len1 = len(num)
      for i in range((len1 - 1), (- 1), (- 1)):
          if (num[i] == '1'):
              dec_value += base1
          base1 = (base1 * 2)
      return dec_value
source_cpp: int program_binary_decimal_conversion_1(string n) {
    string num = n;
    int dec_value = 0;
    int base = 1;
    int len = num . length ( );
    for ( int i = len - 1;
    i >= 0;
    i -- ) {
      if ( num [ i ] == '1' ) dec_value += base;
      base = base * 2;
    }
    return dec_value;
  }