title: Eulers Criterion Check If Square Root Under Modulo P Exists
signature: function eulers_criterion_check_if_square_root_under_modulo_p_exists(n, p)
source_py: def eulers_criterion_check_if_square_root_under_modulo_p_exists(n, p):
      n = (n % p)
      for x in range(2, p, 1):
          if (((x * x) % p) == n):
              return True
      return False
source_cpp: bool eulers_criterion_check_if_square_root_under_modulo_p_exists(int n, int p) {
    n = n % p;
    for ( int x = 2;
    x < p;
    x ++ ) if ( ( x * x ) % p == n ) return true;
    return false;
  }
question_info.entry_fn_name: eulers_criterion_check_if_square_root_under_modulo_p_exists
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(n, p, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(n, p) 
      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(71, 78, false)
      print(string.format("TEST-0...%s",result))
  
      result = driver(85, 75, false)
      print(string.format("TEST-1...%s",result))
  
      result = driver(4, 35, true)
      print(string.format("TEST-2...%s",result))
  
      result = driver(20, 99, false)
      print(string.format("TEST-3...%s",result))
  
      result = driver(71, 29, true)
      print(string.format("TEST-4...%s",result))
  
      result = driver(72, 88, false)
      print(string.format("TEST-5...%s",result))
  
      result = driver(36, 54, true)
      print(string.format("TEST-6...%s",result))
  
      result = driver(95, 52, false)
      print(string.format("TEST-7...%s",result))
  
      result = driver(83, 33, false)
      print(string.format("TEST-8...%s",result))
  
      result = driver(72, 13, false)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": false, "inputs": {"n": 71, "p": 78}}, {"idx": 1, "outputs": false, "inputs": {"n": 85, "p": 75}}, {"idx": 2, "outputs": true, "inputs": {"n": 4, "p": 35}}, {"idx": 3, "outputs": false, "inputs": {"n": 20, "p": 99}}, {"idx": 4, "outputs": true, "inputs": {"n": 71, "p": 29}}, {"idx": 5, "outputs": false, "inputs": {"n": 72, "p": 88}}, {"idx": 6, "outputs": true, "inputs": {"n": 36, "p": 54}}, {"idx": 7, "outputs": false, "inputs": {"n": 95, "p": 52}}, {"idx": 8, "outputs": false, "inputs": {"n": 83, "p": 33}}, {"idx": 9, "outputs": false, "inputs": {"n": 72, "p": 13}}]