source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
evol_instruct_66k | 26,903 | Write a Python function to transform a provided list of fruit names into a dictionary where the keys are the indices of the fruits in the list and the values are the fruits themselves. The function should handle lists of varying lengths and ensure that the dictionary is correctly populated.
The code should start with:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def list_to_indexed_dict(fruits: List[str]) -> Dict[int, str]:
"""
Transforms a list of fruit names into a dictionary where the keys are the indices of the fruits in the list and the values are the... |
evol_instruct_66k | 26,910 | Write a Python function to generate a random alphanumeric sequence of a specified length, using only distinct English upper-case letters (A-Z) and individual numerical integers (0-9). The function should ensure that the sequence contains exactly one occurrence of each character from the set of 36 characters (26 letters... | 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_distinct_sequence(length: int) -> str:
"""
Generate a random alphanumeric sequence of the specified length using distinct English upper-case letters and digits.
... |
evol_instruct_66k | 26,911 | Write a Python function to calculate the average of numbers stored in a list. The function should handle empty lists by returning `None` instead of attempting to divide by zero. The code should start with:
```python
from typing import List, Optional
def calculate_average(numbers: List[int]) -> Optional[float]:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List, Optional
def calculate_average(numbers: List[int]) -> Optional[float]:
"""
Calculate the average of numbers stored in a list.
Args:
numbers (List[int]): A list of integers for which the a... |
evol_instruct_66k | 26,915 | Write a Python function to replace every instance of the numerical value "7" with the symbol "#" in a given digital sequence. The digital sequence can be a string or an integer. The function should handle both types of input and return the modified sequence as a string.
The code should start with:
```python
def replac... | Here is the Python code to solve the given problem in the markdown block:
```python
def replace_seven_with_hash(sequence: str) -> str:
"""
Replace every instance of the numerical value "7" with the symbol "#" in the given digital sequence.
Args:
sequence (str): The digital sequence (either a string... |
evol_instruct_66k | 26,916 | Write a Python function to identify the floating point number with the least occurrences in a given list of floating point numbers. If there are multiple numbers with the same least frequency, return the smallest number among them. The function should handle cases where the list is empty by returning `None`.
The code ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def least_frequent_number(numbers: List[float]) -> Optional[float]:
"""
Identify the floating point number with the least occurrences in a given list.
If there are multiple numbers with the... |
evol_instruct_66k | 26,917 | Write a Python function to format a given number as a percentage value, rounding it to two decimal places. The function should handle both positive and negative numbers, as well as zero. The code should start with:
```python
def format_as_percent(value: float) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def format_as_percent(value: float) -> str:
"""
Formats a given number as a percentage value, rounding it to two decimal places.
Args:
value (float): The number to be formatted as a percentage.
Returns:
... |
evol_instruct_66k | 26,930 | Write a Python function to merge two sorted arrays into a single sorted array. The function should efficiently combine the elements from both arrays while maintaining the ascending order. The code should start with:
```python
from typing import List
def merge_sorted_arrays(array_a: List[int], array_b: List[int]) -> Li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_sorted_arrays(array_a: List[int], array_b: List[int]) -> List[int]:
"""
Merges two sorted arrays into a single sorted array.
Args:
array_a (List[int]): The first sorted array.
... |
evol_instruct_66k | 26,933 | Write a Python function that takes a dictionary as an argument and yields each value stored within the dictionary one by one using a generator. The function should be able to handle any dictionary, regardless of the number of key-value pairs.
The code should start with:
```python
from typing import Dict, Any
def dict... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Any, Generator
def dict_values_generator(input_dict: Dict[Any, Any]) -> Generator[Any, None, None]:
"""
A generator function that yields each value from the given dictionary one by one.
Args:
... |
evol_instruct_66k | 26,959 | Write a Python function to filter out all the words from an input list of strings that do not contain the letter 'a' and have an even number of characters. Implement this using a list comprehension.
The code should start with:
```python
from typing import List
def filter_words(words: List[str]) -> List[str]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_words(words: List[str]) -> List[str]:
"""
Filters out words from the input list that do not contain the letter 'a' and have an even number of characters.
Args:
words (List[str]): ... |
evol_instruct_66k | 26,967 | Write a Python function to parse a multi-line string containing key/value pairs separated by equal signs and return a dictionary. If a key appears multiple times, append the values into a list. Handle edge cases such as lines without an equal sign, keys or values containing equals signs, and invalid entries.
The code ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Union
def parse_kv_pairs(kv_string: str) -> Dict[str, Union[str, list]]:
"""
Parse a multi-line string containing key/value pairs separated by equal signs and return a dictionary.
If a key appears m... |
evol_instruct_66k | 26,980 | Write a Python function to merge two sorted integer arrays into a single sorted array without using any built-in sorting or merging functions. The function should handle arrays of different lengths and ensure that the merged array is sorted in ascending order.
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 merge_sorted_arrays(arr1: List[int], arr2: List[int]) -> List[int]:
"""
Merges two sorted integer arrays into a single sorted array without using built-in functions.
Args:
arr1 (List[int... |
evol_instruct_66k | 26,983 | Write a Python function that takes a list of integers and returns a dictionary where the keys are the unique integers from the list and the values are the counts of their occurrences in the list. The function should be efficient and handle edge cases such as an empty list.
The code should start with:
```python
from ty... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_occurrences(numbers: List[int]) -> Dict[int, int]:
"""
Counts the occurrences of each unique integer in the given list.
Args:
numbers (List[int]): A list of integers to count... |
evol_instruct_66k | 26,984 | Write a Python function to swap the values between two lists at the unique indexes. The function should take two lists as input and return the two lists with their values swapped at the unique indexes. The unique indexes are those where the values in the two lists are different. The code should start with:
```python
fr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def swap_unique_values(list_a: List[int], list_b: List[int]) -> (List[int], List[int]):
"""
Swaps the values between two lists at the unique indexes.
Args:
list_a (List[int]): The first list... |
evol_instruct_66k | 26,985 | Write a Python function to remove the last two characters from a given alphanumeric sequence. The sequence is a string containing only alphanumeric characters. The function should return the modified sequence.
The code should start with:
```python
def trim_sequence(sequence: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def trim_sequence(sequence: str) -> str:
"""
Removes the last two characters from the given alphanumeric sequence.
Args:
sequence (str): The alphanumeric sequence from which to remove the last two characters.
R... |
evol_instruct_66k | 27,004 | Write a Python function to convert a given temperature in Fahrenheit to Celsius. The function should take a single argument representing the temperature in Fahrenheit and return the corresponding temperature in Celsius. 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 given temperature in Fahrenheit to Celsius.
Args:
fahrenheit (float): The temperature in Fahrenheit to be converted.
Returns:
float: ... |
evol_instruct_66k | 27,006 | Write a Python function to find the longest common continuous subarray between two given arrays of integers. The function should return the subarray and its length. The code should start with:
```python
from typing import List, Tuple
def longest_common_continuous_subarray(arr1: List[int], arr2: List[int]) -> Tuple[Lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def longest_common_continuous_subarray(arr1: List[int], arr2: List[int]) -> Tuple[List[int], int]:
"""
Finds the longest common continuous subarray between two given arrays of integers.
Args:... |
evol_instruct_66k | 27,025 | Write a Python function to compute the product of the absolute values of a list of numerical inputs, after rounding down to the nearest integer. Any values exceeding 100 should be excluded from the computation. The function should start with:
```python
from typing import List
import math
def compute_absolute_product(l... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import math
def compute_absolute_product(lst: List[float]) -> int:
"""
Computes the product of the absolute values of a list of numerical inputs,
after rounding down to the nearest integer. Any value... |
evol_instruct_66k | 27,030 | Write a Python function to print all elements of a list of strings, along with the count of occurrences of a specified character in each string. The function should iterate through each string in the list, count the occurrences of the specified character, and print the string followed by the count.
The code should sta... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def print_strings_with_char_count(strings: List[str], char: str) -> None:
"""
Prints each string in the list followed by the count of occurrences of a specified character in that string.
Args:
... |
evol_instruct_66k | 27,037 | Write a Python function to generate a dictionary named `ancient_artifacts` that contains seven distinct key-value pairs. Each key should represent the name of an ancient artifact, and each value should represent the era of its historical significance. The function should return the dictionary.
The code should start wi... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_ancient_artifacts_dictionary() -> dict:
"""
Generates a dictionary containing seven ancient artifacts and their respective eras of historical significance.
Returns:
dict: A dictionary where each key is ... |
evol_instruct_66k | 27,042 | Write a Python function to sort a list of strings based on their length in ascending order. If two strings have the same length, they should remain in the order they were originally in the list. The function should be efficient and handle various edge cases, such as an empty list or a list with strings of the same leng... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_strings_by_length(input_list: List[str]) -> List[str]:
"""
Sorts a list of strings based on their length in ascending order.
If two strings have the same length, they remain in their origina... |
evol_instruct_66k | 27,046 | Write a Python function to decode a slugified URL back to its original verbose version using a provided dictionary of slug-original URL pairs. The function should first unslugify the slug to get the verbose title and then use this title to retrieve the original URL from the dictionary.
The code should start with:
```p... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def unslugify(slug: str) -> str:
"""
Converts a slugified string back to a verbose title.
Args:
slug (str): The slugified string to be converted.
Returns:
str: The verbose title... |
evol_instruct_66k | 27,052 | Write a Python function to calculate the sum of the highest (maximum) and lowest (minimum) integers within a given list of numerical values. The function should handle lists of any length, including empty lists. If the list is empty, the function should return 0.
The code should start with:
```python
from typing impor... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_of_extremes(numbers: List[int]) -> int:
"""
Calculate the sum of the highest (maximum) and lowest (minimum) integers within a given list of numerical values.
Args:
numbers (List[int]... |
evol_instruct_66k | 27,069 | Write a Python function to perform an optimized linear search on a given list of integers to find the index of a specified element. If the element is not found, the function should return -1. The function should be optimized for readability and efficiency.
The code should start with:
```python
from typing import List
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def optimized_linear_search(arr: List[int], x: int) -> int:
"""
Perform an optimized linear search to find the index of the specified element in the list.
Args:
arr (List[int]): The list of ... |
evol_instruct_66k | 27,073 | Write a Python function to merge two sorted arrays into a single sorted array efficiently. The function should not use the built-in `sort` method and should instead use a two-pointer technique to achieve the merge. The code should start with:
```python
from typing import List
def merge_sorted_arrays(arr1: List[int], a... | 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]:
"""
Merge two sorted arrays into a single sorted array using a two-pointer technique.
Args:
arr1 (List[int]): The firs... |
evol_instruct_66k | 27,091 | Write a Python function to calculate the frequency of each distinct character in a given string and identify their positions in the string without using built-in functions. The output should be a dictionary where the keys are the characters from the string, and the values are another dictionary. This nested dictionary ... | Here is the Python code to solve the given problem in the markdown block:
```python
def char_freq_and_positions(s: str) -> dict:
"""
Calculate the frequency and positions of each distinct character in the given string.
Args:
s (str): The input string to analyze.
Returns:
dict: A dictio... |
evol_instruct_66k | 27,092 | Write a Python function to perform matrix multiplication on two given matrices. The function should check if the matrices can be multiplied and raise an appropriate error if they cannot. The function should return the resulting matrix after multiplication.
The code should start with:
```python
from typing import List
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def matrix_multiply(A: List[List[int]], B: List[List[int]]) -> List[List[int]]:
"""
Perform matrix multiplication on two given matrices.
Args:
A (List[List[int]]): The first matrix.
... |
evol_instruct_66k | 27,114 | Write a Python function to combine and sort two or more given arrays with different data types into one sorted array without using built-in sorting functions. The sorting should be done considering the following criteria:
1. Numbers have higher priority than strings.
2. Data should be sorted in ascending order for same... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def custom_sort(arrays: List[List[Union[int, float, str]]]) -> List[Union[int, float, str]]:
"""
Combine and sort multiple arrays with different data types into one sorted array.
Args:
... |
evol_instruct_66k | 27,117 | Write a Python function to predict the stock prices for the next three consecutive trading days based on the average price of the last five trading days. The function should take a list of the last five trading days' prices as input and return a list of the predicted prices for the next three days. The prediction shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def predict_next_three_days_prices(last_five_days_prices: List[float]) -> List[float]:
"""
Predicts the stock prices for the next three consecutive trading days based on the average price of the last fiv... |
evol_instruct_66k | 27,120 | Write a Python function to calculate the difference between the maximum and minimum values in a given list of integers. The function should handle lists of any length, including empty lists, and return `None` for empty lists. The code should start with:
```python
from typing import List, Optional
def find_difference(l... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def find_difference(lst: List[int]) -> Optional[int]:
"""
Calculate the difference between the maximum and minimum values in a list of integers.
Args:
lst (List[int]): The list of ... |
evol_instruct_66k | 27,129 | Write a Python function to calculate the minimum value in a 2D array, the positions (row, column) of this minimum value, and its frequency in the array. The function should not use built-in Python functions like `min()`. The code should start with:
```python
from typing import List, Tuple
def find_min_info(arr: List[L... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_min_info(arr: List[List[int]]) -> Tuple[int, List[Tuple[int, int]], int]:
"""
Calculate the minimum value in a 2D array, its positions, and its frequency.
Args:
arr (List[Lis... |
evol_instruct_66k | 27,139 | Write a Python function to find the common city between the `Orders` and `Customers` datasets. The function should return a list of tuples containing the order ID and customer name for each common city.
The code should start with:
```python
from typing import List, Tuple
def find_common_city(orders: List[Tuple[int, s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_common_city(orders: List[Tuple[int, str, int, str]], customers: List[Tuple[str, int, int, str]]) -> List[Tuple[int, str]]:
"""
Find the common city between the Orders and Customers datase... |
evol_instruct_66k | 27,146 | Write a Python function to find the maximum integer in a given list of integers without using any pre-built Python functions for determining the maximum integer. The function should iterate through the list and compare each element to find the highest value.
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 find_max_integer(arr: List[int]) -> int:
"""
Finds the maximum integer in a given list of integers without using pre-built Python functions.
Args:
arr (List[int]): The list of integers f... |
evol_instruct_66k | 27,151 | Write a Python function to calculate the sum of the squared values for each element within a given numerical array. The function should handle any size of numerical array and return the sum of the squares of its elements. The code should start with:
```python
from typing import List
def sum_of_squares(numbers: List[in... | Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def sum_of_squares(numbers: List[int]) -> int:
"""
Calculate the sum of the squared values for each element within the provided numerical array.
Args:
numbers (List[int]): A list of intege... |
evol_instruct_66k | 27,157 | Write a Python function to iterate through all elements of a given dictionary and swap the letter case of all string values. The function should return the modified dictionary. The code should start with:
```python
from typing import Dict
def swap_string_case(d: Dict[str, any]) -> Dict[str, any]:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import Dict
def swap_string_case(d: Dict[str, any]) -> Dict[str, any]:
"""
Swaps the letter case of all string values in the given dictionary.
Args:
d (Dict[str, any]): The dictionary whose string val... |
evol_instruct_66k | 27,162 | Write a Python function to convert a binary search tree (BST) into a doubly-linked circular list (DCL) where the nodes are sorted in ascending order. The function should also include utility functions to insert new nodes into the BST and to print the doubly-linked circular list. The doubly-linked circular list's previo... | Here is the Python code to solve the given problem in the markdown block:
```python
class TreeNode:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
class DoublyLinkedListNode:
def __init__(self, value):
self.value = value
self.prev = None... |
evol_instruct_66k | 27,177 | Write a Python function to calculate the mean temperature from a given list of temperature values. The function should handle the case where the list is empty by returning 0. The code should start with:
```python
from typing import List
def calculate_mean_temperature(temperatures: List[float]) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_mean_temperature(temperatures: List[float]) -> float:
"""
Calculate the mean temperature from a given list of temperature values.
Args:
temperatures (List[float]): A list of te... |
evol_instruct_66k | 27,201 | Write a Python function to calculate the product of all integers from 1 to n using an efficient while loop algorithm. The function should ensure optimal computational performance by avoiding unnecessary operations and leveraging efficient coding techniques.
The code should start with:
```python
def calculate_product(n... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_product(n: int) -> int:
"""
Calculate the product of all integers from 1 to n using an efficient while loop algorithm.
Args:
n (int): The upper limit of the range (inclusive) for which the product is t... |
evol_instruct_66k | 27,205 | Write a Python function to remove sequential duplicates from a given list while preserving the original order of elements. The list can contain both strings and integers. The function should start with:
```python
from typing import List, Union
def remove_sequential_duplicates(input_list: List[Union[str, int]]) -> List... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def remove_sequential_duplicates(input_list: List[Union[str, int]]) -> List[Union[str, int]]:
"""
Removes sequential duplicates from a given list while preserving the original order of elements.
... |
evol_instruct_66k | 27,208 | Write a Python function to double the value of the element at a specified index in a given list. If the specified index is out of bounds, the function should return the original list without any modifications.
The code should start with:
```python
from typing import List
def double_element_at_index(arr: List[int], in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def double_element_at_index(arr: List[int], index: int) -> List[int]:
"""
Doubles the value of the element at the specified index in the given list.
If the index is out of bounds, returns the origina... |
evol_instruct_66k | 27,211 | Write a Python function to scale a number using a non-linear scaling method based on the sigmoid function. The sigmoid function is defined as \( f(x) = \frac{1}{1 + e^{-x}} \). The function should allow for a customizable scaling factor. The code should start with:
```python
import math
def scale_number_with_sigmoid(n... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def scale_number_with_sigmoid(num: float, factor: float = 0.5) -> float:
"""
Scales a number using a non-linear scaling method based on the sigmoid function.
The sigmoid function is defined as f(x) = 1 / (1 + e... |
evol_instruct_66k | 27,225 | Write a Python function to count the number of vowels in each word of a given list of words. The function should return a list of integers where each integer represents the count of vowels in the corresponding word from the input list.
The code should start with:
```python
from typing import List
def count_vowels_in_... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_vowels_in_words(word_list: List[str]) -> List[int]:
"""
Counts the number of vowels in each word of a given list of words.
Args:
word_list (List[str]): A list of words where each w... |
evol_instruct_66k | 27,239 | Write two Python functions to manipulate a list of dictionaries. The first function should return a list of dictionaries with distinct values based on a provided key. The second function should return a new list of dictionaries that does not contain a specific key-value pair.
The starter code for the first function is... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def return_unique_dicts(input_data: List[Dict], key: str) -> List[Dict]:
"""
Returns a list of dictionaries with distinct values based on a provided key.
Args:
input_data (List[Dict]):... |
evol_instruct_66k | 27,250 | Write a Python function to display the current date and time in the format 'Day/Month/Year, Hours:Minutes:Seconds'. The function should handle any potential exceptions related to date and time handling. The code should start with:
```python
from datetime import datetime
def display_current_datetime() -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime
def display_current_datetime() -> str:
"""
Display the current date and time in the format 'Day/Month/Year, Hours:Minutes:Seconds'.
Returns:
str: The current date and time formatted as... |
evol_instruct_66k | 27,264 | Write a Python function to replicate each element in a given list a specified number of times. The function should take two parameters: the list to be replicated and the number of times each element should be replicated. The function should return a new list containing the replicated elements.
The code should start wi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def replicate_elements(lst: List[str], n: int) -> List[str]:
"""
Replicates each element in the given list `n` times and returns a new list.
Args:
lst (List[str]): The list of elements to be... |
evol_instruct_66k | 27,271 | Write a Python function to split a given sentence into its fundamental word components. The function should handle various delimiters such as spaces, commas, periods, and other punctuation marks. The function should return a list of words, where each word is a string stripped of any leading or trailing punctuation.
Th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def split_sentence_into_words(sentence: str) -> List[str]:
"""
Splits a given sentence into its fundamental word components, handling various delimiters and stripping punctuation.
Args:
... |
evol_instruct_66k | 27,282 | Write a Python function to generate a sequence that periodically loops through the discrete alphabetic entities of a given character array, yielding each singular entity in uppercase manifestation. The function should ignore non-alphabetic characters and continue looping through the alphabetic characters indefinitely.
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Generator
def generate_alphabetic_loop(string: str) -> Generator[str, None, None]:
"""
Generates a sequence that periodically loops through the discrete alphabetic entities
of a given character array, yie... |
evol_instruct_66k | 27,287 | Write two Python functions to capitalize and uncapitalize each character of a given string. The first function should convert all characters in the string to uppercase, and the second function should convert all characters in the string to lowercase. The functions should handle strings of any length, including empty st... | Here is the Python code to solve the given problem in the markdown block:
```python
def capitalize_string(s: str) -> str:
"""
Convert all characters in the string to uppercase.
Args:
s (str): The input string to be capitalized.
Returns:
str: The string with all characters converted to ... |
evol_instruct_66k | 27,298 | Write a Python function to determine the frequency of a specific value in a given list of strings. The function should take two parameters: the list of strings and the target string whose frequency is to be determined. The function should return the frequency as an integer.
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
def count_frequency(strings: List[str], target: str) -> int:
"""
Counts the frequency of a specific string in a given list of strings.
Args:
strings (List[str]): The list of strings in which... |
evol_instruct_66k | 27,309 | Write a Python function to sort a given list of integers in descending order and return the sorted list. The function should handle an empty list gracefully and return it as is. The code should start with:
```python
from typing import List
def sort_descending(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 sort_descending(arr: List[int]) -> List[int]:
"""
Sorts the given list of integers in descending order and returns the sorted list.
Args:
arr (List[int]): The list of integers to be so... |
evol_instruct_66k | 27,312 | Write a Python function to compute the multiplication of two distinct numerical values provided as input parameters. The function should return the result of the multiplication. The code should start with:
```python
def multiply_numbers(num1: int, num2: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def multiply_numbers(num1: int, num2: int) -> int:
"""
Computes the multiplication of two distinct numerical values.
Args:
num1 (int): The first numerical value.
num2 (int): The second numerical value.
... |
evol_instruct_66k | 27,318 | Write a Python function to sort a dictionary by its values in ascending order while maintaining the original structure and ensuring minimal alterations to the keys. The function should return a new dictionary with the sorted key-value pairs.
The code should start with:
```python
from typing import Dict
def sort_dict_... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def sort_dict_by_value(input_dict: Dict[str, int]) -> Dict[str, int]:
"""
Sorts a dictionary by its values in ascending order while maintaining the original structure.
Args:
input_dict (Dict... |
evol_instruct_66k | 27,335 | Write a Python function to detect the unique elements in two unsorted arrays of integers and output their count along with their respective frequency. The function should handle up to 10^7 elements efficiently.
The code should start with:
```python
from typing import List, Dict
def count_unique_elements(arr1: List[in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_unique_elements(arr1: List[int], arr2: List[int]) -> Dict[int, int]:
"""
Detects the unique elements in two unsorted arrays of integers and outputs their count along with their respective... |
evol_instruct_66k | 27,340 | Write a Python function to generate an array of 10 unique numbers between 0 and 20 (both inclusive) and sort this array in descending order. The function should ensure that there are no repeated numbers in the array. The code should start with:
```python
from typing import List
import random
def generate_unique_sorted... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_unique_sorted_numbers() -> List[int]:
"""
Generates an array of 10 unique numbers between 0 and 20 (both inclusive) and sorts this array in descending order.
Returns:
... |
evol_instruct_66k | 27,342 | Write a Python function to sort a given list of integers in ascending order and then rearrange the sorted list in descending order. The function should return the final rearranged list. The code should start with:
```python
from typing import List
def sort_and_reverse(nums: 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_and_reverse(nums: List[int]) -> List[int]:
"""
Sorts the given list of integers in ascending order and then rearranges it in descending order.
Args:
nums (List[int]): The list of in... |
evol_instruct_66k | 27,353 | Write a Python function to compute the factorial of a given natural number `x` and return the result. The function should handle the case where `x` is 0 by returning 1, as the factorial of 0 is defined to be 1. The function should also handle invalid inputs (e.g., negative numbers) by raising a `ValueError`.
The code ... | Here is the Python code to solve the given problem in the markdown block:
```python
def factorial(x: int) -> int:
"""
Compute the factorial of a given natural number x.
Args:
x (int): The natural number for which to compute the factorial.
Returns:
int: The factorial of x.
Raises:
... |
evol_instruct_66k | 27,367 | Write a Python function to calculate the cumulative product of all odd numbers in a given range from 1 to `n` (inclusive). The function should return the result of this cumulative multiplication.
The code should start with:
```python
def cumulative_product_of_odds(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def cumulative_product_of_odds(n: int) -> int:
"""
Calculate the cumulative product of all odd numbers in the range from 1 to n (inclusive).
Args:
n (int): The upper limit of the range (inclusive).
Returns:
... |
evol_instruct_66k | 27,395 | Write a Python function to calculate the sum of two integers provided as command-line arguments. The function should handle the input validation to ensure that exactly two integers are provided and that they are valid integers. The code should start with:
```python
import sys
def sum_two_integers(args: list) -> int:
`... | Here is the Python code to solve the given problem in the markdown block:
:
```python
import sys
def sum_two_integers(args: list) -> int:
"""
Calculate the sum of two integers provided as command-line arguments.
Args:
args (list): A list containing the command-line arguments.
Returns:
... |
evol_instruct_66k | 27,405 | Write a Python function to organize students into classes based on their major. The function should take a list of dictionaries, where each dictionary represents a student with keys "name" and "major". The function should return a dictionary where the keys are the majors and the values are lists of student names belong... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def organize_students_by_major(student_list: List[Dict[str, str]]) -> Dict[str, List[str]]:
"""
Organizes students into classes based on their major.
Args:
student_list (List[Dict[str,... |
evol_instruct_66k | 27,417 | Write a Python function to check if a given number is a prime number using recursion. The function should not use traditional iteration methods or conditional statements. Additionally, it should handle potential exceptions such as negative numbers and non-integer inputs. The function should start with:
```python
def is... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_prime(n: int, i: int = 2) -> bool:
"""
Check if a given number is a prime number using recursion.
Args:
n (int): The number to check for primality.
i (int, optional): The current divisor to check. Def... |
evol_instruct_66k | 27,421 | Write a Python function to determine if a given number is present in a predefined list of integers. The function should return `True` if the number is found in the list, and `False` otherwise. The code should start with:
```python
from typing import List
def is_number_in_list(arr: List[int], num: int) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_number_in_list(arr: List[int], num: int) -> bool:
"""
Determines if a given number is present in a predefined list of integers.
Args:
arr (List[int]): The list of integers to search w... |
evol_instruct_66k | 27,448 | Write a Python function to generate all non-repeated permutations (subgroups) of a given alphabet string, ignoring the sequence of the characters. The function should return a set of tuples, where each tuple represents a unique permutation of the string.
The code should start with:
```python
from typing import Set, Tu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Set, Tuple
from itertools import combinations
def generate_unique_permutations(s: str) -> Set[Tuple[str]]:
"""
Generate all non-repeated permutations (subgroups) of a given alphabet string,
ignoring the s... |
evol_instruct_66k | 27,449 | Write a Python function to find the earliest absent positive integer in a given non-sequenced array. The function should return the smallest positive integer that is missing from the array. The code should start with:
```python
from typing import List
def find_earliest_absent_positive(array: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_earliest_absent_positive(array: List[int]) -> int:
"""
Find the earliest absent positive integer in a given non-sequenced array.
Args:
array (List[int]): The input array of integers... |
evol_instruct_66k | 27,458 | Write a Python function to compute the factorial of a given non-negative integer `n`. The factorial of a number `n` is the product of all positive integers less than or equal to `n`. The function should handle edge cases such as `n` being 0 or 1, and should raise a `ValueError` if `n` is negative.
The code should star... | Here is the Python code to solve the given problem in the markdown block:
```python
def factorial(n: int) -> int:
"""
Compute the factorial of a given non-negative integer n.
The factorial of a number n (denoted as n!) is the product of all positive integers
less than or equal to n. For example, 5! = 5... |
evol_instruct_66k | 27,479 | Write a Python function to calculate the cumulative total of all non-repetitive elements in a given bidimensional numeric matrix. The function should flatten the matrix into a single list, remove any duplicate elements, and then sum the remaining unique elements.
The code should start with:
```python
from typing impor... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def cumulative_total_of_unique_elements(matrix: List[List[int]]) -> int:
"""
Calculate the cumulative total of all non-repetitive elements in a given bidimensional numeric matrix.
Args:
matr... |
evol_instruct_66k | 27,482 | Write a Python function to generate a two-dimensional array filled with zeros of a specified size. The function should take two parameters: the number of rows and the number of columns, and return a 2D list (list of lists) filled with zeros.
The code should start with:
```python
from typing import List
def generate_z... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_zero_matrix(rows: int, cols: int) -> List[List[int]]:
"""
Generates a two-dimensional array filled with zeros.
Args:
rows (int): The number of rows in the matrix.
cols (... |
evol_instruct_66k | 27,485 | Write a Python function to sort a list of integers using the QuickSort algorithm. The function should be optimized for performance and should handle edge cases such as empty lists and lists with all identical elements. The code should start with:
```python
from typing import List
def quicksort(arr: List[int]) -> List[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def quicksort(arr: List[int]) -> List[int]:
"""
Sorts a list of integers using the QuickSort algorithm.
Args:
arr (List[int]): The list of integers to be sorted.
Returns:
List[i... |
evol_instruct_66k | 27,493 | Write a Python function to remove duplicate elements from a given list of integers while preserving the order of the first occurrence of each element. The function should return a new list with unique elements.
The code should start with:
```python
from typing import List
def remove_duplicates(nums: List[int]) -> Lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_duplicates(nums: List[int]) -> List[int]:
"""
Removes duplicate elements from the given list of integers while preserving the order of the first occurrence of each element.
Args:
... |
evol_instruct_66k | 27,497 | Write a Python function to generate all possible subsets of a given size `K` from a provided numerical array. The function should return a list of tuples, where each tuple represents a subset of size `K`.
The code should start with:
```python
from typing import List, Tuple
import itertools
def generate_subsets(arr: L... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import itertools
def generate_subsets(arr: List[int], K: int) -> List[Tuple[int, ...]]:
"""
Generate all possible subsets of a given size K from a provided numerical array.
Args:
arr ... |
evol_instruct_66k | 27,502 | Write a Python function to calculate the product of all integers within a specified range `[start, end]` that are present in a given list of integers. The function should return the product of these integers. If no integers fall within the specified range, the function should return 1.
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 calculate_product_in_range(lst: List[int], start: int, end: int) -> int:
"""
Calculate the product of all integers within a specified range [start, end] that are present in the given list.
Args:... |
evol_instruct_66k | 27,505 | Write a Python function to iterate over a list of integers using a `while` loop and return the sum of the elements. The function should start with:
```python
from typing import List
def sum_with_while(arr: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def sum_with_while(arr: List[int]) -> int:
"""
Calculate the sum of all elements in a list using a while loop.
Args:
arr (List[int]): The list of integers to sum.
Returns:
int... |
evol_instruct_66k | 27,549 | Write a Python function to reverse a given string. The function should take a string as input and return the reversed string. The code should start with:
```python
def reverse_string(input_string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_string(input_string: str) -> str:
"""
Reverses the given input string.
Args:
input_string (str): The string to be reversed.
Returns:
str: The reversed string.
"""
# Use slicing to re... |
evol_instruct_66k | 27,554 | Write a Python function to subtract two given two-dimensional 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 dim... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def subtract_matrices(matrix1: List[List[int]], matrix2: List[List[int]]) -> List[List[int]]:
"""
Subtracts two given two-dimensional matrices.
Args:
matrix1 (List[List[int]]): The first mat... |
evol_instruct_66k | 27,565 | Write a Python function to identify the smallest disparity between any pair of elements within a provided two-dimensional matrix. The disparity can be calculated between elements in the same row, same column, or diagonally. The function should handle matrices of varying sizes and return an error message if the matrix i... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def find_min_disparity(matrix: np.ndarray) -> float:
"""
Identifies the smallest disparity between any pair of elements within a provided two-dimensional matrix.
Args:
matrix (np.ndarray): A 2D n... |
evol_instruct_66k | 27,587 | Write a Python function to convert a list of temperatures from Celsius to Fahrenheit. The function should take a list of integers representing temperatures in Celsius and return a list of floats representing the corresponding temperatures in Fahrenheit. 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
def convert_celsius_to_fahrenheit(celsius_list: List[int]) -> List[float]:
"""
Converts a list of temperatures from Celsius to Fahrenheit.
Args:
celsius_list (List[int]): A list of integers ... |
evol_instruct_66k | 27,593 | Write a Python function to return the nth element of a given array, considering zero-based indexing. If the index is out of bounds, return `None`. The function should handle both positive and negative indices. Negative indices should count from the end of the array.
The code should start with:
```python
from typing im... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def get_nth_element(arr: List[int], n: int) -> Optional[int]:
"""
Returns the nth element of the given array, considering zero-based indexing.
If the index is out of bounds, returns None.
... |
evol_instruct_66k | 27,605 | Write a Python function to find the common elements between two given lists. The function should return a list of common elements in ascending order. The code should start with:
```python
from typing import List
def find_common_elements(list1: List[int], list2: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_common_elements(list1: List[int], list2: List[int]) -> List[int]:
"""
Finds the common elements between two lists and returns them in ascending order.
Args:
list1 (List[int]): The f... |
evol_instruct_66k | 27,611 | Write a Python function to dynamically adjust the font size of a message based on its color. If the color is 'red', the font size should increase by 20%. The function should validate the input parameters to ensure they are of the correct type and format.
The code should start with:
```python
def adjust_font_size(messa... | Here is the Python code to solve the given problem in the markdown block:
```python
def adjust_font_size(message: str, color: str, font_size: int) -> int:
"""
Adjusts the font size of a message based on its color. If the color is 'red', the font size increases by 20%.
Args:
message (str): The messa... |
evol_instruct_66k | 27,622 | Write a Python function to count the number of vowels in a given input string. The function should be case-insensitive and should return the total count of vowel letters ('a', 'e', 'i', 'o', 'u') in the string.
The code should start with:
```python
def count_vowels(input_string: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def count_vowels(input_string: str) -> int:
"""
Count the number of vowels in the given input string.
Args:
input_string (str): The input string to count vowels from.
Returns:
int: The total number of v... |
evol_instruct_66k | 27,630 | Write a Python function to determine if a given string is a pangram. A pangram is a phrase that uses every letter of the alphabet at least once. The function should ignore case and non-alphabetic characters.
The code should start with:
```python
def is_pangram(input_string: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_pangram(input_string: str) -> bool:
"""
Determine if the given string is a pangram.
A pangram is a phrase that uses every letter of the alphabet at least once.
This function ignores case and non-alphabetic charac... |
evol_instruct_66k | 27,636 | Write a Python function to find all prime numbers up to a given limit `n` using the Sieve of Eratosthenes algorithm. The function should return a list of all prime numbers less than `n`.
The code should start with:
```python
from typing import List
def find_primes_up_to(n: int) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_primes_up_to(n: int) -> List[int]:
"""
Find all prime numbers up to a given limit n using the Sieve of Eratosthenes algorithm.
Args:
n (int): The upper limit up to which to find pri... |
evol_instruct_66k | 27,642 | Write a Python function to filter out any element from a given list that is divisible by a specified divisor. The function should return a new list containing only the elements that are not divisible by the specified divisor.
The code should start with:
```python
from typing import List
def filter_divisible_elements(... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_divisible_elements(lst: List[int], divisor: int) -> List[int]:
"""
Filters out any element from the given list that is divisible by the specified divisor.
Args:
lst (List[int]): T... |
evol_instruct_66k | 27,664 | Write a Python function to generate a list of squared outcomes for integers within a specified range. The function should take two parameters: the start and end of the range (inclusive). The function should return a list of squared values for each integer in the specified range.
The code should start with:
```python
f... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_squared_outcomes(start: int, end: int) -> List[int]:
"""
Generate a list of squared outcomes for integers within the specified range [start, end].
Args:
start (int): The startin... |
evol_instruct_66k | 27,666 | Write a Python function to modify the text casing of each separate lexical unit (word) within a supplied sentence, converting them into uncapitalized letters. A lexical unit is defined as a sequence of alphanumeric characters separated by non-alphanumeric characters. The function should handle sentences with various pu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def uncapitalize_lexical_units(sentence: str) -> str:
"""
Modifies the text casing of each separate lexical unit within a supplied sentence,
converting them into uncapitalized letters.
... |
evol_instruct_66k | 27,668 | Write a Python function to generate a random sequence of 0s and 1s of a given length, ensuring that no more than three consecutive identical numbers appear in the sequence. The function should start with:
```python
from typing import List
def generate_random_sequence(length: 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_random_sequence(length: int) -> List[int]:
"""
Generates a random sequence of 0s and 1s of the given length, ensuring that no more than three consecutive identical numbers appe... |
evol_instruct_66k | 27,678 | Write a Python function to check if three variables `A`, `B`, and `C` match specific values `1`, `2`, and `3` respectively, and if `A` is not equal to `0`. Optimize the code for efficiency and conciseness. The function should return `True` if the conditions are met, otherwise `False`.
The code should start with:
```py... | Here is the Python code to solve the given problem in the markdown block:
```python
def check_conditions(A: int, B: int, C: int) -> bool:
"""
Check if the variables A, B, and C match specific values and if A is not equal to 0.
Args:
A (int): The first variable to check.
B (int): The second ... |
evol_instruct_66k | 27,681 | Write a Python function to count the total number of even numbers in a given array, calculate the sum of these even numbers, and return the indices where these even numbers occur. The function should return these three values as a tuple: (count_of_even_numbers, sum_of_even_numbers, indices).
The code should start with... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def count_sum_indices_even_numbers(arr: List[int]) -> Tuple[int, int, List[int]]:
"""
Counts the total number of even numbers in a given array, calculates the sum of these even numbers,
and re... |
evol_instruct_66k | 27,691 | Write a Python function to create a dictionary from a given list where each key represents a unique even number and each value represents its count. The function should handle lists with both even and odd numbers, and only include even numbers in the resulting dictionary.
The code should start with:
```python
from typ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
from collections import Counter
def count_even_numbers(numbers: List[int]) -> Dict[int, int]:
"""
Create a dictionary from a given list where each key represents a unique even number and each value... |
evol_instruct_66k | 27,692 | Write a Python function to organize two distinct compilations, one constituted of numeric integers and the other of distinct English language words. The numeric compilation should be portrayed in a sequentially increasing mode, whereas the English language words compilation should be sequenced in lexicographical order.... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def organize_compilations(numeric_compilation: List[int], word_compilation: List[str]) -> Tuple[List[int], List[str]]:
"""
Organizes two distinct compilations: one of numeric integers and the othe... |
evol_instruct_66k | 27,707 | Write a Python function to calculate the maximum sum of all possible subarrays of a given array. A subarray is defined as a contiguous segment of the array. The function should return the maximum sum found amongst all subarrays.
The code should start with:
```python
from typing import List
def max_subarray_sum(arr: L... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_subarray_sum(arr: List[int]) -> int:
"""
Calculate the maximum sum of all possible subarrays of a given array.
Args:
arr (List[int]): The input array of integers.
Returns:
... |
evol_instruct_66k | 27,710 | Write a Python function to filter out elements from a given list of integers that are divisible by a specified divisor. The function should utilize a list comprehension for efficiency.
The code should start with:
```python
from typing import List
def filter_divisible_by(numbers: List[int], divisor: int) -> List[int]:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_divisible_by(numbers: List[int], divisor: int) -> List[int]:
"""
Filters out elements from the given list of integers that are divisible by the specified divisor.
Args:
numbers (L... |
evol_instruct_66k | 27,711 | Write a Python function to search for a specific sequence of characters within a given body of text using regular expressions. The function should return the matched sequence if found, otherwise return `None`. The code should start with:
```python
import re
def find_sequence(text: str, pattern: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def find_sequence(text: str, pattern: str) -> str:
"""
Searches for a specific sequence of characters within a given body of text using regular expressions.
Args:
text (str): The body of text to search.
... |
evol_instruct_66k | 27,717 | Write a Python function to create a dictionary from a given tuple of key-value pairs and compute the sum of the values in the dictionary. The function should return both the dictionary and the sum of its values.
The code should start with:
```python
from typing import Tuple, Dict, Any
def create_dict_and_sum_values(m... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple, Dict, Any
def create_dict_and_sum_values(my_tuple: Tuple[Tuple[Any, int], ...]) -> Tuple[Dict[Any, int], int]:
"""
Create a dictionary from a given tuple of key-value pairs and compute the sum of the v... |
evol_instruct_66k | 27,720 | Write a Python function to sort a list of numbers in increasing order using the merge sort algorithm. The merge sort algorithm is a divide-and-conquer algorithm that recursively divides the list into halves until each sublist contains a single element, then merges these sublists back together in sorted order.
The code... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_sort(num_list: List[int]) -> List[int]:
"""
Sorts a list of numbers in increasing order using the merge sort algorithm.
Args:
num_list (List[int]): The list of numbers to be sorted... |
evol_instruct_66k | 27,729 | Write a Python function to sort a list of integers using the bubble sort algorithm. The function should take a list of integers as input and return the sorted list. The code should start with:
```python
from typing import List
def bubble_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 bubble_sort(arr: List[int]) -> List[int]:
"""
Sorts a list of integers using the bubble sort algorithm.
Args:
arr (List[int]): The list of integers to be sorted.
Returns:
... |
evol_instruct_66k | 27,743 | Write a Python function to compare two lists element-wise and determine if the first list is greater than the second list. The comparison should be done by comparing each corresponding element of the two lists. If all corresponding elements of the first list are greater than those of the second list, the function shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_first_list_greater(list1: List[int], list2: List[int]) -> bool:
"""
Compare two lists element-wise and determine if the first list is greater than the second list.
Args:
list1 (List[i... |
evol_instruct_66k | 27,751 | Write a Python function to calculate the dot product of two vectors, ensuring that the function handles vectors of different lengths by raising a `ValueError`. The function should also correctly handle vectors with both positive and negative integers. The code should start with:
```python
from typing import List
def d... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def dot_product(vector1: List[int], vector2: List[int]) -> int:
"""
Calculate the dot product of two vectors.
Args:
vector1 (List[int]): The first vector.
vector2 (List[int]): The se... |
evol_instruct_66k | 27,766 | Write a Python function to generate all prime numbers between 1 and a given number `n` (inclusive) using an optimized algorithm, and then calculate and return the sum of these prime numbers. The function should be efficient in terms of both time and space complexity.
The code should start with:
```python
def generate_... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_and_sum_primes(n: int) -> int:
"""
Generate all prime numbers between 1 and n (inclusive) using the Sieve of Eratosthenes algorithm,
and return the sum of these prime numbers.
Args:
n (int): The upp... |
evol_instruct_66k | 27,772 | Write a Python function to create a list that maintains the insertion order of elements, similar to how a LinkedHashSet works in Java. The function should take a variable number of arguments and return a list containing these elements in the order they were inserted.
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 linked_hash_set_like(elements: List[int]) -> List[int]:
"""
Returns a list that maintains the insertion order of elements, similar to a LinkedHashSet in Java.
Args:
elements (List[int]):... |
evol_instruct_66k | 27,784 | Write a Python function to create a dictionary from a given list of tuples, where the keys are the ASCII values of the characters in the tuples, and the values remain the same. The function should handle lists of tuples where each tuple contains exactly two elements: a character and an integer.
The code should start w... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def map_tuples_to_ascii_dict(tuples: List[Tuple[str, int]]) -> dict:
"""
Creates a dictionary from a given list of tuples, where the keys are the ASCII values of the characters and the values rema... |
evol_instruct_66k | 27,793 | Write a Python function to convert military time (24-hour format) to standard time (12-hour format) with AM/PM designation. The function should handle edge cases such as midnight (00:00) and noon (12:00). The code should start with:
```python
def convert_military_to_standard_time(military_time: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def convert_military_to_standard_time(military_time: str) -> str:
"""
Converts a given military time (24-hour format) to standard time (12-hour format) with AM/PM designation.
Args:
military_time (str): A string rep... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.