title: Minimize The Sum Of Digits Of A And B Such That A B N
signature: function minimizeTheSumOfDigitsOfAAndBSuchThatABN(n: number): number {
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(2, 2);
    console.log(`TEST-0...${result}`);
  
    result = driver(39, 12);
    console.log(`TEST-1...${result}`);
  
    result = driver(31, 4);
    console.log(`TEST-2...${result}`);
  
    result = driver(45, 9);
    console.log(`TEST-3...${result}`);
  
    result = driver(35, 8);
    console.log(`TEST-4...${result}`);
  
    result = driver(94, 13);
    console.log(`TEST-5...${result}`);
  
    result = driver(67, 13);
    console.log(`TEST-6...${result}`);
  
    result = driver(50, 5);
    console.log(`TEST-7...${result}`);
  
    result = driver(4, 4);
    console.log(`TEST-8...${result}`);
  
    result = driver(63, 9);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
source_py: def minimize_the_sum_of_digits_of_a_and_b_such_that_a_b_n(n):
      sum = 0
      while (n > 0):
          sum += (n % 10)
          n //= 10
      if (sum == 1):
          return 10
      return sum
source_cpp: int minimize_the_sum_of_digits_of_a_and_b_such_that_a_b_n(int n) {
    int sum = 0;
    while ( n > 0 ) {
      sum += ( n % 10 );
      n /= 10;
    }
    if ( sum == 1 ) return 10;
    return sum;
  }