Skip to content

chore: removed extra file #358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lesson_07/conditionals/.env.test
Original file line number Diff line number Diff line change
@@ -1 +1 @@
HW_VERSION=your homework version here
HW_VERSION=E
15 changes: 0 additions & 15 deletions lesson_07/conditionals/package-lock.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file needs to be reverted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not reverted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 40 additions & 12 deletions lesson_07/conditionals/src/lesson7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ export function compareStrings(a: string, b: string): number {
// if it is greater, and 0 if the strings are equal.
const distance = computeLexicographicDistance(a, b);

if (distance < 0) {
return -1;
} else if (distance > 0) {
return 1;
}
// TODO(you): Finish this method.

return 0;
}

Expand All @@ -24,17 +28,36 @@ export function compareStrings(a: string, b: string): number {
* @return The factorial of n.
*/
export function computeFactorial(n: number): number {
return 0;
if (n === 0 || n === 1) {
return 1;
}
if (n < 0) {
return 0;
}
let result = 1;
for (let i = 2; i <= n; i++) {
result *= i;
}
return result;
}

/**
* Returns an array of the first `n` Fibonacci numbers starting from 1.
*
* @param n The first `n` of Fibonacci values to compute.
* @return An array containing the first `n` Fibonacci values.
*/
export function getFirstNFibonacciNumbers(n: number): number[] {
return [];
if (n <= 0) {
return [];
}
if (n === 1) {
return [1];
}
const Fibonacci: number[] = [1, 1];
for (let i = 2; i < n; i++) {
Fibonacci.push(Fibonacci[i - 1] + Fibonacci[i - 2]);
}
return Fibonacci;
}

/**
Expand All @@ -58,12 +81,17 @@ export function binarySearch(
}

const pivotIndex = Math.floor((start + end) / 2); // The index in the middle of the array.

// TODO(you): Finish implementing this algorithm

// If values[pivotIndex] is equal to value then return `pivotIndex`.
// Else if values[pivotIndex] is greater than the value, then
// call `binarySearch(values, start, pivotIndex - 1, value)` and return its value;
// Else call `binarySearch(values, pivotIndex + 1, end, value)` and return its value.
return -1;
if (values[pivotIndex] === value) {
return pivotIndex;
} else if (values[pivotIndex] > value) {
return binarySearch(values, start, pivotIndex - 1, value); // Search in the right half
} else {
return binarySearch(values, pivotIndex + 1, end, value); // Search in the left half
}
}
// TODO(you): Finish implementing this algorithm

// If values[pivotIndex] is equal to value then return `pivotIndex`.
// Else if values[pivotIndex] is greater than the value, then
// call `binarySearch(values, start, pivotIndex - 1, value)` and return its value;
// Else call `binarySearch(values, pivotIndex + 1, end, value)` and return its value.
45 changes: 43 additions & 2 deletions lesson_07/conditionals/src/part_e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,39 @@
* @returns
*/
export function isUppercase(char: string): boolean {
const lower: string[] = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
];
for (const letter of lower) {
if (char === letter) {
return true;
}
}
return false;
}

Expand All @@ -17,7 +50,11 @@ export function isUppercase(char: string): boolean {
* @returns
*/
export function canGetDriverLicense(age: number, passedTest: boolean): boolean {
return false;
if (age >= 18 && passedTest === true) {
return true;
} else {
return false;
}
}

/**
Expand All @@ -29,5 +66,9 @@ export function canGetDriverLicense(age: number, passedTest: boolean): boolean {
* @returns
*/
export function isStoreOpen(day: string, hour: number): boolean {
return false;
if (day !== "Sunday" && hour < 21 && hour >= 9) {
return true;
} else {
return false;
}
}
Loading