title: Program Binary Decimal Conversion 1
signature: int programBinaryDecimalConversion1(string n) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual == expected;
  }
  
  string driver(string n, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver("uEmIAgF", 0); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      result = driver("753310137", 20); 
      cout << "TEST-" << 1 << "..."
           <<  result
           << "\n";
  
      result = driver("010011010", 154); 
      cout << "TEST-" << 2 << "..."
           <<  result
           << "\n";
  
      result = driver("kNi", 0); 
      cout << "TEST-" << 3 << "..."
           <<  result
           << "\n";
  
      result = driver("04562016903312", 130); 
      cout << "TEST-" << 4 << "..."
           <<  result
           << "\n";
  
      result = driver("000111101", 61); 
      cout << "TEST-" << 5 << "..."
           <<  result
           << "\n";
  
      result = driver("bk", 0); 
      cout << "TEST-" << 6 << "..."
           <<  result
           << "\n";
  
      result = driver("9", 0); 
      cout << "TEST-" << 7 << "..."
           <<  result
           << "\n";
  
      result = driver("1", 1); 
      cout << "TEST-" << 8 << "..."
           <<  result
           << "\n";
  
      result = driver("XxT nXLlk", 0); 
      cout << "TEST-" << 9 << "..."
           <<  result
           << "\n";
  
      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;
  }