source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
code_exercise_27k | 4,656 | Write a Python function to capitalize the first letter of each string in a given list of strings. The function should use the `map` function to achieve this. The code should start with:
```python
from typing import List
def capitalize_first_letter(strings: List[str]) -> List[str]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def capitalize_first_letter(strings: List[str]) -> List[str]:
"""
Capitalizes the first letter of each string in the given list.
Args:
strings (List[str]): A list of strings to be processed.... |
code_exercise_27k | 4,660 | Write a Python function to check if each element in a list of strings is a palindrome using the `map` function. The function should return a list of booleans, where each boolean indicates whether the corresponding string in the input list is a palindrome.
The code should start with:
```python
from typing import List
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_palindrome(word: str) -> bool:
"""
A helper function to check if a word is a palindrome.
Parameters:
- word: A string representing a word.
Returns:
- True if the word is a palind... |
code_exercise_27k | 4,665 | Write a Python function to count the number of subsets of a given set that contain exactly k elements. The function should take a set and an integer k as input and return the number of subsets of the given set that have exactly k elements. The code should start with:
```python
from typing import Set
def count_k_elemen... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Set
import math
def count_k_element_subsets(s: Set[int], k: int) -> int:
"""
Count the number of subsets of a given set that contain exactly k elements.
Args:
s (Set[int]): The input set.
... |
code_exercise_27k | 4,669 | Write a Python function to remove all whitespace characters from each string in a given list of strings. The function should use the `map` function to apply the transformation to each string in the list. The code should start with:
```python
from typing import List
def remove_whitespace_from_strings(strings: List[str]... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_whitespace_from_strings(strings: List[str]) -> List[str]:
"""
Removes all whitespace characters from each string in the given list.
Args:
strings (List[str]): A list of strings fr... |
code_exercise_27k | 4,670 | Write a Python function to compute the union of multiple lists, where each element is a sublist. The union should be a list containing all unique elements from all sublists, maintaining the order of their first appearance.
The code should start with:
```python
from typing import List
def compute_union_of_lists(lists:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def compute_union_of_lists(lists: List[List[int]]) -> List[int]:
"""
Compute the union of multiple lists where each element is a sublist.
Args:
lists (List[List[int]]): The list of sublists.... |
code_exercise_27k | 4,674 | Write a Python function to check if a given set of strings is symmetric. A set is considered symmetric if for every string in the set, its reverse is also present in the set. The function should return `True` if the set is symmetric and `False` otherwise.
The code should start with:
```python
def is_symmetric(s: set) ... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_symmetric(s: set) -> bool:
"""
Checks if a given set of strings is symmetric.
A set is considered symmetric if for every string in the set, its reverse is also present in the set.
Args:
s (set): The set ... |
code_exercise_27k | 4,675 | Write a Python function to calculate the factorial of each number in a given list using the `map` function. The function should take a list of integers as input and return a list of integers where each element is the factorial of the corresponding element in the input list. The code should start with:
```python
from ty... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
from math import factorial
def calculate_factorials(numbers: List[int]) -> List[int]:
"""
Calculate the factorial of each number in the given list using the `map` function.
Parameters:
numbe... |
code_exercise_27k | 4,677 | Write a Python function to check if a given set of tuples represents a reflexive relation on a set of elements. A relation is reflexive if every element in the set is related to itself. The function should take a set of tuples as input and return a boolean indicating whether the relation is reflexive.
The code should ... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_reflexive(relation: set) -> bool:
"""
Check if a given set of tuples represents a reflexive relation.
A relation is reflexive if every element in the set is related to itself.
Args:
relation (set): A set... |
code_exercise_27k | 4,682 | Write a Python function to remove all punctuation marks from each string in a given list of strings. The function should use the `map` function to apply the punctuation removal to each string in the list. The code should start with:
```python
from typing import List
import string
def remove_punctuation_from_list(strin... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import string
def remove_punctuation(s: str) -> str:
"""
Removes punctuation marks from a string.
Args:
s (str): Input string.
Returns:
str: String without punctuati... |
code_exercise_27k | 4,685 | Write a Python function to convert a list of binary numbers represented as strings to their corresponding decimal numbers using the `map` function. The function should handle a list of binary strings and return a list of integers representing the decimal equivalents.
The code should start with:
```python
from typing i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def binary_to_decimal(binary_list: List[str]) -> List[int]:
"""
Converts a list of binary numbers represented as strings to their corresponding decimal numbers.
Args:
binary_list (List[str])... |
code_exercise_27k | 4,688 | Write a Python function to determine if a given undirected graph is connected. The graph is represented as a set of edges, where each edge is a tuple `(u, v)` indicating an undirected edge between nodes `u` and `v`. The function should return `True` if the graph is connected (i.e., there is a path between any two nodes... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Set, Tuple
def is_graph_connected(graph: Set[Tuple[str, str]]) -> bool:
"""
Determine if a given undirected graph is connected.
Args:
graph (Set[Tuple[str, str]]): A set of edges representing the... |
code_exercise_27k | 4,690 | Write a Python function to find the union of multiple lists, where each element is a sublist, while preserving the original order of sublists and removing duplicates. The function should return a new list representing the union of all sublists.
The code should start with:
```python
from typing import List
def find_un... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_union_of_lists(lists: List[List[int]]) -> List[int]:
"""
Find the union of multiple lists, preserving the original order of sublists and removing duplicates.
Args:
lists (List[List[... |
code_exercise_27k | 4,691 | Write a Python function to count the number of vowels in each word of a given sentence using the `map` function. The function should return a list where each element corresponds to the number of vowels in the respective word of the sentence. The function should handle both uppercase and lowercase vowels.
The code shou... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_vowels_in_sentence(sentence: str) -> List[int]:
"""
Count the number of vowels in each word of a given sentence.
Args:
sentence (str): The input sentence.
Returns:
Lis... |
code_exercise_27k | 4,692 | Write a Python function to determine if a given directed graph is acyclic. The graph is represented as a dictionary where each key is a node and the corresponding value is a set of nodes that the key node has directed edges to. The function should return `True` if the graph is acyclic and `False` otherwise.
The code s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Set
def is_acyclic_graph(graph: Dict[str, Set[str]]) -> bool:
"""
Determines if a given directed graph is acyclic.
Args:
graph (Dict[str, Set[str]]): A dictionary representing the graph whe... |
code_exercise_27k | 4,695 | Write a Python function to find the length of each string in a given list of strings using the `map` function. The function should return a list containing the lengths of the strings in the same order as they appear in the input list.
The code should start with:
```python
from typing import List
def find_string_lengt... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_string_lengths(strings: List[str]) -> List[int]:
"""
Calculate the length of each string in a list using the map function.
Args:
strings (List[str]): A list of strings.
Returns... |
code_exercise_27k | 4,700 | Write a Python function to check if each number in a given list is prime using the `map` function. The function should return a list of boolean values where each boolean indicates whether the corresponding number in the input list is prime.
The code should start with:
```python
from typing import List
def check_prime... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_prime(n: int) -> bool:
"""
Check if a number is prime.
Parameters:
n (int): The number to be checked.
Returns:
bool: True if the number is prime, False otherwise.
"""
if ... |
code_exercise_27k | 4,703 | Write a Python function to determine if a given set of integers is compact. A set is considered compact if all its elements form an arithmetic sequence with a common difference. The function should return `True` if the set is compact and `False` otherwise.
The code should start with:
```python
def is_compact(s: set) -... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_compact(s: set) -> bool:
"""
Determine if a given set of integers is compact.
A set is considered compact if all its elements form an arithmetic sequence
with a common difference.
Args:
s (set): The ... |
code_exercise_27k | 4,708 | Write a Python function to reverse the characters in each string from a given list of strings using the `map` function. The function should return a new list containing the reversed strings. The code should start with:
```python
from typing import List
def reverse_strings(strings: List[str]) -> List[str]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_strings(strings: List[str]) -> List[str]:
"""
Reverse the characters in each string from the provided list.
Args:
strings (List[str]): A list of strings to be reversed.
Retu... |
code_exercise_27k | 4,710 | Write a Python function to compute the union of two lists, where each element is a sublist, without using any built-in functions or data structures. The function should handle nested lists and ensure that the union contains only unique sublists. The code should start with:
```python
from typing import List
def union_o... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def union_of_lists(list1: List[List[int]], list2: List[List[int]]) -> List[List[int]]:
"""
Computes the union of two lists where each element is a sublist.
Args:
list1 (List[List[int]]): The... |
code_exercise_27k | 4,714 | Write a Python function to find the union of two lists, where each element is a sublist, without using any built-in functions or data structures and removing duplicates. The function should start with:
```python
from typing import List
def find_union_of_lists(list1: List[List[int]], list2: List[List[int]]) -> List[Lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_union_of_lists(list1: List[List[int]], list2: List[List[int]]) -> List[List[int]]:
"""
Returns the union of two lists of sublists, without duplicates.
Args:
list1 (List[List[int]]):... |
code_exercise_27k | 4,718 | Write a Python function to compute the union of multiple lists, where each element is a sublist, without using any built-in functions or data structures like `set`, `dict`, or `collections`. The function should return a list containing all unique elements from the input lists.
The code should start with:
```python
fro... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def compute_union_of_lists(lists: List[List[int]]) -> List[int]:
"""
Compute the union of multiple lists, where each element is a sublist, without using built-in functions or data structures.
Args:
... |
code_exercise_27k | 4,721 | Write a Python function to find the union of multiple lists, where each element is a sublist, without using any built-in functions or data structures and removing duplicates. The function should start with:
```python
from typing import List
def find_union_of_lists(lists: List[List[int]]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_union_of_lists(lists: List[List[int]]) -> List[int]:
"""
Finds the union of multiple lists, where each element is a sublist, without using any built-in functions or data structures.
Args:
... |
code_exercise_27k | 4,722 | Write a Python function to remove any leading or trailing spaces from each string in a given list of strings. The function should use the `map` function to apply the `strip` method to each string in the list. The code should start with:
```python
from typing import List
def remove_spaces(strings: List[str]) -> List[st... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_spaces(strings: List[str]) -> List[str]:
"""
Removes leading and trailing spaces from each string in a list.
Args:
strings (List[str]): A list of strings from which to remove lead... |
code_exercise_27k | 4,724 | Write a Python function to find the complement of a given set with respect to a universal set. The complement of a set is defined as the set of all elements in the universal set that are not in the given set. The function should handle sets of integers and return the complement set.
The code should start with:
```pyth... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_complement(given_set: set, universal_set: set) -> set:
"""
Returns the complement of a given set with respect to the universal set.
Args:
given_set (set): The set for which the complement needs to be found.... |
code_exercise_27k | 4,730 | Write a Python function to find the Cartesian product of two sets using the `itertools` module. The function should return a set of tuples, where each tuple represents a pair of elements from the two sets. The code should start with:
```python
from typing import Set
import itertools
def cartesian_product(set1: Set[int... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Set
import itertools
def cartesian_product(set1: Set[int], set2: Set[int]) -> Set[tuple]:
"""
Calculates the Cartesian product of two sets.
Args:
set1 (Set[int]): The first set.
set2 (Set... |
code_exercise_27k | 4,735 | Write a Python function to find all possible combinations of selecting `k` elements from a given set of elements. The function should use the `itertools` module to generate the combinations. The function should handle both lists and sets as input and return a list of tuples, where each tuple represents a combination of... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Set, Tuple
import itertools
def get_combinations(elements: List[int] or Set[int], k: int) -> List[Tuple[int]]:
"""
Find all possible combinations of selecting k elements from a given set of elements.
... |
code_exercise_27k | 4,737 | Write a Python function to replace all occurrences of a specific character in each string of a given list of strings using the `map` function. The function should return a new list of strings with the specified character replaced. The code should start with:
```python
from typing import List
def replace_char_in_string... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def replace_char_in_strings(strings: List[str], old_char: str, new_char: str) -> List[str]:
"""
Replace all occurrences of a specific character in each string of a list.
Args:
strings (List[... |
code_exercise_27k | 4,739 | Write a Python function to find all possible permutations of selecting `k` elements from a given set of elements. The function should return a list of tuples, where each tuple represents a unique permutation of the selected elements. The function should handle cases where `k` is greater than the number of elements in t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Any
import itertools
def find_permutations(elements: List[Any], k: int) -> List[Tuple[Any, ...]]:
"""
Find all possible permutations of selecting k elements from the given set.
Args:
... |
code_exercise_27k | 4,740 | Write a Python function to find the union of multiple sorted lists, where each element is a sublist, and remove duplicates. The function should efficiently merge the lists while maintaining the sorted order. The code should start with:
```python
from typing import List
def union_of_sorted_lists(sorted_lists: List[List... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import heapq
def union_of_sorted_lists(sorted_lists: List[List[int]]) -> List[int]:
"""
Returns the union of multiple sorted lists, removing duplicates.
Args:
sorted_lists (List[List[int]]):... |
code_exercise_27k | 4,744 | Write a Python function to find the maximum element in each sublist of a given list of sublists. The function should use the `map` function to achieve this efficiently. The code should start with:
```python
from typing import List
def find_maximum_in_sublists(numbers: List[List[int]]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_maximum_in_sublists(numbers: List[List[int]]) -> List[int]:
"""
Find the maximum element in each sublist of a list of numbers.
Args:
numbers (List[List[int]]): A list of sublists co... |
code_exercise_27k | 4,752 | Write a Python function to concatenate a given suffix to the end of each string in a list of strings using the `map` function. The function should handle input validation to ensure that the input is a list of strings and the suffix is a string. The code should start with:
```python
from typing import List
def concaten... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def concatenate_strings(strings_list: List[str], suffix: str) -> List[str]:
"""
Concatenates a given suffix to the end of each string in the input list.
Args:
strings_list (List[str]): A lis... |
code_exercise_27k | 4,757 | Write a Python function to calculate the square root of each number in a given list using the `map` function. The function should handle both positive and negative numbers by returning the absolute value of the square root. The code should start with:
```python
from typing import List
import math
def calculate_square_... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import math
def calculate_square_roots(numbers: List[int]) -> List[float]:
"""
Calculates the square root of each number in a given list using the map function.
For negative numbers, the absolute val... |
code_exercise_27k | 4,762 | Write a Python function to find the union of multiple sorted lists, where each element is a sublist, preserving the original order of sublists and removing duplicates. The function should efficiently handle the union operation by leveraging the sorted nature of the sublists.
The code should start with:
```python
from ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_union_of_sorted_lists(sorted_lists: List[List[int]]) -> List[int]:
"""
Find the union of multiple sorted lists, preserving the original order of sublists and removing duplicates.
Args:
... |
code_exercise_27k | 4,770 | Write a Python function to find the product of each sublist in a given list of numbers using the `map` function. The function should take a list of sublists, where each sublist contains numbers, and return a list of the products of each sublist. The code should start with:
```python
from typing import List
def find_su... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_sublist_products(numbers: List[List[int]]) -> List[int]:
"""
Find the product of each sublist in a given list of numbers using the map function.
Args:
numbers: A list of sublists, w... |
code_exercise_27k | 4,774 | Write a Python function to find the union of two sorted lists of sublists, where each sublist contains exactly two integers, using the merge technique and removing duplicates. The function should return the union of the two lists, sorted in ascending order based on the first element of each sublist.
The code should st... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_union_of_sorted_lists(list1: List[List[int]], list2: List[List[int]]) -> List[List[int]]:
"""
Finds the union of two sorted lists of sublists using the merge technique and removes duplicates.
... |
code_exercise_27k | 4,775 | Write a Python function to remove all digits from each string in a given list of strings using the `map` function. The function should return a new list where each string has all its digits removed. The code should start with:
```python
from typing import List
def remove_digits_from_strings(strings: List[str]) -> List... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_digits_from_strings(strings: List[str]) -> List[str]:
"""
Remove all digits from each string in the given list of strings.
Args:
strings (List[str]): A list of strings from which ... |
code_exercise_27k | 4,777 | Write a Python function to compute the union of multiple sorted lists, where each element is a sublist, using the merge technique. The function should efficiently merge the lists while maintaining the sorted order of elements. The code should start with:
```python
from typing import List
def merge_sorted_lists(lists: ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_sorted_lists(lists: List[List[int]]) -> List[int]:
"""
Compute the union of multiple sorted lists using the merge technique.
Args:
lists (List[List[int]]): The input lists, where e... |
code_exercise_27k | 4,778 | Write a Python function to calculate the sum of each sublist in a given list of lists using the `map` function. The function should return a new list containing the sums of the sublists. The code should start with:
```python
from typing import List
def sum_sublists(lst: List[List[int]]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_sublists(lst: List[List[int]]) -> List[int]:
"""
Calculate the sum of each sublist in a list of lists.
Args:
lst (List[List[int]]): A list containing sublists of integers.
Retur... |
code_exercise_27k | 4,780 | Write a Python function to calculate the power of each number in a given list with a specified exponent. The function should use the `map` function to apply the power operation to each element in the list. The code should start with:
```python
from typing import List
def calculate_powers(numbers: List[int], exponent: ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_powers(numbers: List[int], exponent: int) -> List[int]:
"""
Calculate the power of each number in a list with a given exponent.
Args:
numbers (List[int]): A list of integers.
... |
code_exercise_27k | 4,784 | Write a Python function to check if each element in a list is divisible by a specific number using the `map` function. The function should return a list of booleans where each boolean indicates whether the corresponding element in the input list is divisible by the specified divisor.
The code should start with:
```pyt... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def check_divisibility(numbers: List[int], divisor: int) -> List[bool]:
"""
Check if each element in a list is divisible by the specified divisor.
Args:
numbers (List[int]): A list of intege... |
code_exercise_27k | 4,793 | Write a Python function to check if each element in a list is even using the `map` function. The function should return a list of boolean values indicating whether each element in the input list is even or not. The code should start with:
```python
from typing import List
def check_even_elements(lst: List[int]) -> Lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def check_even_elements(lst: List[int]) -> List[bool]:
"""
Checks if each element in the input list is even and returns a list of boolean values.
Args:
lst (List[int]): A list of integers to... |
code_exercise_27k | 4,800 | Write a Python function to calculate the average of each sublist in a given list of sublists. Each sublist contains numbers, and the function should return a list of averages for each sublist. The code should start with:
```python
from typing import List
def calculate_sublist_averages(list_of_numbers: List[List[float]... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_sublist_averages(list_of_numbers: List[List[float]]) -> List[float]:
"""
Calculate the average of each sublist in a list of sublists.
Args:
list_of_numbers (List[List[float]]):... |
code_exercise_27k | 4,804 | Write a Python function to find the union of multiple sorted lists, where each element is a sublist, without using any built-in functions or data structures and removing duplicates. The function should start with:
```python
def find_union_of_sorted_lists(sorted_lists: List[List[int]]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_union_of_sorted_lists(sorted_lists: List[List[int]]) -> List[int]:
"""
Finds the union of multiple sorted lists, removing duplicates.
Args:
sorted_lists (List[List[int]]): A list of... |
code_exercise_27k | 4,805 | Write a Python function to convert each string in a given list to uppercase and reverse it using the `map` function. The function should return a list of the transformed strings.
The code should start with:
```python
from typing import List
def convert_and_reverse_strings(strings: List[str]) -> List[str]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def convert_and_reverse_strings(strings: List[str]) -> List[str]:
"""
Convert each string in the given list to uppercase and reverse it.
Args:
strings (List[str]): A list of strings to be co... |
code_exercise_27k | 4,806 | Write a Python function to compute the union of two lists of sublists, where each element is a sublist, and duplicates are counted multiple times. The function should return a new list containing all sublists from both input lists, preserving the order and frequency of their occurrences.
The code should start with:
``... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def compute_union_of_sublists(list1: List[List[int]], list2: List[List[int]]) -> List[List[int]]:
"""
Compute the union of two lists of sublists, counting duplicates multiple times.
Args:
li... |
code_exercise_27k | 4,813 | Write a Python function to compute the union of multiple lists, where each element is a sublist, and duplicates are counted multiple times. The function should take a list of sublists as input and return a single list containing all elements from the sublists, preserving the order and frequency of each element.
The co... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def compute_union_of_lists(lists: List[List[int]]) -> List[int]:
"""
Compute the union of multiple lists, where each element is a sublist,
and duplicates are counted multiple times.
Args:
... |
code_exercise_27k | 4,816 | Write a Python function to find the union of multiple lists, where each element is a sublist, counts duplicates multiple times, and removes duplicates. The function should return a new list containing all unique elements from the sublists, preserving the order of their first appearance.
The code should start with:
```... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_union_of_lists(lists: List[List[int]]) -> List[int]:
"""
Finds the union of multiple lists, where each element is a sublist, counts duplicates multiple times, and removes duplicates.
The res... |
code_exercise_27k | 4,820 | Write a Python function to determine if a given set of vectors is linearly dependent. A set of vectors is linearly dependent if there exist scalars, not all zero, such that their linear combination equals the zero vector. The function should take a list of vectors (each represented as a list of numbers) and return a bo... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import numpy as np
def is_linearly_dependent(vec_set: List[List[float]]) -> bool:
"""
Determine if a given set of vectors is linearly dependent.
Args:
vec_set (List[List[float]]): A list of ... |
code_exercise_27k | 4,827 | Write a Python function to calculate the sum of each sublist in a given list of lists. The function should use the `map()` function to achieve this. The input list can contain any number of sublists, and each sublist can contain any number of integers. The function should return a list containing the sum of each sublis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_sum_of_sublists(numbers: List[List[int]]) -> List[int]:
"""
Calculate the sum of each sublist in a given list of lists.
Args:
numbers (List[List[int]]): A list of lists, where ... |
code_exercise_27k | 4,832 | Write a Python function to find the union of multiple lists, where each element is a sublist. The function should count the occurrences of each element, sort the elements based on their counts in descending order, and remove duplicates. The code should start with:
```python
from typing import List
from collections impo... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
from collections import Counter
def union_of_lists(lists: List[List[int]]) -> List[int]:
"""
Find the union of multiple lists, counting duplicates and sorting based on their counts, while removing duplic... |
code_exercise_27k | 4,834 | Write a Python function to calculate the rank of a matrix represented by a list of lists. The rank of a matrix is defined as the maximum number of linearly independent rows or columns in the matrix. The function should handle matrices of any size and ensure that the matrix is valid (i.e., all rows have the same length)... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def rank_of_matrix(matrix: List[List[float]]) -> int:
"""
Calculates the rank of a matrix represented by a list of lists.
Parameters:
matrix (List[List[float]]): The matrix represented by a list... |
code_exercise_27k | 4,837 | Write a Python function to compute the union of two lists where each element is a sublist and the sublists are of different lengths. The union should contain all unique sublists from both lists. The function should handle lists with sublists of varying lengths and ensure that no duplicate sublists are included in the r... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def compute_union_of_lists(list1: List[List[int]], list2: List[List[int]]) -> List[List[int]]:
"""
Computes the union of two lists where each element is a sublist and the sublists are of different length... |
code_exercise_27k | 4,846 | Write a Python function to remove all vowels from each string in a given list of strings. The function should use the `map` function to apply the transformation to each string in the list. The code should start with:
```python
from typing import List
def remove_vowels_from_strings(strings: List[str]) -> List[str]:
```... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_vowels_from_strings(strings: List[str]) -> List[str]:
"""
Removes all vowels from each string in a given list of strings.
Args:
strings (List[str]): A list of strings from which v... |
code_exercise_27k | 4,847 | Write a Python function to compute the union of multiple lists, where each element is a sublist and the sublists are of different lengths. The function should return a list containing all unique elements from the input sublists, maintaining the order of their first appearance.
The code should start with:
```python
fro... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def union_of_lists(lists: List[List[int]]) -> List[int]:
"""
Compute the union of multiple lists, where each element is a sublist and the sublists are of different lengths.
The union is returned as a... |
code_exercise_27k | 4,851 | Write a Python function to check if each element in a list of strings is a palindrome using the `map` function. The function should return a list of boolean values, where each boolean indicates whether the corresponding string is a palindrome.
The code should start with:
```python
from typing import List
def check_pa... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_palindrome(s: str) -> bool:
"""
Check if a given string is a palindrome.
Parameters:
s (str): The string to check.
Returns:
bool: True if the string is a palindrome, False otherw... |
code_exercise_27k | 4,855 | Write a Python function to compute the union of two lists, where each element is a sublist and the sublists are of different lengths, preserving the original order of sublists. The function should return a new list containing the unique sublists from both input lists. The code should start with:
```python
from typing i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def compute_sublist_union(list1: List[List[int]], list2: List[List[int]]) -> List[List[int]]:
"""
Compute the union of two lists of sublists, preserving the original order of sublists.
Args:
... |
code_exercise_27k | 4,860 | Write a Python function to convert each string in a given list to lowercase and reverse it using the `map` function. The function should return a new list containing the converted strings. The code should start with:
```python
from typing import List
def convert_strings(strings: List[str]) -> List[str]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def convert_strings(strings: List[str]) -> List[str]:
"""
Convert each string in the given list to lowercase and reverse it.
Args:
strings (List[str]): A list of strings to be converted.
... |
code_exercise_27k | 4,875 | Write a Python function to compute the union of multiple lists, where each element is a sublist and the sublists are of different lengths, using the set data structure. The function should handle any number of sublists and ensure that the union contains only unique elements from all sublists.
The code should start wit... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def compute_union_of_lists(lists: List[List[int]]) -> set:
"""
Computes the union of multiple lists, where each element is a sublist with different lengths.
Args:
lists (List[List[int]]): A ... |
code_exercise_27k | 4,883 | Write a Python function to compute the union of two lists, where each element is a sublist and the sublists are of different lengths, without using any built-in functions or data structures. The function should ensure that the union contains only unique sublists, meaning no duplicate sublists should be present in the r... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def compute_union_of_lists(list1: List[List[int]], list2: List[List[int]]) -> List[List[int]]:
"""
Computes the union of two lists of sublists, ensuring that the result contains only unique sublists.
... |
code_exercise_27k | 4,888 | Write a Python function to find the union of two lists, where each element is a sublist and the sublists are of different lengths, without using any built-in functions or data structures and removing duplicates. The function should start with:
```python
from typing import List
def find_union_of_lists(list1: List[List[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_union_of_lists(list1: List[List[int]], list2: List[List[int]]) -> List[List[int]]:
"""
Find the union of two lists, where each element is a sublist and the sublists are of different lengths,
... |
code_exercise_27k | 4,889 | Write a Python function to count the number of occurrences of a specific word in each string of a given list of strings. The function should use the `map` function to apply a helper function that counts the occurrences of the word in each string. The code should start with:
```python
from typing import List
def count_... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_word_occurrences(strings: List[str], word: str) -> List[int]:
"""
Count the occurrences of a specific word in each string in a given list.
Args:
strings (List[str]): A list of stri... |
code_exercise_27k | 4,892 | Write a Python function to compute the union of multiple lists, where each element is a sublist and the sublists are of different lengths, without using any built-in functions or data structures specifically designed for set operations. The function should return a list containing all unique elements from the sublists,... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def union_of_lists(lists: List[List[int]]) -> List[int]:
"""
Compute the union of multiple lists, where each element is a sublist.
Parameters:
lists (List[List[int]]): A list of sublists.
R... |
code_exercise_27k | 4,896 | Write a Python function to find the union of multiple lists, where each element is a sublist and the sublists are of different lengths, without using any built-in functions or data structures and removing duplicates. The function should start with:
```python
from typing import List
def find_union_of_lists(lists: List[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_union_of_lists(lists: List[List[int]]) -> List[int]:
"""
Finds the union of multiple lists where each element is a sublist.
Removes duplicates and returns the union as a new list.
Args:... |
code_exercise_27k | 4,897 | Write a Python function to calculate the sum of squares of each sublist in a given list of numbers. Each sublist contains integers. The function should use the `map` function to apply a helper function that calculates the sum of squares for each sublist. The code should start with:
```python
from typing import List
de... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_of_squares_sublists(numbers: List[List[int]]) -> List[int]:
"""
Calculates the sum of squares for each sublist in a given list of numbers.
Args:
numbers (List[List[int]]): A list of ... |
code_exercise_27k | 4,900 | Write a Python function to remove all special characters and digits from each string in a given list using the `map` function. The function should return a new list with all the special characters and digits removed from each string. The code should start with:
```python
from typing import List
def remove_special_char... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_special_chars_digits(strings: List[str]) -> List[str]:
"""
Remove all special characters and digits from each string in a list.
Args:
strings (List[str]): A list of strings from w... |
code_exercise_27k | 4,902 | Write a Python function to calculate the area of a triangle given its three vertices as tuples of coordinates. The function should handle the input validation to ensure that the input points are valid tuples of two elements each. The function should return the area of the triangle or `None` if the input is invalid.
Th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple, Optional
def calculate_triangle_area(point1: Tuple[float, float], point2: Tuple[float, float], point3: Tuple[float, float]) -> Optional[float]:
"""
Calculate the area of a triangle given its three vert... |
code_exercise_27k | 4,903 | Write a Python function to compute the union of two sorted lists, where each element is a sublist and the sublists are of different lengths. The union should be computed by merging overlapping sublists and ensuring that the resulting list of sublists is also sorted.
The code should start with:
```python
from typing im... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def get_union_of_sorted_lists(sorted_list1: List[List[int]], sorted_list2: List[List[int]]) -> List[List[int]]:
"""
Computes the union of two sorted lists, where each element is a sublist and the sublist... |
code_exercise_27k | 4,910 | Write a Python function to calculate the sum of cubes of each sublist in a given nested list of numbers. The function should use the `map` function to apply the sum of cubed elements to each sublist. The code should start with:
```python
from typing import List
def calculate_sum_of_cubes(nested_list: List[List[int]]) ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_sum_of_cubes(nested_list: List[List[int]]) -> List[int]:
"""
Calculates the sum of cubes for each sublist in a nested list of numbers.
Args:
nested_list (List[List[int]]): A ne... |
code_exercise_27k | 4,913 | Write a Python function to compute the union of multiple sorted lists, where each element is a sublist and the sublists are of different lengths. The union should be a single sorted list containing all unique elements from the input sublists. The function should efficiently merge the sublists while maintaining the sort... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def compute_union_of_sorted_lists(sorted_lists: List[List[int]]) -> List[int]:
"""
Computes the union of multiple sorted lists, ensuring all elements are unique and sorted.
Args:
sorted_list... |
code_exercise_27k | 4,915 | Write a Python function to find the union of multiple sorted lists, where each element is a sublist and the sublists are of different lengths, removing duplicates. The function should efficiently merge the lists while maintaining the sorted order.
The code should start with:
```python
from typing import List
def find... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import heapq
def find_union_of_sorted_lists(sorted_lists: List[List[int]]) -> List[int]:
"""
Finds the union of multiple sorted lists, removing duplicates, and returns the result in sorted order.
Ar... |
code_exercise_27k | 4,918 | Write a Python function to count the number of occurrences of a specific substring in each string of a given list of strings. The function should use the `map` function to apply the counting operation to each string in the list. The code should start with:
```python
from typing import List
def count_substring_occurren... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_substring_occurrences(strings: List[str], substring: str) -> List[int]:
"""
Count the number of occurrences of a specific substring in each string of a given list.
Args:
strings (L... |
code_exercise_27k | 4,919 | Write a Python function to calculate the sum of all elements in a given list, but with a twist: the function should also handle nested lists, i.e., lists that contain other lists as elements. The function should recursively sum all elements, including those in nested lists.
The code should start with:
```python
from t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def recursive_list_sum(lst: List[Union[int, float, List]]) -> Union[int, float]:
"""
Calculate the sum of all elements in a given list, including elements in nested lists.
Args:
lst (... |
code_exercise_27k | 4,921 | Write a Python function to find the k-th largest element in a given list of integers. The function should efficiently handle cases where the list is empty, contains duplicate elements, or has fewer elements than k. The code should start with:
```python
from typing import List, Optional
def find_kth_largest_element(lst... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def find_kth_largest_element(lst: List[int], k: int) -> Optional[int]:
"""
Find the k-th largest element in a given list of integers.
Args:
lst (List[int]): The list of integers fr... |
code_exercise_27k | 4,924 | Write a Python function to calculate the sum of absolute values for each sublist in a given list of sublists. The function should use the `map` function to achieve this. The code should start with:
```python
from typing import List
def sum_of_abs_sublists(sublists: List[List[int]]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_of_abs_sublists(sublists: List[List[int]]) -> List[int]:
"""
Calculates the sum of absolute values for each sublist in the given list of sublists.
Args:
sublists (List[List[int]]): A... |
code_exercise_27k | 4,927 | Write a Python function to remove all whitespace and punctuation marks from each string in a given list using the `map` function. The function should return a list of modified strings. The code should start with:
```python
from typing import List
import string
def remove_whitespace_and_punctuation(strings: List[str]) ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import string
def remove_whitespace_and_punctuation(strings: List[str]) -> List[str]:
"""
Remove all whitespace and punctuation marks from each string in the given list.
Args:
strings (List[... |
code_exercise_27k | 4,928 | Write a Python function to remove duplicate elements from a given list while preserving the order of the first occurrence of each element. The function should return a new list with all duplicate elements removed. The code should start with:
```python
from typing import List
def remove_duplicates_preserve_order(lst: L... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_duplicates_preserve_order(lst: List[int]) -> List[int]:
"""
Remove duplicate elements from a given list while preserving the order of the first occurrence of each element.
Args:
l... |
code_exercise_27k | 4,930 | Write a Python function to process a list of strings such that each string is reversed and converted to lowercase. The function should use the `map` function with a lambda function to achieve this. The code should start with:
```python
from typing import List
def reverse_and_lower(strings: List[str]) -> List[str]:
```... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_and_lower(strings: List[str]) -> List[str]:
"""
Reverse each word in a list of strings and convert it to lowercase.
Args:
strings (List[str]): A list of strings to be processed.
... |
code_exercise_27k | 4,932 | Write a Python function to count the number of occurrences of each element in a given list and return the results as a dictionary where the keys are the elements and the values are their respective counts. The function should handle lists containing any hashable types.
The code should start with:
```python
from typing... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Any
def count_element_occurrences(lst: List[Any]) -> Dict[Any, int]:
"""
Count the number of occurrences of each element in a given list and return the results as a dictionary.
Args:
... |
code_exercise_27k | 4,933 | Write a Python function to calculate the area of a square given the side length. The function should handle both integer and floating-point inputs and raise a `ValueError` if the side length is not a positive number. The code should start with:
```python
def calculate_square_area(side_length: float) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_square_area(side_length: float) -> float:
"""
Calculates the area of a square given the side length.
Args:
side_length (float): The length of the side of the square.
Returns:
float: The ar... |
code_exercise_27k | 4,936 | Write a Python function to check if a given list is sorted in descending order. The function should return `True` if the list is sorted in descending order, and `False` otherwise. The list must contain elements that can be compared using the `>` operator. An empty list is considered sorted.
The code should start with:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_list_sorted_descending(lst: List) -> bool:
"""
Check if a given list is sorted in descending order.
Args:
lst (List): A list of elements.
Returns:
bool: True if the list ... |
code_exercise_27k | 4,938 | Write a Python function to calculate the volume of a pyramid given its base length, base width, and height. The function should handle negative input values by raising a `ValueError`. The code should start with:
```python
def calculate_volume_of_pyramid(base_length: float, base_width: float, height: float) -> float:
``... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_volume_of_pyramid(base_length: float, base_width: float, height: float) -> float:
"""
Calculates the volume of a pyramid given its base length, base width, and height.
Args:
base_length (float): The le... |
code_exercise_27k | 4,939 | Write a Python function to reverse a given list in-place without using any additional data structures or built-in functions that directly reverse the list. The function should modify the original list and return it. The code should start with:
```python
from typing import List
def reverse_list_in_place(lst: List[int])... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_list_in_place(lst: List[int]) -> List[int]:
"""
Reverses a given list in-place.
Args:
lst (List[int]): The list to be reversed.
Returns:
List[int]: The reversed list... |
code_exercise_27k | 4,941 | Write a Python function to find the common elements between two given lists. The function should return a new list containing the common elements, preserving the order of their first appearance in the first list. The code should start with:
```python
from typing import List
def find_common_elements(list1: List, list2:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_common_elements(list1: List, list2: List) -> List:
"""
Finds the common elements between two lists and returns them in a new list,
preserving the order of their first appearance in the first... |
code_exercise_27k | 4,946 | Write a Python function to find the index of the first occurrence of a given element in a list. If the element is not found, the function should return `None`. The function should handle lists of any type, including nested lists.
The code should start with:
```python
from typing import Any, List, Optional
def find_fi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Any, List, Optional
def find_first_occurrence(lst: List[Any], element: Any) -> Optional[int]:
"""
Find the index of the first occurrence of a given element in a list.
Args:
lst (List[Any]): The l... |
code_exercise_27k | 4,948 | Write a Python function to check if each element in a list is a perfect number using the `map` function. A perfect number is a positive integer that is equal to the sum of its proper divisors (excluding itself). The function should return a list of boolean values indicating whether each number in the input list is a pe... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_perfect_number(num: int) -> bool:
"""
Check if a number is a perfect number.
Args:
num (int): The number to check.
Returns:
bool: True if the number is a perfect number, ... |
code_exercise_27k | 4,951 | Write a Python function to remove the nth occurrence of a specific element from a given list. If the element does not exist in the list or the occurrence number is out of range, the function should raise a `ValueError`. The function should start with:
```python
from typing import List, Any
def remove_nth_occurrence(ls... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
def remove_nth_occurrence(lst: List[Any], element: Any, n: int) -> List[Any]:
"""
Remove the nth occurrence of a specific element from a given list.
Args:
lst (List[Any]): The input lis... |
code_exercise_27k | 4,963 | Write a Python function to find the k-th largest element in a given list of integers. The function should handle duplicate elements by treating them as distinct values. If the list has fewer than k elements, the function should raise a `ValueError`.
The code should start with:
```python
from typing import List
def fi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_kth_largest(nums: List[int], k: int) -> int:
"""
Finds the k-th largest element in a given list of integers.
Args:
nums (List[int]): A list of integers.
k (int): The positio... |
code_exercise_27k | 4,965 | Write a Python function to find the symmetric difference between two sets, A and B, and return the result as a new set. The symmetric difference between two sets is defined as the set of elements which are in either of the sets, but not in their intersection. The code should start with:
```python
def symmetric_differen... | Here is the Python code to solve the given problem in the markdown block:
```python
def symmetric_difference(A: set, B: set) -> set:
"""
Compute the symmetric difference between two sets A and B.
The symmetric difference is defined as the set of elements which are in either of the sets,
but not in thei... |
code_exercise_27k | 4,966 | Write a Python function to find all elements in a given list that appear more than once. The function should return a list of these duplicate elements, ensuring that each element appears only once in the result list. The code should start with:
```python
from typing import List
def find_duplicates(lst: List[int]) -> L... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
from collections import Counter
def find_duplicates(lst: List[int]) -> List[int]:
"""
Find all elements in the given list that appear more than once.
Args:
lst (List[int]): The list of integ... |
code_exercise_27k | 4,967 | Write a Python function to check if a given key exists in a dictionary and return the corresponding value if the key exists, otherwise return a default value. The function should handle cases where the dictionary is empty or the key is not found.
The code should start with:
```python
from typing import Any, Dict, Opti... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Any, Dict, Optional
def get_value_or_default(dictionary: Dict[Any, Any], key: Any, default: Optional[Any] = None) -> Optional[Any]:
"""
Check if a given key exists in the dictionary and return the correspondi... |
code_exercise_27k | 4,979 | Write a Python function to calculate the total character count of all the strings combined in a given list of strings. The function should handle an empty list and strings of varying lengths. The code should start with:
```python
from typing import List
def total_character_count(strings: List[str]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def total_character_count(strings: List[str]) -> int:
"""
Calculates the total character count of all the strings in the input list.
Args:
strings (List[str]): A list of strings.
Return... |
code_exercise_27k | 4,980 | Write a Python function to update a given set `A` to contain only the elements that are unique to `A` (i.e., elements that are not present in another set `B`). The function should modify the set `A` in place and return the updated set `A`.
The code should start with:
```python
def update_set_a(a: set, b: set) -> set:
... | Here is the Python code to solve the given problem in the markdown block:
```python
def update_set_a(a: set, b: set) -> set:
"""
Update set A to contain only the elements that are unique to set A (i.e., elements not present in set B).
Args:
a (set): The original set A.
b (set): The set B.
... |
code_exercise_27k | 4,982 | Write a Python function to filter out and return a new list containing only the even numbers from a given list of integers. The function should handle an empty list and return an empty list in that case. The function should also handle lists with no even numbers and return an empty list in that case. The code should st... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_even_numbers(lst: List[int]) -> List[int]:
"""
Filters out and returns a new list containing only the even numbers from the given list.
Args:
lst (List[int]): The original list of... |
code_exercise_27k | 4,987 | Write a Python function to reverse the words in a given sentence while maintaining the order of the words. For example, if the input is "Hello world this is a test", the output should be "test a is this world Hello". The function should handle sentences with varying lengths and multiple spaces between words.
The code ... | Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_sentence(sentence: str) -> str:
"""
Reverses the words in a given sentence while maintaining the order of the words.
Args:
sentence (str): The input sentence whose words are to be reversed.
Returns:... |
code_exercise_27k | 4,990 | Write a Python function to filter out the even numbers from a given list of integers and return a new list containing those even numbers in reverse order. The function should handle an empty list and return an empty list in such cases. The code should start with:
```python
from typing import List
def reverse_even_numb... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_even_numbers(numbers: List[int]) -> List[int]:
"""
Filters out the even numbers from the given list of integers and returns a new list with those even numbers in reverse order.
Args:
... |
code_exercise_27k | 4,994 | Write a Python function to find the symmetric difference between two lists of dictionaries. The symmetric difference should return a list of dictionaries that are present in either of the two lists but not in both. The function should handle dictionaries with different key-value pairs and ensure that the comparison is ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def symmetric_difference(list1: List[Dict], list2: List[Dict]) -> List[Dict]:
"""
Find the symmetric difference between two lists of dictionaries.
Args:
list1 (List[Dict]): The first l... |
code_exercise_27k | 4,996 | Write a Python function to update a set `A` to only contain elements that are present in set `A` but not in set `B`. The function should modify the original set `A` in place and return the updated set `A`. The code should start with:
```python
def update_set_a(set_a: set, set_b: set) -> set:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def update_set_a(set_a: set, set_b: set) -> set:
"""
Update set A to only contain elements that are present in set A but not in set B.
Args:
set_a (set): The original set A.
set_b (set): The set B.
Retu... |
code_exercise_27k | 4,997 | Write a Python function to sort a list of strings in alphabetical order, considering case sensitivity. The function should return a new list with the sorted strings. The code should start with:
```python
from typing import List
def sort_strings_case_sensitive(strings: List[str]) -> List[str]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_strings_case_sensitive(strings: List[str]) -> List[str]:
"""
Sorts a list of strings in alphabetical order with case sensitivity.
Args:
strings (List[str]): A list of strings to be ... |
code_exercise_27k | 5,000 | Write a Python function to determine whether a given number is a prime number or not. The function should return `True` if the number is prime and `False` otherwise. The function should handle edge cases such as numbers less than or equal to 1, which are not prime by definition.
The code should start with:
```python
d... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_prime(number: int) -> bool:
"""
Determine whether a given number is a prime number or not.
Args:
number (int): The number to be checked for primality.
Returns:
bool: True if the number is prime, ... |
code_exercise_27k | 5,008 | Write a Python function to find the length of a given frozen set. The function should raise a `TypeError` if the input is not a `frozenset`. The code should start with:
```python
def get_frozen_set_length(f_set: frozenset) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def get_frozen_set_length(f_set: frozenset) -> int:
"""
Calculate the length of a given frozen set.
Args:
f_set (frozenset): The input frozen set.
Returns:
int: The length of the frozen set.
Raises... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.