source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
evol_instruct_66k | 22,511 | Write a Python function to determine if a given string is a pangram. A pangram is a sentence that contains 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 sentence that contains every letter of the alphabet at least once.
This function ignores case and non-alphabetic ... |
evol_instruct_66k | 22,513 | Write a Python function to sort a numerical array in ascending order, but with alternating odd and even numbers, starting with odd numbers. If the number of odd and even numbers is not equal, the remaining numbers should be appended to the end of the list in ascending order.
The code should start with:
```python
from ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_alternating_odd_even(arr: List[int]) -> List[int]:
"""
Sorts a numerical array in ascending order with alternating odd and even numbers, starting with odd numbers.
If the number of odd and e... |
evol_instruct_66k | 22,517 | Write a Python function to reverse the order of elements in a given list. The function should return a new list with the elements in the exact opposite order of the original list. The code should start with:
```python
from typing import List
def reverse_list(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 reverse_list(arr: List[int]) -> List[int]:
"""
Reverses the order of elements in a given list and returns a new list with the elements in the exact opposite order.
Args:
arr (List[int]... |
evol_instruct_66k | 22,522 | Write a Python function to validate U.S. telephone numbers using a regular expression. The function should handle various formats including different separators and optional country code. The function should return `True` if the input string is a valid U.S. telephone number and `False` otherwise.
The code should start... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def is_valid_us_number(phone_num: str) -> bool:
"""
Validates if the given string is a valid U.S. telephone number.
Args:
phone_num (str): The string to be validated as a U.S. telephone number.
Retur... |
evol_instruct_66k | 22,535 | Write a Python function to calculate the median value from a given list of numbers, which may contain both integers and floating-point numbers. The list might be unsorted and could include repetitive or missing numbers. When the total number of data points is even, the median is defined as the average of the middle two... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def calculate_median(numbers: List[Union[int, float]]) -> Union[int, float]:
"""
Calculate the median value from a given list of numbers.
The list may contain both integers and floating-point... |
evol_instruct_66k | 22,538 | Write a Python function to determine the output of a conditional statement based on given values of `a`, `b`, and `c`. The function should return the result of the multiplication of `a`, `b`, and `c` if the condition `a > b or b < c` is true. Otherwise, it should return `None`.
The code should start with:
```python
de... | Here is the Python code to solve the given problem in the markdown block:
```python
def conditional_multiplication(a: int, b: int, c: int) -> int:
"""
Determine the output of a conditional statement based on the values of a, b, and c.
Args:
a (int): The first integer value.
b (int): The sec... |
evol_instruct_66k | 22,541 | Write a Python function that processes a list of integers and returns a list of integers based on specific conditions using `break` and `continue` statements within a `for` loop. The function should iterate through the list and:
1. Stop processing and return the current list of processed integers when a negative number... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_list(numbers: List[int]) -> List[int]:
"""
Processes a list of integers and returns a list of integers based on specific conditions.
The function iterates through the list and:
1. St... |
evol_instruct_66k | 22,552 | Write a Python function to evaluate a given logical expression and print the result based on the evaluation. The function should take five variables `a`, `b`, `c`, `d`, and `e` as inputs and evaluate the expression `((a > b) or (b < c)) and str((b ** a * d/c) > e)`. If the expression evaluates to `True`, the function s... | Here is the Python code to solve the given problem in the markdown block:
```python
def evaluate_expression(a: int, b: int, c: int, d: int, e: str) -> None:
"""
Evaluates a given logical expression and prints the result based on the evaluation.
Args:
a (int): The first integer.
b (int): The... |
evol_instruct_66k | 22,586 | Write a Python function to generate a stochastic three-dimensional matrix with specified volumetric parameters. The matrix should be generated using a normal distribution with mean 0 and standard deviation 1. The function should take three parameters: `strata`, `rank`, and `columnar_lines`, which define the dimensions ... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def generate_stochastic_matrix(strata: int, rank: int, columnar_lines: int) -> np.ndarray:
"""
Generate a stochastic three-dimensional matrix with specified volumetric parameters.
The matrix is generated... |
evol_instruct_66k | 22,598 | Write a Python function to filter out all integers from a given list that exceed a specified boundary limit. The function should return a new list containing only the integers that are less than or equal to the specified limit. The code should start with:
```python
from typing import List
def filter_integers_by_limit(... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_integers_by_limit(numbers: List[int], limit: int) -> List[int]:
"""
Filters out all integers from the given list that exceed the specified limit.
Args:
numbers (List[int]): The li... |
evol_instruct_66k | 22,606 | Write a Python function to swap the values of two numerical variables using an intervening temporary variable. The function should take two parameters, `a` and `b`, and return a tuple containing the swapped values of `a` and `b`. The code should start with:
```python
def swap_values(a: int, b: int) -> tuple:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def swap_values(a: int, b: int) -> tuple:
"""
Swaps the values of two numerical variables using an intervening temporary variable.
Args:
a (int): The first numerical variable.
b (int): The second numerical v... |
evol_instruct_66k | 22,607 | Write a Python function to find the smallest and the largest elements in a given list of integers with a time complexity of O(n). You are not allowed to use built-in sorting or max/min functions. The function should return a tuple containing the smallest and the largest elements.
The code should start with:
```python
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_smallest_largest(nums: List[int]) -> Tuple[int, int]:
"""
Find the smallest and largest elements in a list of integers with O(n) time complexity.
Args:
nums (List[int]): A li... |
evol_instruct_66k | 22,615 | Write a Python function to determine if a given integer is even or odd. The function should return a string "Yes, it's even" if the integer is even, and "No, it's not even" if the integer is odd. The function should handle any integer input.
The code should start with:
```python
def check_even_or_odd(number: int) -> s... | Here is the Python code to solve the given problem in the markdown block:
```python
def check_even_or_odd(number: int) -> str:
"""
Determines if the given integer is even or odd and returns a corresponding message.
Args:
number (int): The integer to be checked.
Returns:
str: A string i... |
evol_instruct_66k | 22,629 | Write a Python function to find the minimal numerical value within an array of integers using a multi-step thought process. The function should iterate through the array and update the minimum value found so far. The code should start with:
```python
from typing import List
def find_minimum(arr: List[int]) -> int:
```... | Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def find_minimum(arr: List[int]) -> int:
"""
Find the minimal numerical value within an array of integers.
Args:
arr (List[int]): The array of integers from which to find the minimum value... |
evol_instruct_66k | 22,631 | Write a Python function to find the maximum value in a given list of integers. The function should efficiently determine the highest numerical value within the provided sequence. The code should start with:
```python
from typing import List
def find_max_value(arr: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_max_value(arr: List[int]) -> int:
"""
Find the maximum value in a given list of integers.
Args:
arr (List[int]): The list of integers from which to find the maximum value.
Retu... |
evol_instruct_66k | 22,638 | Write a Python function to perform element-wise multiplication between two lists of integers or floats and return a new list containing the results. The function should handle lists of different lengths by truncating the longer list to the length of the shorter list. 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, Union
def element_wise_multiplication(list1: List[Union[int, float]], list2: List[Union[int, float]]) -> List[Union[int, float]]:
"""
Perform element-wise multiplication between two lists of integers or... |
evol_instruct_66k | 22,643 | Write a Python function to split a given string by a specified delimiter, with an optional maximum number of splits. If the `max_splits` argument is provided, the function should perform no more than `max_splits` splits. If `max_splits` is not provided, the function should perform as many splits as possible. The functi... | Here is the Python code to solve the given problem in the markdown block:
```python
def split_string(s: str, delimiter: str, max_splits: int = None) -> list:
"""
Splits a given string by a specified delimiter, with an optional maximum number of splits.
Args:
s (str): The string to be split.
... |
evol_instruct_66k | 22,653 | Write a Python function to generate a unique alphanumeric user ID from the given first name, last name, and date of birth using a custom hashing algorithm. The generated user ID should be case-insensitive and exactly 10 characters long. The function should start with:
```python
def generate_user_id(first_name: str, las... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_user_id(first_name: str, last_name: str, dob: str) -> str:
"""
Generates a unique alphanumeric user ID from the given first name, last name, and date of birth.
Args:
first_name (str): The first name of ... |
evol_instruct_66k | 22,658 | Write a Python function to validate and print a greeting message based on the day of the week provided by the user. The function should ensure that the input is a valid day of the week before printing the greeting message. The code should start with:
```python
def greet_day(day: str) -> None:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def greet_day(day: str) -> None:
"""
Validates the input day and prints a greeting message if the day is a valid weekday.
Args:
day (str): The day of the week to validate and greet.
Returns:
None: This ... |
evol_instruct_66k | 22,660 | Write a Python function to retrieve all research papers from a given dataset where the year of publication is between 1980 and 1990 and the listed co-author is "Jane Smith". The dataset is represented as two lists of dictionaries: one for papers and one for co-authors. Each dictionary in the papers list contains keys `... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def get_papers_by_jane_smith(papers: List[Dict[str, any]], co_authors: List[Dict[str, any]]) -> List[Dict[str, any]]:
"""
Retrieve all research papers from the dataset where the year of publication... |
evol_instruct_66k | 22,661 | Write a Python function to check if a given integer value is divisible by 3 and 5 both, as well as divisible by 7, without using the modulus operator. The function should return a boolean value indicating whether the number meets all three conditions.
The code should start with:
```python
def is_divisible_by_3_5_7(val... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_divisible_by_3_5_7(value: int) -> bool:
"""
Check if a given integer value is divisible by 3, 5, and 7 without using the modulus operator.
Args:
value (int): The integer value to check for divisibility.
... |
evol_instruct_66k | 22,675 | Write a Python function to remove trailing spaces and newline characters from a given string while preserving any special characters or digits that may appear in the string. The function should handle various edge cases, such as strings with no trailing spaces or newlines, strings with only spaces and newlines, and str... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_trailing_spaces_newlines(string: str) -> str:
"""
Removes trailing spaces and newline characters from the given string.
Args:
string (str): The input string from which to remove trailing spaces and newlin... |
evol_instruct_66k | 22,677 | Write a Python function to find the digit with the highest frequency in a given range of integers. If multiple digits have the same frequency, return the smallest digit. The function should accept a list of integers and return the digit as an integer.
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 find_most_frequent_digit(numbers: List[int]) -> int:
"""
Find the digit with the highest frequency in a given list of integers.
If multiple digits have the same frequency, return the smallest dig... |
evol_instruct_66k | 22,691 | Write a Python function to process a nested list of strings by removing duplicate elements within each inner list and then sorting each inner list in ascending lexicographical order. The function should return the processed nested list.
The code should start with:
```python
from typing import List
def process_nested_... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_nested_list(nested_list: List[List[str]]) -> List[List[str]]:
"""
Processes a nested list of strings by removing duplicate elements within each inner list
and then sorting each inner list... |
evol_instruct_66k | 22,696 | Write a Python function to calculate the total number of rows in a given DataFrame. The function should handle any DataFrame, regardless of its structure or the number of columns it contains. The code should start with:
```python
import pandas as pd
def count_rows(df: pd.DataFrame) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import pandas as pd
def count_rows(df: pd.DataFrame) -> int:
"""
Calculate the total number of rows in a given DataFrame.
Args:
df (pd.DataFrame): The DataFrame for which to count the rows.
Returns:
in... |
evol_instruct_66k | 22,700 | Write a Python function to validate if a given string is a valid Semantic Versioning (SemVer) number according to the Semantic Versioning specification. The function should return `True` if the string is a valid SemVer, and `False` otherwise. The SemVer format is defined as `major.minor.patch`, where `major`, `minor`, ... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def is_valid_semver(version: str) -> bool:
"""
Validate if a given string is a valid Semantic Versioning (SemVer) number.
Args:
version (str): The string to be validated.
Returns:
bool: True ... |
evol_instruct_66k | 22,708 | Write a Python function to filter out all integers from a given list that are exact multiples of a specified integer `k`. The function should return a new list containing only the integers that are not multiples of `k`.
The code should start with:
```python
from typing import List
def filter_multiples(lst: List[int],... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_multiples(lst: List[int], k: int) -> List[int]:
"""
Filters out all integers from the given list that are exact multiples of the specified integer `k`.
Args:
lst (List[int]): The ... |
evol_instruct_66k | 22,709 | Write a Python function to print each element of a given list of strings, one element per line, using a different method than the ones shown in the provided code snippet. The function should accept a list of strings as its parameter and print each string in the list.
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 print_each_element(elements: List[str]) -> None:
"""
Prints each element of the given list of strings, one element per line.
Args:
elements (List[str]): The list of strings to be printed... |
evol_instruct_66k | 22,721 | Write a Python function to generate all possible permutations of pairs from two given lists of integers. Each pair should consist of one element from the first list and one element from the second list. The function should return a list of tuples, where each tuple represents a permutation.
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
import itertools
def generate_permutations(list1: List[int], list2: List[int]) -> List[Tuple[int, int]]:
"""
Generate all possible permutations of pairs from two given lists of integers.
Args... |
evol_instruct_66k | 22,727 | Write a Python function to generate a random HTTP response status code and its corresponding reason phrase from a predefined dictionary of HTTP status codes and reason phrases. The function should return a tuple containing the status code and the reason phrase.
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 Tuple
import random
def get_random_http_status() -> Tuple[int, str]:
"""
Generate a random HTTP response status code and its corresponding reason phrase.
Returns:
Tuple[int, str]: A tuple contain... |
evol_instruct_66k | 22,734 | Write a Python function to merge two given dictionaries into a single dictionary. If there are common keys between the two dictionaries, the values for those keys should be added together to form the new value in the merged dictionary. The function should handle dictionaries with integer values.
The code should start ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def merge_dictionaries(dict1: Dict[str, int], dict2: Dict[str, int]) -> Dict[str, int]:
"""
Merges two dictionaries into a single dictionary. If there are common keys, the values are added together.
... |
evol_instruct_66k | 22,749 | Write a Python function to sort an array of strings alphabetically without using the built-in `sort` function. Additionally, the sorting should be case-insensitive. The function should start with:
```python
from typing import List
def custom_sort_strings(array: List[str]) -> List[str]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def custom_sort_strings(array: List[str]) -> List[str]:
"""
Sorts an array of strings alphabetically without using the built-in sort function.
The sorting is case-insensitive.
Args:
arra... |
evol_instruct_66k | 22,758 | Write a Python function to find the sum of two numbers provided as arguments to the function. Additionally, validate the input to ensure they are whole numbers and return the sum. If the input is invalid, return `None`.
The code should start with:
```python
def sum_of_two_numbers(num1: str, num2: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def sum_of_two_numbers(num1: str, num2: str) -> int:
"""
Calculate the sum of two whole numbers provided as strings.
Args:
num1 (str): The first number as a string.
num2 (str): The second number a... |
evol_instruct_66k | 22,761 | Write a Python function to replace a `for` loop with a `while` loop and include error handling for scenarios where the loop limit is not certain or may include non-integer values. The function should take a limit as input and print the values from 0 to the limit (exclusive). If the limit is a non-integer value, the fun... | Here is the Python code to solve the given problem in the markdown block:
```python
def print_numbers_with_while_loop(limit):
"""
Prints numbers from 0 to the given limit (exclusive) using a while loop.
If the limit is a non-integer value, it prints an error message.
Args:
limit (int): The uppe... |
evol_instruct_66k | 22,785 | Write a Python function to perform a nested loop operation and handle potential exceptions that might arise during the execution. The function should iterate over a range of values for `j` and within each iteration, perform a nested while loop operation for `i`. The operations within the loops should include a division... | Here is the Python code to solve the given problem in the markdown block:
```python
def nested_loop_with_error_handling():
"""
Perform a nested loop operation and handle potential exceptions.
The function iterates over a range of values for `j` and within each iteration,
performs a nested while loop op... |
evol_instruct_66k | 22,786 | Write a Python function to calculate the mean value of a collection of whole numbers within the integer domain. The function should handle collections with zero elements by returning 0. The code should start with:
```python
from typing import List
def calculate_mean(numbers: List[int]) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def calculate_mean(numbers: List[int]) -> float:
"""
Calculate the mean value of a collection of whole numbers.
Args:
numbers (List[int]): A list of integers for which the mean is to be ca... |
evol_instruct_66k | 22,787 | Write a Python function to remove the last element from a given list and return the removed element. The original list should not be modified. The function should create a new list without the last element and return both the new list and the removed element.
The code should start with:
```python
from typing import Li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def remove_last_element(arr: List[int]) -> Tuple[List[int], int]:
"""
Removes the last element from the given list and returns the new list without the last element and the removed element.
A... |
evol_instruct_66k | 22,790 | Write a Python function to generate a matrix of given dimensions with random floating-point numbers between 0 and 1. The function should allow specifying the number of rows and columns for the matrix. The random numbers should be generated using a uniform distribution.
The code should start with:
```python
from typing... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import numpy as np
def generate_random_matrix(rows: int, cols: int) -> List[List[float]]:
"""
Generates a matrix of the specified dimensions with random floating-point numbers between 0 and 1.
Args:... |
evol_instruct_66k | 22,795 | Write a Python generator function that yields the first ten numbers that are quintic (i.e., numbers that can be expressed as \( n^5 \) for some integer \( n \)). The generator should start from \( n = 1 \) and continue until it has yielded ten quintic numbers.
The code should start with:
```python
def generate_quintic... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_quintics():
"""
A generator function that yields the first ten numbers that are quintic (fifth power).
Yields:
int: The next quintic number in the sequence.
"""
count = 0 # Counter to keep trac... |
evol_instruct_66k | 22,804 | Write a Python function to generate a table that enumerates the first ten non-negative integers along with their cubes and fourth powers. The function should return a list of tuples, where each tuple contains an integer, its cube, and its fourth power. Additionally, write a function to compare the growth rates of cubes... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def generate_exponent_table(n: int) -> List[Tuple[int, int, int]]:
"""
Generates a table of the first n non-negative integers along with their cubes and fourth powers.
Args:
n (int): ... |
evol_instruct_66k | 22,818 | Write a Python function to perform a binary search on a sorted array to find the index of a target element. If the target element is not found, return -1. The function should be efficient and handle edge cases such as an empty array or a target that is not present in the array.
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 binary_search(array: List[int], target: int) -> int:
"""
Perform a binary search on a sorted array to find the index of a target element.
Args:
array (List[int]): A sorted list of intege... |
evol_instruct_66k | 22,832 | Write a Python function to retrieve the element located at the nth position in a one-dimensional numpy numeric series. The function should handle the case where the position is out of bounds by returning `None`. The code should start with:
```python
import numpy as np
from typing import Optional
def get_nth_element(se... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
from typing import Optional
def get_nth_element(series: np.ndarray, n: int) -> Optional[int]:
"""
Retrieve the element located at the nth position in a one-dimensional numpy numeric series.
Args:
... |
evol_instruct_66k | 22,836 | Write a Python function to perform a binary search on a sequence that is not strictly ascending but is generally increasing (i.e., it can have equal values next to each other). The function should find the first occurrence of a target value in the sequence.
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 find_first_occurrence(sequence: List[int], target: int) -> int:
"""
Find the first occurrence of a target value in a generally increasing sequence using binary search.
Args:
sequence (Li... |
evol_instruct_66k | 22,842 | Write a Python function to rearrange a given list in descending order without duplicates and return a tuple containing the rearranged list and a dictionary with each number's frequency in the original list.
The code should start with:
```python
from typing import List, Dict, Tuple
from collections import Counter
def r... | Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List, Dict, Tuple
from collections import Counter
def rearrange_and_count_frequencies(lst: List[int]) -> Tuple[List[int], Dict[int, int]]:
"""
Rearranges the given list in descending order without duplicate... |
evol_instruct_66k | 22,849 | Write a Python function to generate a narrative that maps common fruit names to their Linnaean (scientific) names using a predefined dictionary. The function should accept a list of fruit names and return a formatted string that lists each fruit name followed by its corresponding Linnaean name.
The code should start w... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def generate_linnaean_narrative(fruit_list: List[str], fruit_dict: Dict[str, str]) -> str:
"""
Generates a narrative that maps common fruit names to their Linnaean (scientific) names.
Args:
... |
evol_instruct_66k | 22,860 | Write a Python function to calculate a hash value for each row in a 2D array and return a new 2D array that includes the hash value along with the original row values. The hash value should be calculated using Python's built-in `hash` function applied to a tuple of the row elements. The function should handle 2D arrays... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_hash_for_rows(arr: List[List[int]]) -> List[List[int]]:
"""
Calculate a hash value for each row in a 2D array and return a new 2D array
that includes the hash value along with the origi... |
evol_instruct_66k | 22,861 | Write a Python function to generate a nested list representing Pascal's Triangle up to `n` rows. Each row in Pascal's Triangle is constructed such that each number is the sum of the two numbers directly above it in the previous row. The first and last elements of each row are always 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 generate_pascals_triangle(n: int) -> List[List[int]]:
"""
Generate a nested list representing Pascal's Triangle up to n rows.
Args:
n (int): The number of rows to generate in Pascal's Tr... |
evol_instruct_66k | 22,865 | Write a Python function to count the frequency of each character in a given string. The function should return a dictionary where the keys are characters and the values are the counts of those characters in the string. The function should be case-sensitive, meaning 'A' and 'a' should be considered different characters.... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def count_character_frequencies(string: str) -> Dict[str, int]:
"""
Counts the frequency of each character in the given string.
Args:
string (str): The input string to count character freque... |
evol_instruct_66k | 22,866 | Write a Python function to remove all occurrences of a specified integer from a given list of numerical data. The function should return the modified list. The code should start with:
```python
from typing import List
def remove_all_occurrences(input_list: List[int], target: int) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def remove_all_occurrences(input_list: List[int], target: int) -> List[int]:
"""
Removes all occurrences of the specified integer from the given list.
Args:
input_list (List[int]): The lis... |
evol_instruct_66k | 22,874 | Write a Python function to create an n x n matrix filled with random real numbers in the range of 0.0 to 1.0, except for the diagonal elements which should be a sequence of `((1/n) * i)` where `i` ranges from 0 to n-1. The numbers should be truncated to three decimal places. The function should start with:
```python
fr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def create_random_matrix(n: int) -> List[List[float]]:
"""
Creates an n x n matrix filled with random real numbers in the range of 0.0 to 1.0,
except for the diagonal elements which are... |
evol_instruct_66k | 22,886 | Write a Python function to identify and return the vowels present in a given string. The function should return a list of vowels found in the string, in the order they appear. The function should be case-insensitive, meaning both uppercase and lowercase vowels should be considered.
The code should start with:
```pytho... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_vowels(s: str) -> List[str]:
"""
Identifies and returns the vowels present in a given string.
Args:
s (str): The input string to search for vowels.
Returns:
List[str]: ... |
evol_instruct_66k | 22,904 | Write a Python function to find all the indices of a specified element in a given list. The function should return a list of indices where the element is found. If the element is not found in the list, the function should return an empty list.
The code should start with:
```python
from typing import List
def find_all... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_all_indices(lst: List[str], element: str) -> List[int]:
"""
Find all indices of a specified element in a given list.
Args:
lst (List[str]): The list in which to search for the eleme... |
evol_instruct_66k | 22,911 | Write a Python function to generate the Fibonacci sequence up to the nth term. The function should return a list containing the first n terms of the Fibonacci sequence. The Fibonacci sequence is defined as follows: the first two terms are 0 and 1, and each subsequent term is the sum of the previous two terms.
The code... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_fibonacci_sequence(n: int) -> List[int]:
"""
Generate the Fibonacci sequence up to the nth term.
Args:
n (int): The number of terms to generate.
Returns:
List[int]:... |
evol_instruct_66k | 22,928 | Write a Python function to reverse a given string using a custom iterative approach. The function should not use Python's built-in slicing (`[::-1]`) or the `reversed()` function. Instead, it should use a loop to manually reverse the string.
The code should start with:
```python
def reverse_string_iterative(s: str) ->... | Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_string_iterative(s: str) -> str:
"""
Reverses a given string using a custom iterative approach.
Args:
s (str): The input string to be reversed.
Returns:
str: The reversed string.
"""
... |
evol_instruct_66k | 22,931 | Write a Python function to determine the number of days in a given month and year, considering leap years for February. The function should accept two parameters: the year (an integer) and the month (an integer from 1 to 12). The function should return the number of days in that month.
The code should start with:
```p... | Here is the Python code to solve the given problem in the markdown block:
```python
def days_in_month(year: int, month: int) -> int:
"""
Determine the number of days in a given month and year, considering leap years for February.
Args:
year (int): The year for which to determine the number of days.... |
evol_instruct_66k | 22,937 | Write a Python function to extract the top `n` most frequent words from a given text, ignoring case and special characters. The function should return a list of tuples where each tuple contains a word and its frequency.
The code should start with:
```python
from typing import List, Tuple
import re
from collections imp... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import re
from collections import Counter
def get_top_n_frequent_words(text: str, n: int) -> List[Tuple[str, int]]:
"""
Extracts the top n most frequent words from a given text, ignoring case and ... |
evol_instruct_66k | 22,952 | Write a Python function to determine whether a given target number exists in a sorted array. The function should use a binary search algorithm to achieve this efficiently. The code should start with:
```python
from typing import List
def contains_target(arr: List[int], target: int) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def contains_target(arr: List[int], target: int) -> bool:
"""
Determines whether a given target number exists in a sorted array using binary search.
Args:
arr (List[int]): A sorted list of... |
evol_instruct_66k | 22,960 | Write a Python function to generate a dictionary containing all possible combinations of two words from a given list. Each key in the dictionary should be a string formed by concatenating the two words with an underscore (`_`), and the value should be a tuple containing the two words.
The code should start with:
```py... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
import itertools
def generate_word_combinations(words: List[str]) -> Dict[str, tuple]:
"""
Generate a dictionary containing all possible combinations of two words from a given list.
Args:
... |
evol_instruct_66k | 22,969 | Write a Python function to recursively compute the square of each element in a given 2D array. The function should handle nested lists of arbitrary depth and return a new array with the same structure, where each element is replaced by its square.
The code should start with:
```python
from typing import List, Union
d... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def squares_of_array(arr: Union[List[Union[int, List]], int]) -> Union[List[Union[int, List]], int]:
"""
Recursively computes the square of each element in a given 2D array.
Args:
arr... |
evol_instruct_66k | 22,983 | Write a Python function to determine if all elements in a given list are even numbers. The function should return `True` if all elements are even, and `False` otherwise. The code should start with:
```python
from typing import List
def all_elements_even(arr: List[int]) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def all_elements_even(arr: List[int]) -> bool:
"""
Determine if all elements in the given list are even numbers.
Args:
arr (List[int]): The list of integers to check.
Returns:
b... |
evol_instruct_66k | 22,991 | Write a Python function to calculate the mean of a given sequence of numbers efficiently. The function should handle both lists and NumPy arrays. The code should start with:
```python
from typing import Union
import numpy as np
def calculate_mean(sequence: Union[list, np.ndarray]) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import Union
import numpy as np
def calculate_mean(sequence: Union[list, np.ndarray]) -> float:
"""
Calculate the mean of a given sequence of numbers.
Args:
sequence (Union[list, np.ndarray]): The seq... |
evol_instruct_66k | 22,999 | Write a Python function to generate a unique random number between 0 and 10 each time the function is called. Numbers should not be repeated until all possible numbers (0 through 10) have been generated. The function should maintain the state of generated numbers across multiple calls.
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
import random
# Global set to keep track of available numbers
available_numbers = set(range(11))
def generate_unique_random_number() -> int:
"""
Generates a unique random number between 0 and 10 each ti... |
evol_instruct_66k | 23,011 | Write a Python function to reverse a given list, remove its duplicates, and then rearrange the resulting list in ascending order. The function should take a list of integers as input and return the processed list. The code should start with:
```python
from typing import List
def process_list(lst: List[int]) -> List[in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_list(lst: List[int]) -> List[int]:
"""
Reverses the given list, removes its duplicates, and then rearranges it in ascending order.
Args:
lst (List[int]): The list of integers to ... |
evol_instruct_66k | 23,019 | Write a Python function to calculate the cumulative total of an arbitrary number of integer values. The function should accept a variable number of arguments and return the sum of these integers. The code should start with:
```python
from typing import List
def cumulative_total(*args: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def cumulative_total(*args: int) -> int:
"""
Calculate the cumulative total of an arbitrary number of integer values.
Args:
*args (int): Variable number of integer arguments.
Returns:
... |
evol_instruct_66k | 23,027 | Write a Python function to iterate through a given list and return a new list containing every other element from the original list, starting from the first element. The function should handle lists of any length and type of elements.
The code should start with:
```python
from typing import List, Any
def get_every_ot... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
def get_every_other_element(lst: List[Any]) -> List[Any]:
"""
Returns a new list containing every other element from the given list, starting from the first element.
Args:
lst (List[Any... |
evol_instruct_66k | 23,035 | Write a Python function to count the number of vowel characters in a given string. The function should be case-insensitive and should consider both uppercase and lowercase vowels.
The code should start with:
```python
def count_vowels(sentence: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def count_vowels(sentence: str) -> int:
"""
Count the number of vowel characters in a given string.
Args:
sentence (str): The input string to count vowels in.
Returns:
int: The number of vowel character... |
evol_instruct_66k | 23,037 | 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 string.
Args:
input_string (str): The string to be reversed.
Returns:
str: The reversed string.
"""
# Use slicing to revers... |
evol_instruct_66k | 23,044 | Write a Python function to count the frequency of occurrence of each unique character in a given string. The function should return a dictionary where the keys are the characters and the values are their respective frequencies.
The code should start with:
```python
from typing import Dict
def count_character_frequenc... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def count_character_frequencies(s: str) -> Dict[str, int]:
"""
Counts the frequency of occurrence of each unique character in the given string.
Args:
s (str): The input string to analyze.
... |
evol_instruct_66k | 23,046 | Write a Python function to find the intersection of two arrays, ensuring the result is sorted regardless of the input arrays' order. The function should be optimized for efficiency, even for larger array sizes.
The code should start with:
```python
from typing import List
def sorted_intersection(arr1: List[int], arr2... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sorted_intersection(arr1: List[int], arr2: List[int]) -> List[int]:
"""
Finds the intersection of two arrays and returns the result in sorted order.
Args:
arr1 (List[int]): The first arr... |
evol_instruct_66k | 23,060 | Write a Python function to determine if there is any common element between two given lists of integers. The function should return `True` if there is at least one common element, and `False` otherwise. The code should start with:
```python
from typing import List
def has_common_element(vector1: List[int], vector2: Li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def has_common_element(vector1: List[int], vector2: List[int]) -> bool:
"""
Determines if there is any common element between two given lists of integers.
Args:
vector1 (List[int]): The firs... |
evol_instruct_66k | 23,063 | Write a Python function to remove recurring elements from a given numerical array while preserving the order of first occurrences. The function should not use sets or built-in functions like `set()` or `dict.fromkeys()`. The function should start with:
```python
from typing import List
def remove_duplicates_preserve_o... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_duplicates_preserve_order(input_list: List[int]) -> List[int]:
"""
Removes recurring elements from a numerical array while preserving the order of first occurrences.
Args:
input_l... |
evol_instruct_66k | 23,075 | Write a Python function to find the largest number in a given list and return both the largest number and its index. The function should handle potential bugs in the provided code snippet and ensure correct implementation.
The code should start with:
```python
from typing import List, Tuple
def find_largest_and_index... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Optional
def find_largest_and_index(numbers: List[int]) -> Optional[Tuple[int, int]]:
"""
Finds the largest number in the given list and returns both the number and its index.
Args:
... |
evol_instruct_66k | 23,081 | Write a Python function to evaluate a mathematical expression given as a string, taking into account operator precedence and handling parentheses. The function should not use Python's `eval()` function. The code should start with:
```python
from typing import Union
def evaluate_expression(expression: str) -> Union[int... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Union
import re
import operator
def evaluate_expression(expression: str) -> Union[int, float]:
"""
Evaluate a mathematical expression given as a string, taking into account operator precedence and handling pa... |
evol_instruct_66k | 23,082 | Write a Python function to print a message a specified number of times, but only display the message during even-numbered iterations. The function should take two parameters: the message to be printed and the total number of iterations. The function should start with:
```python
def print_message_on_even_iterations(mess... | Here is the Python code to solve the given problem in the markdown block:
:
```python
def print_message_on_even_iterations(message: str, iterations: int) -> None:
"""
Prints the given message during even-numbered iterations up to the specified number of iterations.
Args:
message (str): The message ... |
evol_instruct_66k | 23,090 | Write a Python function to perform a bitwise operation between two integers and return the result. The function should accept two integers as input and a string representing the bitwise operation to be performed. The valid operations are "AND", "OR", "XOR", "LEFT_SHIFT", and "RIGHT_SHIFT". The function should return th... | Here is the Python code to solve the given problem in the markdown block:
```python
def bitwise_operation(a: int, b: int, operation: str) -> int:
"""
Perform a bitwise operation between two integers based on the given operation string.
Args:
a (int): The first integer.
b (int): The second i... |
evol_instruct_66k | 23,098 | Write a Python function to compute the value of Euler's number (e) using an infinite series approximation up to a specified precision. The function should take an integer `precision` as input, which indicates the number of terms to consider in the series. The series for Euler's number is given by:
\[ e = 1 + \frac{1}{... | Here is the Python code to solve the given problem in the markdown block:
```python
def compute_eulers_number(precision: int) -> float:
"""
Compute the value of Euler's number (e) using an infinite series approximation up to a specified precision.
The series for Euler's number is:
e = 1 + 1/1! + 1/2! +... |
evol_instruct_66k | 23,102 | Write a Python function to reverse a given string using a stack data structure. The function should take a string as input and return the reversed string. The stack should be implemented using a list, and the reversal should be achieved by pushing each character of the string onto the stack and then popping each charac... | Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_string_with_stack(s: str) -> str:
"""
Reverses a given string using a stack data structure.
Args:
s (str): The input string to be reversed.
Returns:
str: The reversed string.
"""
# I... |
evol_instruct_66k | 23,131 | Write a Python function to perform a ternary search on a sorted array to find the index of a given element. If the element is not found, return -1. The function should be efficient and should handle edge cases such as an empty array or an element not present in the array.
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
def ternary_search(arr: List[int], to_find: int) -> int:
"""
Perform a ternary search on a sorted array to find the index of a given element.
Args:
arr (List[int]): A sorted list of integers... |
evol_instruct_66k | 23,132 | Write a Python function to implement the quicksort algorithm efficiently. The function should sort a list of integers in ascending order. The code should start with:
```python
from typing import List
def quicksort(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 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 | 23,145 | Write a Python function to traverse a given bidimensional matrix (a two-dimensional array) and return a list of all elements in the matrix in a specific order. The order should be such that it first traverses the first row from left to right, then the second row from right to left, then the third row from left to right... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def traverse_matrix_alternating(matrix: List[List[str]]) -> List[str]:
"""
Traverse a bidimensional matrix in an alternating left-to-right and right-to-left order.
Args:
matrix (List[List[st... |
evol_instruct_66k | 23,159 | Write a Python function to introduce an element of entropy to a specified array, causing its elements to be arranged in a seemingly unpredictable and non-linear order. The function should take a list of numbers as input and return a new list with the elements shuffled. The original list should remain unchanged.
The co... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def shuffle_array(arr: List[float]) -> List[float]:
"""
Shuffles the elements of the input array in a seemingly unpredictable and non-linear order.
Args:
arr (List[float]): The... |
evol_instruct_66k | 23,177 | Write a Python function to reverse a given string without using any looping mechanisms. The function should utilize slicing to achieve the reversal. 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 string using slicing.
Args:
input_string (str): The string to be reversed.
Returns:
str: The reversed string.
"""
# Use slici... |
evol_instruct_66k | 23,178 | Write a Python function to calculate the sum of the digits of a given integer. The function should handle both positive and negative integers. The code should start with:
```python
def sum_of_digits(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_digits(n: int) -> int:
"""
Calculate the sum of the digits of a given integer.
Args:
n (int): The integer whose digits are to be summed.
Returns:
int: The sum of the digits of the integer.
... |
evol_instruct_66k | 23,179 | Write a Python function to compute the sum of the first `n` natural numbers efficiently, ensuring optimal performance for large inputs (up to `n < 10^7`). The function should minimize computation time and memory usage.
The code should start with:
```python
def sum_of_first_n(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_first_n(n: int) -> int:
"""
Computes the sum of the first n natural numbers efficiently.
Args:
n (int): The number of natural numbers to sum.
Returns:
int: The sum of the first n natural numb... |
evol_instruct_66k | 23,197 | Write a Python function to create a 3-dimensional tensor (3 x 3 x 3) filled with integers starting from 1 and ending at 27. The integers should be arranged such that they increase sequentially along the last axis (depth) first, then the second axis (rows), and finally the first axis (columns). The function should retur... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def create_cubic_tensor() -> np.ndarray:
"""
Creates a 3-dimensional tensor (3 x 3 x 3) filled with integers from 1 to 27.
Returns:
np.ndarray: A 3 x 3 x 3 tensor with integers from 1 to 27.
... |
evol_instruct_66k | 23,208 | Write a Python function to reverse a given string of ASCII characters and maintain a frequency count of each character. The frequency count should not differentiate between upper and lower-case characters. The function should return a tuple containing the reversed string and a dictionary with the frequency count of eac... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Tuple
def reverse_string_and_count_frequency(input_string: str) -> Tuple[str, Dict[str, int]]:
"""
Reverses the given string of ASCII characters and counts the frequency of each character.
The frequ... |
evol_instruct_66k | 23,217 | Write a Python function to calculate the sum and product of the digits of a given integer. The function should handle both positive and negative integers. The code should start with:
```python
def additive_multiplicative(num: int) -> tuple:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def additive_multiplicative(num: int) -> tuple:
"""
Calculate the sum and product of the digits of a given integer.
Args:
num (int): The integer whose digits' sum and product are to be calculated.
Returns:
... |
evol_instruct_66k | 23,222 | Write a Python function to extract the specific weekday from an inputted date and timestamp. The function should accept a `datetime` object as input and return the name of the weekday as a string.
The code should start with:
```python
from datetime import datetime
def get_weekday(date: datetime) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime
def get_weekday(date: datetime) -> str:
"""
Extracts the name of the weekday from a given datetime object.
Args:
date (datetime): The datetime object from which to extract the weekday.... |
evol_instruct_66k | 23,229 | Write a Python function to find the least frequent word in a given text and return both the word and its frequency. The function should be case-insensitive and should ignore punctuation. The code should start with:
```python
from typing import Tuple
def find_least_frequent_word(text: str) -> Tuple[str, int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
import re
from collections import Counter
def find_least_frequent_word(text: str) -> Tuple[str, int]:
"""
Finds the least frequent word in a given text and returns the word along with its frequency.
... |
evol_instruct_66k | 23,232 | Write a Python function to reverse a given byte array without using any pre-existing reverse string or array functions. The function should take a byte array as input and return a new byte array that is the reverse of the input.
The code should start with:
```python
from typing import ByteString
def reverse_byte_arra... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import ByteString
def reverse_byte_array(byte_array: ByteString) -> bytearray:
"""
Reverses the given byte array without using any pre-existing reverse functions.
Args:
byte_array (ByteString): The byte... |
evol_instruct_66k | 23,239 | Write a Python function to create an array of a specified length composed of unique entities, and then return the trailing half of the array. The function should handle cases where the length of the array is odd or even.
The code should start with:
```python
from typing import List, Any
def get_trailing_half(length: ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
def get_trailing_half(length: int) -> List[Any]:
"""
Creates an array of a specified length with unique entities and returns the trailing half of the array.
Args:
length (int): The leng... |
evol_instruct_66k | 23,254 | Write a Python function to generate a matrix of integers with exactly two rows and four columns. The function should allow customization of the starting integer and the step size between consecutive integers in each row. The matrix should be returned as a list of lists.
The code should start with:
```python
from typin... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_matrix(start: int, step: int) -> List[List[int]]:
"""
Generates a matrix of integers with exactly two rows and four columns.
Args:
start (int): The starting integer for the firs... |
evol_instruct_66k | 23,267 | Write a Python function to find the top 5 most frequent characters in a given string. The function should return a list of tuples, where each tuple contains a character and its frequency in descending order of frequency. If there are fewer than 5 unique characters, the function should return as many as are available.
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
from collections import Counter
def top_5_frequent_characters(s: str) -> List[Tuple[str, int]]:
"""
Find the top 5 most frequent characters in a given string.
Args:
s (str): The input... |
evol_instruct_66k | 23,269 | Write a Python function to remove all vowels from a given alphanumeric sequence. The function should handle both uppercase and lowercase vowels. The code should start with:
```python
def remove_vowels(sequence: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def remove_vowels(sequence: str) -> str:
"""
Removes all vowels from the given alphanumeric sequence.
Args:
sequence (str): The alphanumeric sequence from which vowels are to be removed.
Returns:
str:... |
evol_instruct_66k | 23,287 | Write a Python function to determine if at least one element from the second vector is present in the first vector. The function should return `True` if there is at least one common element, otherwise it should return `False`. The code should start with:
```python
from typing import List
def has_common_element(vector1... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def has_common_element(vector1: List[int], vector2: List[int]) -> bool:
"""
Determines if there is at least one common element between two vectors.
Args:
vector1 (List[int]): The first vecto... |
evol_instruct_66k | 23,295 | Write a Python function to sort a given list of integers in ascending order. The function should return the sorted list. The code should start with:
```python
from typing import List
def sort_list(lst: 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_list(lst: List[int]) -> List[int]:
"""
Sorts a given list of integers in ascending order.
Args:
lst (List[int]): The list of integers to be sorted.
Returns:
List[int]... |
evol_instruct_66k | 23,310 | Write a Python function to find the most frequent item in a list of arbitrary strings. If there are multiple items with the same highest frequency, return any one of them. The function should be efficient and handle lists of varying sizes.
The code should start with:
```python
from typing import List
def most_frequen... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
from collections import Counter
def most_frequent_item(lst: List[str]) -> str:
"""
Find the most frequent item in a list of strings.
Args:
lst (List[str]): A list of strings from which to fi... |
evol_instruct_66k | 23,322 | Write a Python function to find the most significant (largest) integer in a given list of integers. The function should be able to handle lists of any size, including empty lists. If the list is empty, the function should return `None`. The code should start with:
```python
from typing import List, Optional
def find_m... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def find_max_value(arr: List[int]) -> Optional[int]:
"""
Find the most significant (largest) integer in a given list of integers.
Args:
arr (List[int]): The list of integers from w... |
evol_instruct_66k | 23,323 | Write a Python function to compute the union of two sets and return the result. The function should handle sets of any size and ensure that the union operation is performed efficiently. The code should start with:
```python
from typing import Set
def compute_set_union(set1: Set[int], set2: Set[int]) -> Set[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Set
def compute_set_union(set1: Set[int], set2: Set[int]) -> Set[int]:
"""
Computes the union of two sets and returns the result.
Args:
set1 (Set[int]): The first set of integers.
set2 (S... |
evol_instruct_66k | 23,324 | Write a Python function to determine if a given string is a valid IPv4 address. An IPv4 address is a string that consists of four decimal numbers, each ranging from 0 to 255, separated by dots. The function should handle edge cases such as leading zeros, empty strings, and invalid characters.
The code should start wit... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_valid_ipv4(ip: str) -> bool:
"""
Determines if the given string is a valid IPv4 address.
Args:
ip (str): The string to be checked for IPv4 validity.
Returns:
bool: True if the string is a valid I... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.