title: Program Binary Decimal Conversion 1
signature: class Solution {
  
      public Integer programBinaryDecimalConversion1(String n) {
test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(String n, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(n,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution("uEmIAgF", 0);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution("753310137", 20);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution("010011010", 154);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution("kNi", 0);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution("04562016903312", 130);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution("000111101", 61);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution("bk", 0);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution("9", 0);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution("1", 1);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution("XxT nXLlk", 0);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(String n, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(n),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
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;
  }