Merge pull request #322 from gnh1201/dev
Some checks are pending
CodeQL / Analyze (javascript) (push) Waiting to run
Deploy Jekyll with GitHub Pages dependencies preinstalled / build (push) Waiting to run
Deploy Jekyll with GitHub Pages dependencies preinstalled / deploy (push) Blocked by required conditions

Add abnormal case check to clusteredCellsDensity
This commit is contained in:
Namhyeon Go 2025-08-26 10:07:51 +09:00 committed by GitHub
commit 3865f3216f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -89,6 +89,14 @@ function clusteredCellsDensity(numbers, size, minDensity) {
coords.push({ x: idx % size, y: Math.floor(idx / size) }); coords.push({ x: idx % size, y: Math.floor(idx / size) });
} }
// --- Additional rule: if more than 1/3 of the entire grid is selected,
// treat it as an abnormal case and return false immediately.
var globalRatio = coords.length / (size * size);
if (globalRatio > (1/3)) {
return false;
}
// --- Normal density calculation based on bounding box ---
var xs = coords.map(function (c) { return c.x; }); var xs = coords.map(function (c) { return c.x; });
var ys = coords.map(function (c) { return c.y; }); var ys = coords.map(function (c) { return c.y; });
@ -135,7 +143,7 @@ exports.cartesianProduct = cartesianProduct;
exports.clusteredCellsDensity = clusteredCellsDensity; exports.clusteredCellsDensity = clusteredCellsDensity;
exports.estimateTileStartPosition = estimateTileStartPosition; exports.estimateTileStartPosition = estimateTileStartPosition;
exports.VERSIONINFO = "ExtraMath module (extramath.js) version 1.0.3"; exports.VERSIONINFO = "ExtraMath module (extramath.js) version 1.0.4";
exports.AUTHOR = "gnh1201@catswords.re.kr"; exports.AUTHOR = "gnh1201@catswords.re.kr";
exports.global = global; exports.global = global;
exports.require = global.require; exports.require = global.require;