https://github.com/arye-eidelman/coding_challenge_grader
https://github.com/arye-eidelman/coding_challenge_grader
deno
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/arye-eidelman/coding_challenge_grader
- Owner: arye-eidelman
- Created: 2022-02-20T06:04:52.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-02-23T04:35:10.000Z (over 4 years ago)
- Last Synced: 2026-01-02T04:46:30.861Z (6 months ago)
- Topics: deno
- Language: TypeScript
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# coding_challenge_grader
A function for running TypeScript/JavaScript leet code chalenges.
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:
```typescript
Array<{
name?: string;
input: any[],
output: any
}>
```
For example if the chalenge is to get the square of the input number and you
wrote the following:
```typescript
import { grade } from "https://deno.land/x/coding_challenge_grader@v0.2.0/mod.ts";
const testCases: { input: [number]; output: number }[] = [
[{ input: [1], output: 1 }],
[{ input: [2], output: 4 }],
[{ input: [3], output: 9 }],
[{ input: [-3], output: 9, name: "negetive inputs" }],
];
function solution(n: number): number {
return n * Math.abs(n);
}
grade(solution, testCases);
```
you'de get the following output:
