Improve performance of checker for valid math contracts (#1286)

This commit is contained in:
Yichi Zhang
2024-05-23 00:41:52 -07:00
committed by GitHub
parent 819e9f3448
commit 7ed64cbc9c

View File

@ -1282,8 +1282,9 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
// Prevent player from providing extra wrong answers and still receiving credit
if (result.length !== sanitizedPlayerAnsArr.length) return false;
for (const expr of result) {
if (!sanitizedPlayerAnsArr.includes(expr)) {
const resultsSet = new Set(result);
for (const expr of sanitizedPlayerAnsArr) {
if (!resultsSet.has(expr)) {
return false;
}
}