Skip to content

Chore: added equations into Lesson 7 and Lesson 7 part e homework #315

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 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6d8dda2
Create README.md
JEKLUND251 Mar 4, 2025
ec0b53d
Update README.md
JEKLUND251 Mar 4, 2025
08494d8
Update README.md
JEKLUND251 Mar 4, 2025
4d289e1
Create Images subfolder
JEKLUND251 Mar 4, 2025
5ff6a5e
Add files via upload
JEKLUND251 Mar 4, 2025
76d6adf
Delete lesson_00/JustinEKlund.md/Images subfolder
JEKLUND251 Mar 4, 2025
094cf02
Rename IMG_2810.jpg to Images subfolder
JEKLUND251 Mar 4, 2025
f8174e6
Rename Images subfolder to Images
JEKLUND251 Mar 4, 2025
7a9fa54
Rename lesson_00/JustinEKlund.md/Images to lesson_00/JustinEKlund.md/…
JEKLUND251 Mar 4, 2025
1be4541
Add files via upload
JEKLUND251 Mar 4, 2025
01d896e
Rename IMG_2810 (1).jpg to readme pic 1
JEKLUND251 Mar 4, 2025
15e3d77
Update README.md
JEKLUND251 Mar 5, 2025
706c4c2
Delete lesson_00/JustinEKlund.md/Images files directory
JEKLUND251 Mar 5, 2025
3d2cd35
Add files via upload
JEKLUND251 Mar 5, 2025
c89c4d2
Delete lesson_00/JustinEKlund.md/Images file directory
JEKLUND251 Mar 5, 2025
1eb5166
Create txt
JEKLUND251 Mar 5, 2025
f9b0b73
Add files via upload
JEKLUND251 Mar 5, 2025
edfaa94
Delete lesson_00/JustinEKlund.md/Images/txt
JEKLUND251 Mar 5, 2025
aa23cde
Update README.md
JEKLUND251 Mar 5, 2025
f2c7cf9
Fix: Punctuation and grammar
VicenteVigueras Mar 7, 2025
c91781d
Merge branch 'code-differently:main' into main
JEKLUND251 Mar 10, 2025
f770163
Merge branch 'code-differently:main' into main
JEKLUND251 Mar 10, 2025
fec1b98
Merge branch 'code-differently:main' into main
JEKLUND251 Mar 10, 2025
58a4a65
Merge branch 'code-differently:main' into main
JEKLUND251 Mar 10, 2025
a1bbed5
Merge branch 'code-differently:main' into main
JEKLUND251 Mar 11, 2025
90c2cc4
Merge branch 'code-differently:main' into main
JEKLUND251 Mar 11, 2025
52ba282
Merge branch 'code-differently:main' into main
JEKLUND251 Mar 11, 2025
cabde79
Merge branch 'code-differently:main' into main
JEKLUND251 Mar 12, 2025
bb55696
Merge branch 'code-differently:main' into main
JEKLUND251 Mar 12, 2025
4e5cc9c
Merge branch 'code-differently:main' into main
JEKLUND251 Mar 12, 2025
933c415
Merge branch 'code-differently:main' into main
JEKLUND251 Mar 14, 2025
ca27460
Merge branch 'code-differently:main' into main
JEKLUND251 Mar 18, 2025
b29e113
Merge branch 'code-differently:main' into main
JEKLUND251 Mar 19, 2025
aeab489
Merge branch 'code-differently:main' into main
JEKLUND251 Mar 19, 2025
168ca99
Merge branch 'code-differently:main' into main
JEKLUND251 Mar 19, 2025
7f332cf
chore added functions into lesson 7 and part e
JEKLUND251 Mar 20, 2025
36222c2
chore: added homework letter
JEKLUND251 Mar 21, 2025
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
54 changes: 46 additions & 8 deletions lesson_07/conditionals/src/lesson7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,33 @@ import { computeLexicographicDistance } from "./util.js";
export function compareStrings(a: string, b: string): number {
// The distance will be a number less than 0 if string `a` is lexicographically less than `b`, 1
// if it is greater, and 0 if the strings are equal.
const distance = computeLexicographicDistance(a, b);
const distance = computeLexicographicDistance(a, b);

// TODO(you): Finish this method.

return 0;
if (distance < 0) {
return -1;
} else if (distance > 0) {
return 1;
} else {
return 0;
}
}

/**
* Computes the factorial of the given value of `n`.
*
* @param n The value for which to compute the factorial.
* @return The factorial of n.
*/
export function computeFactorial(n: number): number {
return 0;
if (n === 0 ) {
return 1; // Base case: 0! and 1! both equal 1
}
else if (n === 1) {
return 1;
}
else if (n < 0) {
return 0;
}
return n * computeFactorial(n - 1);
}

/**
Expand All @@ -34,6 +46,22 @@ export function computeFactorial(n: number): number {
* @return An array containing the first `n` Fibonacci values.
*/
export function getFirstNFibonacciNumbers(n: number): number[] {
for (let i = 0; i < n; i++) {
if (n === 0) {
return [];
}
else if (n === 1) {
return [1];
}
else if (n === 2) {
return [1, 1];
}
else {
const fib = getFirstNFibonacciNumbers(n - 1);
fib.push(fib[fib.length - 1] + fib[fib.length - 2]);
return fib;
}
}
return [];
}

Expand All @@ -57,9 +85,19 @@ export function binarySearch(
return -1;
}

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

// TODO(you): Finish implementing this algorithm
const pivotIndex = Math.floor((start + end) / 2); // The index in the middle of the array.
if (values[pivotIndex] === value) {
return pivotIndex;
} else if (values[pivotIndex] > value) {
return binarySearch(values, start, pivotIndex - 1, value);
} else {
return binarySearch(values, pivotIndex + 1, end, value);
return -1;
}




// If values[pivotIndex] is equal to value then return `pivotIndex`.
// Else if values[pivotIndex] is greater than the value, then
Expand Down
17 changes: 14 additions & 3 deletions lesson_07/conditionals/src/part_e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
* Write a function that takes a single character as an argument and
* returns boolean value true if the character is an uppercase letter.
*
* @param char
* @returns
*
*
*/
export function isUppercase(char: string): boolean {
if (char >= "A" && char <= "Z") {
return true;
}

return false;
}

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

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