source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
evol_instruct_66k | 10,660 | Write a Python function to generate a list of odd integers within a specified range, excluding any even numbers. The function should take two integers, `start` and `end`, as input and return a list of odd integers within this range (inclusive).
The code should start with:
```python
from typing import List
def generat... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_odd_numbers(start: int, end: int) -> List[int]:
"""
Generate a list of odd integers within the specified range [start, end] (inclusive).
Args:
start (int): The starting integer ... |
evol_instruct_66k | 10,676 | Write a Python function to generate a sequence of `n` unsystematically assorted alphanumeric characters, specifically comprising of letters and digits. The function should ensure that the generated sequence contains exactly `n` characters, where `n` is a positive integer provided as an argument. The function should ret... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
import string
def generate_random_sequence(n: int) -> str:
"""
Generate a sequence of `n` unsystematically assorted alphanumeric characters.
Args:
n (int): The number of charac... |
evol_instruct_66k | 10,677 | Write a Python function to merge two ascending-ordered arrays of integers into a single, consolidated, and arranged series without using any pre-defined sorting or merging functions. The function should efficiently combine the two arrays by iterating through them and appending the smallest element from either array to ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_sorted_arrays(arr1: List[int], arr2: List[int]) -> List[int]:
"""
Merges two ascending-ordered arrays of integers into a single, consolidated, and arranged series.
Args:
arr1 (List... |
evol_instruct_66k | 10,688 | Write a Python function to determine if there exist three distinct elements in a given array that sum up to a specified target value. The function should return `True` if such a triplet exists, otherwise `False`.
The code should start with:
```python
from typing import List
def find_triplet_sum(array: List[int], targ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_triplet_sum(array: List[int], target: int) -> bool:
"""
Determines if there exist three distinct elements in the array that sum up to the target value.
Args:
array (List[int]): The ... |
evol_instruct_66k | 10,693 | Write a Python function to calculate the sum of two integer inputs `a` and `b`, and return the resulting total. The function should handle any integer inputs, including negative numbers and zero. The code should start with:
```python
def add_two_numbers(a: int, b: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def add_two_numbers(a: int, b: int) -> int:
"""
Calculate the sum of two integer inputs a and b.
Args:
a (int): The first integer to be added.
b (int): The second integer to be added.
Returns:
i... |
evol_instruct_66k | 10,712 | Write a Python function to convert a binary input (in string format) to its octal equivalent (represented as a string) without using any built-in or external libraries. The function should handle error cases such as binary strings starting with more than one '0' and invalid characters. Additionally, the function should... | Here is the Python code to solve the given problem in the markdown block:
```python
def custom_binary_to_octal(binary_str: str) -> str:
"""
Convert a binary input (string) to its octal representation (string) without using any built-in or imported functions.
Args:
binary_str (str): The binary strin... |
evol_instruct_66k | 10,715 | Write a Python function to perform an element-wise addition operation on two lists of numerical values. The function should ensure that each corresponding element from the two lists is summed together. If the lists are of different lengths, the function should handle this by summing only the elements that have correspo... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def element_wise_addition(list1: List[int], list2: List[int]) -> List[int]:
"""
Performs an element-wise addition operation on two lists of numerical values.
Args:
list1 (List[int]): The fir... |
evol_instruct_66k | 10,717 | Write a Python function to calculate the factorial of a given non-negative integer and count the number of trailing zeroes in the factorial result. The function should handle invalid inputs (non-integer or negative values) by returning an appropriate error message. The function should be recursive and should start with... | Here is the Python code to solve the given problem in the markdown block:
```python
def factorial_with_trailing_zeros(n: int) -> str:
"""
Calculate the factorial of a given non-negative integer and count the number of trailing zeroes in the factorial result.
Args:
n (int): The non-negative integer ... |
evol_instruct_66k | 10,719 | Write a Python function to calculate the arithmetic mean of a given list of numerical values. The function should handle an empty list by returning `None` and should be able to handle lists with non-numeric values by raising a `ValueError`. The code should start with:
```python
from typing import List, Union
def calcu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def calculate_arithmetic_mean(numbers: List[Union[int, float]]) -> Union[float, None]:
"""
Calculate the arithmetic mean of a given list of numerical values.
Args:
numbers (List[Union... |
evol_instruct_66k | 10,723 | Write a Python function to perform the subtraction of two matrices. The matrices are represented as lists of lists, where each inner list represents a row of the matrix. The function should ensure that the matrices are of the same dimensions before performing the subtraction. If the matrices are not of the same dimensi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def subtract_matrices(mat1: List[List[int]], mat2: List[List[int]]) -> Optional[List[List[int]]]:
"""
Subtracts two matrices if they have the same dimensions.
Args:
mat1 (List[List... |
evol_instruct_66k | 10,724 | Write a Python function to remove the k-th element from a given list and return the modified list. The function should handle cases where `k` is out of bounds by returning the original list unchanged. The function should start with:
```python
from typing import List
def remove_kth_element(arr: List[int], k: int) -> Li... | Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def remove_kth_element(arr: List[int], k: int) -> List[int]:
"""
Removes the k-th element from the given list and returns the modified list.
If k is out of bounds, the original list is returned unc... |
evol_instruct_66k | 10,731 | 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 not use any built-in Python functions like `sorted()` or `colle... | Here is the Python code to solve the given problem in the markdown block:
```python
def are_anagrams(str1: str, str2: str) -> bool:
"""
Determine if two given strings are anagrams of each other.
Args:
str1 (str): The first string to check.
str2 (str): The second string to check.
Return... |
evol_instruct_66k | 10,732 | Write a Python function to convert a decimal number to its binary representation without using the built-in `bin()` function. The function should handle both positive and zero decimal numbers. The code should start with:
```python
def decimal_to_binary(decimal_number: int) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def decimal_to_binary(decimal_number: int) -> str:
"""
Converts a decimal number to its binary representation.
Args:
decimal_number (int): The decimal number to be converted.
Returns:
str: The binary re... |
evol_instruct_66k | 10,740 | Write a Python function to store a list of books in a dictionary. Each book should include the title, author, and number of pages. The function should accept a list of tuples, where each tuple contains the title, author, and number of pages of a book. The function should return a list of dictionaries, where each dictio... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def store_books(books: List[Tuple[str, str, int]]) -> List[dict]:
"""
Stores a list of books in a dictionary format.
Args:
books (List[Tuple[str, str, int]]): A list of tuples, where ... |
evol_instruct_66k | 10,745 | Write a Python function to manipulate and analyze a given JSON-like dictionary. The dictionary contains the following fields: "name" with the value 'John Smith', "age" with the value 35, and "location" with the value 'Online'. The function should update the values of these fields to 'John Doe', 40, and 'Offline' respec... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def update_json_data(json_data: Dict[str, any]) -> Dict[str, any]:
"""
Updates the values of the keys "name", "age", and "location" in the given JSON-like dictionary.
Args:
json_data (Dict[s... |
evol_instruct_66k | 10,746 | Write a Python function to replace each alphabetic character in a given string with its immediate succeeding character in the English alphabet. If the character is 'z' or 'Z', it should wrap around to 'a' or 'A', respectively. Non-alphabetic characters should remain unchanged.
The code should start with:
```python
def... | Here is the Python code to solve the given problem in the markdown block:
```python
def replace_characters(word: str) -> str:
"""
Replace each alphabetic character in the given string with its immediate succeeding character in the English alphabet.
If the character is 'z' or 'Z', it wraps around to 'a' or '... |
evol_instruct_66k | 10,748 | Write a Python function to sort a given list of numbers in descending order using the bubble sort algorithm. The function should handle cases where the input is not a list or the list contains non-numeric elements by returning appropriate error messages. The code should start with:
```python
def bubble_sort_desc(lst):
... | Here is the Python code to solve the given problem in the markdown block:
```python
def bubble_sort_desc(lst):
"""
Sorts a given list of numbers in descending order using the bubble sort algorithm.
Returns an error message if the input is not a list or contains non-numeric elements.
Args:
lst (... |
evol_instruct_66k | 10,752 | Write a Python function to recursively merge two pre-sorted subarrays into a single sorted array. The function should take two lists as input and return a new list that contains all elements from both input lists in sorted order. The function should not modify the original input lists.
The code should start with:
```p... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_sorted_arrays(ar1: List[int], ar2: List[int]) -> List[int]:
"""
Recursively merges two pre-sorted subarrays into a single sorted array.
Args:
ar1 (List[int]): The first pre-sorted ... |
evol_instruct_66k | 10,761 | Write a Python function to convert a temperature from Fahrenheit to Celsius. The function should handle both integer and decimal inputs and return the result rounded to two decimal places. The code should start with:
```python
def fahrenheit_to_celsius(fahrenheit: float) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def fahrenheit_to_celsius(fahrenheit: float) -> float:
"""
Convert a temperature from Fahrenheit to Celsius and round the result to two decimal places.
Args:
fahrenheit (float): The temperature in Fahrenheit to be c... |
evol_instruct_66k | 10,769 | Write a Python function to create a dictionary where the keys are tuples of integers, and the values are the products of the integers within the tuples. The function should take a list of tuples as input and return the resulting dictionary.
The code should start with:
```python
from typing import List, Dict, Tuple
de... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Tuple
def tuple_product_dict(tuples_list: List[Tuple[int, int]]) -> Dict[Tuple[int, int], int]:
"""
Creates a dictionary where the keys are tuples of integers, and the values are the products of t... |
evol_instruct_66k | 10,782 | Write a Python function to convert a given Laplacian matrix of an unweighted, undirected graph into its equivalent adjacency list representation. The Laplacian matrix is a square matrix where the elements of the matrix represent the degree of the vertex minus the adjacency matrix of the graph. The function should retur... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def laplacian_to_adjacency_list(laplacian: List[List[int]]) -> Dict[int, List[int]]:
"""
Converts a given Laplacian matrix of an unweighted, undirected graph into its equivalent adjacency list repr... |
evol_instruct_66k | 10,784 | Write a Python function to segment a given list of integers into two separate lists: one for odd numbers and one for even numbers. The odd numbers should be sorted in ascending order, and the even numbers should be sorted in descending order. The function should return a tuple containing the sorted odd numbers list and... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def segment_and_sort_numbers(lst: List[int]) -> Tuple[List[int], List[int]]:
"""
Segments a list of integers into two lists: one for odd numbers and one for even numbers.
The odd numbers list ... |
evol_instruct_66k | 10,793 | Write a Python function to generate a unique identifier of a specified length, consisting of random alphanumeric characters and special characters. The function should ensure that the generated identifier is unique by checking against a list of previously generated identifiers. If a duplicate is found, the function sho... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
import string
def generate_unique_id(length: int, existing_ids: List[str]) -> str:
"""
Generates a unique identifier of the specified length, consisting of random alphanumeric and special c... |
evol_instruct_66k | 10,798 | Write a Python function to create two new arrays of integers which contain the sums of corresponding elements of two existing arrays and the differences, respectively. The function should handle arrays of different lengths by taking the minimum length of the two arrays for the calculations. 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 calculate_sums_and_differences(arr1: List[int], arr2: List[int]) -> (List[int], List[int]):
"""
Calculate the sums and differences of corresponding elements of two arrays.
Args:
arr1 (Li... |
evol_instruct_66k | 10,804 | Write a Python function to find the maximum and minimum values in a given list of integers. The function should return a tuple containing the maximum and minimum values. If the list is empty, the function should return `None`.
The code should start with:
```python
from typing import List, Optional, Tuple
def find_ext... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional, Tuple
def find_extremes(arr: List[int]) -> Optional[Tuple[int, int]]:
"""
Find the maximum and minimum values in a given list of integers.
Args:
arr (List[int]): The list of integ... |
evol_instruct_66k | 10,823 | Write a Python function to merge two strings together without using any built-in string manipulation functions. The function should handle strings containing special symbols, non-English alphabetical characters, and varying character data types without generating any errors. Additionally, analyze how the code caters to... | Here is the Python code to solve the given problem in the markdown block:
```python
def merge_strings(string1: str, string2: str) -> str:
"""
Merges two strings together without using any built-in string manipulation functions.
Handles strings containing special symbols, non-English alphabetical characters,... |
evol_instruct_66k | 10,831 | Write a Python function to compute the edit distance (Levenshtein distance) between two given words using dynamic programming techniques. The edit distance is the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one word into the other. The function should use a 2D l... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def edit_distance_dp(str1: str, str2: str) -> int:
"""
Compute the edit distance (Levenshtein distance) between two strings using dynamic programming.
Args:
str1 (str): The first string.
... |
evol_instruct_66k | 10,835 | Write a Python function to generate a structured table that displays academic scores achieved by learners. The table should include a fifth column that calculates and displays the deviation of each score from the mean score. The function should also support adding a new score and modifying an existing score, ensuring t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_table(scores: List[int]) -> str:
"""
Generate an HTML table displaying academic scores and their deviations from the mean.
Args:
scores (List[int]): A list of academic scores.
... |
evol_instruct_66k | 10,856 | Write a Python function to determine if you can reach any index with a specific target value in an array by jumping from a given start index. You can jump to `i + arr[i]` or `i - arr[i]`, but you cannot jump outside the array bounds.
The code should start with:
```python
from typing import List
def can_reach_target(a... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
from collections import deque
def can_reach_target(arr: List[int], start: int, target: int) -> bool:
"""
Determines if you can reach any index with the target value in the array starting from the given s... |
evol_instruct_66k | 10,857 | Write a Python function to update the population of a metropolis in a given dictionary. If the metropolis is not already in the dictionary, add it with the specified population. The function should return the updated dictionary.
The code should start with:
```python
from typing import Dict
def update_population(metro... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def update_population(metropolis_population: Dict[str, float], city: str, population: float) -> Dict[str, float]:
"""
Updates the population of a metropolis in the given dictionary. If the metropolis is ... |
evol_instruct_66k | 10,884 | Write a Python function to filter out all elements from a given list of integers that exceed a specified threshold. The function should return a new list containing only the elements that are less than or equal to the threshold.
The code should start with:
```python
from typing import List
def filter_elements_below_t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_elements_below_threshold(numbers: List[int], threshold: int) -> List[int]:
"""
Filters out all elements from the given list of integers that exceed the specified threshold.
Args:
... |
evol_instruct_66k | 10,893 | Write a Python function to perform a binary search on a sorted list of integers. The function should return the index of the target element if it exists in the list, otherwise it should return -1. The function should be efficient in terms of time complexity, and you should analyze and explain the time and space complex... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def binary_search(arr: List[int], target: int) -> int:
"""
Perform a binary search on a sorted list to find the index of the target element.
Args:
arr (List[int]): A sorted list of integers.... |
evol_instruct_66k | 10,894 | Write a Python function to minimize a given floating-point number to exactly four decimal places. The function should handle both positive and negative numbers, as well as numbers with fewer than four decimal places. The code should start with:
```python
def minimize_to_four_decimals(num: float) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def minimize_to_four_decimals(num: float) -> float:
"""
Minimize a given floating-point number to exactly four decimal places.
Args:
num (float): The floating-point number to be minimized.
Returns:
floa... |
evol_instruct_66k | 10,897 | Write a Python function to compute the nth value in the Fibonacci series using an iterative approach. The Fibonacci series is defined such that each number is the sum of the two preceding ones, starting from 0 and 1. The function should start with:
```python
def fibonacci_nth(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def fibonacci_nth(n: int) -> int:
"""
Compute the nth value in the Fibonacci series using an iterative approach.
The Fibonacci series is defined such that each number is the sum of the two preceding ones,
starting from ... |
evol_instruct_66k | 10,906 | Write a Python function to determine the larger of two given numbers. The function should take two integers as input and return the larger one. If the numbers are equal, it should return either number.
The code should start with:
```python
def find_larger_number(num1: int, num2: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def find_larger_number(num1: int, num2: int) -> int:
"""
Determines the larger of two given numbers.
Args:
num1 (int): The first number to compare.
num2 (int): The second number to compare.
Returns:
... |
evol_instruct_66k | 10,913 | Write a Python function to sort an array of unique numerical entities using the insertion sort algorithm. The function should be able to handle any array of unique integers and return the sorted array. The code should start with:
```python
from typing import List
def insertion_sort(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 insertion_sort(arr: List[int]) -> List[int]:
"""
Sorts an array of unique numerical entities using the insertion sort algorithm.
Args:
arr (List[int]): The array of unique integers to be... |
evol_instruct_66k | 10,935 | 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 return `True` if the strings are anagrams, and `False` otherwis... | Here is the Python code to solve the given problem in the markdown block:
```python
def are_anagrams(str1: str, str2: str) -> bool:
"""
Determines if two given strings are anagrams of each other.
Args:
str1 (str): The first string to compare.
str2 (str): The second string to compare.
R... |
evol_instruct_66k | 10,939 | Write a Python function to determine if a set of criteria is fulfilled based on the values of two variables, `volume` and `pitch`. The criteria are:
1. The `volume` must exceed 10.
2. The `pitch` must be greater than or equal to 800.
The function should return a boolean value indicating whether both criteria are met.
... | Here is the Python code to solve the given problem in the markdown block:
```python
def criteria_fulfilled(volume: int, pitch: int) -> bool:
"""
Determine if the specified criteria are fulfilled based on the values of volume and pitch.
Args:
volume (int): The audio intensity value.
pitch (i... |
evol_instruct_66k | 10,942 | Write a Python function to convert a given string to its lowercase version. The function should handle various types of characters, including alphabetic characters, digits, and special characters. The function should return the lowercase version of the input string.
The code should start with:
```python
def convert_to... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_to_lowercase(input_string: str) -> str:
"""
Converts the given string to its lowercase version.
Args:
input_string (str): The string to be converted to lowercase.
Returns:
str: The lowercase... |
evol_instruct_66k | 10,962 | Write a Python function to determine if a given character is an uppercase letter. If the character is not an uppercase letter but is a special symbol (e.g., punctuation, or any non-alphanumeric character), return its Unicode point value. If the character is neither an uppercase letter nor a special symbol, return `Fals... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_uppercase_or_special(char: str) -> bool | int:
"""
Determine if a given character is an uppercase letter or a special symbol.
Args:
char (str): A single character to be checked.
Returns:
bool | i... |
evol_instruct_66k | 10,990 | Write a Python function to convert a given Python dictionary representing user information into a JSON string. The dictionary should include an array of contact methods, each with a unique key and value. The function should handle the conversion efficiently and ensure that the JSON structure is well-formed.
The code s... | Here is the Python code to solve the given problem in the markdown block:
```python
import json
from typing import Dict
def convert_to_json(user_info: Dict) -> str:
"""
Converts a given Python dictionary representing user information into a JSON string.
Args:
user_info (dict): A dictionary contain... |
evol_instruct_66k | 10,998 | Write a Python function to sort a list of integers using the insertion sort algorithm. The function should modify the input list in-place and return the sorted list. The code should start with:
```python
from typing import List
def insertion_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 insertion_sort(array: List[int]) -> List[int]:
"""
Sorts a list of integers in-place using the insertion sort algorithm.
Args:
array (List[int]): The list of integers to be sorted.
... |
evol_instruct_66k | 11,005 | Write a Python function to combine a list of textual phrases into a single comprehensive sentence. Each phrase in the list should be separated by a semicolon followed by a space. The function should handle an empty list by returning an empty string.
The code should start with:
```python
from typing import List
def co... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def combine_phrases(phrases: List[str]) -> str:
"""
Combines a list of textual phrases into a single comprehensive sentence.
Each phrase is separated by a semicolon followed by a space.
Args:
... |
evol_instruct_66k | 11,018 | Write a Python function to interpret a symbolic representation of numbers stored in a dictionary. The dictionary maps symbols (letters) to lists of numbers. The function should return a new dictionary where each key is a symbol from the input dictionary, and the value is a list of strings. Each string in the list shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def interpret_symbolic_representation(symbol_dict: Dict[str, List[int]]) -> Dict[str, List[str]]:
"""
Interpret the symbolic representation of numbers stored in a dictionary.
Args:
sym... |
evol_instruct_66k | 11,025 | Write a Python function to invert the order of keys in a given dictionary. The function should return a new dictionary with the keys in reverse order of their appearance in the original dictionary. The values should remain associated with their respective keys.
The code should start with:
```python
from typing import ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Any
def invert_dictionary_order(d: Dict[Any, Any]) -> Dict[Any, Any]:
"""
Inverts the order of keys in the given dictionary.
Args:
d (Dict[Any, Any]): The input dictionary whose keys' order... |
evol_instruct_66k | 11,026 | Write a Python function to categorize a list of words into their respective parts of speech. The function should take a list of words as input and return a dictionary where the keys are the words and the values are their corresponding parts of speech. The parts of speech to be considered are: Noun, Verb, Adjective, Adv... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def categorize_words(words: List[str]) -> Dict[str, str]:
"""
Categorizes a list of words into their respective parts of speech.
Args:
words (List[str]): A list of words to be categori... |
evol_instruct_66k | 11,043 | Write a Python function to shuffle a given list in place using the Fisher-Yates algorithm. The function should modify the original list and not return a new list. The code should start with:
```python
from typing import List
def shuffle_list(lst: List[int]) -> None:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def shuffle_list(lst: List[int]) -> None:
"""
Shuffles the given list in place using the Fisher-Yates algorithm.
Args:
lst (List[int]): The list to be shuffled.
Returns:
... |
evol_instruct_66k | 11,055 | Write a Python function to create a dictionary that stores the square roots of prime numbers within a given range. Additionally, implement a function to check if a number is prime. The code should start with:
```python
import math
from typing import Dict, Union
def is_prime(n: int) -> bool:
"""
Check if a numb... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
from typing import Dict, Union
def is_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 | 11,075 | Write a Python function to find the longest common subsequence (LCS) between two given strings. The function should return the length of the LCS.
The code should start with:
```python
from typing import List
def longest_common_subsequence(str1: str, str2: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def longest_common_subsequence(str1: str, str2: str) -> int:
"""
Calculate the length of the longest common subsequence (LCS) between two strings.
Args:
str1 (str): The first string.
... |
evol_instruct_66k | 11,104 | Write a Python function to blend together an array of distinct textual elements into a single cohesive entity. The function should concatenate the elements with a specified delimiter and ensure that the resulting string maintains the order of the elements as they appear in the array. The function should also handle cas... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def blend_elements(arr: List[str], delimiter: str = ' ') -> str:
"""
Blends together an array of distinct textual elements into a single cohesive entity.
Args:
arr (List[str]): The array of ... |
evol_instruct_66k | 11,107 | Write a Python function to reverse a given string using both a traditional iterative approach and a recursive approach. The function should return a tuple containing the reversed string from the iterative method and the reversed string from the recursive method. The code should start with:
```python
def reverse_string(... | Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_string(s: str) -> tuple:
"""
Reverses the given string using both an iterative and a recursive approach.
Args:
s (str): The input string to be reversed.
Returns:
tuple: A tuple containing th... |
evol_instruct_66k | 11,110 | Write a Python function to compute the highest common divisor (GCD) of two positive integers using the Euclidean algorithm. The function should be efficient and handle edge cases such as zero or negative inputs. The code should start with:
```python
def gcd(a: int, b: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def gcd(a: int, b: int) -> int:
"""
Computes the greatest common divisor (GCD) of two positive integers using the Euclidean algorithm.
Args:
a (int): The first positive integer.
b (int): The second positive ... |
evol_instruct_66k | 11,115 | Write a Python function to convert a given string of space-separated floating-point numbers into a list of floats, retaining the original order and ensuring accuracy in decimal representation.
The code should start with:
```python
from typing import List
def string_to_float_list(s: str) -> List[float]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def string_to_float_list(s: str) -> List[float]:
"""
Converts a string of space-separated floating-point numbers into a list of floats.
Args:
s (str): The input string containing space-separ... |
evol_instruct_66k | 11,121 | Write a Python function to convert an angle given in arc minutes to radians. The function should take an integer representing the angle in arc minutes and return the equivalent angle in radians. The code should start with:
```python
import math
def arc_minutes_to_radians(arc_minutes: int) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
import math
def arc_minutes_to_radians(arc_minutes: int) -> float:
"""
Convert an angle given in arc minutes to radians.
Args:
arc_minutes (int): The angle in arc minutes to be converted.
Returns:
fl... |
evol_instruct_66k | 11,130 | Write a Python function to find the greatest common factor (GCF) of two integers using the Euclidean algorithm. The function should be efficient and handle edge cases such as zero and negative numbers.
The code should start with:
```python
def get_greatest_common_factor(x: int, y: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def get_greatest_common_factor(x: int, y: int) -> int:
"""
Calculate the greatest common factor (GCF) of two integers using the Euclidean algorithm.
Args:
x (int): The first integer.
y (int): The second inte... |
evol_instruct_66k | 11,138 | Write a Python function to sort a given list of integers in descending order using the merge sort algorithm. The merge sort algorithm is a divide-and-conquer algorithm that recursively divides the list into halves, sorts each half, and then merges the sorted halves back together. The function should be efficient and ha... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_sort_descending(A: List[int]) -> List[int]:
"""
Sorts a list of integers in descending order using the merge sort algorithm.
Args:
A (List[int]): The list of integers to be sorted.... |
evol_instruct_66k | 11,153 | Write a Python function to create a dictionary with numbers 1 to 20 as keys and their corresponding squares as values. The function should include error handling for each unsuccessful addition to the dictionary. The code should start with:
```python
def create_squares_dict() -> dict:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def create_squares_dict() -> dict:
"""
Creates a dictionary with numbers 1 to 20 as keys and their corresponding squares as values.
Includes error handling for each unsuccessful addition to the dictionary.
Returns:
... |
evol_instruct_66k | 11,154 | Write a Python function to generate an SQL query that retrieves the entire list of employees working specifically within the "Marketing" department of a company, but only include those with above average annual salary and have been with the company for at least 3 years. The function should take the current year as an i... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_sql_query(current_year: int) -> str:
"""
Generates an SQL query to retrieve the list of employees working in the "Marketing" department
with above average annual salary and have been with the company for at leas... |
evol_instruct_66k | 11,171 | Write a Python function to find the longest palindromic substring in a given string. A palindrome is a string that reads the same backward as forward. The function should return the longest palindromic substring found in the input string.
The code should start with:
```python
def longest_palindromic_substring(input_st... | Here is the Python code to solve the given problem in the markdown block:
```python
def longest_palindromic_substring(input_string: str) -> str:
"""
Find the longest palindromic substring in the given input string.
Args:
input_string (str): The input string in which to find the longest palindromic ... |
evol_instruct_66k | 11,186 | Write a Python function to create a dictionary that encapsulates comprehensive information about a student. The dictionary should include the following attributes: "Name", "Age", and "Grade". The function should accept three parameters: the student's name (a string), age (an integer), and grade (a string). The function... | Here is the Python code to solve the given problem in the markdown block:
```python
def create_student_info(name: str, age: int, grade: str) -> dict:
"""
Constructs a dictionary encapsulating comprehensive information about a student.
Args:
name (str): The name of the student.
age (int): Th... |
evol_instruct_66k | 11,191 | Write a Python function to convert each element in a given numerical string array into integers and then calculate their running total. The function should return a list of integers representing the running total of the converted integers.
The code should start with:
```python
from typing import List
def calculate_ru... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_running_total(lst: List[str]) -> List[int]:
"""
Converts each element in a given numerical string array into integers and calculates their running total.
Args:
lst (List[str]):... |
evol_instruct_66k | 11,195 | Write a Python function to reverse the order of elements in a given list and return the reversed list. The function should handle lists of any length and any type of elements. The code should start with:
```python
from typing import List, Any
def reverse_list(arr: List[Any]) -> List[Any]:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List, Any
def reverse_list(arr: List[Any]) -> List[Any]:
"""
Reverses the order of elements in the given list and returns the reversed list.
Args:
arr (List[Any]): The list to be reversed.
... |
evol_instruct_66k | 11,196 | Write a Python function to calculate the sum of the first `n` elements in a given array while excluding any repeating elements. If `n` is greater than the length of the array, the function should consider the entire array. The function should start with:
```python
from typing import List
def sum_first_n_unique_element... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_first_n_unique_elements(arr: List[int], n: int) -> int:
"""
Calculate the sum of the first n unique elements in the given array.
Args:
arr (List[int]): The array of integers from whi... |
evol_instruct_66k | 11,198 | Write a Python function to format a given floating-point number to a specified number of decimal places. The function should take two parameters: the floating-point number and the number of decimal places to which the number should be formatted. The function should return the formatted number as a string.
The code sho... | Here is the Python code to solve the given problem in the markdown block:
```python
def format_float_to_decimal_places(number: float, decimal_places: int) -> str:
"""
Formats a given floating-point number to the specified number of decimal places.
Args:
number (float): The floating-point number to ... |
evol_instruct_66k | 11,204 | Write a Python function to compute the element-wise product of two given matrices. The function should take two matrices as input and return a new matrix where each element is the product of the corresponding elements from the input matrices.
The code should start with:
```python
from typing import List
def element_w... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def element_wise_product(A: List[List[int]], B: List[List[int]]) -> List[List[int]]:
"""
Compute the element-wise product of two matrices.
Args:
A (List[List[int]]): The first matrix.
... |
evol_instruct_66k | 11,210 | Write a Python function to update the age of a student in a given dictionary of students' ages. If the student does not exist in the dictionary, add the student with the given age. The function should return the updated dictionary.
The code should start with:
```python
from typing import Dict
def update_student_age(s... | Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import Dict
def update_student_age(students: Dict[str, int], name: str, age: int) -> Dict[str, int]:
"""
Updates the age of a student in the given dictionary of students' ages.
If the student does not exist in... |
evol_instruct_66k | 11,214 | Write a Python function to create a two-dimensional array from a given list of numerical values, ensuring that the values are distributed evenly across the specified number of rows and columns. The function should handle cases where the number of elements in the list does not perfectly fit into the specified dimensions... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
def create_2d_array(numbers: List[int], rows: int, cols: int, default_value: Any = None) -> List[List[Any]]:
"""
Create a two-dimensional array from a given list of numerical values.
Args:
... |
evol_instruct_66k | 11,222 | Write a Python function to filter out elements from a list that appear more than once, keeping only the elements that appear exactly once in their original order. The function should be efficient and work with large datasets containing up to 10,000 elements.
The code should start with:
```python
from typing import Lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_unique_elements(lst: List[int]) -> List[int]:
"""
Filters out elements from the list that appear more than once, keeping only the elements that appear exactly once in their original order.
... |
evol_instruct_66k | 11,226 | Write a Python function to find the kth smallest element in an unordered list. The function should take three parameters: the list of integers, the value of k, and the length of the list. The function should return the kth smallest element in the list. The code should start with:
```python
from typing import List
def ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import heapq
def find_kth_smallest(lst: List[int], n: int, k: int) -> int:
"""
Find the kth smallest element in an unordered list.
Args:
lst (List[int]): The list of integers.
n (int... |
evol_instruct_66k | 11,240 | Write a Python function to find all words in a given list that appear at least `n` times. The function should return a list of these words. The code should start with:
```python
from typing import List
def find_frequent_words(words: List[str], n: int) -> List[str]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_frequent_words(words: List[str], n: int) -> List[str]:
"""
Find all words in the given list that appear at least `n` times.
Args:
words (List[str]): The list of words to analyze.
... |
evol_instruct_66k | 11,250 | Write a Python function to calculate the average of three numbers. The function should take three integers as input and return the average as a float. The code should start with:
```python
def calculate_average(num1: int, num2: int, num3: int) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def calculate_average(num1: int, num2: int, num3: int) -> float:
"""
Calculate the average of three given integers.
Args:
num1 (int): The first integer.
num2 (int): The second integer.
num3 (int): ... |
evol_instruct_66k | 11,252 | Write a Python function to extract specific information from a given dictionary and return it as a formatted string. The dictionary contains information about a celestial object, including its constellation, coordinates, and visibility period. The function should accept the dictionary and a list of keys as input and re... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def extract_info(dictionary: Dict[str, str], keys: List[str]) -> str:
"""
Extracts specific information from a given dictionary and returns it as a formatted string.
Args:
dictionary (... |
evol_instruct_66k | 11,265 | Write a Python function to determine if a given array of numbers follows a strictly increasing order. The function should return `True` if the array is strictly increasing, and `False` otherwise. The array is considered strictly increasing if each element is strictly greater than the previous element.
The code should ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_strictly_increasing(arr: List[int]) -> bool:
"""
Determine if the given array of numbers follows a strictly increasing order.
Args:
arr (List[int]): The array of integers to be checke... |
evol_instruct_66k | 11,269 | Write a Python function to generate a duplicate of a given list where the elements are in reverse order compared to the original input. The function should return a new list that is a reversed copy of the input list. The code should start with:
```python
from typing import List
def reverse_list(input_list: List[int]) ... | 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[int]) -> List[int]:
"""
Generates a duplicate of the given list where the elements are in reverse order.
Args:
input_list (List[int]): The list of integer... |
evol_instruct_66k | 11,272 | Write a Python function to perform the NOR operation on a pair of binary numerals. The NOR operation is a logical operation that returns `True` (or `1`) if and only if both inputs are `False` (or `0`). The function should take two binary inputs and return the result of the NOR operation as an integer (`0` or `1`).
The... | Here is the Python code to solve the given problem in the markdown block:
```python
def nor_operation(x: int, y: int) -> int:
"""
Perform the NOR operation on a pair of binary numerals.
The NOR operation returns 1 if both inputs are 0, otherwise it returns 0.
Args:
x (int): The first binary in... |
evol_instruct_66k | 11,294 | Write a Python function to perform a binary search on a sorted array and return the index of the target element if it exists in the array. If the target element is not found, return the string 'Not Found'. The function should be efficient and handle edge cases such as an empty array or a target that is not present in t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def binary_search(arr: List[int], target: int) -> Union[int, str]:
"""
Perform a binary search on a sorted array to find the index of the target element.
If the target is not found, return 'No... |
evol_instruct_66k | 11,298 | Write a Python function to determine if a given number is a prime number or not. The function should handle potential errors and edge cases, such as non-integer inputs and numbers less than 2. The function should return a string "Prime" if the number is prime and "Not Prime" otherwise.
The code should start with:
```p... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_prime(number: int) -> str:
"""
Determine if a given number is a prime number.
Args:
number (int): The number to check for primality.
Returns:
str: "Prime" if the number is prime, "Not Prime" othe... |
evol_instruct_66k | 11,303 | Write a Python function to generate a unique, unguessable secret code of a specified length, which incorporates both capital and small alphabetic symbols, numerical digits, and non-alphanumeric special symbols. The function should ensure that the generated code is random and does not repeat characters within the same c... | Here is the Python code to solve the given problem in the markdown block:
```python
import string
import random
def generate_secret_code(length: int) -> str:
"""
Generates a unique, unguessable secret code of the specified length.
The secret code incorporates both capital and small alphabetic symbols,
... |
evol_instruct_66k | 11,304 | Write a Python function to sort a given list of numerical entities in ascending order. The function should return the sorted list. The code should start with:
```python
from typing import List
def sort_numerical_list(dataset: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def sort_numerical_list(dataset: List[int]) -> List[int]:
"""
Sorts a given list of numerical entities in ascending order.
Args:
dataset (List[int]): The list of numerical entities to be s... |
evol_instruct_66k | 11,310 | Write a Python function to display the initial quintet (first five) of elements from a given numerical array, ensuring they are arranged in descending order. If the array has fewer than five elements, display all elements in descending order.
The code should start with:
```python
from typing import List
def display_i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def display_initial_quintet(arr: List[int]) -> List[int]:
"""
Display the initial quintet of elements from a given numerical array, ensuring they are arranged in descending order.
Args:
arr ... |
evol_instruct_66k | 11,312 | Write a Python function to find all numbers between 1 and n that are divisible by both 3 and 5 without using a loop structure. The function should return a list of these numbers.
The code should start with:
```python
from typing import List
def get_multiples_of_3_and_5(n: int) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def get_multiples_of_3_and_5(n: int) -> List[int]:
"""
Returns a list of numbers between 1 and n that are divisible by both 3 and 5.
Args:
n (int): The upper limit of the range (inclusive).
... |
evol_instruct_66k | 11,318 | Write a Python function to generate a series of unique numbers in random order within a specified range. The function should ensure that no number is repeated in the series. The code should start with:
```python
from typing import List
import random
def generate_unique_random_series(start: int, end: int) -> List[int]:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_unique_random_series(start: int, end: int) -> List[int]:
"""
Generates a series of unique numbers in random order within a specified range.
Args:
start (int): The ... |
evol_instruct_66k | 11,320 | Write a Python function to sort a given list of non-negative integers in ascending order using the Counting Sort algorithm. The function should not use any pre-existing sorting techniques and should sort the list in O(n) time complexity.
The code should start with:
```python
from typing import List
def counting_sort(... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def counting_sort(arr: List[int]) -> List[int]:
"""
Sorts a list of non-negative integers in ascending order using the Counting Sort algorithm.
Args:
arr (List[int]): The list of non-negativ... |
evol_instruct_66k | 11,332 | Write a Python function to determine if two given strings are isomorphic without using any external libraries, recursive methods, or built-in functions like `len()`. The function should check if there is a one-to-one correspondence between the characters of the two strings.
The code should start with:
```python
def is... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_isomorphic(str1: str, str2: str) -> bool:
"""
Determines if two strings are isomorphic.
Args:
str1 (str): The first string to check.
str2 (str): The second string to check.
Returns:
bool:... |
evol_instruct_66k | 11,350 | Write a Python function to check the syntax of a given Python statement and determine if it is legitimate. The function should take a string representing a Python statement as input and return a boolean indicating whether the statement is syntactically correct. The function should also handle common syntax errors such ... | Here is the Python code to solve the given problem in the markdown block:
```python
import ast
def is_syntax_correct(statement: str) -> bool:
"""
Check if the given Python statement is syntactically correct.
Args:
statement (str): The Python statement to check.
Returns:
bool: True if ... |
evol_instruct_66k | 11,356 | Write a Python function to determine the precise index location of a specified alphabetic character within a given string. The function should handle cases where the character is not found by returning `-1`. The code should start with:
```python
def find_character_index(text: str, char: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def find_character_index(text: str, char: str) -> int:
"""
Determine the precise index location of a specified alphabetic character within a given string.
If the character is not found, return -1.
Args:
text (st... |
evol_instruct_66k | 11,363 | Write a Python function to construct a dictionary that counts the occurrences of each distinct element in a given input sequence. The input sequence can be any iterable (e.g., list, tuple, string). The function should return a dictionary where the keys are the distinct elements from the input sequence, and the values a... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Iterable
def count_elements(input_sequence: Iterable) -> Dict[str, int]:
"""
Constructs a dictionary that counts the occurrences of each distinct element in the input sequence.
Args:
input_... |
evol_instruct_66k | 11,368 | Write a Python function to create a multi-dimensional array representing the column names and their respective data types for a MySQL table. The function should accept a list of tuples, where each tuple contains a column name and its data type. The function should return a NumPy array with the same structure. The code ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import numpy as np
def create_mysql_column_array(columns: List[Tuple[str, str]]) -> np.ndarray:
"""
Create a multi-dimensional NumPy array representing the column names and their respective data t... |
evol_instruct_66k | 11,376 | Write a Python function to insert an element into a list at a specified index, handling the scenario where the specified index is out of range. If the index is greater than the length of the list, the element should be appended to the end of the list. If the index is negative, the element should be inserted at the begi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def insert_element(lst: List[int], index: int, element: int) -> List[int]:
"""
Inserts an element into a list at a specified index. If the index is out of range,
the element is appended to the end of... |
evol_instruct_66k | 11,380 | Write a Python function to compute the element-wise product of two lists. The function should take two lists of integers as input and return a new list containing the products of corresponding elements from the input lists. If the input lists are of different lengths, the function should raise a `ValueError` with an ap... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def element_wise_product(lst1: List[int], lst2: List[int]) -> List[int]:
"""
Computes the element-wise product of two lists.
Args:
lst1 (List[int]): The first list of integers.
lst2 ... |
evol_instruct_66k | 11,395 | Write a Python function to determine if a given list of strings is sorted in descending alphabetical order. The function should use comparison operators and iterative loops for multi-step processing. The code should start with:
```python
from typing import List
def is_descending_alphabetical_order(arr: List[str]) -> b... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_descending_alphabetical_order(arr: List[str]) -> bool:
"""
Determines if a given list of strings is sorted in descending alphabetical order.
Args:
arr (List[str]): The list of strings... |
evol_instruct_66k | 11,398 | Write a Python function to compute the sum of all integer values in a nested list, disregarding any non-integer values. The function should be able to handle lists that contain other lists as elements, and it should recursively sum all integers found at any level of nesting.
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, Union
def sum_nested_integers(lst: List[Union[int, List]]) -> int:
"""
Computes the sum of all integer values in a nested list, disregarding any non-integer values.
Args:
lst (List[Union[in... |
evol_instruct_66k | 11,403 | Write a Python function to perform a binary search on a sorted list of integers to determine if a specific number is included. The function should return the index of the number if it is found, otherwise it should return -1. The binary search should stop as soon as the number is found.
The code should start with:
```p... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def binary_search(arr: List[int], x: int) -> int:
"""
Perform a binary search on a sorted list of integers to determine if a specific number is included.
Args:
arr (List[int]): A sorted list... |
evol_instruct_66k | 11,416 | Write a Python function to generate a sequence of numerical integers starting from a given commencement point and ending at a given concluding point. The function should handle cases where the start point is greater than the end point by generating an empty sequence. The function should also handle cases where the star... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_sequence(start: int, end: int) -> List[int]:
"""
Generate a sequence of numerical integers starting from a given commencement point
and ending at a given concluding point. If the start p... |
evol_instruct_66k | 11,426 | Write a Python function to identify the smallest alphanumeric string value from a given list of strings. The function should return the smallest string based on lexicographical order.
The code should start with:
```python
from typing import List
def find_smallest_string(strings: List[str]) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_smallest_string(strings: List[str]) -> str:
"""
Identifies the smallest alphanumeric string value from a given list of strings.
Args:
strings (List[str]): A list of strings from whi... |
evol_instruct_66k | 11,431 | Write a Python function to calculate the number of trailing zeros in the factorial of a given large number `n` (up to `10^8`). The function should be optimized for large calculations and avoid directly computing the factorial, which would be computationally infeasible for very large numbers.
The code should start with... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_trailing_zeros_in_factorial(n: int) -> int:
"""
Calculate the number of trailing zeros in the factorial of a given number `n`.
Args:
n (int): The number for which to calculate the factorial's trailing zero... |
evol_instruct_66k | 11,456 | Write a Python function to determine if the sum of all integers in a given list falls within a specified range and if the list contains an even number of elements. The function should return `True` if both conditions are met, otherwise `False`.
The code should start with:
```python
from typing import List
def sum_wit... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_within_bounds(l: List[int], lower_limit: int, upper_limit: int) -> bool:
"""
Determines if the sum of all integers in the list `l` falls within the inclusive range
defined by `lower_limit` an... |
evol_instruct_66k | 11,458 | Write a Python function to find the sum of the two largest numbers in a given list of integers. The function should be efficient and handle edge cases such as an empty list or a list with fewer than two elements. The code should start with:
```python
from typing import List
def sum_of_two_largest(numbers: List[int]) -... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import sys
def sum_of_two_largest(numbers: List[int]) -> int:
"""
Calculate the sum of the two largest numbers in a given list of integers.
Args:
numbers (List[int]): The list of integers fr... |
evol_instruct_66k | 11,461 | Write a Python function to find the index of the first occurrence of a given element in a list that contains multiple data types (i.e., strings and integers). If the element is not found, return `-1`. The function should handle the case where the list is not sorted and contains mixed data types.
The code should start ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def find_first_occurrence(my_list: List[Union[int, str]], element: Union[int, str]) -> int:
"""
Find the index of the first occurrence of a given element in a list containing mixed data types.
... |
evol_instruct_66k | 11,464 | Write a Python function to generate a dictionary containing the frequency of specified words in a given text string. The function should handle punctuation and ignore case for word frequencies. The code should start with:
```python
from typing import List, Dict
def word_frequency(text: str, words: List[str]) -> Dict[s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
import string
def word_frequency(text: str, words: List[str]) -> Dict[str, int]:
"""
Generates a dictionary containing the frequency of specified words in a given text string.
Punctuation is re... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.