title: Find The Missing Number 1
signature: function find_the_missing_number_1(a, n)
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(a, n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(a, 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({13, 27, 46, 59, 62, 82, 92}, 6, -261)
      print(string.format("TEST-0...%s",result))
  
      result = driver({22, 86, -64, -20, -56, -16, 86, 42, 72, -90, 10, 42, 56, 8, 50, 24, -34, 0, -78, 64, 18, 20, -84, -22, 90, -20, 86, 26, -54, 0, 90, -48, 4, 88, 18, -64, -22, -74, 48, -36, -86, -24, 88, -64, 68, 62, 92}, 38, 524)
      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}, 15, 131)
      print(string.format("TEST-2...%s",result))
  
      result = driver({55, 89, 56, 85, 26, 4, 91, 91, 3, 77, 63, 59, 76, 90, 1, 94, 44, 70, 8, 54, 3, 91, 29, 95, 28, 75, 20}, 22, -954)
      print(string.format("TEST-3...%s",result))
  
      result = driver({-94, -84, -80, -78, -66, -62, -54, -52, -26, -8, -8, -6, 4, 4, 8, 14, 26, 58, 60, 62, 62, 76, 78, 86, 92}, 18, 694)
      print(string.format("TEST-4...%s",result))
  
      result = driver({1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0}, 25, 341)
      print(string.format("TEST-5...%s",result))
  
      result = driver({1, 2, 7, 7, 9, 14, 23, 29, 31, 31, 35, 35, 38, 41, 44, 49, 49, 50, 51, 54, 55, 56, 57, 63, 67, 69, 73, 79, 79, 80, 86, 88, 93}, 24, -506)
      print(string.format("TEST-6...%s",result))
  
      result = driver({78, -48, 16, 22, -16, 34, 56, -20, -62, -82, -74, -40, 20, -24, -46, 64, 66, -76, 58, -84, 96, 76, 86, -32, 46}, 12, 227)
      print(string.format("TEST-7...%s",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, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 29, 463)
      print(string.format("TEST-8...%s",result))
  
      result = driver({73, 76, 25, 59, 40, 85, 90, 38, 13, 97, 93, 99, 45, 7}, 12, -697)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
source_py: def find_the_missing_number_1(a, n):
      (i, total) = (0, 1)
      for i in range(2, (n + 2)):
          total += i
          total -= a[(i - 2)]
      return total
source_cpp: int find_the_missing_number_1(vector<int> a, int n) {
    int i, total = 1;
    for ( i = 2;
    i <= ( n + 1 );
    i ++ ) {
      total += i;
      total -= a [ i - 2 ];
    }
    return total;
  }