-
Notifications
You must be signed in to change notification settings - Fork 29
chore: adds additional group assignments #325
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import * as jest from "@jest/globals"; | ||
| import { countCharacter, getLetterGrade, sumEvenNumbers } from "./part_f.js"; | ||
|
|
||
| const describe = | ||
| !process.env.HW_VERSION || process.env.HW_VERSION === "F" | ||
| ? jest.describe | ||
| : jest.describe.skip; | ||
|
|
||
| describe("getLetterGrade", () => { | ||
| it("should return 'A' for scores 90-100", () => { | ||
| expect(getLetterGrade(95)).toBe("A"); | ||
| expect(getLetterGrade(90)).toBe("A"); | ||
| expect(getLetterGrade(100)).toBe("A"); | ||
| }); | ||
|
|
||
| it("should return 'B' for scores 80-89", () => { | ||
| expect(getLetterGrade(85)).toBe("B"); | ||
| expect(getLetterGrade(80)).toBe("B"); | ||
| expect(getLetterGrade(89)).toBe("B"); | ||
| }); | ||
|
|
||
| it("should return 'C' for scores 70-79", () => { | ||
| expect(getLetterGrade(75)).toBe("C"); | ||
| expect(getLetterGrade(70)).toBe("C"); | ||
| expect(getLetterGrade(79)).toBe("C"); | ||
| }); | ||
|
|
||
| it("should return 'D' for scores 60-69", () => { | ||
| expect(getLetterGrade(65)).toBe("D"); | ||
| expect(getLetterGrade(60)).toBe("D"); | ||
| expect(getLetterGrade(69)).toBe("D"); | ||
| }); | ||
|
|
||
| it("should return 'F' for scores below 60", () => { | ||
| expect(getLetterGrade(59)).toBe("F"); | ||
| expect(getLetterGrade(0)).toBe("F"); | ||
| expect(getLetterGrade(45)).toBe("F"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("sumEvenNumbers", () => { | ||
| it("should return 0 for an empty array", () => { | ||
| expect(sumEvenNumbers([])).toBe(0); | ||
| }); | ||
|
|
||
| it("should return the sum of even numbers", () => { | ||
| expect(sumEvenNumbers([1, 2, 3, 4, 5, 6])).toBe(12); // 2 + 4 + 6 | ||
| expect(sumEvenNumbers([2, 4, 6, 8])).toBe(20); | ||
| }); | ||
|
|
||
| it("should return 0 if no even numbers exist", () => { | ||
| expect(sumEvenNumbers([1, 3, 5, 7])).toBe(0); | ||
| }); | ||
|
|
||
| it("should handle negative even numbers", () => { | ||
| expect(sumEvenNumbers([-2, -1, 0, 1, 2])).toBe(0); // -2 + 0 + 2 | ||
| }); | ||
| }); | ||
|
|
||
| describe("countCharacter", () => { | ||
| it("should count occurrences of a character", () => { | ||
| expect(countCharacter("hello", "l")).toBe(2); | ||
| expect(countCharacter("hello", "o")).toBe(1); | ||
| expect(countCharacter("hello", "h")).toBe(1); | ||
| }); | ||
|
|
||
| it("should return 0 if character is not found", () => { | ||
| expect(countCharacter("hello", "x")).toBe(0); | ||
| }); | ||
|
|
||
| it("should handle empty string", () => { | ||
| expect(countCharacter("", "a")).toBe(0); | ||
| }); | ||
|
|
||
| it("should be case sensitive", () => { | ||
| expect(countCharacter("Hello", "h")).toBe(0); | ||
| expect(countCharacter("Hello", "H")).toBe(1); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||
| * Determines the grade letter based on a numeric score. | ||||||||||||||||||||||||||
| * A: 90-100, B: 80-89, C: 70-79, D: 60-69, F: below 60 | ||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||
| * @param score | ||||||||||||||||||||||||||
| * @returns | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| * @returns | |
| * @param score The numeric score to convert to a letter grade. | |
| * @returns The letter grade (A, B, C, D, or F) corresponding to the score. |
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @param documentation is incomplete. It should include the parameter type and description, e.g., '@param numbers - Array of numbers to sum even values from'.
| * @returns | |
| * @param numbers - number[] - Array of numbers to sum even values from. | |
| * @returns number - The sum of all even numbers in the array. |
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @param documentation is incomplete. It should include the parameter type and description, e.g., '@param text - The string to search in'.
| * @returns | |
| * @param {string} text - The string to search in. | |
| * @param {string} character - The character to count occurrences of. | |
| * @returns {number} The number of times the character appears in the string. |
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @param documentation is incomplete. It should include the parameter type and description, e.g., '@param character - The character to count occurrences of'.
| * @returns | |
| * @param text {string} - The string to search within. | |
| * @param character {string} - The character to count occurrences of. | |
| * @returns {number} The number of times the character appears in the string. |
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @returns documentation is incomplete. It should describe what is returned, e.g., '@returns The number of times the character appears in the text'.
| * @returns | |
| * @param text The string to search. | |
| * @param character The character to count. | |
| * @returns The number of times the character appears in the text. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import * as jest from "@jest/globals"; | ||
| import { daysUntilBirthday, findLargestNumber, isPalindrome } from "./part_g.js"; | ||
|
|
||
| const describe = | ||
| !process.env.HW_VERSION || process.env.HW_VERSION === "G" | ||
| ? jest.describe | ||
| : jest.describe.skip; | ||
|
|
||
| describe("findLargestNumber", () => { | ||
| it("should find the largest number in an array", () => { | ||
| expect(findLargestNumber([1, 5, 3, 9, 2])).toBe(9); | ||
| expect(findLargestNumber([10, 20, 5, 30])).toBe(30); | ||
| }); | ||
|
|
||
| it("should handle arrays with one element", () => { | ||
| expect(findLargestNumber([42])).toBe(42); | ||
| }); | ||
|
|
||
| it("should handle negative numbers", () => { | ||
| expect(findLargestNumber([-1, -5, -3])).toBe(-1); | ||
| }); | ||
|
|
||
| it("should handle arrays with duplicate largest values", () => { | ||
| expect(findLargestNumber([5, 5, 5])).toBe(5); | ||
| }); | ||
| }); | ||
|
|
||
| describe("isPalindrome", () => { | ||
| it("should return true for palindromes", () => { | ||
| expect(isPalindrome("racecar")).toBe(true); | ||
| expect(isPalindrome("A man a plan a canal Panama")).toBe(true); | ||
| expect(isPalindrome("race a car")).toBe(false); | ||
| }); | ||
|
|
||
| it("should ignore case", () => { | ||
| expect(isPalindrome("Racecar")).toBe(true); | ||
| expect(isPalindrome("RaceCar")).toBe(true); | ||
| }); | ||
|
|
||
| it("should ignore spaces", () => { | ||
| expect(isPalindrome("race car")).toBe(false); | ||
| expect(isPalindrome("taco cat")).toBe(true); | ||
| }); | ||
|
|
||
| it("should handle empty string", () => { | ||
| expect(isPalindrome("")).toBe(true); | ||
| }); | ||
|
|
||
| it("should handle single character", () => { | ||
| expect(isPalindrome("a")).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe("daysUntilBirthday", () => { | ||
| it("should calculate days until birthday in same year", () => { | ||
| // Birthday is later in the same year | ||
| expect(daysUntilBirthday(3, 15, 6, 15)).toBe(92); // March 15 to June 15 (roughly) | ||
| }); | ||
|
|
||
| it("should calculate days until birthday next year", () => { | ||
| // Birthday already passed this year | ||
| expect(daysUntilBirthday(6, 15, 3, 15)).toBe(273); // June 15 to March 15 next year (roughly) | ||
| }); | ||
|
|
||
| it("should return 0 if today is the birthday", () => { | ||
| expect(daysUntilBirthday(5, 20, 5, 20)).toBe(0); | ||
| }); | ||
|
|
||
| it("should handle birthdays tomorrow", () => { | ||
| expect(daysUntilBirthday(5, 20, 5, 21)).toBe(1); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,40 @@ | ||||||||
| /** | ||||||||
| * Finds the largest number in an array. | ||||||||
| * | ||||||||
| * @param numbers | ||||||||
| * @returns | ||||||||
|
||||||||
| * @returns | |
| * @param numbers {number[]} Array of numbers to find the largest from. | |
| * @returns {number} The largest number in the array. |
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| import * as jest from "@jest/globals"; | ||
| import { convertTemperature, findGCD, generateMultiplicationTable } from "./part_h.js"; | ||
|
|
||
| const describe = | ||
| !process.env.HW_VERSION || process.env.HW_VERSION === "H" | ||
| ? jest.describe | ||
| : jest.describe.skip; | ||
|
|
||
| describe("generateMultiplicationTable", () => { | ||
| it("should generate multiplication table for a given number", () => { | ||
| const result = generateMultiplicationTable(3); | ||
| expect(result).toEqual([ | ||
| "3 x 1 = 3", | ||
| "3 x 2 = 6", | ||
| "3 x 3 = 9", | ||
| "3 x 4 = 12", | ||
| "3 x 5 = 15", | ||
| "3 x 6 = 18", | ||
| "3 x 7 = 21", | ||
| "3 x 8 = 24", | ||
| "3 x 9 = 27", | ||
| "3 x 10 = 30" | ||
| ]); | ||
| }); | ||
|
|
||
| it("should handle multiplication table for 1", () => { | ||
| const result = generateMultiplicationTable(1); | ||
| expect(result[0]).toBe("1 x 1 = 1"); | ||
| expect(result[9]).toBe("1 x 10 = 10"); | ||
| expect(result.length).toBe(10); | ||
| }); | ||
| }); | ||
|
|
||
| describe("findGCD", () => { | ||
| it("should find GCD of two positive numbers", () => { | ||
| expect(findGCD(12, 8)).toBe(4); | ||
| expect(findGCD(15, 25)).toBe(5); | ||
| expect(findGCD(17, 13)).toBe(1); | ||
| expect(findGCD(100, 75)).toBe(25); | ||
| }); | ||
|
|
||
| it("should handle when one number is zero", () => { | ||
| expect(findGCD(5, 0)).toBe(5); | ||
| expect(findGCD(0, 7)).toBe(7); | ||
| }); | ||
|
|
||
| it("should handle identical numbers", () => { | ||
| expect(findGCD(7, 7)).toBe(7); | ||
| expect(findGCD(20, 20)).toBe(20); | ||
| }); | ||
|
|
||
| it("should handle when one number divides the other", () => { | ||
| expect(findGCD(20, 5)).toBe(5); | ||
| expect(findGCD(6, 18)).toBe(6); | ||
| }); | ||
|
|
||
| it("should handle order independence", () => { | ||
| expect(findGCD(8, 12)).toBe(4); | ||
| expect(findGCD(12, 8)).toBe(4); | ||
| }); | ||
| }); | ||
|
|
||
| describe("convertTemperature", () => { | ||
| it("should convert Celsius to Fahrenheit", () => { | ||
| expect(convertTemperature(0, "C", "F")).toBe(32); | ||
| expect(convertTemperature(100, "C", "F")).toBe(212); | ||
| expect(convertTemperature(25, "C", "F")).toBe(77); | ||
| }); | ||
|
|
||
| it("should convert Fahrenheit to Celsius", () => { | ||
| expect(convertTemperature(32, "F", "C")).toBe(0); | ||
| expect(convertTemperature(212, "F", "C")).toBe(100); | ||
| }); | ||
|
|
||
| it("should convert Celsius to Kelvin", () => { | ||
| expect(convertTemperature(0, "C", "K")).toBe(273.15); | ||
| expect(convertTemperature(25, "C", "K")).toBe(298.15); | ||
| }); | ||
|
|
||
| it("should convert Kelvin to Celsius", () => { | ||
| expect(convertTemperature(273.15, "K", "C")).toBe(0); | ||
| expect(convertTemperature(298.15, "K", "C")).toBe(25); | ||
| }); | ||
|
|
||
| it("should return same temperature for same scales", () => { | ||
| expect(convertTemperature(25, "C", "C")).toBe(25); | ||
| expect(convertTemperature(77, "F", "F")).toBe(77); | ||
| }); | ||
|
|
||
| it("should handle complex conversions", () => { | ||
| // F to K: (77°F - 32) × 5/9 + 273.15 = 298.15K | ||
| expect(convertTemperature(77, "F", "K")).toBeCloseTo(298.15, 2); | ||
| // K to F: (298.15K - 273.15) × 9/5 + 32 = 77°F | ||
| expect(convertTemperature(298.15, "K", "F")).toBeCloseTo(77, 2); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,38 @@ | ||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * Generates a multiplication table for the given number up to 10. | ||||||||||||||||||||||
| * Returns an array of strings in the format "number x 1 = result". | ||||||||||||||||||||||
| * | ||||||||||||||||||||||
| * @param number | ||||||||||||||||||||||
| * @returns | ||||||||||||||||||||||
|
||||||||||||||||||||||
| * @returns | |
| * @param {number} number - The number to generate the multiplication table for. | |
| * @returns {string[]} An array of strings representing the multiplication table. |
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @returns documentation is incomplete. It should describe what is returned, e.g., '@returns Array of strings representing the multiplication table'.
| * @returns | |
| * @param number The number for which to generate the multiplication table | |
| * @returns Array of strings representing the multiplication table for the given number |
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @param documentation is incomplete. It should include the parameter type and description, e.g., '@param temperature - The temperature value to convert'.
| * @param toScale | |
| * @param {number} temperature - The temperature value to convert. | |
| * @param {string} fromScale - The scale to convert from ("C", "F", or "K"). | |
| * @param {string} toScale - The scale to convert to ("C", "F", or "K"). |
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @param documentation is incomplete. It should include the parameter type and description, e.g., '@param fromScale - The source temperature scale (C, F, or K)'.
| * @returns | |
| * @param temperature {number} - The temperature value to convert. | |
| * @param fromScale {string} - The source temperature scale ("C", "F", or "K"). | |
| * @param toScale {string} - The target temperature scale ("C", "F", or "K"). | |
| * @returns {number} - The converted temperature value. |
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @param documentation is incomplete. It should include the parameter type and description, e.g., '@param toScale - The target temperature scale (C, F, or K)'.
| * @returns | |
| * @param temperature {number} The temperature value to convert. | |
| * @param fromScale {string} The scale to convert from ("C", "F", or "K"). | |
| * @param toScale {string} The scale to convert to ("C", "F", or "K"). | |
| * @returns {number} The converted temperature value. |
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @param documentation is incomplete. It should include the parameter type and description, e.g., '@param score - The numeric score to convert to a letter grade'.