From 996cfd282134daa74c48c70e625927143fc282a4 Mon Sep 17 00:00:00 2001 From: rattatwinko Date: Sun, 17 Aug 2025 16:04:13 +0200 Subject: [PATCH] rewrote --- readme.md | 2 ++ src/app.py | 3 +-- src/problems/sortlist/description.md | 15 ++++++++++++++- src/problems/sortlist/test.py | 25 +++++++++++++++++-------- 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/readme.md b/readme.md index 48c56a8..aefefe7 100644 --- a/readme.md +++ b/readme.md @@ -85,6 +85,8 @@ When removing or refactoring legacy code: ## Committing Changes +**WE NEED FRONTED PEOPLE!!**, I have no Idea how that works, please someone ( if they are interested help ) + * Ensure your editor uses **LF** line endings (`\n`) instead of CRLF. * To automatically fix CRLF on commit: diff --git a/src/app.py b/src/app.py index 02d9801..4983e22 100644 --- a/src/app.py +++ b/src/app.py @@ -8,7 +8,6 @@ from src.leaderboard import create_leaderboard_table, log_leaderboard, get_leade import os -## from problem_loader import load_problems_from_json, schedule_problem_reload from src.problem_scanner import start_problem_scanner import sqlite3 from pathlib import Path @@ -26,7 +25,7 @@ db.init_app(app) def setup(): db.create_all() create_leaderboard_table() # Ensure leaderboard table exists - # Problems are now loaded from manifests by the background scanner. No need to load problems.json. + # Problems are loaded from manifests by the background scanner ; running on a different thread. No need to load problems.json. # Start the background thread to scan problems start_problem_scanner() diff --git a/src/problems/sortlist/description.md b/src/problems/sortlist/description.md index 72acc64..bbb427f 100644 --- a/src/problems/sortlist/description.md +++ b/src/problems/sortlist/description.md @@ -1 +1,14 @@ -this is a easy sorting problem **it is solvable in less than 2 seconds** \ No newline at end of file +## Sorting a List + +In this example you are given a Task: **Sort a List of _say_ Apples**. + +## Function Signature: + +```python +def sortlist(lst: list) -> list: + return # Your solution +``` + +Using the Type Inferrence gives you a Idea of what to return. You may freely choose to type or not to. The Python Interpreter does not care about Type Inferrence + +Sorting manually may be tedious. Look at the [PyDocs](https://docs.python.org/3/howto/sorting.html#sorting-basics) \ No newline at end of file diff --git a/src/problems/sortlist/test.py b/src/problems/sortlist/test.py index 2c21403..83f2c18 100644 --- a/src/problems/sortlist/test.py +++ b/src/problems/sortlist/test.py @@ -1,17 +1,26 @@ import unittest -# This is the function the user is expected to write. -# Its a really simple one, the user can choose not to type tho. - #def sortlist(lst = [4,3,2,1]) -> list: #return sorted(lst) class TestSolution(unittest.TestCase): def test_sort(self): - # define x as a empty array. - # this will be used for the functiun ; a empty var does not work. - self.x = [] - self.assertEqual(sortlist(self.x), sorted(self.x)) # pyright: ignore[reportUndefinedVariable] + test_cases=[ + ([3,2,1],[1,2,3]), + ([4,3,2,1],[1,2,3,4]) + ] + + print("\n Function Output Test Results: ") + for input_val, expected in test_cases: + try: + actual = sortlist(input_val) # pyright: ignore[reportUndefinedVariable] + status = "PASS" if actual == expected else "FAIL" + print(f"{status} | Input: '{input_val}' -> Got: '{actual}' | Expected: '{expected}'") + self.assertEqual(actual,expected) + except Exception as e: + print(f"ERROR | Input: '{input_val}' -> Exception: {e}") + raise + if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main(verbosity=2) \ No newline at end of file