This commit is contained in:
2025-02-02 18:50:09 +01:00
parent 978844ed75
commit 0ebad86104
3 changed files with 152 additions and 0 deletions

21
5kyu/k-primes/tests.ts Normal file
View File

@@ -0,0 +1,21 @@
import { countKprimes, puzzle } from './solution'
import { assert, config } from "chai";
config.truncateThreshold = 0
function testing(actual: number | number[], expected: number | number[]) {
assert.deepEqual(actual, expected);
}
describe("Fixed Tests", function () {
it("Basic tests countKprimes", function () {
testing(countKprimes(2, 0, 100), [4, 6, 9, 10, 14, 15, 21, 22, 25, 26, 33, 34, 35, 38, 39, 46, 49, 51, 55, 57, 58, 62, 65, 69, 74, 77, 82, 85, 86, 87, 91, 93, 94, 95]);
testing(countKprimes(3, 0, 100), [8, 12, 18, 20, 27, 28, 30, 42, 44, 45, 50, 52, 63, 66, 68, 70, 75, 76, 78, 92, 98, 99]);
testing(countKprimes(5, 1000, 1100), [1020, 1026, 1032, 1044, 1050, 1053, 1064, 1072, 1092, 1100]);
testing(countKprimes(5, 500, 600), [500, 520, 552, 567, 588, 592, 594]);
});
it("Basic tests puzzle", function () {
testing(puzzle(138), 1);
testing(puzzle(143), 2);
});
});