title: Program Binary Decimal Conversion 1
signature: fun programBinaryDecimalConversion1(n: String): Int {
test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Int, expected:Int):Boolean{
    return actual.equals(expected)
  }
  fun driver(n: String, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver("uEmIAgF", 0)
      println("TEST-0...${result}")
      
      result = driver("753310137", 20)
      println("TEST-1...${result}")
      
      result = driver("010011010", 154)
      println("TEST-2...${result}")
      
      result = driver("kNi", 0)
      println("TEST-3...${result}")
      
      result = driver("04562016903312", 130)
      println("TEST-4...${result}")
      
      result = driver("000111101", 61)
      println("TEST-5...${result}")
      
      result = driver("bk", 0)
      println("TEST-6...${result}")
      
      result = driver("9", 0)
      println("TEST-7...${result}")
      
      result = driver("1", 1)
      println("TEST-8...${result}")
      
      result = driver("XxT nXLlk", 0)
      println("TEST-9...${result}")
      
          
  }
  
  main()
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;
  }