conversations listlengths 2 2 | source stringclasses 8
values |
|---|---|
[
{
"role": "user",
"content": "I need a Python helper `gcd` that compute the greatest common divisor. Add a brief docstring."
},
{
"role": "assistant",
"content": "def gcd(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be i... | math |
[
{
"role": "user",
"content": "Can you write code for `gcd` that compute the greatest common divisor? Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def gcd(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\... | math |
[
{
"role": "user",
"content": "Create a robust `lcm` that compute the least common multiple. Use only the standard library."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be in... | math |
[
{
"role": "user",
"content": "Write `lcm` handling edge cases; it should compute the least common multiple. Add a brief docstring."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b mu... | math |
[
{
"role": "user",
"content": "Add a function `lcm` that compute the least common multiple. Keep it efficient."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be int\")\n def... | math |
[
{
"role": "user",
"content": "Write code for `lcm` (integers a and b) that compute the least common multiple. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and... | math |
[
{
"role": "user",
"content": "Implement `lcm` with proper validation: compute the least common multiple. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b mu... | math |
[
{
"role": "user",
"content": "Code a function `lcm` to compute the least common multiple. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be int\... | math |
[
{
"role": "user",
"content": "Define a function `lcm` taking integers a and b and returning the lcm. Keep it efficient."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be int\"... | math |
[
{
"role": "user",
"content": "Create a utility function named `lcm` which compute the least common multiple. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\... | math |
[
{
"role": "user",
"content": "Write a Python function `lcm` that compute the least common multiple. Add a brief docstring."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be in... | math |
[
{
"role": "user",
"content": "Create `lcm(integers a and b)` returning the lcm. "
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be int\")\n def _gcd(x, y):\n x, y = ... | math |
[
{
"role": "user",
"content": "Please provide `lcm` that compute the least common multiple. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b m... | math |
[
{
"role": "user",
"content": "Write `lcm`: compute the least common multiple. "
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be int\")\n def _gcd(x, y):\n x, y = ab... | math |
[
{
"role": "user",
"content": "Implement `lcm(integers a and b)` to compute the least common multiple. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b ... | math |
[
{
"role": "user",
"content": "Develop `lcm` such that it compute the least common multiple. Include basic type checks."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be int\")... | math |
[
{
"role": "user",
"content": "Write a reusable function `lcm` which compute the least common multiple. Include basic type checks."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b mus... | math |
[
{
"role": "user",
"content": "Add a function `lcm` that compute the least common multiple. Include basic type checks."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be int\")\... | math |
[
{
"role": "user",
"content": "Write `lcm` handling edge cases; it should compute the least common multiple. Keep it efficient."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must b... | math |
[
{
"role": "user",
"content": "Write code for `lcm` (integers a and b) that compute the least common multiple. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise Ty... | math |
[
{
"role": "user",
"content": "Create a robust `lcm` that compute the least common multiple. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be int\")\... | math |
[
{
"role": "user",
"content": "Can you write code for `lcm` that compute the least common multiple? Avoid mutating the input."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be ... | math |
[
{
"role": "user",
"content": "Help me write `lcm` that compute the least common multiple. Include basic type checks."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be int\")\n... | math |
[
{
"role": "user",
"content": "Can you write code for `lcm` that compute the least common multiple? Keep it efficient."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be int\")\... | math |
[
{
"role": "user",
"content": "Generate a Python function `lcm` for compute the least common multiple. Keep it efficient."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be int\... | math |
[
{
"role": "user",
"content": "Produce a clean implementation of `lcm`: compute the least common multiple. Add a brief docstring."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must... | math |
[
{
"role": "user",
"content": "Help me write `lcm` that compute the least common multiple. Add a brief docstring."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be int\")\n ... | math |
[
{
"role": "user",
"content": "Create `lcm(integers a and b)` returning the lcm. Use only the standard library."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be int\")\n de... | math |
[
{
"role": "user",
"content": "Implement the function `lcm` (integers a and b) -> the lcm. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be int\")\n ... | math |
[
{
"role": "user",
"content": "Create `lcm(integers a and b)` returning the lcm. Add a brief docstring."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be int\")\n def _gcd(x... | math |
[
{
"role": "user",
"content": "Draft a Python function `lcm` to compute the least common multiple. Use only the standard library."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must... | math |
[
{
"role": "user",
"content": "Create a robust `lcm` that compute the least common multiple. Include basic type checks."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeError(\"a and b must be int\")... | math |
[
{
"role": "user",
"content": "Produce a clean implementation of `lcm`: compute the least common multiple. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def lcm(a: int, b: int) -> int:\n if not (isinstance(a, int) and isinstance(b, int)):\n raise TypeEr... | math |
[
{
"role": "user",
"content": "Formulate `mod_pow` to compute (base^exp) mod mod efficiently. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")\n resul... | math |
[
{
"role": "user",
"content": "Write a reusable function `mod_pow` which compute (base^exp) mod mod efficiently. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be posit... | math |
[
{
"role": "user",
"content": "Help me write `mod_pow` that compute (base^exp) mod mod efficiently. "
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")\n result = 1 % mod\n base %= m... | math |
[
{
"role": "user",
"content": "Can you write code for `mod_pow` that compute (base^exp) mod mod efficiently? Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\... | math |
[
{
"role": "user",
"content": "Can you write code for `mod_pow` that compute (base^exp) mod mod efficiently? Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positiv... | math |
[
{
"role": "user",
"content": "Make a function `mod_pow` to compute (base^exp) mod mod efficiently. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")\n result... | math |
[
{
"role": "user",
"content": "Implement `mod_pow` with proper validation: compute (base^exp) mod mod efficiently. Add a brief docstring."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")... | math |
[
{
"role": "user",
"content": "Please provide `mod_pow` that compute (base^exp) mod mod efficiently. Keep it efficient."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")\n result = 1 %... | math |
[
{
"role": "user",
"content": "Add a function `mod_pow` that compute (base^exp) mod mod efficiently. Use only the standard library."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")\n ... | math |
[
{
"role": "user",
"content": "Implement `mod_pow` with proper validation: compute (base^exp) mod mod efficiently. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod m... | math |
[
{
"role": "user",
"content": "Generate a Python function `mod_pow` for compute (base^exp) mod mod efficiently. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")... | math |
[
{
"role": "user",
"content": "Write code for `mod_pow` (base, exp, mod) that compute (base^exp) mod mod efficiently. Add a brief docstring."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive... | math |
[
{
"role": "user",
"content": "Write code for `mod_pow` (base, exp, mod) that compute (base^exp) mod mod efficiently. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must b... | math |
[
{
"role": "user",
"content": "Create `mod_pow(base, exp, mod)` returning the modular result. Include basic type checks."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")\n result = 1 ... | math |
[
{
"role": "user",
"content": "Make a function `mod_pow` to compute (base^exp) mod mod efficiently. "
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")\n result = 1 % mod\n base %= m... | math |
[
{
"role": "user",
"content": "Create a robust `mod_pow` that compute (base^exp) mod mod efficiently. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positi... | math |
[
{
"role": "user",
"content": "Write code for `mod_pow` (base, exp, mod) that compute (base^exp) mod mod efficiently. Include basic type checks."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be posi... | math |
[
{
"role": "user",
"content": "Construct `mod_pow` to compute (base^exp) mod mod efficiently. Keep it efficient."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")\n result = 1 % mod\n ... | math |
[
{
"role": "user",
"content": "Add a function `mod_pow` that compute (base^exp) mod mod efficiently. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")\n ... | math |
[
{
"role": "user",
"content": "Create a robust `mod_pow` that compute (base^exp) mod mod efficiently. Keep it efficient."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")\n result = 1 ... | math |
[
{
"role": "user",
"content": "Write a Python function `mod_pow` that compute (base^exp) mod mod efficiently. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positi... | math |
[
{
"role": "user",
"content": "Define a function `mod_pow` taking base, exp, mod and returning the modular result. Keep it efficient."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")\n ... | math |
[
{
"role": "user",
"content": "Define a function `mod_pow` taking base, exp, mod and returning the modular result. Use only the standard library."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be pos... | math |
[
{
"role": "user",
"content": "Generate a Python function `mod_pow` for compute (base^exp) mod mod efficiently. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must... | math |
[
{
"role": "user",
"content": "Write code for `mod_pow` (base, exp, mod) that compute (base^exp) mod mod efficiently. Use only the standard library."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be ... | math |
[
{
"role": "user",
"content": "Formulate `mod_pow` to compute (base^exp) mod mod efficiently. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")\n ... | math |
[
{
"role": "user",
"content": "Define a function `mod_pow` taking base, exp, mod and returning the modular result. Add a brief docstring."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")... | math |
[
{
"role": "user",
"content": "I need a Python helper `mod_pow` that compute (base^exp) mod mod efficiently. Use only the standard library."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\... | math |
[
{
"role": "user",
"content": "Implement `mod_pow` returning the modular result given base, exp, mod. Keep it efficient."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")\n result = 1 ... | math |
[
{
"role": "user",
"content": "Code a function `mod_pow` to compute (base^exp) mod mod efficiently. Add a brief docstring."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")\n result = ... | math |
[
{
"role": "user",
"content": "Can you write code for `mod_pow` that compute (base^exp) mod mod efficiently? Keep it efficient."
},
{
"role": "assistant",
"content": "def mod_pow(base: int, exp: int, mod: int) -> int:\n if mod <= 0:\n raise ValueError(\"mod must be positive\")\n resu... | math |
[
{
"role": "user",
"content": "I need a Python helper `sieve_primes` that list all primes up to n using a sieve. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True... | math |
[
{
"role": "user",
"content": "Implement `sieve_primes`. It should list all primes up to n using a sieve. Use only the standard library."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + ... | math |
[
{
"role": "user",
"content": "Write code for `sieve_primes` (an integer n) that list all primes up to n using a sieve. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n ... | math |
[
{
"role": "user",
"content": "Implement the function `sieve_primes` (an integer n) -> a list of primes. "
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1)\n sieve[0] = sieve[1] = F... | math |
[
{
"role": "user",
"content": "Can you write code for `sieve_primes` that list all primes up to n using a sieve? Keep it efficient."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1)\n ... | math |
[
{
"role": "user",
"content": "Develop `sieve_primes` such that it list all primes up to n using a sieve. "
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1)\n sieve[0] = sieve[1] = ... | math |
[
{
"role": "user",
"content": "Please provide `sieve_primes` that list all primes up to n using a sieve. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n +... | math |
[
{
"role": "user",
"content": "Write a Python function `sieve_primes` that list all primes up to n using a sieve. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [Tru... | math |
[
{
"role": "user",
"content": "Generate a Python function `sieve_primes` for list all primes up to n using a sieve. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [Tru... | math |
[
{
"role": "user",
"content": "Provide a Python solution for `sieve_primes`: list all primes up to n using a sieve. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [T... | math |
[
{
"role": "user",
"content": "Write `sieve_primes` handling edge cases; it should list all primes up to n using a sieve. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n siev... | math |
[
{
"role": "user",
"content": "Construct `sieve_primes` to list all primes up to n using a sieve. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1)\n ... | math |
[
{
"role": "user",
"content": "Implement `sieve_primes` returning a list of primes given an integer n. Add a brief docstring."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1)\n sie... | math |
[
{
"role": "user",
"content": "Please provide `sieve_primes` that list all primes up to n using a sieve. Use only the standard library."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1... | math |
[
{
"role": "user",
"content": "Implement the function `sieve_primes` (an integer n) -> a list of primes. Add a brief docstring."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1)\n s... | math |
[
{
"role": "user",
"content": "Make a function `sieve_primes` to list all primes up to n using a sieve. "
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1)\n sieve[0] = sieve[1] = Fa... | math |
[
{
"role": "user",
"content": "Define a function `sieve_primes` taking an integer n and returning a list of primes. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [Tru... | math |
[
{
"role": "user",
"content": "Create a robust `sieve_primes` that list all primes up to n using a sieve. Add a brief docstring."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1)\n ... | math |
[
{
"role": "user",
"content": "Implement `sieve_primes` with proper validation: list all primes up to n using a sieve. Keep it efficient."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n +... | math |
[
{
"role": "user",
"content": "Implement the function `sieve_primes` (an integer n) -> a list of primes. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1)\n ... | math |
[
{
"role": "user",
"content": "Implement `sieve_primes`. It should list all primes up to n using a sieve. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n ... | math |
[
{
"role": "user",
"content": "Implement the function `sieve_primes` (an integer n) -> a list of primes. Return sensible defaults for edge cases."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True... | math |
[
{
"role": "user",
"content": "Define a function `sieve_primes` taking an integer n and returning a list of primes. Avoid mutating the input."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * ... | math |
[
{
"role": "user",
"content": "Formulate `sieve_primes` to list all primes up to n using a sieve. Use only the standard library."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1)\n ... | math |
[
{
"role": "user",
"content": "Implement `sieve_primes`. It should list all primes up to n using a sieve. Keep it efficient."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1)\n siev... | math |
[
{
"role": "user",
"content": "Implement `sieve_primes`. It should list all primes up to n using a sieve. Add a brief docstring."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1)\n ... | math |
[
{
"role": "user",
"content": "Construct `sieve_primes` to list all primes up to n using a sieve. Keep it efficient."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1)\n sieve[0] = s... | math |
[
{
"role": "user",
"content": "Generate a Python function `sieve_primes` for list all primes up to n using a sieve. Make it robust to invalid input."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [T... | math |
[
{
"role": "user",
"content": "Code a function `sieve_primes` to list all primes up to n using a sieve. Use only the standard library."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1)... | math |
[
{
"role": "user",
"content": "Code a function `sieve_primes` to list all primes up to n using a sieve. "
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1)\n sieve[0] = sieve[1] = Fa... | math |
[
{
"role": "user",
"content": "Please provide `sieve_primes` that list all primes up to n using a sieve. Keep it efficient."
},
{
"role": "assistant",
"content": "def sieve_primes(n: int) -> list:\n if not isinstance(n, int) or n < 2:\n return []\n sieve = [True] * (n + 1)\n sieve... | math |
[
{
"role": "user",
"content": "Write `is_perfect_square`: check whether n is a perfect square. Include basic type checks."
},
{
"role": "assistant",
"content": "def is_perfect_square(n: int) -> bool:\n if not isinstance(n, int) or n < 0:\n return False\n if n == 0:\n return Tr... | math |
[
{
"role": "user",
"content": "I need a Python helper `is_perfect_square` that check whether n is a perfect square. Include basic type checks."
},
{
"role": "assistant",
"content": "def is_perfect_square(n: int) -> bool:\n if not isinstance(n, int) or n < 0:\n return False\n if n == ... | math |
[
{
"role": "user",
"content": "Draft a Python function `is_perfect_square` to check whether n is a perfect square. Use only the standard library."
},
{
"role": "assistant",
"content": "def is_perfect_square(n: int) -> bool:\n if not isinstance(n, int) or n < 0:\n return False\n if n ... | math |
[
{
"role": "user",
"content": "Formulate `is_perfect_square` to check whether n is a perfect square. Handle empty input gracefully."
},
{
"role": "assistant",
"content": "def is_perfect_square(n: int) -> bool:\n if not isinstance(n, int) or n < 0:\n return False\n if n == 0:\n ... | math |
[
{
"role": "user",
"content": "Write `is_perfect_square` handling edge cases; it should check whether n is a perfect square. Keep it efficient."
},
{
"role": "assistant",
"content": "def is_perfect_square(n: int) -> bool:\n if not isinstance(n, int) or n < 0:\n return False\n if n ==... | math |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.