Skip to content

Commit 10eaa00

Browse files
author
Jakub Jirous
committed
add index.md to each challenge, ts types refactoring
1 parent a2b94e3 commit 10eaa00

File tree

25 files changed

+345
-46
lines changed

25 files changed

+345
-46
lines changed

.github/labeler.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
code-challenge:
2+
- any: ["src/**/*.ts"]

.github/pull_request_template.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## NAME
2+
3+
- [Problem Description @ Code Signal](URL)
4+
5+
---
6+
7+
### PR Checklist:
8+
9+
- [ ] Understand the problem
10+
- You know what is known
11+
- You know what is unknown
12+
- You thought throw some edge cases that could potentially happen
13+
- [ ] Devise a plan
14+
- Writing a comment to code challenge what you want to do
15+
- Showing the ability to take that problem and break it down to the parts
16+
- Take the larger problem and take it down into smaller problems
17+
- [ ] Execute the plan
18+
- Turning into an actual code
19+
- [ ] Review your solution
20+
- Time to consider if there were a better approach
21+
- Backwards realizing room for improvements
22+
- [ ] Unit test
23+
- Cover your result with appropriate assertions
24+
25+
---
26+
27+
@octocat :+1: This PR looks great - it's ready to merge! :shipit:

.github/workflows/labeler.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: "Pull Request Labeler"
2+
3+
on:
4+
- pull_request_target
5+
6+
jobs:
7+
triage:
8+
name: "Labeler"
9+
permissions:
10+
contents: read
11+
pull-requests: write
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/labeler@v4
17+
with:
18+
repo-token: "${{ secrets.GITHUB_TOKEN }}"

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ In preparation for technical interviews, I discovered this platform that provide
1212

1313
<p align="center">
1414
<img src="https://sonarcloud.io/api/project_badges/measure?project=jakubjirous_code-signal&metric=coverage" alt="Coverage">
15+
<img src="https://sonarcloud.io/api/project_badges/measure?project=jakubjirous_code-signal&metric=code_smells" alt="Code Smells">
1516
<img src="https://sonarcloud.io/api/project_badges/measure?project=jakubjirous_code-signal&metric=ncloc" alt="Lines of Code">
1617
</p>
1718

@@ -23,16 +24,16 @@ In preparation for technical interviews, I discovered this platform that provide
2324

2425
#### The Journey Begins
2526

26-
1) [Add](/src/arcade/intro/01-add/)
27-
2) [Century From Year](/src/arcade/intro/02-century-from-year/)
28-
3) [Check Palindrome](/src/arcade/intro/03-check-palindrome/)
27+
1) [Add](/src/arcade/intro/01-add/INDEX.md)
28+
2) [Century From Year](/src/arcade/intro/02-century-from-year/INDEX.md)
29+
3) [Check Palindrome](/src/arcade/intro/03-check-palindrome/INDEX.md)
2930

3031
#### Edge Of The Ocean
3132

32-
4) [Adjacent Elements Product](/src/arcade/intro/04-adjacent-elements-product/)
33-
5) [Shape Area](/src/arcade/intro/05-shape-area/)
34-
6) [Make Array Consecutive](/src/arcade/intro/06-make-array-consecutive/)
35-
7) [Almost Increasing Sequence](/src/arcade/07-almost-increasing-sequence/)
33+
4) [Adjacent Elements Product](/src/arcade/intro/04-adjacent-elements-product/INDEX.md)
34+
5) [Shape Area](/src/arcade/intro/05-shape-area/INDEX.md)
35+
6) [Make Array Consecutive](/src/arcade/intro/06-make-array-consecutive/INDEX.md)
36+
7) [Almost Increasing Sequence](/src/arcade/intro/07-almost-increasing-sequence/INDEX.md)
3637

3738
---
3839

src/arcade/intro/01-add/INDEX.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Add
2+
3+
Write a function that returns the sum of two numbers.
4+
5+
---
6+
7+
### Example:
8+
9+
- For `param1 = 1` and `param2 = 2`, the output should be `solution(param1, param2) = 3`.
10+
11+
### Input/Output:
12+
13+
- **[execution time limit]** 5 seconds (ts)
14+
15+
16+
- **[input]** integer `param1`
17+
- Guaranteed constraints:
18+
- $-1000 \le param1 \le 1000$
19+
20+
21+
- **[input]** integer `param2`
22+
- Guaranteed constraints:
23+
- $-1000 \le param2 \le 1000$
24+
25+
26+
- **[output]** integer
27+
- The sum of the two inputs.
28+
29+
---
30+
31+
### Solution:
32+
33+
- [Code](/src/arcade/intro/01-add/add.ts)
34+
- [Tests](/src/arcade/intro/01-add/test/add.test.ts)

src/arcade/intro/01-add/add.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
export type Param1 = number;
2+
export type Param2 = number;
3+
export type Output = number;
4+
15
/**
26
* Write a function that returns the sum of two numbers.
37
*
48
* Example:
59
* - for param1 = 1 and param2 = 2, the output should be solution(param1, param2) = 3
610
*/
7-
export const add = (param1: number, param2: number): number => {
11+
export const add = (param1: Param1, param2: Param2): Output => {
812
return param1 + param2;
913
};

src/arcade/intro/01-add/test/add.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import { add } from "../add";
1+
import { add, Output, Param1, Param2 } from '../add';
22

3-
type FirstArg = number;
4-
type SecondArg = number;
5-
type ExpectedResult = number;
6-
type Cases = [FirstArg, SecondArg, ExpectedResult][];
3+
type Cases = [Param1, Param2, Output][];
74

85
/**
96
* Testing a function that returns the sum of two numbers.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Century From Year
2+
3+
Given a year, return the century it is in.
4+
5+
The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc.
6+
7+
---
8+
9+
### Example:
10+
11+
- For `year = 1905`, the output should be `centuryFromYear(year) = 20`
12+
- For `year = 1700`, the output should be `centuryFromYear(year) = 17`
13+
14+
### Input/Output:
15+
16+
- **[execution time limit]** 5 seconds (ts)
17+
18+
19+
- **[input]** integer `year`
20+
- A positive integer, designating the year.
21+
- Guaranteed constraints:
22+
- $1 \le year \le 2005$
23+
24+
25+
- **[output]** integer
26+
- The number of the century the year is in.
27+
28+
---
29+
30+
### Solution:
31+
32+
- [Code](/src/arcade/intro/02-century-from-year/century-from-year.ts)
33+
- [Tests](/src/arcade/intro/02-century-from-year/test/century-from-year.test.ts)
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
export type Input = number;
2+
export type Output = number;
3+
14
/**
25
* Given a year, return the century it is in.
36
* The first century spans from the year 1 up to and including the year 100,
47
* the second - from the year 101 up to and including the year 200, etc.
58
* @param year
69
*/
7-
export const centuryFromYear = (year: number): number => {
10+
export const centuryFromYear = (year: Input): Output => {
811
return Math.ceil(year / 100);
912
};

src/arcade/intro/02-century-from-year/test/century-from-year.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { centuryFromYear } from "../century-from-year";
1+
import { centuryFromYear, Input, Output } from '../century-from-year';
22

3-
type FirstArg = number;
4-
type ExpectedResult = number;
5-
type Cases = [FirstArg, ExpectedResult][];
3+
type Cases = [Input, Output][];
64

75
/**
86
* Given a year, return the century it is in.

0 commit comments

Comments
 (0)