source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
evol_instruct_66k | 6,307 | Write a Python function to calculate the total cost of purchasing a specified quantity of items at a given per-unit price. The function should handle both integer and floating-point values for the quantity and per-unit price. The code should start with:
```python
def calculate_total_cost(quantity: float, per_unit_price... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_total_cost(quantity: float, per_unit_price: float) -> float:
"""
Calculate the total cost of purchasing a specified quantity of items at a given per-unit price.
Args:
quantity (float): The number of it... |
evol_instruct_66k | 6,309 | Write a Python function to initialize a dictionary from two lists: one containing keys and the other containing corresponding values. The function should ensure that the dictionary is correctly assigned with the provided keys and values. The code should start with:
```python
from typing import List, Dict
def create_di... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def create_dictionary(keys: List[str], values: List[any]) -> Dict[str, any]:
"""
Creates a dictionary from two lists: one containing keys and the other containing corresponding values.
Args:
... |
evol_instruct_66k | 6,310 | Write a Python function to determine if two given strings are anagrams of each other. An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. The function should handle case insensitivity and ignore spaces. The function shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
def are_anagrams(string1: str, string2: str) -> bool:
"""
Determine if two strings are anagrams of each other.
Args:
string1 (str): The first string to check.
string2 (str): The second string to check.
... |
evol_instruct_66k | 6,315 | Write a Python function to find all even integers within a given range `[start, end]` (both inclusive) and return them as a list. The function should include a check to ensure only even numbers are included in the result. The code should start with:
```python
from typing import List
def find_even_numbers(start: int, e... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_even_numbers(start: int, end: int) -> List[int]:
"""
Find all even integers within the given range [start, end] (both inclusive).
Args:
start (int): The starting integer of the rang... |
evol_instruct_66k | 6,330 | Write a Python function to calculate the highest common factor (HCF) of three given integers, `a`, `b`, and `c`. Additionally, ensure that `a`, `b`, and `c` are positive integers between 1 and 500. The function should raise an `AssertionError` if any of the inputs are outside this range.
The code should start with:
``... | Here is the Python code to solve the given problem in the markdown block:
```python
def highest_common_factor(a: int, b: int, c: int) -> int:
"""
Calculate the highest common factor (HCF) of three integers a, b, and c.
Ensure that a, b, and c are positive integers between 1 and 500.
Args:
a (in... |
evol_instruct_66k | 6,335 | Write a Python function that takes a list of integers as input and returns a list of tuples where each tuple contains the position (index) and the corresponding element from the input list. The function should use the `enumerate` function to achieve this.
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, Tuple
def list_elements_with_positions(my_list: List[int]) -> List[Tuple[int, int]]:
"""
Returns a list of tuples where each tuple contains the position (index) and the corresponding element from the in... |
evol_instruct_66k | 6,361 | Write a Python function to arrange a list of numerical elements in a hierarchical sequence starting from the smallest node and incrementally progressing to the largest node. The function should return the sorted list.
The code should start with:
```python
from typing import List
def hierarchical_sort(elements: List[i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def hierarchical_sort(elements: List[int]) -> List[int]:
"""
Arrange a list of numerical elements in a hierarchical sequence starting from the smallest node and incrementally progressing to the largest n... |
evol_instruct_66k | 6,364 | Write a Python function to generate a list of tuples where each tuple contains successive elements from a given list. The function should handle lists of any length, including empty lists. The code should start with:
```python
from typing import List, Tuple
def successive_pairs(lst: List[int]) -> List[Tuple[int, int]]... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def successive_pairs(lst: List[int]) -> List[Tuple[int, int]]:
"""
Generate a list of tuples where each tuple contains successive elements from the given list.
Args:
lst (List[int]): ... |
evol_instruct_66k | 6,395 | Write a Python function to display the elements of a given multi-dimensional array along with their index positions within their respective sub-arrays. The function should iterate through each sub-array and each element within the sub-array, printing the element and its index position in the format: "Element 'element' ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def display_elements_with_indices(array: List[List[str]]) -> None:
"""
Displays each element of a multi-dimensional array along with its index position within its respective sub-array.
Args:
... |
evol_instruct_66k | 6,401 | Write a Python function to merge two sorted lists into a single sorted list efficiently. The function should use a two-pointer technique to achieve this without using the built-in `sort` method. The code should start with:
```python
from typing import List
def merge_sorted_lists(list1: List[int], list2: List[int]) -> ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_sorted_lists(list1: List[int], list2: List[int]) -> List[int]:
"""
Merge two sorted lists into a single sorted list using a two-pointer technique.
Args:
list1 (List[int]): The firs... |
evol_instruct_66k | 6,406 | 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 be efficient and handle large lists.
The code should start with:
```python
from typing import List
def remove_duplicates(arr: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_duplicates(arr: List[int]) -> List[int]:
"""
Removes duplicate elements from the given list while preserving the order of the first occurrence of each element.
Args:
arr (List[int... |
evol_instruct_66k | 6,416 | Write a Python function to validate a string based on the following criteria:
1. The string must start with a non-alphanumeric character.
2. Followed by exactly three lowercase alphabetic characters.
3. Ending with a numeric sequence of two to four digits.
The function should return `True` if the string matches the cr... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_string(s: str) -> bool:
"""
Validates a string based on the following criteria:
1. The string must start with a non-alphanumeric character.
2. Followed by exactly three lowercase alphabetic charac... |
evol_instruct_66k | 6,420 | Write a Python function to isolate and identify the alphanumeric elements within a given textual segment. The function should return a list of these elements. The code should start with:
```python
from typing import List
import re
def extract_alphanumeric_elements(text: str) -> List[str]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def extract_alphanumeric_elements(text: str) -> List[str]:
"""
Extracts and returns a list of alphanumeric elements from the given text.
Args:
text (str): The input text from which... |
evol_instruct_66k | 6,427 | Write a Python function to create a 5x5 2D array where each row is a sequence of numbers from 1 to 5 in increments of 1. Additionally, create a function that rotates the 2D array 90 degrees clockwise. The code should start with:
```python
from typing import List
def create_2d_array() -> List[List[int]]:
"""
Cr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def create_2d_array() -> List[List[int]]:
"""
Create a 5x5 2D array where each row is a sequence of numbers from 1 to 5.
Returns:
List[List[int]]: A 5x5 2D array with each row as [1, 2, 3, 4... |
evol_instruct_66k | 6,449 | Write a Python function to reverse the order of elements in a given list of strings. The function should take a list of strings as input and return a new list with the elements in reverse order. The original list should not be modified.
The code should start with:
```python
from typing import List
def reverse_list(in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_list(input_list: List[str]) -> List[str]:
"""
Reverses the order of elements in a given list of strings.
Args:
input_list (List[str]): The list of strings to be reversed.
Re... |
evol_instruct_66k | 6,453 | Write a Python function to generate all possible subsets of a given set of elements, including the empty set and duplicate subsets of non-distinct elements. The function should maintain a time complexity below O(2^n * n), where n is the number of elements in the set.
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 generate_all_subsets(original_set: List[int]) -> List[List[int]]:
"""
Generate all possible subsets of a given set of elements, including the empty set and duplicate subsets of non-distinct elements.... |
evol_instruct_66k | 6,456 | Write a Python function to compute the aggregate sum of all numerical entities within a supplied list of tuples. The function should traverse nested tuple structures, exclude non-numeric elements, and handle complex numbers by summing their real components. The function should also be robust enough to handle edge cases... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Union
from collections import deque
def aggregate_sum_of_tuples(tuples: Union[List[Tuple], Tuple]) -> float:
"""
Computes the aggregate sum of all numerical entities within a supplied list of tup... |
evol_instruct_66k | 6,458 | Write a Python function to create a list of dictionaries, where each dictionary contains a unique name and a random number. Additionally, implement a method to calculate the sum of all random numbers in the list. The function should ensure that no two dictionaries have the same name.
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, Dict
import random
import string
def create_random_list(n: int) -> List[Dict[str, int]]:
"""
Create a list of dictionaries, each containing a unique name and a random number.
Additionally, provide a... |
evol_instruct_66k | 6,459 | Write a Python function to rearrange a given list in descending order without duplicates. The function should take a list of integers as input and return a new list with the elements sorted in descending order, with all duplicates removed.
The code should start with:
```python
from typing import List
def rearrange_de... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def rearrange_descending_unique(lst: List[int]) -> List[int]:
"""
Rearranges the given list in descending order without duplicates.
Args:
lst (List[int]): The list of integers to rearrange.
... |
evol_instruct_66k | 6,477 | Write a Python function to display the key-value pairs of a given dictionary. The dictionary contains personal data attributes such as name, age, and city of residence. The function should iterate over the dictionary and print each key-value pair in the format "Key: {key}, Value: {value}".
The code should start with:
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def display_key_value_pairs(personal_data: Dict[str, str]) -> None:
"""
Display the key-value pairs of a given dictionary containing personal data attributes.
Args:
personal_data (Dict[str, ... |
evol_instruct_66k | 6,487 | Write a Python function to find all possible original decimal numbers that satisfy the given conditions. The conditions are:
1. The digit in the tenth place (`b`) is twice the digit in the hundredths place (`c`) minus the digit in the ones place (`a`).
2. The digit in the thousandths place (`d`) is equivalent to the su... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_possible_decimals() -> List[float]:
"""
Find all possible original decimal numbers that satisfy the given conditions.
Conditions:
1. The digit in the tenth place (b) is twice the digit ... |
evol_instruct_66k | 6,489 | Write a Python function to determine if a given substring is present within another input string. The function should return a boolean value indicating whether the substring is found within the main string. The code should start with:
```python
def is_substring_present(main_string: str, substring: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_substring_present(main_string: str, substring: str) -> bool:
"""
Determines if a given substring is present within another input string.
Args:
main_string (str): The main string in which to search for the sub... |
evol_instruct_66k | 6,497 | Write a Python function to perform cross-multiplication on two lists of numerical entities. The function should handle cases where the lists are of unequal length or contain non-numeric values. If the lists are of unequal length or contain non-numeric values, the function should return an appropriate error message. Oth... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def cross_multiply(list_1: List[Union[int, float]], list_2: List[Union[int, float]]) -> Union[List[Union[int, float]], str]:
"""
Perform cross-multiplication on two lists of numerical entities.
... |
evol_instruct_66k | 6,508 | Write a Python function to create a dictionary where the keys are prime numbers between 1 and 50, and the values are their respective natural logarithms. Use a dictionary comprehension for this task. The function should start with:
```python
from typing import Dict
def prime_logarithms() -> Dict[int, float]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
import math
def check_prime(n: int) -> bool:
"""
Check if a number is prime.
Args:
n (int): The number to check.
Returns:
bool: True if the number is prime, False otherwise.
... |
evol_instruct_66k | 6,510 | Write a Python function to rotate the elements of a given array of commodities by a specified number of intervals. The rotation should be such that the elements are repositioned in a cyclic manner. The function should handle both positive and negative values of the interval, and it should ensure that the interval is wi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def rotate_commodities(commodities: List[str], interval: int) -> List[str]:
"""
Rotates the elements of a given array of commodities by a specified number of intervals.
Args:
commodities (Li... |
evol_instruct_66k | 6,512 | Write a Python function to reverse the order of words in a given string while maintaining the order of characters within each word. The function should handle strings with multiple spaces and leading/trailing spaces. The code should start with:
```python
def reverse_words_in_string(input_string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_words_in_string(input_string: str) -> str:
"""
Reverses the order of words in a given string while maintaining the order of characters within each word.
Args:
input_string (str): The input string to be p... |
evol_instruct_66k | 6,521 | Write a Python function to generate all possible permutations of N distinct numerical values. Each permutation should be a tuple of integers, and the function should return a list of all such permutations. The code should start with:
```python
from typing import List, Tuple
def generate_permutations(N: int) -> List[Tu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
from itertools import permutations
def generate_permutations(N: int) -> List[Tuple[int]]:
"""
Generate all possible permutations of N distinct numerical values.
Args:
N (int): The num... |
evol_instruct_66k | 6,524 | Write a Python function to convert between different heat measurement units, specifically British Thermal Units (BTUs), Joules, Calories, and Watt-Hours. The function should handle incorrect or out-of-bound input values and return appropriate error messages. The function should start with:
```python
def convert_heat_un... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_heat_units(value: float, from_unit: str, to_unit: str) -> float or str:
"""
Converts between different heat measurement units (BTUs, Joules, Calories, Watt-Hours).
Args:
value (float): The value to be co... |
evol_instruct_66k | 6,538 | Write a Python function to decode a string of colors in a specialized hex format into a list of RGB triplet tuples. Each color in the string is represented by a 4-character string starting with a `#` followed by three hexadecimal digits. The function should handle both uppercase and lowercase letters and raise an excep... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def decode_complex_colors(color_string: str) -> List[Tuple[int, int, int]]:
"""
Decodes a string of colors in a specialized hex format into a list of RGB triplet tuples.
Args:
color_s... |
evol_instruct_66k | 6,543 | Write a Python function to generate a formatted string that describes the taxonomic nomenclature of a given list of botanical fruit entities. The function should iterate over the list and construct a single string where each fruit is described in the format "The {fruit} is a botanical fruit entity." The final string sh... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_taxonomic_description(fruits: List[str]) -> str:
"""
Generates a formatted string that describes the taxonomic nomenclature of a given list of botanical fruit entities.
Args:
fr... |
evol_instruct_66k | 6,547 | Write a Python function to compute the product of all elements in a given list of numerical values efficiently. The function should handle lists of any length, including empty lists, and return the product of the elements. If the list is empty, the function should return 1.
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
import functools
import operator
def product_of_list(numbers: List[int]) -> int:
"""
Computes the product of all elements in the given list of numerical values.
Args:
numbers (List[int]): Th... |
evol_instruct_66k | 6,549 | Write a Python function to calculate the sum of the first 10 elements from a given sequence of integers. If the sequence has fewer than 10 elements, the function should return the sum of all elements in the sequence. The function should handle sequences of any length, including empty sequences.
The code should start w... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_first_10_elements(sequence: List[int]) -> int:
"""
Calculate the sum of the first 10 elements from a given sequence of integers.
If the sequence has fewer than 10 elements, return the sum of ... |
evol_instruct_66k | 6,561 | Write a Python function to calculate the value of the mathematical expression \((x-1)^2\) for a given integer \(x\). The function should be efficient and handle both positive and negative integers. The code should start with:
```python
def calculate_expression(x: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_expression(x: int) -> int:
"""
Calculate the value of the mathematical expression (x-1)^2 for a given integer x.
Args:
x (int): The integer input for which the expression is to be calculated.
Retu... |
evol_instruct_66k | 6,563 | Write a Python function to identify common elements from four distinct arrays, `a1`, `a2`, `a3`, and `a4`, that appear under the same index in all four arrays. The function should return an array of these common elements. The function should handle arrays of varying lengths and return common elements up to the length o... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
def find_common_elements(a1: List[Any], a2: List[Any], a3: List[Any], a4: List[Any]) -> List[Any]:
"""
Identifies common elements from four distinct arrays that appear under the same index in all fo... |
evol_instruct_66k | 6,569 | Write a Python function to distribute a given number of items evenly among a specified number of people, and determine the number of items that will remain undistributed. The function should return the number of items each person receives and the number of items left over.
The code should start with:
```python
def dis... | Here is the Python code to solve the given problem in the markdown block:
```python
def distribute_items(total_items: int, total_people: int) -> tuple[int, int]:
"""
Distributes a given number of items evenly among a specified number of people,
and determines the number of items that will remain undistribut... |
evol_instruct_66k | 6,574 | Write a Python function to identify and replace single-character strings in a nested list with a specified non-null value. The function should handle multi-dimensional arrays and cases where the replacement character might be included in the array. An empty string can also be embedded in the array.
The code should sta... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
def replace_single_char_strings(arr: List[Any], replacement: str) -> List[Any]:
"""
Replaces all single-character strings in a nested list with a specified non-null value.
Args:
arr (Li... |
evol_instruct_66k | 6,583 | Write a Python function to generate a GraphQL query string that retrieves a list of products from a database, including their ID, name, price, and any related categories. The query should support pagination with parameters for a limit and an offset. Additionally, provide a sample erroneous GraphQL query that demonstrat... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_product_query(limit: int, offset: int) -> str:
"""
Generates a GraphQL query string to retrieve a list of products from a database,
including their ID, name, price, and any related categories. The query supports... |
evol_instruct_66k | 6,587 | Write a Python function to calculate the absolute difference between two complex numbers. The function should return the magnitude of the difference between the two complex numbers. The code should start with:
```python
def absolute_difference_complex(num1: complex, num2: complex) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
import cmath
def absolute_difference_complex(num1: complex, num2: complex) -> float:
"""
Calculate the absolute difference between two complex numbers.
Args:
num1 (complex): The first complex number.
num2... |
evol_instruct_66k | 6,592 | Write a Python function to determine the numbers in a list based on a given ratio and their total sum. The function should handle multiple ratio and sum combinations efficiently. The code should start with:
```python
from typing import List, Tuple
def find_numbers_from_ratios(ratios: List[str], sums: List[int]) -> Lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_numbers_from_ratios(ratios: List[str], sums: List[int]) -> List[List[float]]:
"""
Determine the numbers in a list based on given ratios and their total sums.
Args:
ratios (Li... |
evol_instruct_66k | 6,612 | Write a Python function that generates a list of numbers from a given start value up to and including a given end value. The function should handle both positive and negative ranges, and should return an empty list if the start value is greater than the end value. The function should be named `generate_range` and shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_range(start: int, end: int) -> List[int]:
"""
Generate a list of numbers from the start value up to and including the end value.
Args:
start (int): The starting value of the ran... |
evol_instruct_66k | 6,618 | Write a Python function to find and return the highest even integer from a given list of integers. If the list does not contain any even integers, the function should return `None`.
The code should start with:
```python
from typing import List, Optional
def find_highest_even(numbers: List[int]) -> Optional[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def find_highest_even(numbers: List[int]) -> Optional[int]:
"""
Find and return the highest even integer from a given list of integers.
Args:
numbers (List[int]): A list of integer... |
evol_instruct_66k | 6,637 | Write a Python function to determine if a given integer array `arr` is a valid mountain array. A mountain array is defined as an array that meets the following criteria:
1. The length of the array is at least 3.
2. There exists an index `i` such that:
- The elements before `i` are strictly increasing.
- The eleme... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_valid_mountain_array(arr: List[int]) -> bool:
"""
Determines if the given array is a valid mountain array.
A valid mountain array must satisfy the following conditions:
1. The length of t... |
evol_instruct_66k | 6,645 | Write a Python function to filter out all instances of a specific number from a multi-dimensional input array and return the modified array. The function should handle arrays of different depths and formats. The code should start with:
```python
from typing import List, Union
def filter_number_from_array(input_array: ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def filter_number_from_array(input_array: List[Union[int, List]], filter_number: int) -> List[Union[int, List]]:
"""
Filters out all instances of a specific number from a multi-dimensional input a... |
evol_instruct_66k | 6,646 | Write a Python function to merge two sorted lists of integers without using built-in functions or libraries. The function should be implemented recursively. The code should start with:
```python
from typing import List
def merge_sorted_lists(list_1: List[int], list_2: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_sorted_lists(list_1: List[int], list_2: List[int]) -> List[int]:
"""
Merge two sorted lists of integers recursively without using built-in functions or libraries.
Args:
list_1 (Lis... |
evol_instruct_66k | 6,648 | Write a Python function to filter out integers from a given list that exceed a specified limit. The function should return a new list containing only the integers that are less than or equal to the specified limit. The code should start with:
```python
from typing import List
def filter_numbers_by_limit(numbers: List[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_numbers_by_limit(numbers: List[int], limit: int) -> List[int]:
"""
Filters out integers from a given list that exceed a specified limit.
Args:
numbers (List[int]): The list of int... |
evol_instruct_66k | 6,657 | Write a Python function to extract and return the rightmost digit before the decimal point from a given floating-point number. The function should handle both positive and negative floating-point numbers. The code should start with:
```python
def rightmost_digit_before_decimal(num: float) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def rightmost_digit_before_decimal(num: float) -> int:
"""
Extracts and returns the rightmost digit before the decimal point from a given floating-point number.
Args:
num (float): The floating-point number from whic... |
evol_instruct_66k | 6,660 | Write a Python function to count the number of vowels in a given string. The function should be case-insensitive, meaning both uppercase and lowercase vowels should be counted. The code should start with:
```python
def count_vowels(word: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def count_vowels(word: str) -> int:
"""
Counts the number of vowels in a given string.
Args:
word (str): The input string in which to count the vowels.
Returns:
int: The number of vowels in the input ... |
evol_instruct_66k | 6,666 | Write a Python function to find all the index positions of a particular element in a given list. The function should return a list of indices where the element is found. The code should start with:
```python
from typing import List
def find_indices(initial_list: List[int], element: int) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_indices(initial_list: List[int], element: int) -> List[int]:
"""
Find all the index positions of a particular element in a given list.
Args:
initial_list (List[int]): The list in wh... |
evol_instruct_66k | 6,667 | Write a Python function to calculate the normalized population density for each continent based on the provided population and land area data. The function should take two dictionaries as input: one containing the population data for each continent and the other containing the land area data for each continent. The fun... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def calculate_normalized_population_density(population_data: Dict[str, int], land_area_data: Dict[str, int]) -> Dict[str, float]:
"""
Calculate the normalized population density for each continent.
... |
evol_instruct_66k | 6,669 | Write a Python function to verify if a main list fully contains a sublist. The function should return `True` if all elements of the sublist are present in the main list in the same order, and `False` otherwise. The function should handle lists of any length, including empty lists.
The code should start with:
```python... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_sublist_in_order(main_list: List[str], sub_list: List[str]) -> bool:
"""
Verify if a main list fully contains a sublist in the same order.
Args:
main_list (List[str]): The main list t... |
evol_instruct_66k | 6,672 | Write a Python function to sort a list of tuples according to the specified criteria. Each tuple contains two integers and one string. The list should be sorted first by the first integer in ascending order, then by the second integer in descending order, and finally by the length of the string in descending order. The... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def custom_sort_tuples(lst: List[Tuple[int, int, str]]) -> List[Tuple[int, int, str]]:
"""
Sorts a list of tuples according to the specified criteria:
1. First by the first integer in ascendin... |
evol_instruct_66k | 6,674 | Write a Python function to generate the first `n` numbers in the Fibonacci sequence efficiently. The function should handle edge cases such as non-integer inputs and non-positive integers gracefully by raising appropriate exceptions. The code should start with:
```python
def generate_fibonacci(n: int) -> list:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def generate_fibonacci(n: int) -> list:
"""
Generate the first n numbers in the Fibonacci sequence.
Args:
n (int): The number of Fibonacci numbers to generate.
Returns:
list: A list containing the first... |
evol_instruct_66k | 6,677 | Write a Python function to extract and format specific key-value pairs from a given dictionary. The dictionary contains personal profile information such as the person's name, age, and city. The function should return a formatted string that includes the key and value for each specified key in the dictionary. If a spec... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List, Optional
def format_profile_info(profile: Dict[str, str], keys: List[str]) -> str:
"""
Extracts and formats specific key-value pairs from a given dictionary.
Args:
profile (Dict[str, ... |
evol_instruct_66k | 6,679 | Write a Python function to determine if one number is divisible by another. The function should handle exceptions and edge cases, such as when the divisor is zero or when the inputs are not integers or floats. The function should return a string indicating whether the first number is divisible by the second number or a... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_divisible(a: int, b: int) -> str:
"""
Determine if one number is divisible by another and handle exceptions.
Args:
a (int): The dividend.
b (int): The divisor.
Returns:
str: "Yes" if a is... |
evol_instruct_66k | 6,683 | Write a Python function to triple each element in a given list and then subtract 15 from each element. The function should return the modified list. The code should start with:
```python
from typing import List
def triple_and_subtract_15(arr: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def triple_and_subtract_15(arr: List[int]) -> List[int]:
"""
Triples each element in the given list and then subtracts 15 from each element.
Args:
arr (List[int]): The list of integers to ... |
evol_instruct_66k | 6,685 | Write a Python function that uses the `enumerate()` function to iterate over a list of numbers and prints both the index and the square of the respective indexed element. The function should handle any list of integers and should be designed to avoid common mistakes such as incorrect usage of `enumerate()`.
The code s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def print_indices_and_squares(num_list: List[int]) -> None:
"""
Prints the index and the square of the respective indexed element in the given list.
Args:
num_list (List[int]): A list of int... |
evol_instruct_66k | 6,688 | Write a Python function to convert a hexadecimal string into its corresponding ASCII string. The function should handle hexadecimal strings of even length and return the decoded ASCII string. If the input hexadecimal string is of odd length, the function should raise a `ValueError`.
The code should start with:
```pyth... | Here is the Python code to solve the given problem in the markdown block:
```python
def hex_to_ascii(hex_str: str) -> str:
"""
Converts a hexadecimal string into its corresponding ASCII string.
Args:
hex_str (str): The hexadecimal string to be converted. Must be of even length.
Returns:
... |
evol_instruct_66k | 6,700 | Write a Python function to reverse the elements of a given list while converting each element to lowercase, without using any built-in reverse methods or libraries. The function should start with:
```python
from typing import List
def reverse_and_lowercase(arr: 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_lowercase(arr: List[str]) -> List[str]:
"""
Reverses the elements of a given list of strings and converts each element to lowercase.
Args:
arr (List[str]): The list of string... |
evol_instruct_66k | 6,703 | Write a Python function to generate a new string by interleaving characters from three given numeric strings in an inverse sequence. The function should take three strings as input and return a single string where each character from the input strings is interleaved in reverse order.
The code should start with:
```pyt... | Here is the Python code to solve the given problem in the markdown block:
```python
def interleave_and_reverse_strings(numString1: str, numString2: str, numString3: str) -> str:
"""
Generates a new string by interleaving characters from three given numeric strings in an inverse sequence.
Args:
numS... |
evol_instruct_66k | 6,712 | Write a Python function to disassemble a given sentence into fragments, ensuring that spaces and punctuation marks are bypassed. The function should return a list of words extracted from the sentence.
The code should start with:
```python
from typing import List
def disassemble_sentence(sentence: str) -> List[str]:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import string
def disassemble_sentence(sentence: str) -> List[str]:
"""
Disassembles a given sentence into fragments, bypassing spaces and punctuation marks.
Args:
sentence (str): The senten... |
evol_instruct_66k | 6,718 | Write a Python function to determine the minimum number of operations required to ensure all computers in a network are interconnected. Each computer is identified by a unique number ranging from `0` to `n-1`, and the connections between computers are given as a list of pairs. Each pair `[a, b]` signifies a direct link... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def min_reorder_operations(n: int, connections: List[List[int]]) -> int:
"""
Determine the minimum number of operations required to ensure all computers in a network are interconnected.
Args:
... |
evol_instruct_66k | 6,726 | Write a Python function to count the occurrences of each distinct word in a given paragraph. The function should return a dictionary where the keys are the distinct words and the values are their respective counts. The function should be case-insensitive, meaning "Python" and "python" should be considered the same word... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
from collections import Counter
def count_distinct_words(paragraph: str) -> Dict[str, int]:
"""
Counts the occurrences of each distinct word in a given paragraph.
Args:
paragraph (str): The ... |
evol_instruct_66k | 6,727 | Write a Python function to create a NumPy array with four negative twos and four threes, and then reshape it into a 2x4 matrix. The function should handle the creation and reshaping of the array correctly. The code should start with:
```python
import numpy as np
def create_and_reshape_array() -> np.ndarray:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def create_and_reshape_array() -> np.ndarray:
"""
Creates a NumPy array with four negative twos and four threes, and reshapes it into a 2x4 matrix.
Returns:
np.ndarray: A 2x4 NumPy array with fou... |
evol_instruct_66k | 6,745 | Write a Python function to implement the Gnome Sort algorithm, which sorts a list of integers in ascending order. The function should start with:
```python
from typing import List
def gnome_sort(array: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def gnome_sort(array: List[int]) -> List[int]:
"""
Sorts the given list of integers using the Gnome Sort algorithm.
Args:
array (List[int]): The list of integers to be sorted.
Returns:
... |
evol_instruct_66k | 6,747 | Write a Python function to systematically remove all occurrences of a designated character from a provided textual dataset while ensuring the underlying grammar and syntactic structure remains undistorted. The function should handle various edge cases, such as the character appearing at the beginning, middle, or end of... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_character(text: str, char: str) -> str:
"""
Removes all occurrences of a designated character from the provided text while preserving the grammar and syntactic structure.
Args:
text (str): The input text ... |
evol_instruct_66k | 6,755 | Write a Python function to calculate and return the residue (remainder) of the division operation between two integers `x` and `y`. The function should handle potential errors, such as division by zero. The code should start with:
```python
def calculate_residue(x: int, y: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_residue(x: int, y: int) -> int:
"""
Calculate the residue (remainder) of the division operation between two integers x and y.
Args:
x (int): The dividend, an integer in the range [-10^4, 10^4].
... |
evol_instruct_66k | 6,756 | Write a Python function to compare two binary strings of equal length and return the number of differing bits between them, the binary representation of the differences (where '1' indicates a differing bit and '0' indicates an identical bit), and the decimal equivalent of the binary difference string.
The code should ... | Here is the Python code to solve the given problem in the markdown block:
```python
def compare_binary_strings(string1: str, string2: str) -> tuple:
"""
Compares two binary strings of equal length and returns the number of differing bits,
the binary representation of the differences, and the decimal equival... |
evol_instruct_66k | 6,759 | Write a Python function to calculate the total time that Ashe is in a poisoned condition given Teemo's attacking time series, the poisoning duration per attack, and the recovery time. The function should return the total poisoned time.
The code should start with:
```python
from typing import List
def total_poisoned_t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def total_poisoned_time(time_series: List[int], duration: int, recovery_time: int) -> int:
"""
Calculate the total time that Ashe is in a poisoned condition given Teemo's attacking time series,
the p... |
evol_instruct_66k | 6,772 | Write a Python function to scale all elements in a given list by a specified factor. The function should take two parameters: a list of integers and a scaling factor, which is an integer. The function should return a new list where each element is the corresponding element in the input list multiplied by the scaling fa... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def scale_elements(arr: List[int], scale_factor: int) -> List[int]:
"""
Scales all elements in the given list by the specified factor.
Args:
arr (List[int]): The list of integers to be scale... |
evol_instruct_66k | 6,774 | Write a Python function to normalize consecutive white spaces in a given text fragment into single spaces. The function should handle any number of consecutive white spaces and ensure that the resulting text contains only single spaces between words.
The code should start with:
```python
def normalize_spaces(text: str... | Here is the Python code to solve the given problem in the markdown block:
```python
def normalize_spaces(text: str) -> str:
"""
Normalizes consecutive white spaces in a given text fragment into single spaces.
Args:
text (str): The input text fragment containing potential consecutive white spaces.
... |
evol_instruct_66k | 6,784 | Write a Python function to determine if a given number is a perfect square. A perfect square is a number that can be expressed as the square of an integer. The function should handle both positive and negative integers. The code should start with:
```python
def is_perfect_square(n: int) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
import math
def is_perfect_square(n: int) -> bool:
"""
Determine if a given number is a perfect square.
Args:
n (int): The number to check.
Returns:
bool: True if the number is a perfect square, Fals... |
evol_instruct_66k | 6,788 | Write a Python function to convert a given date string in a human-readable format to the standardized ISO 8601 format. The input date string will be in the format "DayOfWeek, Month DayOfMonth, Year" (e.g., "Monday, April 7th, 2020"). The function should handle the removal of ordinal suffixes (like 'st', 'nd', 'rd', 'th... | Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime
def convert_to_iso_format(date_string: str) -> str:
"""
Converts a human-readable date string to the standardized ISO 8601 format.
Args:
date_string (str): The date string in the forma... |
evol_instruct_66k | 6,794 | Write a Python function to calculate the total number of unique paths from the top-left corner to the bottom-right corner of an m x n grid, where you can only move either down or right at any point in time.
The code should start with:
```python
from typing import List
def unique_paths(m: int, n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def unique_paths(m: int, n: int) -> int:
"""
Calculate the total number of unique paths from the top-left corner to the bottom-right corner of an m x n grid.
Args:
m (int): The number ... |
evol_instruct_66k | 6,808 | Write a Python function to decrement a provided number until it reaches zero, appending each intermediate number to a list. The function should return the list of numbers in the order they were appended.
The code should start with:
```python
from typing import List
def decrement_to_zero(start_number: int) -> List[int... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def decrement_to_zero(start_number: int) -> List[int]:
"""
Decrements the provided number until it reaches zero, appending each intermediate number to a list.
Args:
start_number (int): The i... |
evol_instruct_66k | 6,816 | Write a Python function to merge two lists into a dictionary, where the elements of the first list serve as the keys and the elements of the second list serve as the corresponding values. If the lists are of unequal length, the function should only merge the elements up to the length of the shorter list.
The code shou... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def merge_lists_to_dict(list1: List[str], list2: List[int]) -> Dict[str, int]:
"""
Merges two lists into a dictionary where the elements of the first list serve as keys
and the elements of the ... |
evol_instruct_66k | 6,818 | Write a Python function to perform a ternary search on a sorted numerical array. The function should return the index of the target element if it exists in the array, otherwise return -1. The code should start with:
```python
from typing import List
def ternary_search(arr: List[int], x: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def ternary_search(arr: List[int], x: int) -> int:
"""
Perform a ternary search on a sorted numerical array to find the index of the target element.
Args:
arr (List[int]): A sorted list of i... |
evol_instruct_66k | 6,820 | Write a Python function to determine if a given number is divisible by 4 but not by 8 using bitwise operations. The function should return `True` if the number meets the criteria and `False` otherwise. The code should start with:
```python
def is_divisible_by_4_not_8(n: int) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_divisible_by_4_not_8(n: int) -> bool:
"""
Determines if a given number is divisible by 4 but not by 8 using bitwise operations.
Args:
n (int): The number to be checked.
Returns:
bool: True if the... |
evol_instruct_66k | 6,852 | Write a Python function to calculate the nth Fibonacci number efficiently using dynamic programming. The function should have a time complexity of O(N) and a space complexity of O(N). The code should start with:
```python
def fibonacci(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def fibonacci(n: int) -> int:
"""
Calculate the nth Fibonacci number using dynamic programming.
Args:
n (int): The position of the Fibonacci number to calculate.
Returns:
int: The nth Fibonacci number.
... |
evol_instruct_66k | 6,858 | Write a Python function to compute the sum of the squares of two input variables. The function should take two numerical inputs, compute the square of each input, sum these squared values, and return the result. The code should start with:
```python
def sum_of_squares(x: float, y: float) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_squares(x: float, y: float) -> float:
"""
Computes the sum of the squares of two input variables.
Args:
x (float): The first input variable.
y (float): The second input variable.
Returns:
... |
evol_instruct_66k | 6,861 | Write a Python function to find the largest even number within a given inclusive range `[x, y]` that is divisible by a specified integer `z`. If no such number exists, the function should return `-1`.
The code should start with:
```python
def superior_parallel_dividend(x: int, y: int, z: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def superior_parallel_dividend(x: int, y: int, z: int) -> int:
"""
Find the largest even number within the inclusive range [x, y] that is divisible by z.
Args:
x (int): The lower bound of the range (inclusive).
... |
evol_instruct_66k | 6,869 | Write a Python function to subtract the second row from the first row of a given 2D matrix. The matrix is represented as a list of lists, where each inner list represents a row. The function should return the modified matrix with the first row updated as the result of the subtraction.
The code should start with:
```py... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def subtract_second_row_from_first(matrix: List[List[int]]) -> List[List[int]]:
"""
Subtracts the second row from the first row of a given 2D matrix.
Args:
matrix (List[List[int]]): A 2D mat... |
evol_instruct_66k | 6,884 | Write a Python function to continuously subtract the value of one from a given number until it hits zero. In every iteration of this process, record the present value of the number inside a list. The function should return the list of all intermediate numbers.
The code should start with:
```python
from typing import L... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def subtract_to_zero(start_number: int) -> List[int]:
"""
Continuously subtracts one from the given start_number until it hits zero,
recording each intermediate value in a list.
Args:
st... |
evol_instruct_66k | 6,885 | Write a Python function to compute the sum of consonants found in a submitted piece of text. The function should ignore case and count both uppercase and lowercase consonants. The function should start with:
```python
def consonant_count(text: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def consonant_count(text: str) -> int:
"""
Computes the sum of consonants found in the submitted piece of text.
Args:
text (str): The input text string to count consonants from.
Returns:
int: The cumula... |
evol_instruct_66k | 6,903 | Write a Python function to multiply two given 2D matrices. The function should handle matrices of any size, provided they are compatible for multiplication (i.e., the number of columns in the first matrix should be equal to the number of rows in the second matrix). The function should return the resulting matrix after ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def matrix_multiplication(matrixA: List[List[int]], matrixB: List[List[int]]) -> List[List[int]]:
"""
Multiplies two given 2D matrices and returns the resulting matrix.
Args:
matrixA (List[L... |
evol_instruct_66k | 6,905 | Write a Python function to count the number of vowel and consonant characters in a given string. The function should ignore case and non-alphabetic characters. The code should start with:
```python
def count_vowels_and_consonants(text: str) -> tuple:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def count_vowels_and_consonants(text: str) -> tuple:
"""
Counts the number of vowel and consonant characters in a given string.
Args:
text (str): The input string to analyze.
Returns:
tuple: A tuple con... |
evol_instruct_66k | 6,913 | Write a Python function to sort a given list of integers in ascending order using the Merge Sort algorithm. The function should be implemented from scratch without using Python's built-in `sort()` or `sorted()` functions. The code should start with:
```python
from typing import List
def merge_sort(arr: List[int]) -> L... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_sort(arr: List[int]) -> List[int]:
"""
Sorts a list of integers in ascending order using the Merge Sort algorithm.
Args:
arr (List[int]): The list of integers to be sorted.
Re... |
evol_instruct_66k | 6,916 | Write a Python function to implement an optimized version of a given multidimensional recursive function using memoization to ensure efficient use of memory and reduce time complexity. The function should handle large values of `n` and `m` efficiently.
The original recursive function is defined as follows:
```python
d... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def optimized_recursive_function(n: int, m: int) -> int:
"""
Optimized version of a multidimensional recursive function using memoization.
Args:
n (int): The first dimension of the recursion... |
evol_instruct_66k | 6,925 | Write a Python function to interweave a fresh and unrepeated key-value pair into an existing dictionary structure. If the key already exists in the dictionary, the function should return the original dictionary without any modifications. The function should start with:
```python
from typing import Dict, Any
def interw... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Any
def interweave_key_value(existing_dict: Dict[str, Any], new_key: str, new_value: Any) -> Dict[str, Any]:
"""
Interweave a fresh and unrepeated key-value pair into an existing dictionary.
If the... |
evol_instruct_66k | 6,936 | Write a Python function to determine if an array of integers is symmetric. An array is symmetric if it reads the same backward as forward. The function should return `True` if the array is symmetric and `False` otherwise. The code should start with:
```python
from typing import List
def is_symmetric(arr: List[int]) ->... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_symmetric(arr: List[int]) -> bool:
"""
Determine if an array of integers is symmetric.
Args:
arr (List[int]): The array of integers to check for symmetry.
Returns:
bool: ... |
evol_instruct_66k | 6,938 | Write a Python function to perform a deep copy of a given object using two different methods: one using the `json` module and another using a custom method. The custom method should handle circular references in objects and arrays. Additionally, compare the execution times of both methods and explain under what circums... | Here is the Python code to solve the given problem in the markdown block:
```python
import json
import time
from typing import Any, Dict, List, Union
def deep_copy_with_json(obj: Any) -> Any:
"""
Perform a deep copy of the given object using the JSON method.
Args:
obj (Any): The object to be deep ... |
evol_instruct_66k | 6,943 | Write a Python function to find the longest palindromic substring within a given string. A palindromic substring is a sequence of characters that reads the same backward as forward. The function should return the longest such substring found in the input string.
The code should start with:
```python
def longest_palind... | Here is the Python code to solve the given problem in the markdown block:
```python
def longest_palindromic_substring(text: str) -> str:
"""
Find the longest palindromic substring within the given text.
Args:
text (str): The input string in which to find the longest palindromic substring.
Retu... |
evol_instruct_66k | 6,947 | Write a Python function to extract the second element from each row of a given matrix and return them as a list. The matrix is represented as a list of lists, where each inner list represents a row. The function should handle matrices of varying sizes, including those with fewer than two elements in a row. If a row has... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def extract_second_elements(matrix: List[List[int]]) -> List[int]:
"""
Extracts the second element from each row of a given matrix and returns them as a list.
If a row has fewer than two elements, ap... |
evol_instruct_66k | 6,959 | Write a Python function to calculate the following information about a ship's journey:
1. The total distance the ship has traveled after 6 hours, considering the change in speed and the impact of the current.
2. The ship's actual average speed considering the current's impact on its speed.
3. The additional time it wou... | Here is the Python code to solve the given problem in the markdown block:
```python
def ship_journey_info(n: float) -> tuple:
"""
Calculate the total distance traveled, actual average speed, and additional time to travel the same distance without the current.
Args:
n (float): The speed decrease fac... |
evol_instruct_66k | 6,967 | Write a Python function to calculate the product of all integers in a nested list, regardless of the depth of nesting. The function should raise a `TypeError` if the input is not a list or if any element within the nested list is not an integer. The function should be implemented using recursion and should not use any ... | Here is the Python code to solve the given problem in the markdown block:
```python
def multiply_numbers(lst):
"""
Calculate the product of all integers in a nested list, regardless of the depth of nesting.
Args:
lst (list): A nested list of integers.
Returns:
int: The product of all i... |
evol_instruct_66k | 6,974 | Write a Python function to optimize the runtime and memory usage of a given function that doubles each element in a list. Additionally, implement error handling to account for potential issues with the input. The function should return a generator that yields the doubled values one by one.
The code should start with:
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Generator
def optimized_doubler(my_list: List[int]) -> Generator[int, None, None]:
"""
Optimized function to double each element in a list and yield the results one by one.
Args:
my_list (L... |
evol_instruct_66k | 6,975 | Write a Python function to perform basic arithmetic operations (addition, subtraction, multiplication, and division with remainder) on two given integers. The function should handle input errors and return a dictionary with the results of each operation. The code should start with:
```python
from typing import Dict, Un... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Union
def arithmetic_operations(a: int, b: int) -> Dict[str, Union[int, float]]:
"""
Perform basic arithmetic operations (addition, subtraction, multiplication, and division with remainder) on two integ... |
evol_instruct_66k | 6,984 | Write a Python function to categorize characters in a given string into vowels and consonants. The function should return two lists: one containing all the vowels and the other containing all the consonants. The input string is case-insensitive, meaning both uppercase and lowercase characters should be treated the same... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def categorize_characters(data: str) -> Tuple[List[str], List[str]]:
"""
Categorizes characters in a given string into vowels and consonants.
Args:
data (str): The input string to be ... |
evol_instruct_66k | 6,995 | Write a Python function to find the second smallest unique number in a given array of floating-point numbers. The array should contain at least 2 unique numbers, including negative numbers and zero. The function should return the second smallest unique number or an appropriate error message if the input does not meet t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def second_smallest_unique_number(numbers: List[float]) -> Union[float, str]:
"""
Find the second smallest unique number in a given array of floating-point numbers.
Args:
numbers (Lis... |
evol_instruct_66k | 7,001 | Write a Python function to count the number of occurrences of a given word in an array of strings, considering case sensitivity and ensuring the target word has more than 3 characters. The function should return 0 if the target word has 3 or fewer characters.
The code should start with:
```python
from typing import Li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_occurrences(words: List[str], target_word: str) -> int:
"""
Counts the number of occurrences of a given word in an array of strings, considering case sensitivity.
Returns 0 if the target wo... |
evol_instruct_66k | 7,012 | Write a Python function to compute the Kronecker product of two given matrices using the NumPy library. The function should take two 2D NumPy arrays as input and return the resulting Kronecker product matrix. The code should start with:
```python
import numpy as np
def kronecker_product(matrix1: np.ndarray, matrix2: n... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def kronecker_product(matrix1: np.ndarray, matrix2: np.ndarray) -> np.ndarray:
"""
Compute the Kronecker product of two given matrices.
Args:
matrix1 (np.ndarray): The first 2D NumPy array (matri... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.