Skip to content

Commit 281ff35

Browse files
authored
feat(challenge pack 1): add new challenge packages (#1)
1 parent 339d7bd commit 281ff35

51 files changed

Lines changed: 3612 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# **Role:**
2+
3+
You are to act as a **University Lecturer** in Computer Science. Your task is to design a set of programming challenges for students with varying levels of expertise, from first-year undergraduates to final-year students specializing in software development. Your tone should be encouraging and educational.
4+
5+
# **Objective:**
6+
7+
Generate a complete set of 10 programming challenges (5 for Python, 5 for C++) that can be integrated into this repository.
8+
9+
# **Primary Instructions:**
10+
11+
You must adhere strictly to the contribution guidelines outlined in this repository's `CONTRIBUTING.md` file and the workflow specifications from `.github/TEMPLATE_ACTION_WORKFLOW.yaml`.
12+
13+
For each of the 10 challenges, you must generate the complete file structure and content, including:
14+
15+
1. A **descriptive folder name** (e.g., `palindrome_checker`, `inventory_system`).
16+
2. A detailed **`README.md`** file containing:
17+
* `# Challenge Name`
18+
* `## 🎯 Description`: A clear, concise overview of the problem.
19+
* `## 🔍 Task`: Specific implementation details, including function/class names, parameters, and return types.
20+
* `## 📋 Requirements`: Language versions (Python 3.8+, C++20), standards (PEP 8, Google C++ Style Guide), and any constraints.
21+
* `## 🧪 Test Cases`: A comprehensive list of test cases, including basic, edge, and error-handling scenarios.
22+
3. **Solution Template Files**:
23+
* For Python: `solution.py` with function signatures and docstrings.
24+
* For C++: `solution.h` (with header guards) and `solution.cpp` with function/class declarations and empty implementations.
25+
4. **Test Files**:
26+
* For Python: `test_main.py` using the `unittest` module.
27+
* For C++: `test.cpp` using the `GoogleTest` framework.
28+
5. A **`CMakeLists.txt`** file for each C++ challenge, configured for `GoogleTest`.
29+
6. A **GitHub Actions workflow file** named `{language}_{challenge_folder_name}_ci.yaml` in the `.github/workflows/` directory. This file must be based on the provided template and include the mandatory, unmodified `points-system` job.
30+
31+
---
32+
33+
### **Challenge Specifications**
34+
35+
Generate the following challenges, ensuring a mix of difficulties as described.
36+
37+
#### **Python Challenges (5 total)**
38+
39+
1. **Beginner - Palindrome Checker:**
40+
* **Task**: Implement a function `is_palindrome(s: str) -> bool` that checks if a string is a palindrome, ignoring case and non-alphanumeric characters.
41+
2. **Beginner - Factorial Calculator:**
42+
* **Task**: Implement a function `factorial(n: int) -> int` that calculates the factorial of a non-negative integer. It should raise a `ValueError` for negative input.
43+
3. **Intermediate (OOP) - Simple Bank Account:**
44+
* **Task**: Implement a `BankAccount` class with methods for `deposit`, `withdraw`, and `get_balance`.
45+
* **Requirements**: The constructor should initialize the account with a starting balance. The `withdraw` method should prevent overdrawing.
46+
4. **Intermediate - CSV Data Parser:**
47+
* **Task**: Implement a function `parse_csv(file_path: str) -> list[dict]` that reads a CSV file and returns a list of dictionaries, where each dictionary represents a row.
48+
5. **Advanced (OOP) - Inventory Management System:**
49+
* **Task**: Implement two classes: `Product` and `Inventory`. The `Product` class will store item details (ID, name, price, quantity). The `Inventory` class will manage a collection of `Product` objects, with methods to add products, remove stock, and generate a report of all items.
50+
51+
#### **C++ Challenges (5 total)**
52+
53+
1. **Beginner - String Reverser:**
54+
* **Task**: Implement a function `std::string reverseString(const std::string& str)` that returns a reversed version of the input string.
55+
2. **Intermediate - Vector Statistics:**
56+
* **Task**: Implement a function `std::tuple<double, int, int> calculateVectorStats(const std::vector<int>& vec)` that returns the mean, minimum, and maximum values of an integer vector. It should handle empty vectors gracefully.
57+
3. **Intermediate (OOP) - Shape Hierarchy:**
58+
* **Task**: Implement a base class `Shape` with a virtual function `double area()`. Create two derived classes, `Circle` and `Rectangle`, that override the `area()` method.
59+
* **Requirements**: Use modern C++ features and proper class design.
60+
4. **Advanced - Integer Overflow Safe Addition:**
61+
* **Task**: Re-implement the `int add_numbers(int a, int b)` function from the `test_challenge`.
62+
* **Requirements**: This new version must correctly handle and throw exceptions for integer overflow and underflow cases as described in the original `cpp/test_challenge/README.md`.
63+
5. **Advanced (OOP) - Simple Smart Pointer:**
64+
* **Task**: Implement a basic `SimpleUniquePtr` template class that mimics the behavior of `std::unique_ptr`.
65+
* **Requirements**: It should manage a raw pointer, prevent copying, and correctly deallocate memory when it goes out of scope. It should implement a constructor, destructor, and overload the `*` and `->` operators.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: C++ Binary Search Tree CI
2+
3+
on:
4+
push:
5+
paths:
6+
- 'cpp/binary_search_tree/**'
7+
8+
defaults:
9+
run:
10+
shell: bash
11+
working-directory: ./cpp/binary_search_tree
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
test:
18+
name: Run Tests
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Build C++ solution
26+
uses: threeal/cmake-action@v2
27+
with:
28+
source-dir: cpp/binary_search_tree
29+
build-dir: ci-build
30+
31+
- name: Run C++ tests
32+
working-directory: ci-build/
33+
run: |
34+
ctest --output-on-failure
35+
36+
points-system:
37+
name: Award Points
38+
runs-on: ubuntu-latest
39+
needs: test
40+
defaults:
41+
run:
42+
shell: bash
43+
working-directory: .
44+
45+
steps:
46+
- name: Check secrets and increment points
47+
shell: bash
48+
run: |
49+
if [[ -n "${{ secrets.GKSS_LEADERBOARD_API_URL }}" && -n "${{ secrets.GKSS_LEADERBOARD_API_KEY }}" ]]; then
50+
echo "Incrementing points..."
51+
curl -X POST ${{ secrets.GKSS_LEADERBOARD_API_URL }} \
52+
-H "x-gkssunisa-api-key: ${{ secrets.GKSS_LEADERBOARD_API_KEY }}" \
53+
-H "Content-Type: application/json" \
54+
-d '{"message": "i did it! ${{ github.actor }}"}'
55+
else
56+
echo "Skipping points increment - required secrets not found"
57+
exit 1
58+
fi
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: C++ Prime Checker CI
2+
3+
on:
4+
push:
5+
paths:
6+
- 'cpp/prime_checker/**'
7+
8+
defaults:
9+
run:
10+
shell: bash
11+
working-directory: ./cpp/prime_checker
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
test:
18+
name: Run Tests
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Build C++ solution
26+
uses: threeal/cmake-action@v2
27+
with:
28+
source-dir: cpp/prime_checker
29+
build-dir: ci-build
30+
31+
- name: Run C++ tests
32+
working-directory: ci-build/
33+
run: |
34+
ctest --output-on-failure
35+
36+
points-system:
37+
name: Award Points
38+
runs-on: ubuntu-latest
39+
needs: test
40+
defaults:
41+
run:
42+
shell: bash
43+
working-directory: .
44+
45+
steps:
46+
- name: Check secrets and increment points
47+
shell: bash
48+
run: |
49+
if [[ -n "${{ secrets.GKSS_LEADERBOARD_API_URL }}" && -n "${{ secrets.GKSS_LEADERBOARD_API_KEY }}" ]]; then
50+
echo "Incrementing points..."
51+
curl -X POST ${{ secrets.GKSS_LEADERBOARD_API_URL }} \
52+
-H "x-gkssunisa-api-key: ${{ secrets.GKSS_LEADERBOARD_API_KEY }}" \
53+
-H "Content-Type: application/json" \
54+
-d '{"message": "i did it! ${{ github.actor }}"}'
55+
else
56+
echo "Skipping points increment - required secrets not found"
57+
exit 1
58+
fi
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: C++ Smart Array CI
2+
3+
on:
4+
push:
5+
paths:
6+
- 'cpp/smart_array/**'
7+
8+
defaults:
9+
run:
10+
shell: bash
11+
working-directory: ./cpp/smart_array
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
test:
18+
name: Run Tests
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Build C++ solution
26+
uses: threeal/cmake-action@v2
27+
with:
28+
source-dir: cpp/smart_array
29+
build-dir: ci-build
30+
31+
- name: Run C++ tests
32+
working-directory: ci-build/
33+
run: |
34+
ctest --output-on-failure
35+
36+
points-system:
37+
name: Award Points
38+
runs-on: ubuntu-latest
39+
needs: test
40+
defaults:
41+
run:
42+
shell: bash
43+
working-directory: .
44+
45+
steps:
46+
- name: Check secrets and increment points
47+
shell: bash
48+
run: |
49+
if [[ -n "${{ secrets.GKSS_LEADERBOARD_API_URL }}" && -n "${{ secrets.GKSS_LEADERBOARD_API_KEY }}" ]]; then
50+
echo "Incrementing points..."
51+
curl -X POST ${{ secrets.GKSS_LEADERBOARD_API_URL }} \
52+
-H "x-gkssunisa-api-key: ${{ secrets.GKSS_LEADERBOARD_API_KEY }}" \
53+
-H "Content-Type: application/json" \
54+
-d '{"message": "i did it! ${{ github.actor }}"}'
55+
else
56+
echo "Skipping points increment - required secrets not found"
57+
exit 1
58+
fi
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: C++ String Reverser CI
2+
3+
on:
4+
push:
5+
paths:
6+
- 'cpp/string_reverser/**'
7+
8+
defaults:
9+
run:
10+
shell: bash
11+
working-directory: ./cpp/string_reverser
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
test:
18+
name: Run Tests
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Build C++ solution
26+
uses: threeal/cmake-action@v2
27+
with:
28+
source-dir: cpp/string_reverser
29+
build-dir: ci-build
30+
31+
- name: Run C++ tests
32+
working-directory: ci-build/
33+
run: |
34+
ctest --output-on-failure
35+
36+
points-system:
37+
name: Award Points
38+
runs-on: ubuntu-latest
39+
needs: test
40+
defaults:
41+
run:
42+
shell: bash
43+
working-directory: .
44+
45+
steps:
46+
- name: Check secrets and increment points
47+
shell: bash
48+
run: |
49+
if [[ -n "${{ secrets.GKSS_LEADERBOARD_API_URL }}" && -n "${{ secrets.GKSS_LEADERBOARD_API_KEY }}" ]]; then
50+
echo "Incrementing points..."
51+
curl -X POST ${{ secrets.GKSS_LEADERBOARD_API_URL }} \
52+
-H "x-gkssunisa-api-key: ${{ secrets.GKSS_LEADERBOARD_API_KEY }}" \
53+
-H "Content-Type: application/json" \
54+
-d '{"message": "i did it! ${{ github.actor }}"}'
55+
else
56+
echo "Skipping points increment - required secrets not found"
57+
exit 1
58+
fi
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: C++ Vector Math CI
2+
3+
on:
4+
push:
5+
paths:
6+
- 'cpp/vector_math/**'
7+
8+
defaults:
9+
run:
10+
shell: bash
11+
working-directory: ./cpp/vector_math
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
test:
18+
name: Run Tests
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Build C++ solution
26+
uses: threeal/cmake-action@v2
27+
with:
28+
source-dir: cpp/vector_math
29+
build-dir: ci-build
30+
31+
- name: Run C++ tests
32+
working-directory: ci-build/
33+
run: |
34+
ctest --output-on-failure
35+
36+
points-system:
37+
name: Award Points
38+
runs-on: ubuntu-latest
39+
needs: test
40+
defaults:
41+
run:
42+
shell: bash
43+
working-directory: .
44+
45+
steps:
46+
- name: Check secrets and increment points
47+
shell: bash
48+
run: |
49+
if [[ -n "${{ secrets.GKSS_LEADERBOARD_API_URL }}" && -n "${{ secrets.GKSS_LEADERBOARD_API_KEY }}" ]]; then
50+
echo "Incrementing points..."
51+
curl -X POST ${{ secrets.GKSS_LEADERBOARD_API_URL }} \
52+
-H "x-gkssunisa-api-key: ${{ secrets.GKSS_LEADERBOARD_API_KEY }}" \
53+
-H "Content-Type: application/json" \
54+
-d '{"message": "i did it! ${{ github.actor }}"}'
55+
else
56+
echo "Skipping points increment - required secrets not found"
57+
exit 1
58+
fi

0 commit comments

Comments
 (0)