title: Minimum Sum Two Numbers Formed Digits Array
signature: minimum_sum_two_numbers_formed_digits_array <- function(arr, n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr, n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr, n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(3L, 4L, 5L, 10L, 14L, 16L, 18L, 42L, 43L, 43L, 45L, 46L, 51L, 52L, 53L, 58L, 61L, 66L, 79L, 81L, 82L, 84L), 19L, 
          4183488835L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(-90L, -86L, -76L, -50L, -46L, -30L, -26L, -22L, -22L, -20L, -2L, -2L, 8L, 22L, 32L, 40L, 48L, 48L, 56L, 58L, 60L, 76L, 82L, 82L, 94L, 98L), 25L, 
          -107220607602444L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 23L, 
          1222222L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(45L, 79L), 1L, 
          45L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-90L, -68L, -38L, -34L, -4L, 6L, 10L, 28L, 48L, 52L, 54L, 68L, 88L, 90L), 11L, 
          -10095534L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 22L, 
          122222L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(4L, 8L, 8L, 23L, 26L, 27L, 30L, 42L, 44L, 55L, 59L, 64L, 67L, 69L, 74L, 77L, 82L, 82L, 87L, 96L, 97L), 17L, 
          615688689L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(-98L, -98L, -86L, -82L, -76L, -76L, -66L, -64L, -62L, -60L, -48L, -46L, -42L, -36L, -36L, -32L, -28L, -18L, -18L, -4L, 0L, 0L, 2L, 4L, 10L, 18L, 30L, 46L, 50L, 52L, 62L, 70L, 72L, 76L, 80L, 88L, 88L, 94L, 96L), 32L, 
          -214463225281903248L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L), 6L, 
          0L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(7L, 8L, 9L, 9L, 14L, 14L, 16L, 17L, 22L, 24L, 32L, 32L, 36L, 38L, 42L, 42L, 43L, 45L, 47L, 53L, 54L, 56L, 58L, 58L, 61L, 63L, 64L, 68L, 69L, 69L, 71L, 71L, 71L, 72L, 73L, 74L, 75L, 82L, 86L, 86L, 87L, 90L, 96L, 97L, 98L), 25L, 
          8964536953959L
      )))
  
  }
  
  main()
source_py: def minimum_sum_two_numbers_formed_digits_array(arr, n):
      arr.sort()
      a = 0
      b = 0
      for i in range(n):
          if ((i % 2) != 0):
              a = ((a * 10) + arr[i])
          else:
              b = ((b * 10) + arr[i])
      return (a + b)
source_cpp: int minimum_sum_two_numbers_formed_digits_array(vector<int> arr, int n) {
    sort(arr.begin(), arr.end());
    int a = 0, b = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( i & 1 ) a = a * 10 + arr [ i ];
      else b = b * 10 + arr [ i ];
    }
    return a + b;
  }