rewrote
This commit is contained in:
@@ -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:
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -1 +1,14 @@
|
||||
this is a easy sorting problem **it is solvable in less than 2 seconds**
|
||||
## 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)
|
||||
@@ -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()
|
||||
unittest.main(verbosity=2)
|
||||
Reference in New Issue
Block a user