conversations listlengths 2 2 | source stringclasses 8
values |
|---|---|
[
{
"role": "user",
"content": "Write `bfs` in Python. It should traverse a graph with BFS. Avoid mutating the input."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n ... | algorithms |
[
{
"role": "user",
"content": "Make a function `bfs` to traverse a graph with BFS. Keep it efficient."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n queue = deque(... | algorithms |
[
{
"role": "user",
"content": "Produce a clean implementation of `bfs`: traverse a graph with BFS. Keep it efficient."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n ... | algorithms |
[
{
"role": "user",
"content": "Provide a Python solution for `bfs`: traverse a graph with BFS. "
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n queue = deque([start... | algorithms |
[
{
"role": "user",
"content": "Write `bfs` handling edge cases; it should traverse a graph with BFS. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = se... | algorithms |
[
{
"role": "user",
"content": "Make a function `bfs` to traverse a graph with BFS. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n qu... | algorithms |
[
{
"role": "user",
"content": "Write `bfs` handling edge cases; it should traverse a graph with BFS. Keep it efficient."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n... | algorithms |
[
{
"role": "user",
"content": "I need a Python helper `bfs` that traverse a graph with BFS. Avoid mutating the input."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n ... | algorithms |
[
{
"role": "user",
"content": "Write code for `bfs` (a graph dict and start node) that traverse a graph with BFS. Include basic type checks."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n vis... | algorithms |
[
{
"role": "user",
"content": "Create a utility function named `bfs` which traverse a graph with BFS. Add a brief docstring."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([star... | algorithms |
[
{
"role": "user",
"content": "Write `bfs` in Python. It should traverse a graph with BFS. Use only the standard library."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])... | algorithms |
[
{
"role": "user",
"content": "I need a Python helper `bfs` that traverse a graph with BFS. Add a brief docstring."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n q... | algorithms |
[
{
"role": "user",
"content": "Code a function `bfs` to traverse a graph with BFS. Use only the standard library."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n qu... | algorithms |
[
{
"role": "user",
"content": "Write `bfs`: traverse a graph with BFS. Keep it efficient."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n queue = deque([start])\n ... | algorithms |
[
{
"role": "user",
"content": "Construct `bfs` to traverse a graph with BFS. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n ... | algorithms |
[
{
"role": "user",
"content": "Develop `bfs` such that it traverse a graph with BFS. Use only the standard library."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n ... | algorithms |
[
{
"role": "user",
"content": "Write a reusable function `bfs` which traverse a graph with BFS. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([st... | algorithms |
[
{
"role": "user",
"content": "Develop `bfs` such that it traverse a graph with BFS. Include basic type checks."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n queu... | algorithms |
[
{
"role": "user",
"content": "Help me write `bfs` that traverse a graph with BFS. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n ... | algorithms |
[
{
"role": "user",
"content": "Write `bfs`: traverse a graph with BFS. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n queue = dequ... | algorithms |
[
{
"role": "user",
"content": "Create a robust `bfs` that traverse a graph with BFS. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n ... | algorithms |
[
{
"role": "user",
"content": "Generate a Python function `bfs` for traverse a graph with BFS. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([s... | algorithms |
[
{
"role": "user",
"content": "Implement `bfs`. It should traverse a graph with BFS. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n visited = set([start])\n ... | algorithms |
[
{
"role": "user",
"content": "Write code for `bfs` (a graph dict and start node) that traverse a graph with BFS. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n retu... | algorithms |
[
{
"role": "user",
"content": "Define a function `bfs` taking a graph dict and start node and returning the traversal order. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n ret... | algorithms |
[
{
"role": "user",
"content": "Define a function `bfs` taking a graph dict and start node and returning the traversal order. Use only the standard library."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n ret... | algorithms |
[
{
"role": "user",
"content": "Implement `bfs(a graph dict and start node)` to traverse a graph with BFS. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "from collections import deque\n\ndef bfs(graph: dict, start):\n if start not in graph:\n return []\n ... | algorithms |
[
{
"role": "user",
"content": "Implement `dfs` with proper validation: traverse a graph with DFS. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\... | algorithms |
[
{
"role": "user",
"content": "Formulate `dfs` to traverse a graph with DFS. "
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n visited.add(start)\n result = [sta... | algorithms |
[
{
"role": "user",
"content": "I need a Python helper `dfs` that traverse a graph with DFS. "
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n visited.add(start)\n ... | algorithms |
[
{
"role": "user",
"content": "Make a function `dfs` to traverse a graph with DFS. Include basic type checks."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n visit... | algorithms |
[
{
"role": "user",
"content": "Create `dfs(a graph dict and start node)` returning the traversal order. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n ... | algorithms |
[
{
"role": "user",
"content": "Write code for `dfs` (a graph dict and start node) that traverse a graph with DFS. Add a brief docstring."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n ... | algorithms |
[
{
"role": "user",
"content": "Create `dfs(a graph dict and start node)` returning the traversal order. Include basic type checks."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n ... | algorithms |
[
{
"role": "user",
"content": "Draft a Python function `dfs` to traverse a graph with DFS. Add a brief docstring."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n v... | algorithms |
[
{
"role": "user",
"content": "Provide a Python solution for `dfs`: traverse a graph with DFS. "
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n visited.add(start)\... | algorithms |
[
{
"role": "user",
"content": "Help me write `dfs` that traverse a graph with DFS. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return... | algorithms |
[
{
"role": "user",
"content": "Write `dfs` handling edge cases; it should traverse a graph with DFS. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n ... | algorithms |
[
{
"role": "user",
"content": "Create a robust `dfs` that traverse a graph with DFS. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n ... | algorithms |
[
{
"role": "user",
"content": "Construct `dfs` to traverse a graph with DFS. "
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n visited.add(start)\n result = [sta... | algorithms |
[
{
"role": "user",
"content": "Add a function `dfs` that traverse a graph with DFS. Include basic type checks."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n visi... | algorithms |
[
{
"role": "user",
"content": "Provide a Python solution for `dfs`: traverse a graph with DFS. Use only the standard library."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n retu... | algorithms |
[
{
"role": "user",
"content": "Define a function `dfs` taking a graph dict and start node and returning the traversal order. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if... | algorithms |
[
{
"role": "user",
"content": "Implement `dfs(a graph dict and start node)` to traverse a graph with DFS. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n ... | algorithms |
[
{
"role": "user",
"content": "Code a function `dfs` to traverse a graph with DFS. Use only the standard library."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n v... | algorithms |
[
{
"role": "user",
"content": "Formulate `dfs` to traverse a graph with DFS. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n visited... | algorithms |
[
{
"role": "user",
"content": "Construct `dfs` to traverse a graph with DFS. Use only the standard library."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n visited... | algorithms |
[
{
"role": "user",
"content": "Implement `dfs`. It should traverse a graph with DFS. Add a brief docstring."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n visited... | algorithms |
[
{
"role": "user",
"content": "Implement `dfs(a graph dict and start node)` to traverse a graph with DFS. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\... | algorithms |
[
{
"role": "user",
"content": "Write `dfs`: traverse a graph with DFS. Include basic type checks."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n visited.add(start... | algorithms |
[
{
"role": "user",
"content": "Write a reusable function `dfs` which traverse a graph with DFS. "
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n visited.add(start)... | algorithms |
[
{
"role": "user",
"content": "Write a Python function `dfs` that traverse a graph with DFS. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n retu... | algorithms |
[
{
"role": "user",
"content": "Code a function `dfs` to traverse a graph with DFS. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n visite... | algorithms |
[
{
"role": "user",
"content": "Can you write code for `dfs` that traverse a graph with DFS? Avoid mutating the input."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n ... | algorithms |
[
{
"role": "user",
"content": "Implement the function `dfs` (a graph dict and start node) -> the traversal order. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in vis... | algorithms |
[
{
"role": "user",
"content": "Produce a clean implementation of `dfs`: traverse a graph with DFS. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n retur... | algorithms |
[
{
"role": "user",
"content": "Create a utility function named `dfs` which traverse a graph with DFS. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visit... | algorithms |
[
{
"role": "user",
"content": "Implement `dfs` with proper validation: traverse a graph with DFS. "
},
{
"role": "assistant",
"content": "def dfs(graph: dict, start, visited=None):\n if visited is None:\n visited = set()\n if start in visited:\n return []\n visited.add(star... | algorithms |
[
{
"role": "user",
"content": "Implement `insertion_sort`. It should sort a list with insertion sort. "
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a = list(arr)\n for i in... | algorithms |
[
{
"role": "user",
"content": "Create `insertion_sort(a list arr)` returning a sorted list. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a = l... | algorithms |
[
{
"role": "user",
"content": "Implement `insertion_sort` with proper validation: sort a list with insertion sort. Include basic type checks."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a l... | algorithms |
[
{
"role": "user",
"content": "Write `insertion_sort` in Python. It should sort a list with insertion sort. Keep it efficient."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a =... | algorithms |
[
{
"role": "user",
"content": "Add a function `insertion_sort` that sort a list with insertion sort. Include basic type checks."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a ... | algorithms |
[
{
"role": "user",
"content": "Make a function `insertion_sort` to sort a list with insertion sort. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a = ... | algorithms |
[
{
"role": "user",
"content": "Construct `insertion_sort` to sort a list with insertion sort. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def insertion_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": "I need a Python helper `insertion_sort` that sort a list with insertion sort. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a lis... | algorithms |
[
{
"role": "user",
"content": "Write a Python function `insertion_sort` that sort a list with insertion sort. Keep it efficient."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a... | algorithms |
[
{
"role": "user",
"content": "Add a function `insertion_sort` that sort a list with insertion sort. "
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a = list(arr)\n for i in ... | algorithms |
[
{
"role": "user",
"content": "Construct `insertion_sort` to sort a list with insertion sort. Keep it efficient."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a = list(arr)\n ... | algorithms |
[
{
"role": "user",
"content": "Formulate `insertion_sort` to sort a list with insertion sort. "
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a = list(arr)\n for i in range(1... | algorithms |
[
{
"role": "user",
"content": "Build a function `insertion_sort` that sort a list with insertion sort, with edge-case handling. Include basic type checks."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"ar... | algorithms |
[
{
"role": "user",
"content": "Write code for `insertion_sort` (a list arr) that sort a list with insertion sort. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be ... | algorithms |
[
{
"role": "user",
"content": "Code a function `insertion_sort` to sort a list with insertion sort. Use only the standard library."
},
{
"role": "assistant",
"content": "def insertion_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 `insertion_sort` that sort a list with insertion sort. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n ... | algorithms |
[
{
"role": "user",
"content": "Make a function `insertion_sort` to sort a list with insertion sort. Include basic type checks."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a =... | algorithms |
[
{
"role": "user",
"content": "I need a Python helper `insertion_sort` that sort a list with insertion sort. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\... | algorithms |
[
{
"role": "user",
"content": "Create a utility function named `insertion_sort` which sort a list with insertion sort. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError... | algorithms |
[
{
"role": "user",
"content": "Produce a clean implementation of `insertion_sort`: sort a list with insertion sort. Include basic type checks."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a ... | algorithms |
[
{
"role": "user",
"content": "Implement `insertion_sort`. It should sort a list with insertion sort. Keep it efficient."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a = list(... | algorithms |
[
{
"role": "user",
"content": "Draft a Python function `insertion_sort` to sort a list with insertion sort. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list... | algorithms |
[
{
"role": "user",
"content": "Implement `insertion_sort(a list arr)` to sort a list with insertion sort. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must b... | algorithms |
[
{
"role": "user",
"content": "Write a reusable function `insertion_sort` which sort a list with insertion sort. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be... | algorithms |
[
{
"role": "user",
"content": "Can you write code for `insertion_sort` that sort a list with insertion sort? Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a lis... | algorithms |
[
{
"role": "user",
"content": "Produce a clean implementation of `insertion_sort`: sort a list with insertion sort. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must... | algorithms |
[
{
"role": "user",
"content": "Write `insertion_sort`: sort a list with insertion sort. "
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a = list(arr)\n for i in range(1, len(... | algorithms |
[
{
"role": "user",
"content": "Provide a Python solution for `insertion_sort`: sort a list with insertion sort. "
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list\")\n a = list(arr)\n ... | algorithms |
[
{
"role": "user",
"content": "Make a function `insertion_sort` to sort a list with insertion sort. Use only the standard library."
},
{
"role": "assistant",
"content": "def insertion_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 `insertion_sort` to sort a list with insertion sort. Use only the standard library."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must be a list... | algorithms |
[
{
"role": "user",
"content": "Build a function `insertion_sort` that sort a list with insertion sort, with edge-case handling. Add a brief docstring."
},
{
"role": "assistant",
"content": "def insertion_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr mu... | algorithms |
[
{
"role": "user",
"content": "Build a function `selection_sort` that sort a list with selection sort, with edge-case handling. Keep it efficient."
},
{
"role": "assistant",
"content": "def selection_sort(arr: list) -> list:\n if not isinstance(arr, list):\n raise TypeError(\"arr must b... | algorithms |
[
{
"role": "user",
"content": "Implement the function `selection_sort` (a list arr) -> a sorted list. 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": "Add a function `selection_sort` 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(\"arr must be a l... | algorithms |
[
{
"role": "user",
"content": "Write a reusable function `selection_sort` which 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... | algorithms |
[
{
"role": "user",
"content": "Help me write `selection_sort` that 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(arr)\n n = len(a)... | algorithms |
[
{
"role": "user",
"content": "Write a reusable function `selection_sort` which 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... | algorithms |
[
{
"role": "user",
"content": "Implement `selection_sort` with proper validation: 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\... | algorithms |
[
{
"role": "user",
"content": "Make a function `selection_sort` to 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\")\n a = ... | algorithms |
[
{
"role": "user",
"content": "I need a Python helper `selection_sort` that 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\")... | algorithms |
[
{
"role": "user",
"content": "Implement `selection_sort`. It should 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": "Produce a clean implementation of `selection_sort`: 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(arr)... | algorithms |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.