Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
34 changes: 34 additions & 0 deletions src/__test__/onboarding/auleenadas/01-algorithm.test.ts
Original file line number Diff line number Diff line change
@@ -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]);
});
});
46 changes: 46 additions & 0 deletions src/onboarding/auleenadas/01-algorithm.ts
Original file line number Diff line number Diff line change
@@ -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;
}
20 changes: 20 additions & 0 deletions src/onboarding/auleenadas/02-tsdoc.ts
Original file line number Diff line number Diff line change
@@ -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}`;
}
32 changes: 32 additions & 0 deletions src/onboarding/auleenadas/03-type-errors.ts
Original file line number Diff line number Diff line change
@@ -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);
21 changes: 21 additions & 0 deletions src/onboarding/auleenadas/04-lint.ts
Original file line number Diff line number Diff line change
@@ -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);
}
19 changes: 19 additions & 0 deletions src/onboarding/auleenadas/05-formatting.ts
Original file line number Diff line number Diff line change
@@ -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));
}
Loading