rewrote
This commit is contained in:
@@ -85,6 +85,8 @@ When removing or refactoring legacy code:
|
|||||||
|
|
||||||
## Committing Changes
|
## 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.
|
* Ensure your editor uses **LF** line endings (`\n`) instead of CRLF.
|
||||||
* To automatically fix CRLF on commit:
|
* To automatically fix CRLF on commit:
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ from src.leaderboard import create_leaderboard_table, log_leaderboard, get_leade
|
|||||||
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
## from problem_loader import load_problems_from_json, schedule_problem_reload
|
|
||||||
from src.problem_scanner import start_problem_scanner
|
from src.problem_scanner import start_problem_scanner
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -26,7 +25,7 @@ db.init_app(app)
|
|||||||
def setup():
|
def setup():
|
||||||
db.create_all()
|
db.create_all()
|
||||||
create_leaderboard_table() # Ensure leaderboard table exists
|
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 the background thread to scan problems
|
||||||
start_problem_scanner()
|
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
|
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:
|
#def sortlist(lst = [4,3,2,1]) -> list:
|
||||||
#return sorted(lst)
|
#return sorted(lst)
|
||||||
|
|
||||||
class TestSolution(unittest.TestCase):
|
class TestSolution(unittest.TestCase):
|
||||||
def test_sort(self):
|
def test_sort(self):
|
||||||
# define x as a empty array.
|
test_cases=[
|
||||||
# this will be used for the functiun ; a empty var does not work.
|
([3,2,1],[1,2,3]),
|
||||||
self.x = []
|
([4,3,2,1],[1,2,3,4])
|
||||||
self.assertEqual(sortlist(self.x), sorted(self.x)) # pyright: ignore[reportUndefinedVariable]
|
]
|
||||||
|
|
||||||
|
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__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main(verbosity=2)
|
||||||
Reference in New Issue
Block a user