This file contains hidden or 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
| const hours = Math.floor(duration / 3600); | |
| const minutes = String(Math.floor(duration % 3600 / 60)).padStart(2, "0"); | |
| const seconds = String(duration % 60).padStart(2, "0"); | |
| return `${hours}:${minutes}:${seconds}`; |
This file contains hidden or 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
| function areArraysEqual(a, b) { | |
| if (!Array.isArray(a) || !Array.isArray(b)) { throw new Error("At least one argument is not an Array."); } | |
| if (a === b) { return true; } | |
| if (a.length !== b.length) { return false; } | |
| for (let i = 0; i < a.length; i++) { | |
| if (a[i] !== b[i]) { | |
| return false; |
This file contains hidden or 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
| cache = {} | |
| def fizz_buzz(n: int, factor_1: int = 3, factor_2: int = 5) -> None: | |
| """ | |
| Given an integer n, for a list of integers 1-n, the task is to print, | |
| "FizzBuzz" if i is divisible by `factor_1` and `factor_2`, | |
| "Fizz" if i is divisible by `factor_1`, |
This file contains hidden or 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
| def get_digit(number: int, ltr_place: int) -> int: | |
| if ltr_place < 0: | |
| raise ValueError("ltr_place must be >= 0") | |
| length = math.floor(math.log10(number)) + 1 | |
| if ltr_place > length - 1: | |
| raise ValueError(f"ltr_place is zero-indexed. {ltr_place} exceeds the length of {number}") | |
| return number % pow(10, length - ltr_place) // pow(10, length - ltr_place - 1) |
This file contains hidden or 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
| function practiceDecorator(target, propertyKey, descriptor) { | |
| return { | |
| ...descriptor, | |
| value(...args) { | |
| // Do something here when the decorated function is called | |
| return descriptor.value.apply(this, args); | |
| } | |
| }; | |
| } |
OlderNewer