title: Program Binary Decimal Conversion
signature: function programBinaryDecimalConversion($n) {
test_code: <?php
  
  
  // SOLUTION CODE 
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function validateSolution($actual, $expected){
      return serialize($actual) == serialize($expected);
  }
  
  function driver($n, $expected){
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME($n), $expected)){
          return "PASSED";
        }
        return "FAILED";
      }
      catch (Exception $exception_obj) {
        return get_class($exception_obj);
      }
  }
  
  function main(){
      printf("TEST-0...%s\n",driver(
        70, 
        14));
      
      printf("TEST-1...%s\n",driver(
        95, 
        23));
      
      printf("TEST-2...%s\n",driver(
        41, 
        9));
      
      printf("TEST-3...%s\n",driver(
        97, 
        25));
      
      printf("TEST-4...%s\n",driver(
        8, 
        8));
      
      printf("TEST-5...%s\n",driver(
        16, 
        8));
      
      printf("TEST-6...%s\n",driver(
        41, 
        9));
      
      printf("TEST-7...%s\n",driver(
        57, 
        17));
      
      printf("TEST-8...%s\n",driver(
        81, 
        17));
      
      printf("TEST-9...%s\n",driver(
        78, 
        22));
      
  }
  
  main();
  ?>
source_py: def program_binary_decimal_conversion(n):
      num = n
      dec_value = 0
      base = 1
      temp = num
      while temp:
          last_digit = (temp % 10)
          temp = int((temp / 10))
          dec_value += (last_digit * base)
          base = (base * 2)
      return dec_value
source_cpp: int program_binary_decimal_conversion(int n) {
    int num = n;
    int dec_value = 0;
    int base = 1;
    int temp = num;
    while ( temp ) {
      int last_digit = temp % 10;
      temp = temp / 10;
      dec_value += last_digit * base;
      base = base * 2;
    }
    return dec_value;
  }