title: Minimum Sum Two Numbers Formed Digits Array 2
signature: minimum_sum_two_numbers_formed_digits_array_2 <- function(a, n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(a, n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(a, n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(4L, 16L, 29L, 30L, 38L, 83L), 5L, 
          918L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(58L, 74L, -28L, -60L, -6L, 66L, -76L, 46L, 0L, -24L, 28L, -16L, -14L, 24L, -94L, -56L, -80L, 40L, -18L, -68L, -8L, -94L, -88L, -12L, -20L, -8L), 16L, 
          -2063616120L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 1L), 1L, 
          0L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(7L, 12L, 78L, 8L), 3L, 
          90L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-78L, -48L, -48L, -26L, 8L, 34L), 4L, 
          -1334L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L), 27L, 
          2222222L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(2L, 3L, 5L, 7L, 25L, 30L, 31L, 38L, 42L, 45L, 52L, 53L, 56L, 59L, 60L, 71L, 74L, 76L, 80L, 90L, 91L, 98L), 13L, 
          3190079L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L), 8L, 
          2L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(59L, 9L, 3L, 20L, 83L, 87L, 48L, 4L, 86L, 67L, 89L, 96L, 17L, 36L, 39L, 45L, 99L, 8L, 56L, 92L, 63L, 81L, 7L, 75L, 32L, 10L, 71L, 82L, 97L, 92L, 65L, 23L, 22L, 47L, 70L, 79L, 57L, 81L, 65L, 50L), 35L, 
          430183530665338166L
      )))
  
  }
  
  main()
source_py: def minimum_sum_two_numbers_formed_digits_array_2(a, n):
      a = sorted(a)
      (num1, num2) = (0, 0)
      for i in range(n):
          if ((i % 2) == 0):
              num1 = ((num1 * 10) + a[i])
          else:
              num2 = ((num2 * 10) + a[i])
      return (num2 + num1)
source_cpp: int minimum_sum_two_numbers_formed_digits_array_2(vector<int> a, int n) {
    sort(a.begin(), a.end());
    int num1 = 0;
    int num2 = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( i % 2 == 0 ) num1 = num1 * 10 + a [ i ];
      else num2 = num2 * 10 + a [ i ];
    }
    return num2 + num1;
  }