title: Program Binary Decimal Conversion 1
signature: pub fn program_binary_decimal_conversion_1(n: String) -> i32 {
test_code: use std::collections::HashMap;
  use std::collections::HashSet;
  use std::cmp::*;
  use std::collections::*;
  use std::fmt::*; 
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  pub fn validate_solution(actual: i32, expected: i32)->bool{
  return actual==expected
  }
  pub fn driver(n: String, expected: i32)->String{
      if validate_solution(PLACEHOLDER_FN_NAME(n), expected) {
        return "PASSED".to_string();
      };
      return "FAILED".to_string();
  
  }
  
  fn main() {
      println!("TEST-0...{}", driver(
        "uEmIAgF".to_string(), 
        0
      ));
      
      println!("TEST-1...{}", driver(
        "753310137".to_string(), 
        20
      ));
      
      println!("TEST-2...{}", driver(
        "010011010".to_string(), 
        154
      ));
      
      println!("TEST-3...{}", driver(
        "kNi".to_string(), 
        0
      ));
      
      println!("TEST-4...{}", driver(
        "04562016903312".to_string(), 
        130
      ));
      
      println!("TEST-5...{}", driver(
        "000111101".to_string(), 
        61
      ));
      
      println!("TEST-6...{}", driver(
        "bk".to_string(), 
        0
      ));
      
      println!("TEST-7...{}", driver(
        "9".to_string(), 
        0
      ));
      
      println!("TEST-8...{}", driver(
        "1".to_string(), 
        1
      ));
      
      println!("TEST-9...{}", driver(
        "XxT nXLlk".to_string(), 
        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;
  }