title: Searching Array Adjacent Differ K
signature: function searching_array_adjacent_differ_k(arr, n, x, k)
source_py: def searching_array_adjacent_differ_k(arr, n, x, k):
      i = 0
      while (i < n):
          if (arr[i] == x):
              return i
          i = (i + max(1, int((abs((arr[i] - x)) / k))))
      print('number is not present!')
      return (- 1)
source_cpp: int searching_array_adjacent_differ_k(vector<int> arr, int n, int x, int k) {
    int i = 0;
    while ( i < n ) {
      if ( arr [ i ] == x ) return i;
      i = i + max ( 1, abs ( arr [ i ] - x ) / k );
    }
    return - 1;
  }
question_info.entry_fn_name: searching_array_adjacent_differ_k
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
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, x, k, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(arr, n, x, k) 
      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({1, 5, 9, 11, 14, 18, 19, 21, 26, 32, 38, 38, 43, 47, 49, 52, 55, 61, 65, 67, 69, 73, 74, 79, 84, 90, 91, 91, 92, 93, 94, 99}, 22, 19, 26, 6)
      print(string.format("TEST-0...%s",result))
  
      result = driver({12, -86, -66, -50, -48, 78, -92, -56, -2, 66, 64}, 5, 10, 5, -1)
      print(string.format("TEST-1...%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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 35, 37, 43, -1)
      print(string.format("TEST-2...%s",result))
  
      result = driver({10, 87, 39, 87, 45, 33, 5, 37, 70, 69, 88, 78, 90, 3}, 9, 8, 10, -1)
      print(string.format("TEST-3...%s",result))
  
      result = driver({-78, -70, -68, -60, -52, -34, -24, -4, 12, 18, 58, 58, 64, 76, 84, 94}, 14, 9, 13, -1)
      print(string.format("TEST-4...%s",result))
  
      result = driver({0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0}, 26, 36, 32, -1)
      print(string.format("TEST-5...%s",result))
  
      result = driver({5, 5, 7, 11, 11, 15, 22, 23, 28, 38, 41, 53, 54, 57, 59, 68, 71, 89}, 16, 17, 16, -1)
      print(string.format("TEST-6...%s",result))
  
      result = driver({-4, 0, 60, -14, -48, 54, -96, -68, -40, 64, -50, -74, -20, -22, 48, -48, 42, 62, 66, 84, 54, -52, -52, 6, 46, -90, -18, 90}, 18, 14, 23, -1)
      print(string.format("TEST-7...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}, 9, 8, 9, -1)
      print(string.format("TEST-8...%s",result))
  
      result = driver({30, 91, 34, 44, 3, 76, 43, 75, 49, 33, 74, 72, 68, 79, 26, 62, 23, 5, 32, 75, 82, 25, 7, 19, 32, 87, 87, 94, 34, 62, 3, 32, 59}, 32, 30, 24, 0)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 6, "inputs": {"arr": [1, 5, 9, 11, 14, 18, 19, 21, 26, 32, 38, 38, 43, 47, 49, 52, 55, 61, 65, 67, 69, 73, 74, 79, 84, 90, 91, 91, 92, 93, 94, 99], "n": 22, "x": 19, "k": 26}}, {"idx": 1, "outputs": -1, "inputs": {"arr": [12, -86, -66, -50, -48, 78, -92, -56, -2, 66, 64], "n": 5, "x": 10, "k": 5}}, {"idx": 2, "outputs": -1, "inputs": {"arr": [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, 1, 1, 1, 1], "n": 35, "x": 37, "k": 43}}, {"idx": 3, "outputs": -1, "inputs": {"arr": [10, 87, 39, 87, 45, 33, 5, 37, 70, 69, 88, 78, 90, 3], "n": 9, "x": 8, "k": 10}}, {"idx": 4, "outputs": -1, "inputs": {"arr": [-78, -70, -68, -60, -52, -34, -24, -4, 12, 18, 58, 58, 64, 76, 84, 94], "n": 14, "x": 9, "k": 13}}, {"idx": 5, "outputs": -1, "inputs": {"arr": [0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0], "n": 26, "x": 36, "k": 32}}, {"idx": 6, "outputs": -1, "inputs": {"arr": [5, 5, 7, 11, 11, 15, 22, 23, 28, 38, 41, 53, 54, 57, 59, 68, 71, 89], "n": 16, "x": 17, "k": 16}}, {"idx": 7, "outputs": -1, "inputs": {"arr": [-4, 0, 60, -14, -48, 54, -96, -68, -40, 64, -50, -74, -20, -22, 48, -48, 42, 62, 66, 84, 54, -52, -52, 6, 46, -90, -18, 90], "n": 18, "x": 14, "k": 23}}, {"idx": 8, "outputs": -1, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], "n": 9, "x": 8, "k": 9}}, {"idx": 9, "outputs": 0, "inputs": {"arr": [30, 91, 34, 44, 3, 76, 43, 75, 49, 33, 74, 72, 68, 79, 26, 62, 23, 5, 32, 75, 82, 25, 7, 19, 32, 87, 87, 94, 34, 62, 3, 32, 59], "n": 32, "x": 30, "k": 24}}]