feat: quick update to limgachine.

This commit is contained in:
mpaulson 2022-07-30 20:02:26 -06:00
parent 60d75e1996
commit 29ba2cd3ab
11 changed files with 28 additions and 15 deletions

View file

@ -2,7 +2,7 @@
"clearMocks": true,
"moduleNameMapper": {
"@code/(.*)": [
"<rootDir>/src/day1/$1"
"<rootDir>/src/day5/$1"
]
},
"preset": "ts-jest"

View file

@ -16,9 +16,9 @@ module.exports = {
"BTBFS",
"CompareBinaryTrees",
"DFSOnBST",
"DFSGraphList",
"Trie",
"DFSGraphMatrix",
"BFSGraphList",
"BFSGraphMatrix",
"Map",
],
}

View file

@ -14,10 +14,10 @@
"typescript": "^4.7.4"
},
"scripts": {
"test": "jest LinearSearchList BinarySearchList TwoCrystalBalls BubbleSort DoublyLinkedList Queue Stack ArrayList MazeSolver QuickSort BTPreOrder BTInOrder BTPostOrder BTBFS CompareBinaryTrees DFSOnBST Trie DFSGraphList BFSGraphList BFSGraphMatrix Map",
"test": "jest LinearSearchList BinarySearchList TwoCrystalBalls BubbleSort DoublyLinkedList Queue Stack ArrayList MazeSolver QuickSort BTPreOrder BTInOrder BTPostOrder BTBFS CompareBinaryTrees DFSOnBST DFSGraphList Trie BFSGraphMatrix Map",
"clear": "./scripts/clear",
"prettier": "prettier --write ./src",
"generate": "./scripts/generate",
"day": "echo /home/mpaulson/personal/kata/src/day1"
"day": "echo /home/mpaulson/personal/kata/src/day5"
}
}

View file

@ -223,7 +223,7 @@ module.exports = {
MazeSolver: {
type: "fn",
fn: "solve",
args: "maze: string[], wall: string, path: string, start: Point, end: Point",
args: "maze: string[], wall: string, start: Point, end: Point",
return: "Point[]",
},
@ -264,7 +264,7 @@ module.exports = {
DFSOnBST: {
type: "fn",
fn: "search",
fn: "dfs",
args: "head: BinaryNode<number>, needle: number",
return: "boolean",
},

View file

@ -67,6 +67,9 @@ function create_function(name, item) {
config.dsa.forEach(ds => {
const item = dsa[ds];
if (!item) {
throw new Error(`algorithm ${ds} could not be found`);
}
if (item.type === "class") {
create_class(ds, item);
} else {

View file

@ -3,14 +3,23 @@ import MyMap from "@code/Map";
test("Map", function() {
const map = new MyMap<string, number>();
map.set("foo", 55);
expect(map.size()).toEqual(1);
map.set("fool", 75);
expect(map.size()).toEqual(2);
map.set("foolish", 105);
expect(map.size()).toEqual(3);
map.set("bar", 69);
expect(map.size()).toEqual(4);
console.log(map.size());
expect(map.get("bar")).toEqual(69);
expect(map.get("blaz")).toEqual(undefined);
map.delete("bar")
expect(map.size()).toEqual(3);
map.delete("barblabr")
expect(map.size()).toEqual(2);
expect(map.get("bar")).toEqual(undefined);
});

View file

@ -11,7 +11,7 @@ test("maze solver", function () {
];
// there is only one path through
expect(maze_solver(maze, "x", " ", {x: 10, y: 0}, {x: 1, y: 5})).toEqual([
expect(maze_solver(maze, "x", {x: 10, y: 0}, {x: 1, y: 5})).toEqual([
{x: 10, y: 0},
{x: 10, y: 1},
{x: 10, y: 2},

View file

@ -7,7 +7,7 @@ test("queue", function () {
list.enqueue(7);
list.enqueue(9);
expect(list.dequeue()).toEqual(5);
expect(list.deque()).toEqual(5);
expect(list.length).toEqual(2);
// this must be wrong..?
@ -16,11 +16,11 @@ test("queue", function () {
// i hate using debuggers
list.enqueue(11);
debugger;
expect(list.dequeue()).toEqual(7);
expect(list.dequeue()).toEqual(9);
expect(list.deque()).toEqual(7);
expect(list.deque()).toEqual(9);
expect(list.peek()).toEqual(11);
expect(list.dequeue()).toEqual(11);
expect(list.dequeue()).toEqual(undefined);
expect(list.deque()).toEqual(11);
expect(list.deque()).toEqual(undefined);
expect(list.length).toEqual(0);
// just wanted to make sure that I could not blow up myself when i remove

View file

@ -13,7 +13,7 @@ test("Trie", function() {
"foolish",
]);
trie.remove("fool");
trie.delete("fool");
expect(trie.find("fo").sort()).toEqual([
"foo",

View file

@ -9,5 +9,6 @@ test("two crystal balls", function () {
}
expect(two_crystal_balls(data)).toEqual(idx);
expect(two_crystal_balls(new Array(821).fill(false))).toEqual(-1);
});

View file

@ -12,7 +12,7 @@
"baseUrl": "src",
"paths": {
"@code/*": [
"day1/*"
"day5/*"
]
}
},