Skip to content

Commit 615c47c

Browse files
authored
feat: adds lesson_06 homework and lesson_07 pre-work (code-differently#277)
* chore: adds lesson_06 details and lesson_07 pre-work Signed-off-by: Anthony D. Mays <[email protected]> * chore: remove hint Signed-off-by: Anthony D. Mays <[email protected]> --------- Signed-off-by: Anthony D. Mays <[email protected]>
1 parent 9e65c24 commit 615c47c

20 files changed

+7178
-1
lines changed

lesson_06/README.md

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,87 @@ Please review the following resources before lecture:
88

99
## Homework
1010

11-
- TODO(anthonydmays): Add details on Monday
11+
- [ ] Complete the [Expression Calculator](#expression-calculator) exercise.
12+
- [ ] Read article entitled [3 Questions That Will Make You A Phenomenal Rubber Duck][article-link]
13+
- [ ] Do pre-work for [lesson 07](/lesson_07/).
14+
15+
### Expression Calculator
16+
17+
For this assignment, you will need to implement the functions and logic required to calculate a mathematical expression. After implementing the `add`, `divide`, and `multiply` functions, you will combine these functions to compute the final result.
18+
19+
1. Update the [.env.test][env-file] file to configure the correct homework version.
20+
```bash
21+
# Example config for students assigned to homework "D".
22+
HW_VERSION=D
23+
```
24+
2. Run the program to determine the expression you must implement.
25+
```bash
26+
npm install
27+
npm run compile
28+
npm start
29+
```
30+
1. Update the code in the [expression_calculator.ts][calculator-file] file.
31+
2. To check your work, you can run the application using the first command below and run the tests using the second one.
32+
```bash
33+
npm start
34+
```
35+
1. As usual, make sure that you format your code and run the check command before creating your pull request.
36+
```bash
37+
npm run check
38+
```
39+
1. You must only submit changes to the `expression_calculator.ts` file to receive full credit.
40+
41+
### Stretch Assignment
42+
43+
Implement a function that validates whether a given alphabetic abbreviation matches a word using a special encoding system.
44+
45+
In this system, numbers in abbreviations are replaced by their corresponding alphabet letters:
46+
- 'a' represents 1, 'b' represents 2, 'c' represents 3, ..., 'z' represents 26
47+
- The abbreviation follows the same rules as standard abbreviations but uses letters instead of digits
48+
- Letters cannot have leading zeros (e.g., no 'aa' for 01)
49+
- Adjacent abbreviated substrings are not allowed
50+
- Empty substrings cannot be abbreviated
51+
52+
**Function Signature:**
53+
```typescript
54+
function isValidAlphaAbbreviation(word: string, abbr: string): boolean
55+
```
56+
57+
**Examples:**
58+
59+
Example 1:
60+
```
61+
Input: word = "internationalization", abbr = "irzdn"
62+
Output: true
63+
Explanation:
64+
- "internationalization" can be abbreviated as "i m z d n"
65+
- i + (m=13 chars) + z + (d=4 chars) + n
66+
- i + nternationaliza + z + atio + n = "internationalization"
67+
```
68+
69+
Example 2:
70+
```
71+
Input: word = "substitution", abbr = "sjn"
72+
Output: true
73+
Explanation:
74+
- s + (j=10 chars) + n
75+
- s + ubstitutio + n = "substitution"
76+
```
77+
78+
**Invalid Examples:**
79+
```
80+
Input: word = "test", abbr = "ab"
81+
Output: false
82+
Explanation: Adjacent letters 'a' and 'b' would represent adjacent abbreviated substrings
83+
```
84+
85+
**Constraints:**
86+
- 1 ≤ word.length ≤ 25
87+
- 1 ≤ abbr.length ≤ 15
88+
- word consists of only lowercase English letters
89+
- abbr consists of only lowercase English letters
90+
- Letters representing numbers follow a=1, b=2, ..., z=26
91+
92+
[article-link]: https://blog.danslimmon.com/2024/01/18/3-questions-that-will-make-you-a-phenomenal-rubber-duck/
93+
[calculator-file]: ./expression/src/expression_calculator.ts
94+
[env-file]: ./expression/.env.test

lesson_06/expression/.editorconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
insert_final_newline = true

lesson_06/expression/.env.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
HW_VERSION=your assigned version here

lesson_06/expression/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
build/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore artifacts:
2+
build
3+
coverage

lesson_06/expression/.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// @ts-check
2+
3+
import eslint from "@eslint/js";
4+
import tseslint from "typescript-eslint";
5+
import eslintConfigPrettier from "eslint-config-prettier";
6+
7+
export default tseslint.config(
8+
eslint.configs.recommended,
9+
...tseslint.configs.strict,
10+
...tseslint.configs.stylistic,
11+
eslintConfigPrettier,
12+
{
13+
ignores: ["build"],
14+
},
15+
);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} **/
2+
export default {
3+
testEnvironment: "node",
4+
transform: {
5+
"^.+.tsx?$": ["ts-jest", { useESM: true }],
6+
},
7+
moduleNameMapper: {
8+
"^(\\.\\.?\\/.+)\\.js$": "$1",
9+
},
10+
extensionsToTreatAsEsm: [".ts"],
11+
};

0 commit comments

Comments
 (0)