Skip to content

ltenetwork/DS-Leet-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DS LeetCode

A tiny LeetCode-style practice site for data science fundamentals: Python basics, Linear Regression, Logistic Regression, and PCA — all implemented from scratch with numpy (no scikit-learn).

Run it

pip install -r requirements.txt
streamlit run app.py

Then open the URL Streamlit prints (usually http://localhost:8501).

How it works

  • problems/ — each file defines one or more Problems: a title, markdown description, starter code, and a list of TestCases that check the learner's implementation (numeric tolerance checks, shape checks, accuracy thresholds, etc.), plus a spoiler reference solution.
  • executor.py — the "backend". Takes the code you typed in the editor, execs it in a namespace with a reduced builtins set + numpy available, under a 10s timeout, then runs each test case against that namespace and reports pass/fail with a message.
  • app.py — the Streamlit frontend: sidebar problem list with solved progress, a description pane, a code editor (st.text_area), and a "Run tests" button that calls the executor and renders results.

Adding a new problem

  1. Add a new function/Problem(...) to an existing file in problems/ (or create a new module) and wrap it in register(...).
  2. Import that module from problems/__init__.py if it's a new file.
  3. Write TestCases — each runner(namespace) -> (bool, message) receives the learner's exec'd globals dict, so pull functions out of it by name (e.g. ns["two_sum"]) and check behavior/tolerances rather than exact output for anything numeric/randomized.

Security note

The executor's sandboxing (restricted builtins + thread timeout) is meant for a personal/trusted-user practice tool run locally — it is not a hardened sandbox. Don't deploy this as-is to accept code from untrusted strangers on the public internet; run submissions in an isolated subprocess/container with real resource limits for that use case.

About

its for ds code test purpose

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages