title: Minimum Sum Two Numbers Formed Digits Array
signature: function minimum_sum_two_numbers_formed_digits_array(arr, n)
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;
  }
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(arr, n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(arr, n) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver({3, 4, 5, 10, 14, 16, 18, 42, 43, 43, 45, 46, 51, 52, 53, 58, 61, 66, 79, 81, 82, 84}, 19, 4183488835)
      print(string.format("TEST-0...%s",result))
  
      result = driver({-90, -86, -76, -50, -46, -30, -26, -22, -22, -20, -2, -2, 8, 22, 32, 40, 48, 48, 56, 58, 60, 76, 82, 82, 94, 98}, 25, -107220607602444)
      print(string.format("TEST-1...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 23, 1222222)
      print(string.format("TEST-2...%s",result))
  
      result = driver({45, 79}, 1, 45)
      print(string.format("TEST-3...%s",result))
  
      result = driver({-90, -68, -38, -34, -4, 6, 10, 28, 48, 52, 54, 68, 88, 90}, 11, -10095534)
      print(string.format("TEST-4...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 22, 122222)
      print(string.format("TEST-5...%s",result))
  
      result = driver({4, 8, 8, 23, 26, 27, 30, 42, 44, 55, 59, 64, 67, 69, 74, 77, 82, 82, 87, 96, 97}, 17, 615688689)
      print(string.format("TEST-6...%s",result))
  
      result = driver({-98, -98, -86, -82, -76, -76, -66, -64, -62, -60, -48, -46, -42, -36, -36, -32, -28, -18, -18, -4, 0, 0, 2, 4, 10, 18, 30, 46, 50, 52, 62, 70, 72, 76, 80, 88, 88, 94, 96}, 32, -214463225281903248)
      print(string.format("TEST-7...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 0, 1, 1, 1, 1}, 6, 0)
      print(string.format("TEST-8...%s",result))
  
      result = driver({7, 8, 9, 9, 14, 14, 16, 17, 22, 24, 32, 32, 36, 38, 42, 42, 43, 45, 47, 53, 54, 56, 58, 58, 61, 63, 64, 68, 69, 69, 71, 71, 71, 72, 73, 74, 75, 82, 86, 86, 87, 90, 96, 97, 98}, 25, 8964536953959)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 4183488835, "inputs": {"arr": [3, 4, 5, 10, 14, 16, 18, 42, 43, 43, 45, 46, 51, 52, 53, 58, 61, 66, 79, 81, 82, 84], "n": 19}}, {"idx": 1, "outputs": -107220607602444, "inputs": {"arr": [-90, -86, -76, -50, -46, -30, -26, -22, -22, -20, -2, -2, 8, 22, 32, 40, 48, 48, 56, 58, 60, 76, 82, 82, 94, 98], "n": 25}}, {"idx": 2, "outputs": 1222222, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 23}}, {"idx": 3, "outputs": 45, "inputs": {"arr": [45, 79], "n": 1}}, {"idx": 4, "outputs": -10095534, "inputs": {"arr": [-90, -68, -38, -34, -4, 6, 10, 28, 48, 52, 54, 68, 88, 90], "n": 11}}, {"idx": 5, "outputs": 122222, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 22}}, {"idx": 6, "outputs": 615688689, "inputs": {"arr": [4, 8, 8, 23, 26, 27, 30, 42, 44, 55, 59, 64, 67, 69, 74, 77, 82, 82, 87, 96, 97], "n": 17}}, {"idx": 7, "outputs": -214463225281903248, "inputs": {"arr": [-98, -98, -86, -82, -76, -76, -66, -64, -62, -60, -48, -46, -42, -36, -36, -32, -28, -18, -18, -4, 0, 0, 2, 4, 10, 18, 30, 46, 50, 52, 62, 70, 72, 76, 80, 88, 88, 94, 96], "n": 32}}, {"idx": 8, "outputs": 0, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 1, 1, 1, 1], "n": 6}}, {"idx": 9, "outputs": 8964536953959, "inputs": {"arr": [7, 8, 9, 9, 14, 14, 16, 17, 22, 24, 32, 32, 36, 38, 42, 42, 43, 45, 47, 53, 54, 56, 58, 58, 61, 63, 64, 68, 69, 69, 71, 71, 71, 72, 73, 74, 75, 82, 86, 86, 87, 90, 96, 97, 98], "n": 25}}]
question_info.extension: lua
question_info.entry_fn_name: minimum_sum_two_numbers_formed_digits_array
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__