title: Program Binary Decimal Conversion
signature: function programBinaryDecimalConversion(n: number): number {
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;
  }
question_info.test_list: [{"idx": 0, "outputs": 14, "inputs": {"n": 70}}, {"idx": 1, "outputs": 23, "inputs": {"n": 95}}, {"idx": 2, "outputs": 9, "inputs": {"n": 41}}, {"idx": 3, "outputs": 25, "inputs": {"n": 97}}, {"idx": 4, "outputs": 8, "inputs": {"n": 8}}, {"idx": 5, "outputs": 8, "inputs": {"n": 16}}, {"idx": 6, "outputs": 9, "inputs": {"n": 41}}, {"idx": 7, "outputs": 17, "inputs": {"n": 57}}, {"idx": 8, "outputs": 17, "inputs": {"n": 81}}, {"idx": 9, "outputs": 22, "inputs": {"n": 78}}]
question_info.entry_cls_name: Solution
question_info.test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(n: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(n),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(70, 14);
    console.log(`TEST-0...${result}`);
  
    result = driver(95, 23);
    console.log(`TEST-1...${result}`);
  
    result = driver(41, 9);
    console.log(`TEST-2...${result}`);
  
    result = driver(97, 25);
    console.log(`TEST-3...${result}`);
  
    result = driver(8, 8);
    console.log(`TEST-4...${result}`);
  
    result = driver(16, 8);
    console.log(`TEST-5...${result}`);
  
    result = driver(41, 9);
    console.log(`TEST-6...${result}`);
  
    result = driver(57, 17);
    console.log(`TEST-7...${result}`);
  
    result = driver(81, 17);
    console.log(`TEST-8...${result}`);
  
    result = driver(78, 22);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: programBinaryDecimalConversion
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js