Repository
Current version released
4 years ago
Versions
coding_challenge_grader
A function for running TypeScript/JavaScript leet code chalenges and logging all the results to the console.
Runs on deno.
The grade function accepts your solution function, an array of test cases and an optional options object.
The test cases array should be in the format:
type TestInputArgs = any[]
type TestResult = any
type TestCase = [TestInputArgs, TestResult]
type Solution = (...TestInputArgs) => TestResult
type grade = (solution, TestCase[]) => Promise<void>For example if the chalenge is to get the square of the input number and you wrote the following:
import { grade } from "https://deno.land/x/coding_challenge_grader@v0.1.0/mod.ts";
const testCases: [[number], number][] = [
[[1], 1],
[[2], 4],
[[3], 9],
[[-3], 9],
];
function solution(n: number): number {
return n * Math.abs(n);
}
grade(solution, testCases);you’de get the following output:
