-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0a9118
commit 9441dae
Showing
121 changed files
with
1,116 additions
and
612 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,21 @@ | ||
{ | ||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], | ||
"root": true, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:prettier/recommended" | ||
], | ||
"plugins": [ | ||
"@typescript-eslint", | ||
"jest", | ||
"simple-import-sort", | ||
"unused-imports" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint", "jest"], | ||
"root": true | ||
"rules": { | ||
"no-unused-vars": "off", | ||
"@typescript-eslint/no-unused-vars": "error", | ||
"unused-imports/no-unused-imports": "error", | ||
"simple-import-sort/exports": "error" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"tabWidth": 4, | ||
"semi": false, | ||
"singleQuote": true | ||
"semi": true, | ||
"singleQuote": true, | ||
"endOfLine": "crlf" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,26 +15,41 @@ | |
"type": "module", | ||
"scripts": { | ||
"test": "jest", | ||
"doc": "typedoc --entryPointStrategy expand ./src --exclude \"./src/**/*+(test).ts\" --excludeReferences", | ||
"lint": "eslint .", | ||
"format": "prettier . --write" | ||
"doc": "typedoc", | ||
"trunk:check": "trunk check --all", | ||
"trunk:fix": "trunk check --all --fix", | ||
"trunk:format": "trunk fmt", | ||
"type:check": "tsc --project tsconfig.json" | ||
}, | ||
"devDependencies": { | ||
"@trunkio/launcher": "^1.3.1", | ||
"@types/jest": "^29.5.11", | ||
"@types/node": "^20.10.8", | ||
"@typescript-eslint/eslint-plugin": "^6.18.1", | ||
"@typescript-eslint/parser": "^6.18.1", | ||
"@yarnpkg/sdks": "^3.1.0", | ||
"eslint": "^8.56.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-import-resolver-typescript": "^3.6.3", | ||
"eslint-plugin-jest": "^28.2.0", | ||
"eslint-plugin-prettier": "^5.2.1", | ||
"eslint-plugin-simple-import-sort": "^12.1.1", | ||
"eslint-plugin-unused-imports": "^4.1.3", | ||
"jest": "^29.7.0", | ||
"prettier": "^3.2.5", | ||
"ts-jest": "^29.1.1", | ||
"typedoc": "^0.25.7" | ||
"typedoc": "^0.25.13", | ||
"typedoc-plugin-rename-defaults": "^0.7.0", | ||
"typedoc-theme-hierarchy": "^4.1.2" | ||
}, | ||
"dependencies": { | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.3.3" | ||
}, | ||
"resolutions": { | ||
"@babel/traverse": "7.23.2", | ||
"braces": "3.0.3", | ||
"micromatch": "4.0.8" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
6 changes: 3 additions & 3 deletions
6
src/Problem Solving/Algorithms/Implementation/Angry Professor/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { angryProfessor } from '@ProblemSolving/Algorithms/Implementation' | ||
import { angryProfessor } from '@ProblemSolving/Algorithms/Implementation'; | ||
|
||
test('should return whether the class is cancelled or not', () => { | ||
expect(angryProfessor(3, [-1, -3, 4, 2])).toBe('YES') | ||
}) | ||
expect(angryProfessor(3, [-1, -3, 4, 2])).toBe('YES'); | ||
}); |
22 changes: 16 additions & 6 deletions
22
src/Problem Solving/Algorithms/Implementation/Angry Professor/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
/** | ||
* Determines if the class is cancelled. | ||
* @author Andrew Mamdouh <[email protected]> | ||
* A Discrete Mathematics professor has a class of students. | ||
* Frustrated with their lack of discipline, the professor decides to cancel class if fewer than some number of students are present when class starts. | ||
* Arrival times go from on time `arrivalTime <= 0` to arrived late `arrivalTime > 0`. | ||
* | ||
* Given the arrival time of each student and a threshold number of attendees, determine if the class is cancelled. | ||
* | ||
* @param {number} k - The threshold number of students | ||
* @param {number[]} a - The arrival times of the students | ||
* @returns {"YES" | "NO"} Whether the class is cancelled or not. | ||
* @example | ||
* ```ts | ||
* const result = angryProfessor(3, [-1, -3, 4, 2]); | ||
* console.log(result); // "YES" | ||
* ``` | ||
* @author Andrew Mamdouh <[email protected]> | ||
*/ | ||
const angryProfessor = (k: number, a: number[]): string => { | ||
const students = a.filter((time) => time <= 0).length | ||
return students < k ? 'YES' : 'NO' | ||
} | ||
const students = a.filter((time) => time <= 0).length; | ||
return students < k ? 'YES' : 'NO'; | ||
}; | ||
|
||
export default angryProfessor | ||
export default angryProfessor; |
6 changes: 3 additions & 3 deletions
6
src/Problem Solving/Algorithms/Implementation/Append and Delete/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { appendAndDelete } from '@ProblemSolving/Algorithms/Implementation' | ||
import { appendAndDelete } from '@ProblemSolving/Algorithms/Implementation'; | ||
|
||
test('should return "Yes" or "No"', () => { | ||
expect(appendAndDelete('hackerhappy', 'hackerrank', 9)).toBe('Yes') | ||
}) | ||
expect(appendAndDelete('hackerhappy', 'hackerrank', 9)).toBe('Yes'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { getLongestCommonSubStr } from '@Helpers' | ||
import { getLongestCommonSubStr } from '@Helpers'; | ||
/** | ||
* Determines whether you can convert (s) to (t) by performing exactly (k) of operations | ||
* @author Andrew Mamdouh <[email protected]> | ||
|
@@ -8,14 +8,14 @@ import { getLongestCommonSubStr } from '@Helpers' | |
* @returns {"Yes" | "No"} Whether this can be performed or not | ||
*/ | ||
const appendAndDelete = (s: string, t: string, k: number): 'Yes' | 'No' => { | ||
let longestCommonStr = getLongestCommonSubStr(s, t) | ||
if (s.indexOf(longestCommonStr) !== 0) longestCommonStr = '' | ||
const maxOpsNum = s.length + t.length | ||
let longestCommonStr = getLongestCommonSubStr(s, t); | ||
if (s.indexOf(longestCommonStr) !== 0) longestCommonStr = ''; | ||
const maxOpsNum = s.length + t.length; | ||
return (maxOpsNum - longestCommonStr.length * 2 <= k && | ||
(maxOpsNum - longestCommonStr.length * 2) % 2 === k % 2) || | ||
maxOpsNum <= k | ||
? 'Yes' | ||
: 'No' | ||
} | ||
: 'No'; | ||
}; | ||
|
||
export default appendAndDelete | ||
export default appendAndDelete; |
6 changes: 3 additions & 3 deletions
6
src/Problem Solving/Algorithms/Implementation/Apple and Orange/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { countApplesAndOranges } from '@ProblemSolving/Algorithms/Implementation' | ||
import { countApplesAndOranges } from '@ProblemSolving/Algorithms/Implementation'; | ||
|
||
test("should return the number of apples and oranges that fall on Sam's house", () => { | ||
expect(countApplesAndOranges(7, 11, 5, 15, [-2, 2, 1], [5, -6])).toEqual([ | ||
1, 1, | ||
]) | ||
}) | ||
]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/Problem Solving/Algorithms/Implementation/Beautiful Days at the Movies/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { beautifulDays } from '@ProblemSolving/Algorithms/Implementation' | ||
import { beautifulDays } from '@ProblemSolving/Algorithms/Implementation'; | ||
|
||
test('should return the number of beautiful days', () => { | ||
expect(beautifulDays(20, 23, 6)).toBe(2) | ||
}) | ||
expect(beautifulDays(20, 23, 6)).toBe(2); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/Problem Solving/Algorithms/Implementation/Between Two Sets/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { getTotalX } from '@ProblemSolving/Algorithms/Implementation' | ||
import { getTotalX } from '@ProblemSolving/Algorithms/Implementation'; | ||
|
||
test('should return the number of integers that are between the sets', () => { | ||
expect(getTotalX([2, 4], [16, 32, 96])).toBe(3) | ||
}) | ||
expect(getTotalX([2, 4], [16, 32, 96])).toBe(3); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
src/Problem Solving/Algorithms/Implementation/Bill Division/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { bonAppetit } from '@ProblemSolving/Algorithms/Implementation' | ||
import { bonAppetit } from '@ProblemSolving/Algorithms/Implementation'; | ||
|
||
test('should log the overcharged amount', () => { | ||
console.log = jest.fn() | ||
bonAppetit([3, 10, 2, 9], 1, 12) | ||
expect(console.log).toHaveBeenCalledWith(5) | ||
}) | ||
console.log = jest.fn(); | ||
bonAppetit([3, 10, 2, 9], 1, 12); | ||
expect(console.log).toHaveBeenCalledWith(5); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/Problem Solving/Algorithms/Implementation/Breaking the Records/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { breakingRecords } from '@ProblemSolving/Algorithms/Implementation' | ||
import { breakingRecords } from '@ProblemSolving/Algorithms/Implementation'; | ||
|
||
test('should return the numbers representing the times most points records and least points records have been broken', () => { | ||
expect(breakingRecords([10, 5, 20, 20, 4, 5, 2, 25, 1])).toEqual([2, 4]) | ||
}) | ||
expect(breakingRecords([10, 5, 20, 20, 4, 5, 2, 25, 1])).toEqual([2, 4]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/Problem Solving/Algorithms/Implementation/Cats and a Mouse/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { catAndMouse } from '@ProblemSolving/Algorithms/Implementation' | ||
import { catAndMouse } from '@ProblemSolving/Algorithms/Implementation'; | ||
|
||
test('should return Either "Cat A", "Cat B", or "Mouse C"', () => { | ||
expect(catAndMouse(1, 2, 3)).toBe('Cat B') | ||
}) | ||
expect(catAndMouse(1, 2, 3)).toBe('Cat B'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/Problem Solving/Algorithms/Implementation/Chocolate Feast/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { chocolateFeast } from '@ProblemSolving/Algorithms/Implementation' | ||
import { chocolateFeast } from '@ProblemSolving/Algorithms/Implementation'; | ||
|
||
test('should return the number of chocolates Bobby can eat', () => { | ||
expect(chocolateFeast(10, 2, 5)).toBe(6) | ||
}) | ||
expect(chocolateFeast(10, 2, 5)).toBe(6); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.