conversations listlengths 2 2 | source stringclasses 8
values |
|---|---|
[
{
"role": "user",
"content": "Code a function `selection_sort` to sort a list with selection sort. Include basic type checks."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a =... | algorithms |
[
{
"role": "user",
"content": "Implement `selection_sort`. It should sort a list with selection sort. Use only the standard library."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n ... | algorithms |
[
{
"role": "user",
"content": "Add a function `selection_sort` that sort a list with selection sort. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n... | algorithms |
[
{
"role": "user",
"content": "Write a reusable function `selection_sort` which sort a list with selection sort. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr... | algorithms |
[
{
"role": "user",
"content": "Formulate `selection_sort` to sort a list with selection sort. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\... | algorithms |
[
{
"role": "user",
"content": "Write a Python function `selection_sort` that sort a list with selection sort. Add a brief docstring."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n ... | algorithms |
[
{
"role": "user",
"content": "Create a utility function named `selection_sort` which sort a list with selection sort. "
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a = list(a... | algorithms |
[
{
"role": "user",
"content": "Write `selection_sort` handling edge cases; it should sort a list with selection sort. Use only the standard library."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must... | algorithms |
[
{
"role": "user",
"content": "Write `selection_sort` handling edge cases; it should sort a list with selection sort. Keep it efficient."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\"... | algorithms |
[
{
"role": "user",
"content": "Define a function `selection_sort` taking a list arr and returning a sorted list. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list... | algorithms |
[
{
"role": "user",
"content": "Write code for `selection_sort` (a list arr) that sort a list with selection sort. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"ar... | algorithms |
[
{
"role": "user",
"content": "Write `selection_sort`: sort a list with selection sort. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a = list(ar... | algorithms |
[
{
"role": "user",
"content": "Add a function `selection_sort` that sort a list with selection sort. Keep it efficient."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a = list(a... | algorithms |
[
{
"role": "user",
"content": "Implement `selection_sort(a list arr)` to sort a list with selection sort. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list... | algorithms |
[
{
"role": "user",
"content": "Can you write code for `selection_sort` that sort a list with selection sort? Keep it efficient."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a ... | algorithms |
[
{
"role": "user",
"content": "Define a function `selection_sort` taking a list arr and returning a sorted list. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr... | algorithms |
[
{
"role": "user",
"content": "Code a function `selection_sort` to sort a list with selection sort. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n ... | algorithms |
[
{
"role": "user",
"content": "Generate a Python function `selection_sort` for sort a list with selection sort. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\... | algorithms |
[
{
"role": "user",
"content": "I need a Python helper `selection_sort` that sort a list with selection sort. Keep it efficient."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a ... | algorithms |
[
{
"role": "user",
"content": "Implement the function `selection_sort` (a list arr) -> a sorted list. Use only the standard library."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n ... | algorithms |
[
{
"role": "user",
"content": "Draft a Python function `merge_sort` to sort a list with merge sort. Use only the standard library."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if ... | algorithms |
[
{
"role": "user",
"content": "Please provide `merge_sort` that sort a list with merge sort. Include basic type checks."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr) <=... | algorithms |
[
{
"role": "user",
"content": "Create `merge_sort(a list arr)` returning a sorted list. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr) <= 1:\n ... | algorithms |
[
{
"role": "user",
"content": "Make a function `merge_sort` to sort a list with merge sort. Use only the standard library."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr)... | algorithms |
[
{
"role": "user",
"content": "Add a function `merge_sort` that sort a list with merge sort. Include basic type checks."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr) <=... | algorithms |
[
{
"role": "user",
"content": "Implement `merge_sort`. It should sort a list with merge sort. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr) <=... | algorithms |
[
{
"role": "user",
"content": "Implement `merge_sort` returning a sorted list given a list arr. Include basic type checks."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr)... | algorithms |
[
{
"role": "user",
"content": "Create a robust `merge_sort` that sort a list with merge sort. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n ... | algorithms |
[
{
"role": "user",
"content": "Formulate `merge_sort` to sort a list with merge sort. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr) <= ... | algorithms |
[
{
"role": "user",
"content": "Write `merge_sort` handling edge cases; it should sort a list with merge sort. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\"... | algorithms |
[
{
"role": "user",
"content": "Make a function `merge_sort` to sort a list with merge sort. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr)... | algorithms |
[
{
"role": "user",
"content": "Implement `merge_sort`. It should sort a list with merge sort. Add a brief docstring."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr) <= 1:... | algorithms |
[
{
"role": "user",
"content": "Define a function `merge_sort` taking a list arr and returning a sorted list. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\... | algorithms |
[
{
"role": "user",
"content": "Implement the function `merge_sort` (a list arr) -> a sorted list. Add a brief docstring."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr) <... | algorithms |
[
{
"role": "user",
"content": "Implement `merge_sort` with proper validation: sort a list with merge sort. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a... | algorithms |
[
{
"role": "user",
"content": "Help me write `merge_sort` that sort a list with merge sort. Use only the standard library."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr)... | algorithms |
[
{
"role": "user",
"content": "Implement `merge_sort` returning a sorted list given a list arr. "
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr) <= 1:\n return lis... | algorithms |
[
{
"role": "user",
"content": "Generate a Python function `merge_sort` for sort a list with merge sort. Add a brief docstring."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(... | algorithms |
[
{
"role": "user",
"content": "Write a Python function `merge_sort` that sort a list with merge sort. Use only the standard library."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n i... | algorithms |
[
{
"role": "user",
"content": "Implement `merge_sort(a list arr)` to sort a list with merge sort. Add a brief docstring."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr) <... | algorithms |
[
{
"role": "user",
"content": "Code a function `merge_sort` to sort a list with merge sort. Include basic type checks."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr) <= ... | algorithms |
[
{
"role": "user",
"content": "Implement `merge_sort` with proper validation: sort a list with merge sort. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n i... | algorithms |
[
{
"role": "user",
"content": "Draft a Python function `merge_sort` to sort a list with merge sort. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(a... | algorithms |
[
{
"role": "user",
"content": "Implement `merge_sort` returning a sorted list given a list arr. Keep it efficient."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr) <= 1:\n... | algorithms |
[
{
"role": "user",
"content": "Implement `merge_sort`. It should sort a list with merge sort. Include basic type checks."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr) <... | algorithms |
[
{
"role": "user",
"content": "I need a Python helper `merge_sort` that sort a list with merge sort. Keep it efficient."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr) <=... | algorithms |
[
{
"role": "user",
"content": "Code a function `merge_sort` to sort a list with merge sort. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n i... | algorithms |
[
{
"role": "user",
"content": "Develop `merge_sort` such that it sort a list with merge sort. "
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr) <= 1:\n return list(... | algorithms |
[
{
"role": "user",
"content": "Write `merge_sort`: sort a list with merge sort. Include basic type checks."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr) <= 1:\n ... | algorithms |
[
{
"role": "user",
"content": "Can you write code for `merge_sort` that sort a list with merge sort? Keep it efficient."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n if len(arr) <=... | algorithms |
[
{
"role": "user",
"content": "Create a utility function named `merge_sort` which sort a list with merge sort. Add a brief docstring."
},
{
"role": "assistant",
"content": "def merge_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n ... | algorithms |
[
{
"role": "user",
"content": "Please provide `linear_search` that linearly search for a target. Add a brief docstring."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n for ... | algorithms |
[
{
"role": "user",
"content": "Create `linear_search(a list arr and target)` returning the index or -1. Use only the standard library."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a li... | algorithms |
[
{
"role": "user",
"content": "Create a utility function named `linear_search` which linearly search for a target. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr m... | algorithms |
[
{
"role": "user",
"content": "Can you write code for `linear_search` that linearly search for a target? Keep it efficient."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n ... | algorithms |
[
{
"role": "user",
"content": "Write a reusable function `linear_search` which linearly search for a target. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a li... | algorithms |
[
{
"role": "user",
"content": "Make a function `linear_search` to linearly search for a target. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n fo... | algorithms |
[
{
"role": "user",
"content": "Produce a clean implementation of `linear_search`: linearly search for a target. Use only the standard library."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must... | algorithms |
[
{
"role": "user",
"content": "Implement `linear_search(a list arr and target)` to linearly search for a target. Add a brief docstring."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a l... | algorithms |
[
{
"role": "user",
"content": "Define a function `linear_search` taking a list arr and target and returning the index or -1. Include basic type checks."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\... | algorithms |
[
{
"role": "user",
"content": "Implement `linear_search(a list arr and target)` to linearly search for a target. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr m... | algorithms |
[
{
"role": "user",
"content": "Implement `linear_search`. It should linearly search for a target. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n ... | algorithms |
[
{
"role": "user",
"content": "Construct `linear_search` to linearly search for a target. Add a brief docstring."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n for i, x in... | algorithms |
[
{
"role": "user",
"content": "Can you write code for `linear_search` that linearly search for a target? Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a l... | algorithms |
[
{
"role": "user",
"content": "Generate a Python function `linear_search` for linearly search for a target. Add a brief docstring."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\"... | algorithms |
[
{
"role": "user",
"content": "Implement `linear_search` returning the index or -1 given a list arr and target. Add a brief docstring."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a li... | algorithms |
[
{
"role": "user",
"content": "Write a reusable function `linear_search` which linearly search for a target. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"a... | algorithms |
[
{
"role": "user",
"content": "Implement `linear_search` with proper validation: linearly search for a target. "
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n for i, x in ... | algorithms |
[
{
"role": "user",
"content": "Add a function `linear_search` that linearly search for a target. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")... | algorithms |
[
{
"role": "user",
"content": "Implement `linear_search` with proper validation: linearly search for a target. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a ... | algorithms |
[
{
"role": "user",
"content": "Formulate `linear_search` to linearly search for a target. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\"... | algorithms |
[
{
"role": "user",
"content": "Write `linear_search` handling edge cases; it should linearly search for a target. Add a brief docstring."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a ... | algorithms |
[
{
"role": "user",
"content": "Generate a Python function `linear_search` for linearly search for a target. "
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n for i, x in enu... | algorithms |
[
{
"role": "user",
"content": "Make a function `linear_search` to linearly search for a target. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a ... | algorithms |
[
{
"role": "user",
"content": "Formulate `linear_search` to linearly search for a target. "
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n for i, x in enumerate(arr):\n ... | algorithms |
[
{
"role": "user",
"content": "Implement `linear_search(a list arr and target)` to linearly search for a target. Keep it efficient."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\... | algorithms |
[
{
"role": "user",
"content": "Implement `linear_search` with proper validation: linearly search for a target. Keep it efficient."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")... | algorithms |
[
{
"role": "user",
"content": "Produce a clean implementation of `linear_search`: linearly search for a target. Add a brief docstring."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a li... | algorithms |
[
{
"role": "user",
"content": "Draft a Python function `linear_search` to linearly search for a target. Include basic type checks."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\"... | algorithms |
[
{
"role": "user",
"content": "Code a function `linear_search` to linearly search for a target. Keep it efficient."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n for i, x ... | algorithms |
[
{
"role": "user",
"content": "Implement `linear_search(a list arr and target)` to linearly search for a target. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be ... | algorithms |
[
{
"role": "user",
"content": "Code a function `linear_search` to linearly search for a target. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def linear_search(arr: list, target) -> int:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n ... | algorithms |
[
{
"role": "user",
"content": "Write `dijkstra` in Python. It should 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 distanc... | algorithms |
[
{
"role": "user",
"content": "Write code for `dijkstra` (a weighted graph dict and start) that compute shortest paths with Dijkstra. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") fo... | algorithms |
[
{
"role": "user",
"content": "Provide a Python solution for `dijkstra`: 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 node in graph}\n dis... | algorithms |
[
{
"role": "user",
"content": "Write `dijkstra` in Python. It should compute shortest paths with Dijkstra. "
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for node in graph}\n distances[start] = 0\n pq = [(0, s... | algorithms |
[
{
"role": "user",
"content": "Write a Python function `dijkstra` 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 node in graph}\n dista... | algorithms |
[
{
"role": "user",
"content": "Write `dijkstra`: 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] = 0\n pq = [(0, sta... | algorithms |
[
{
"role": "user",
"content": "Make a function `dijkstra` to 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 node in graph}\n distances[start... | algorithms |
[
{
"role": "user",
"content": "Help me write `dijkstra` 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 node in graph}\n distances[start... | algorithms |
[
{
"role": "user",
"content": "Implement `dijkstra` returning a distance dict given a weighted graph dict and start. 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... | algorithms |
[
{
"role": "user",
"content": "Implement `dijkstra` with proper validation: compute shortest paths with Dijkstra. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for node in gr... | algorithms |
[
{
"role": "user",
"content": "Write a Python function `dijkstra` that compute shortest paths with Dijkstra. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for node in graph}\... | algorithms |
[
{
"role": "user",
"content": "Provide a Python solution for `dijkstra`: 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": "Write `dijkstra`: compute shortest paths with Dijkstra. "
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for node in graph}\n distances[start] = 0\n pq = [(0, start)]\n while pq... | algorithms |
[
{
"role": "user",
"content": "Implement `dijkstra` returning a distance dict given a weighted graph dict and start. 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 di... | algorithms |
[
{
"role": "user",
"content": "Provide a Python solution for `dijkstra`: compute shortest paths with Dijkstra. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "import heapq\n\ndef dijkstra(graph: dict, start):\n distances = {node: float(\"inf\") for node in graph... | algorithms |
[
{
"role": "user",
"content": "Please provide `dijkstra` that compute shortest paths with Dijkstra. 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 distances[start] = 0\n... | algorithms |
[
{
"role": "user",
"content": "Implement `dijkstra`. It should 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] =... | algorithms |
[
{
"role": "user",
"content": "Generate a Python function `dijkstra` for 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 node in graph}\n dis... | algorithms |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.