diff --git a/src/__test__/onboarding/auleenadas/01-algorithm.test.ts b/src/__test__/onboarding/auleenadas/01-algorithm.test.ts new file mode 100644 index 0000000..921099e --- /dev/null +++ b/src/__test__/onboarding/auleenadas/01-algorithm.test.ts @@ -0,0 +1,34 @@ +/** + * Exercise 1 test scaffold. + * + * Full instructions: ../../../docs/exercises/01-algorithms-and-testing.md + */ + +import { describe, it, expect } from 'vitest'; + +import { mergeSortedNumbers } from '../../../onboarding/auleenadas/01-algorithm.ts'; + +/** + * Exercise 1 tests for auleenadas. + */ +describe('mergeSortedNumbers', () => { + it('merges values from both arrays in ascending order', () => { + const result = mergeSortedNumbers([1, 3, 5], [2, 4, 6]); + expect(result).toEqual([1, 2, 3, 4, 5, 6]); + }); + + it('returns a new array instead of mutating either input', () => { + const left = [1, 3]; + const right = [2, 4]; + const result = mergeSortedNumbers(left, right); + + expect(result).toEqual([1, 2, 3, 4]); + expect(left).toEqual([1, 3]); // unchanged + expect(right).toEqual([2, 4]); // unchanged + }); + + it('handles one empty array', () => { + expect(mergeSortedNumbers([], [1, 2, 3])).toEqual([1, 2, 3]); + expect(mergeSortedNumbers([1, 2, 3], [])).toEqual([1, 2, 3]); + }); +}); diff --git a/src/onboarding/auleenadas/01-algorithm.ts b/src/onboarding/auleenadas/01-algorithm.ts new file mode 100644 index 0000000..8d48e52 --- /dev/null +++ b/src/onboarding/auleenadas/01-algorithm.ts @@ -0,0 +1,46 @@ +/** + * Exercise: Algorithm and testing + * Developer: auleenadas + * Instructions: ../../../docs/exercises/01-algorithms-and-testing.md + */ + +/** + * Exercise 1: auleenadas must implement a small algorithm and add tests for it. + * + * Goal: merge two sorted arrays into a new sorted array without mutating either input. + */ + +/** + * Combines two ascending arrays into one ascending array. + * + * @param left The first sorted list. + * @param right The second sorted list. + * @returns A new sorted list containing the values from both inputs. + */ +export function mergeSortedNumbers(left: number[], right: number[]): number[] { + const result: number[] = []; + let i = 0; // pointer for left + let j = 0; // pointer for right + + while (i < left.length && j < right.length) { + if (left[i] <= right[j]) { + result.push(left[i]); + i++; + } else { + result.push(right[j]); + j++; + } + } + + // one array may have leftover elements — add them all + while (i < left.length) { + result.push(left[i]); + i++; + } + while (j < right.length) { + result.push(right[j]); + j++; + } + + return result; +} diff --git a/src/onboarding/auleenadas/02-tsdoc.ts b/src/onboarding/auleenadas/02-tsdoc.ts new file mode 100644 index 0000000..4d1b05b --- /dev/null +++ b/src/onboarding/auleenadas/02-tsdoc.ts @@ -0,0 +1,20 @@ +/** + * Exercise: TSDoc + * Developer: auleenadas + * Instructions: ../../../docs/exercises/02-writing-tsdoc-comments.md + */ + +// Exercise 2: replace the placeholder TSDoc with complete documentation. + +/** + * Formats a person's first and last name into a single display string, + * with the last name listed first, followed by the first name. + * + * @param firstName The person's first name. + * @param lastName The person's last name. + * @returns The formatted full name in "lastName, firstName" order. + */ + +export function formatFullName(firstName: string, lastName: string): string { + return `${lastName}, ${firstName}`; +} diff --git a/src/onboarding/auleenadas/03-type-errors.ts b/src/onboarding/auleenadas/03-type-errors.ts new file mode 100644 index 0000000..f5e77df --- /dev/null +++ b/src/onboarding/auleenadas/03-type-errors.ts @@ -0,0 +1,32 @@ +/** + * Exercise: Type errors + * Developer: auleenadas + * Instructions: ../../../docs/exercises/03-fixing-type-errors.md + */ + +/** + * Exercise 3: fix the type errors in this file without changing the overall behavior. + */ + +type TeamMember = { + name: string; + commits: number; +}; + +/** + * Formats a team activity summary. + * + * @param member The team member to summarize. + * @returns A human-readable summary string. + */ +export function formatTeamSummary(member: TeamMember): string { + return `${member.name} pushed ${member.commits} commits this week.`; +} + +const newestMember: TeamMember = { + name: 'Avery', + + commits: 5, +}; + +formatTeamSummary(newestMember); diff --git a/src/onboarding/auleenadas/04-lint.ts b/src/onboarding/auleenadas/04-lint.ts new file mode 100644 index 0000000..4e701a3 --- /dev/null +++ b/src/onboarding/auleenadas/04-lint.ts @@ -0,0 +1,21 @@ +/** + * Exercise: Lint + * Developer: auleenadas + * Instructions: ../../../docs/exercises/04-fixing-linting-issues.md + */ + +/** + * Exercise 4: clean up the lint issues in this file. + */ + +/** + * Normalizes a repository name. + * + * @param repositoryName The raw repository name. + * @returns The normalized repository name. + */ +export function normalizeRepositoryName(repositoryName: string): string { + const metadata: { source: string } = { source: 'manual' }; + + return repositoryName.trim().toLowerCase() + metadata.source.slice(0, 0); +} diff --git a/src/onboarding/auleenadas/05-formatting.ts b/src/onboarding/auleenadas/05-formatting.ts new file mode 100644 index 0000000..ea85aa9 --- /dev/null +++ b/src/onboarding/auleenadas/05-formatting.ts @@ -0,0 +1,19 @@ +/** + * Exercise: Formatting + * Developer: auleenadas + * Instructions: ../../../docs/exercises/05-fixing-formatting.md + */ + +/** + * Exercise 5: reformat this file so it matches the project's normal style. + */ + +/** + * Sorts team names alphabetically. + * + * @param teams The names to sort. + * @returns A new sorted array. + */ +export function sortTeams(teams: string[]): string[] { + return [...teams].sort((left, right) => left.localeCompare(right)); +}