this modified one, by mixing @engkin idea to mine should work properly :
function checkwq(Value: string): boolean;
const
wq: set of char = ['q', 'w'];
var
t: set of char;
i: integer;
c: Byte;
begin
t := [];
c:=0;
Result := False;
if Length(Value) <> 3 then
Exit;
for i := 1 to 3 do begin
c:=c xor Byte(LowerCase(Value[i]));
include(t, LowerCase(Value[i]));
end;
if (t = wq) and (c = 73) then
Result := True;
end;
string contains at least 1 'w', at least 1 'q' due to the set usage, and xoring its chars returns 73, meaning it surely contains 2 'q', annihilating themselves
sets are fast, they don't use huge amount of mem like strings or TStringList.