conversations listlengths 2 2 | source stringclasses 8
values |
|---|---|
[
{
"role": "user",
"content": "Write code for `dijkstra` (a weighted graph dict and start) that compute shortest paths with Dijkstra. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for ... | algorithms |
[
{
"role": "user",
"content": "Formulate `dijkstra` to compute shortest paths with Dijkstra. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for node in graph}\n distances[start] = 0\... | algorithms |
[
{
"role": "user",
"content": "Implement `dijkstra` returning a distance dict given a weighted graph dict and start. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for node in graph}\n ... | algorithms |
[
{
"role": "user",
"content": "Write code for `dijkstra` (a weighted graph dict and start) that compute shortest paths with Dijkstra. Use only the standard library."
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for ... | algorithms |
[
{
"role": "user",
"content": "Define a function `dijkstra` taking a weighted graph dict and start and returning a distance dict. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for node... | algorithms |
[
{
"role": "user",
"content": "Code a function `dijkstra` to compute shortest paths with Dijkstra. Avoid mutating the input."
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for node in graph}\n distances[start] = 0... | algorithms |
[
{
"role": "user",
"content": "Implement `dijkstra` with proper validation: compute shortest paths with Dijkstra. Keep it efficient."
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for node in graph}\n distances[st... | algorithms |
[
{
"role": "user",
"content": "Write a Python function `dijkstra` that compute shortest paths with Dijkstra. Avoid mutating the input."
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for node in graph}\n distances[... | algorithms |
[
{
"role": "user",
"content": "Implement `dijkstra(a weighted graph dict and start)` to compute shortest paths with Dijkstra. Include basic type checks."
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for node in grap... | algorithms |
[
{
"role": "user",
"content": "Can you write code for `dijkstra` that compute shortest paths with Dijkstra? Include basic type checks."
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for node in graph}\n distances[... | algorithms |
[
{
"role": "user",
"content": "Implement the function `dijkstra` (a weighted graph dict and start) -> a distance dict. Add a brief docstring."
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for node in graph}\n dis... | algorithms |
[
{
"role": "user",
"content": "Define a function `dijkstra` taking a weighted graph dict and start and returning a distance dict. "
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for node in graph}\n distances[star... | algorithms |
[
{
"role": "user",
"content": "Generate a Python function `dijkstra` for compute shortest paths with Dijkstra. Keep it efficient."
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for node in graph}\n distances[start... | algorithms |
[
{
"role": "user",
"content": "Please provide `topological_sort` that topologically sort a DAG. Include basic type checks."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n for node i... | algorithms |
[
{
"role": "user",
"content": "I need a Python helper `topological_sort` that topologically sort a DAG. "
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n for node in graph:\n ... | algorithms |
[
{
"role": "user",
"content": "Create `topological_sort(a graph dict)` returning a topological order. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in gr... | algorithms |
[
{
"role": "user",
"content": "Formulate `topological_sort` to topologically sort a DAG. Avoid mutating the input."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n for node in graph:... | algorithms |
[
{
"role": "user",
"content": "Construct `topological_sort` to topologically sort a DAG. Keep it efficient."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n for node in graph:\n ... | algorithms |
[
{
"role": "user",
"content": "Implement `topological_sort(a graph dict)` to topologically sort a DAG. "
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n for node in graph:\n f... | algorithms |
[
{
"role": "user",
"content": "Develop `topological_sort` such that it topologically sort a DAG. Keep it efficient."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n for node in graph... | algorithms |
[
{
"role": "user",
"content": "Create a utility function named `topological_sort` which topologically sort a DAG. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node i... | algorithms |
[
{
"role": "user",
"content": "I need a Python helper `topological_sort` that topologically sort a DAG. Keep it efficient."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n for node i... | algorithms |
[
{
"role": "user",
"content": "Produce a clean implementation of `topological_sort`: topologically sort a DAG. Use only the standard library."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in gra... | algorithms |
[
{
"role": "user",
"content": "Write a reusable function `topological_sort` which topologically sort a DAG. Use only the standard library."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}... | algorithms |
[
{
"role": "user",
"content": "Make a function `topological_sort` to topologically sort a DAG. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n for nod... | algorithms |
[
{
"role": "user",
"content": "Write a reusable function `topological_sort` which topologically sort a DAG. Avoid mutating the input."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n ... | algorithms |
[
{
"role": "user",
"content": "Produce a clean implementation of `topological_sort`: topologically sort a DAG. Include basic type checks."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\... | algorithms |
[
{
"role": "user",
"content": "Help me write `topological_sort` that topologically sort a DAG. Avoid mutating the input."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n for node in ... | algorithms |
[
{
"role": "user",
"content": "Define a function `topological_sort` taking a graph dict and returning a topological order. "
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n for node ... | algorithms |
[
{
"role": "user",
"content": "Implement `topological_sort` returning a topological order given a graph dict. Include basic type checks."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n... | algorithms |
[
{
"role": "user",
"content": "Generate a Python function `topological_sort` for topologically sort a DAG. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\... | algorithms |
[
{
"role": "user",
"content": "Code a function `topological_sort` to topologically sort a DAG. "
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n for node in graph:\n for neigh... | algorithms |
[
{
"role": "user",
"content": "Construct `topological_sort` to topologically sort a DAG. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n for node in... | algorithms |
[
{
"role": "user",
"content": "Write code for `topological_sort` (a graph dict) that topologically sort a DAG. Include basic type checks."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\... | algorithms |
[
{
"role": "user",
"content": "Write code for `topological_sort` (a graph dict) that topologically sort a DAG. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in gra... | algorithms |
[
{
"role": "user",
"content": "Define a function `topological_sort` taking a graph dict and returning a topological order. Avoid mutating the input."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node... | algorithms |
[
{
"role": "user",
"content": "Write `topological_sort` in Python. It should topologically sort a DAG. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n ... | algorithms |
[
{
"role": "user",
"content": "Implement `topological_sort` with proper validation: topologically sort a DAG. Add a brief docstring."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n ... | algorithms |
[
{
"role": "user",
"content": "Formulate `topological_sort` to topologically sort a DAG. Include basic type checks."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n for node in graph... | algorithms |
[
{
"role": "user",
"content": "Generate a Python function `topological_sort` for topologically sort a DAG. Include basic type checks."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n ... | algorithms |
[
{
"role": "user",
"content": "Help me write `topological_sort` that topologically sort a DAG. Use only the standard library."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n for nod... | algorithms |
[
{
"role": "user",
"content": "Implement the function `topological_sort` (a graph dict) -> a topological order. Add a brief docstring."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n ... | algorithms |
[
{
"role": "user",
"content": "Write a Python function `topological_sort` that topologically sort a DAG. Keep it efficient."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 for node in graph}\n for node ... | algorithms |
[
{
"role": "user",
"content": "Build a function `topological_sort` that topologically sort a DAG, with edge-case handling. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef topological_sort(graph: dict) -> list:\n indegree = {node: 0 f... | algorithms |
[
{
"role": "user",
"content": "Construct `lis` to compute length of longest increasing subsequence. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n ... | algorithms |
[
{
"role": "user",
"content": "Produce a clean implementation of `lis`: compute length of longest increasing subsequence. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums... | algorithms |
[
{
"role": "user",
"content": "Implement `lis`. It should compute length of longest increasing subsequence. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if no... | algorithms |
[
{
"role": "user",
"content": "Write `lis`: compute length of longest increasing subsequence. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if not nums:\n... | algorithms |
[
{
"role": "user",
"content": "Construct `lis` to compute length of longest increasing subsequence. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if not nums:\... | algorithms |
[
{
"role": "user",
"content": "Please provide `lis` that compute length of longest increasing subsequence. "
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if not nums:\n return 0\... | algorithms |
[
{
"role": "user",
"content": "Make a function `lis` to compute length of longest increasing subsequence. Add a brief docstring."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if not num... | algorithms |
[
{
"role": "user",
"content": "Write a Python function `lis` that compute length of longest increasing subsequence. Include basic type checks."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n... | algorithms |
[
{
"role": "user",
"content": "Implement `lis` with proper validation: compute length of longest increasing subsequence. Add a brief docstring."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\... | algorithms |
[
{
"role": "user",
"content": "Define a function `lis` taking a list nums and returning the LIS length. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if not nu... | algorithms |
[
{
"role": "user",
"content": "Construct `lis` to compute length of longest increasing subsequence. Add a brief docstring."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if not nums:\n ... | algorithms |
[
{
"role": "user",
"content": "Create `lis(a list nums)` returning the LIS length. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if not nums:\n ... | algorithms |
[
{
"role": "user",
"content": "Write `lis` in Python. It should compute length of longest increasing subsequence. Include basic type checks."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n ... | algorithms |
[
{
"role": "user",
"content": "Create a utility function named `lis` which compute length of longest increasing subsequence. "
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if not nums:\... | algorithms |
[
{
"role": "user",
"content": "Create a robust `lis` that compute length of longest increasing subsequence. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a lis... | algorithms |
[
{
"role": "user",
"content": "Can you write code for `lis` that compute length of longest increasing subsequence? Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list... | algorithms |
[
{
"role": "user",
"content": "Construct `lis` to compute length of longest increasing subsequence. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if not n... | algorithms |
[
{
"role": "user",
"content": "Draft a Python function `lis` to compute length of longest increasing subsequence. "
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if not nums:\n re... | algorithms |
[
{
"role": "user",
"content": "Generate a Python function `lis` for compute length of longest increasing subsequence. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a lis... | algorithms |
[
{
"role": "user",
"content": "Implement `lis(a list nums)` to compute length of longest increasing subsequence. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n ... | algorithms |
[
{
"role": "user",
"content": "Code a function `lis` to compute length of longest increasing subsequence. Keep it efficient."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if not nums:\n... | algorithms |
[
{
"role": "user",
"content": "Implement `lis(a list nums)` to compute length of longest increasing subsequence. Add a brief docstring."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if ... | algorithms |
[
{
"role": "user",
"content": "Develop `lis` such that it compute length of longest increasing subsequence. Add a brief docstring."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if not n... | algorithms |
[
{
"role": "user",
"content": "Create `lis(a list nums)` returning the LIS length. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if not nums:\n ret... | algorithms |
[
{
"role": "user",
"content": "Please provide `lis` that compute length of longest increasing subsequence. Add a brief docstring."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if not nu... | algorithms |
[
{
"role": "user",
"content": "Create a utility function named `lis` which compute length of longest increasing subsequence. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must b... | algorithms |
[
{
"role": "user",
"content": "Develop `lis` such that it compute length of longest increasing subsequence. Use only the standard library."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n ... | algorithms |
[
{
"role": "user",
"content": "Construct `lis` to compute length of longest increasing subsequence. Include basic type checks."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a list\")\n if not nums:... | algorithms |
[
{
"role": "user",
"content": "Write a Python function `lis` that compute length of longest increasing subsequence. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must ... | algorithms |
[
{
"role": "user",
"content": "Implement `lis` with proper validation: compute length of longest increasing subsequence. Use only the standard library."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nums must be a ... | algorithms |
[
{
"role": "user",
"content": "Build a function `lis` that compute length of longest increasing subsequence, with edge-case handling. Use only the standard library."
},
{
"role": "assistant",
"content": "def lis(nums: list) -> int:\n if not isinstance(nums, list):\n raise TypeError(\"nu... | algorithms |
[
{
"role": "user",
"content": "Develop `read_lines` such that it read all lines from a file. Add a brief docstring."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for line in f]\... | file_io |
[
{
"role": "user",
"content": "Implement `read_lines(a file path)` to read all lines from a file. Keep it efficient."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for line in f]... | file_io |
[
{
"role": "user",
"content": "Can you write code for `read_lines` that read all lines from a file? Include basic type checks."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for ... | file_io |
[
{
"role": "user",
"content": "Please provide `read_lines` that read all lines from a file. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for line in f... | file_io |
[
{
"role": "user",
"content": "Implement `read_lines`. It should read all lines from a file. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\... | file_io |
[
{
"role": "user",
"content": "Create `read_lines(a file path)` returning a list of lines. Add a brief docstring."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for line in f]\n"... | file_io |
[
{
"role": "user",
"content": "Implement the function `read_lines` (a file path) -> a list of lines. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstri... | file_io |
[
{
"role": "user",
"content": "Implement `read_lines(a file path)` to read all lines from a file. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for lin... | file_io |
[
{
"role": "user",
"content": "Please provide `read_lines` that read all lines from a file. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for li... | file_io |
[
{
"role": "user",
"content": "Write `read_lines` in Python. It should read all lines from a file. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(... | file_io |
[
{
"role": "user",
"content": "Make a function `read_lines` to read all lines from a file. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for lin... | file_io |
[
{
"role": "user",
"content": "Can you write code for `read_lines` that read all lines from a file? Avoid mutating the input."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for l... | file_io |
[
{
"role": "user",
"content": "Develop `read_lines` such that it read all lines from a file. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for lin... | file_io |
[
{
"role": "user",
"content": "Provide a Python solution for `read_lines`: read all lines from a file. Keep it efficient."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for line ... | file_io |
[
{
"role": "user",
"content": "Write a Python function `read_lines` that read all lines from a file. "
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for line in f]\n"
}
] | file_io |
[
{
"role": "user",
"content": "Build a function `read_lines` that read all lines from a file, with edge-case handling. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n ... | file_io |
[
{
"role": "user",
"content": "Implement the function `read_lines` (a file path) -> a list of lines. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for ... | file_io |
[
{
"role": "user",
"content": "Implement `read_lines(a file path)` to read all lines from a file. Add a brief docstring."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for line i... | file_io |
[
{
"role": "user",
"content": "Add a function `read_lines` that read all lines from a file. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for line in f... | file_io |
[
{
"role": "user",
"content": "Build a function `read_lines` that read all lines from a file, with edge-case handling. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rs... | file_io |
[
{
"role": "user",
"content": "Formulate `read_lines` to read all lines from a file. Add a brief docstring."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for line in f]\n"
}
] | file_io |
[
{
"role": "user",
"content": "Implement `read_lines`. It should read all lines from a file. Use only the standard library."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for lin... | file_io |
[
{
"role": "user",
"content": "Create a robust `read_lines` that read all lines from a file. Keep it efficient."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for line in f]\n"
... | file_io |
[
{
"role": "user",
"content": "Formulate `read_lines` to read all lines from a file. Keep it efficient."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for line in f]\n"
}
] | file_io |
[
{
"role": "user",
"content": "Can you write code for `read_lines` that read all lines from a file? Add a brief docstring."
},
{
"role": "assistant",
"content": "def read_lines(path: str) -> list:\n with open(path, \"r\", encoding=\"utf-8\") as f:\n return [line.rstrip(\"\\n\") for line... | file_io |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.