title: Making Elements Of Two Arrays Same With Minimum Incrementdecrement
signature: function makingElementsOfTwoArraysSameWithMinimumIncrementdecrement(a: Array<number>, b: Array<number>, n: number): number {
source_py: def making_elements_of_two_arrays_same_with_minimum_incrementdecrement(a, b, n):
      a.sort(reverse=False)
      b.sort(reverse=False)
      result = 0
      for i in range(0, n, 1):
          if (a[i] > b[i]):
              result = (result + abs((a[i] - b[i])))
          elif (a[i] < b[i]):
              result = (result + abs((a[i] - b[i])))
      return result
source_cpp: int making_elements_of_two_arrays_same_with_minimum_incrementdecrement(vector<int> a, vector<int> b, int n) {
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    int result = 0;
    for ( int i = 0;
    i < n;
    ++ i ) {
      result = result + abs ( a [ i ] - b [ i ] );
    }
    return result;
  }
question_info.test_list: [{"idx": 0, "outputs": 263, "inputs": {"a": [1, 6, 6, 7, 10, 11, 13, 18, 19, 19, 19, 31, 34, 37, 37, 40, 41, 41, 47, 47, 53, 54, 55, 55, 56, 56, 60, 60, 62, 62, 66, 73, 75, 76, 78, 81, 81, 85, 88, 90, 91, 92, 93, 95, 97, 98], "b": [2, 2, 4, 7, 8, 8, 8, 8, 8, 9, 9, 12, 15, 16, 21, 25, 26, 27, 29, 34, 34, 35, 38, 40, 40, 44, 44, 47, 48, 54, 58, 61, 63, 64, 66, 69, 69, 70, 73, 74, 75, 76, 79, 80, 80, 93], "n": 23}}, {"idx": 1, "outputs": 158, "inputs": {"a": [-32, -12, -6, 62, 78, 86], "b": [-86, -60, 20, 32, 50, 52], "n": 4}}, {"idx": 2, "outputs": 4, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1], "b": [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 14}}, {"idx": 3, "outputs": 58, "inputs": {"a": [74, 76], "b": [16, 98], "n": 1}}, {"idx": 4, "outputs": 506, "inputs": {"a": [-92, -90, -88, -84, -76, -54, -44, -42, -38, -30, 34, 42], "b": [-80, -54, -34, 12, 14, 16, 16, 46, 50, 64, 84, 92], "n": 8}}, {"idx": 5, "outputs": 0, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "b": [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 14}}, {"idx": 6, "outputs": 105, "inputs": {"a": [4, 5, 6, 13, 16, 24, 36, 40, 40, 44, 47, 52, 58, 58, 59, 63, 66, 67, 69, 70, 74, 77, 81, 88, 89, 90, 94, 96], "b": [1, 7, 10, 17, 21, 22, 22, 27, 36, 37, 39, 46, 52, 53, 56, 59, 65, 67, 70, 75, 78, 78, 79, 89, 89, 94, 96, 97], "n": 24}}, {"idx": 7, "outputs": 392, "inputs": {"a": [-54, -36, -36, -16, -12, -10, -8, -2, 10, 22, 36, 40, 44, 50, 54, 66, 84, 92, 98], "b": [-92, -76, -74, -62, -58, -26, -18, -10, -10, -10, -6, 22, 26, 50, 62, 78, 84, 86, 86], "n": 16}}, {"idx": 8, "outputs": 5, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 1, 1, 1, 1, 1], "b": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1], "n": 36}}, {"idx": 9, "outputs": 354, "inputs": {"a": [3, 7, 8, 15, 19, 24, 26, 30, 32, 34, 37, 42, 43, 43, 55, 55, 55, 63, 64, 64, 76, 81, 88, 94], "b": [3, 4, 11, 17, 17, 22, 28, 44, 63, 63, 65, 66, 69, 74, 80, 80, 81, 81, 81, 86, 90, 91, 96, 98], "n": 22}}]
question_info.entry_cls_name: Solution
question_info.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(a: Array<number>, b: Array<number>, n: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(a, b, n),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver([1, 6, 6, 7, 10, 11, 13, 18, 19, 19, 19, 31, 34, 37, 37, 40, 41, 41, 47, 47, 53, 54, 55, 55, 56, 56, 60, 60, 62, 62, 66, 73, 75, 76, 78, 81, 81, 85, 88, 90, 91, 92, 93, 95, 97, 98], [2, 2, 4, 7, 8, 8, 8, 8, 8, 9, 9, 12, 15, 16, 21, 25, 26, 27, 29, 34, 34, 35, 38, 40, 40, 44, 44, 47, 48, 54, 58, 61, 63, 64, 66, 69, 69, 70, 73, 74, 75, 76, 79, 80, 80, 93], 23, 263);
    console.log(`TEST-0...${result}`);
  
    result = driver([-32, -12, -6, 62, 78, 86], [-86, -60, 20, 32, 50, 52], 4, 158);
    console.log(`TEST-1...${result}`);
  
    result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 14, 4);
    console.log(`TEST-2...${result}`);
  
    result = driver([74, 76], [16, 98], 1, 58);
    console.log(`TEST-3...${result}`);
  
    result = driver([-92, -90, -88, -84, -76, -54, -44, -42, -38, -30, 34, 42], [-80, -54, -34, 12, 14, 16, 16, 46, 50, 64, 84, 92], 8, 506);
    console.log(`TEST-4...${result}`);
  
    result = driver([0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 14, 0);
    console.log(`TEST-5...${result}`);
  
    result = driver([4, 5, 6, 13, 16, 24, 36, 40, 40, 44, 47, 52, 58, 58, 59, 63, 66, 67, 69, 70, 74, 77, 81, 88, 89, 90, 94, 96], [1, 7, 10, 17, 21, 22, 22, 27, 36, 37, 39, 46, 52, 53, 56, 59, 65, 67, 70, 75, 78, 78, 79, 89, 89, 94, 96, 97], 24, 105);
    console.log(`TEST-6...${result}`);
  
    result = driver([-54, -36, -36, -16, -12, -10, -8, -2, 10, 22, 36, 40, 44, 50, 54, 66, 84, 92, 98], [-92, -76, -74, -62, -58, -26, -18, -10, -10, -10, -6, 22, 26, 50, 62, 78, 84, 86, 86], 16, 392);
    console.log(`TEST-7...${result}`);
  
    result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1], 36, 5);
    console.log(`TEST-8...${result}`);
  
    result = driver([3, 7, 8, 15, 19, 24, 26, 30, 32, 34, 37, 42, 43, 43, 55, 55, 55, 63, 64, 64, 76, 81, 88, 94], [3, 4, 11, 17, 17, 22, 28, 44, 63, 63, 65, 66, 69, 74, 80, 80, 81, 81, 81, 86, 90, 91, 96, 98], 22, 354);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: makingElementsOfTwoArraysSameWithMinimumIncrementdecrement
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js