messages listlengths 2 634 |
|---|
[
{
"role": "user",
"content": "Implement Dijkstra's shortest path in Python (stdlib only) as a package: dijkstra/graph.py with `shortest_paths(adj: dict[str, list[tuple[str, float]]], src: str) -> dict[str, float]` using heapq, and dijkstra/cli.py that reads an edge list file (lines: \"u v weight\") plus a s... |
[
{
"role": "user",
"content": "In TypeScript, implement topological sort with useful cycle diagnostics. Set up a minimal npm project (package.json, tsconfig.json, vitest). src/toposort.ts exports `toposort(edges: [string, string][]): { order: string[] } | { cycle: string[] }` β Kahn's algorithm; when a cycle... |
[
{
"role": "user",
"content": "Build a max-flow module in Python: dinic.py with a Dinic's algorithm implementation (BFS level graph + DFS blocking flow, adjacency via edge arrays with reverse-edge indices). Deliverables: `class Dinic` with add_edge(u, v, cap) and max_flow(s, t); a `bipartite_matching(left, r... |
[
{
"role": "user",
"content": "Write tarjan.py implementing Tarjan's strongly connected components algorithm iteratively (no recursion, so it survives a 50k-node path graph without hitting Python's recursion limit). API: `scc(adj: dict[int, list[int]]) -> list[list[int]]` returning components in reverse topo... |
[
{
"role": "user",
"content": "Kruskal MST with a proper disjoint-set union. Write mst.py: DSU class (path compression + union by size), and `minimum_spanning_forest(n, edges)` where edges are (w, u, v), returning (total_weight, chosen_edges). Handle disconnected graphs (forest, not error). Then verify it th... |
[
{
"role": "user",
"content": "Bellman-Ford that doesn't just say \"negative cycle: yes\" β it must return an actual cycle. Python file bellman_ford.py: `shortest_paths(n, edges, src)` returns dist list, and if a negative cycle is reachable from src, raise NegativeCycleError carrying `.cycle`, a list of vert... |
[{"role":"user","content":"Implement A* pathfinding on a 2D grid in Python and prove the heuristic m(...TRUNCATED) |
[{"role":"user","content":"Write bridges.py finding all bridges and articulation points of an undire(...TRUNCATED) |
[{"role":"user","content":"Quick one: word-ladder shortest transformation with BFS. Python script la(...TRUNCATED) |
[{"role":"user","content":"Node.js task, plain JavaScript with the built-in node:test runner. Implem(...TRUNCATED) |
End of preview. Expand in Data Studio
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
- Downloads last month
- -