source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
evol_instruct_66k | 36,252 | Write a Python function to remove consecutive duplicate characters from a given string. The function should iterate through the string and construct a new string that contains only the first occurrence of each consecutive duplicate character. The code should start with:
```python
def remove_consecutive_duplicates(input... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_consecutive_duplicates(input_string: str) -> str:
"""
Removes consecutive duplicate characters from the given string.
Args:
input_string (str): The input string from which consecutive duplicates are to be... |
evol_instruct_66k | 36,256 | Write a Python function to compare the magnitudes of two variables `x` and `y`. If `x` is greater than `y`, the function should return the string `"x is greater than y"`. Otherwise, it should return the string `"x is not greater than y"`. The function should handle any numeric inputs for `x` and `y`.
The code should s... | Here is the Python code to solve the given problem in the markdown block:
```python
def compare_magnitudes(x: float, y: float) -> str:
"""
Compares the magnitudes of two variables x and y.
Args:
x (float): The first variable to compare.
y (float): The second variable to compare.
Return... |
evol_instruct_66k | 36,261 | Write a Python function to determine if two given phrases contain the same set of unique words. The function should ignore the order of words and any duplicate words within each phrase.
The code should start with:
```python
def compare_word_sets(phrase1: str, phrase2: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def compare_word_sets(phrase1: str, phrase2: str) -> bool:
"""
Determines if two given phrases contain the same set of unique words.
Args:
phrase1 (str): The first phrase to compare.
phrase2 (str): The secon... |
evol_instruct_66k | 36,266 | Write a Python function to remove duplicates from a given sorted array while maintaining the order of the elements. The function should take a list of integers as input and return a new list with all duplicates removed. The original list should not be modified.
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 List
def remove_duplicates_from_sorted_array(arr: List[int]) -> List[int]:
"""
Removes duplicates from a given sorted array while maintaining the order of the elements.
Args:
arr (List[int]): The... |
evol_instruct_66k | 36,281 | Write a Python function to create and populate a fixed-size array with a specified capacity, and then populate it with integers in ascending order starting from a given start value up to a given end value. The function should return the populated array.
The code should start with:
```python
from typing import List
de... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def create_and_populate_array(capacity: int, start: int, end: int) -> List[int]:
"""
Creates and populates a fixed-size array with integers in ascending order.
Args:
capacity (int): The capa... |
evol_instruct_66k | 36,282 | Write a Python function to reverse the keys and values in a given dictionary and arrange the new pairs in descending order based on the alphabetical order of the values. The function should take a dictionary as input and return a new dictionary with the reversed and sorted key-value pairs.
The code should start with:
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def reverse_and_sort_dict(input_dict: Dict[str, str]) -> Dict[str, str]:
"""
Reverses the keys and values in a given dictionary and arranges the new pairs in descending order based on the alphabetical or... |
evol_instruct_66k | 36,283 | Write a Python function to create a dictionary from two tuples of equal length. The first tuple contains keys, and the second tuple contains corresponding values. The function should handle cases where the tuples are not of equal length by truncating the longer tuple to match the length of the shorter one.
The code sh... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple, Dict
def create_dictionary_from_tuples(tuple1: Tuple[str], tuple2: Tuple[str]) -> Dict[str, str]:
"""
Creates a dictionary from two tuples of equal length. The first tuple contains keys, and the second... |
evol_instruct_66k | 36,288 | Write a Python function to validate whether a given integer falls within a specified inclusive range. The function should return a boolean value indicating whether the integer is within the range. The code should start with:
```python
def is_within_range(number: int, lower_bound: int, upper_bound: int) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_within_range(number: int, lower_bound: int, upper_bound: int) -> bool:
"""
Validate whether a given integer falls within a specified inclusive range.
Args:
number (int): The integer to be checked.
low... |
evol_instruct_66k | 36,311 | Write a Python function to swap the values of two strings representing large integers without converting the entire strings to integers. The function should handle strings of any length, including those longer than 15 digits. The code should start with:
```python
def swap_large_integers(x: str, y: str) -> tuple:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def swap_large_integers(x: str, y: str) -> tuple:
"""
Swaps the values of two strings representing large integers without converting the entire strings to integers.
Args:
x (str): The first string representing a lar... |
evol_instruct_66k | 36,342 | Write a Python function to print numbers in a decrementing loop from a given integer `start` down to 0, inclusive. The function should handle cases where `start` is less than 0 by printing nothing. The function should start with:
```python
def decrement_loop(start: int) -> None:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def decrement_loop(start: int) -> None:
"""
Prints numbers in a decrementing loop from the given integer `start` down to 0, inclusive.
If `start` is less than 0, the function prints nothing.
Args:
start (int): T... |
evol_instruct_66k | 36,349 | Write a Python function to categorize and sort a list of numerical entries in descending order. The function should accept a list of integers as input and return a sorted list in descending order. The code should start with:
```python
from typing import List
def sort_descending(unsorted_list: List[int]) -> List[int]:
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_descending(unsorted_list: List[int]) -> List[int]:
"""
Sorts a list of numerical entries in descending order.
Args:
unsorted_list (List[int]): The list of integers to be sorted.
... |
evol_instruct_66k | 36,351 | Write a Python function to flatten a given matrix (a two-dimensional list) into a one-dimensional list. The function should handle matrices of varying sizes and ensure that all elements are included in the resulting list in row-major order.
The code should start with:
```python
from typing import List
def flatten_mat... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def flatten_matrix(matrix: List[List[int]]) -> List[int]:
"""
Flattens a given matrix (a two-dimensional list) into a one-dimensional list.
Args:
matrix (List[List[int]]): The matrix to be f... |
evol_instruct_66k | 36,366 | Write a Python function to calculate the mean, mode, median, and range of a given list of numbers. The function should return a dictionary with keys 'mean', 'mode', 'median', and 'range', each containing the corresponding calculated value.
The code should start with:
```python
from typing import List, Dict, Union
def... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
from collections import Counter
def calculate_statistics(numbers: List[int]) -> Dict[str, Union[int, float]]:
"""
Calculate the mean, mode, median, and range of a given list of numbers.
... |
evol_instruct_66k | 36,379 | Write a Python function to determine the highest and lowest numerical values within a given list of integers, along with their respective indices. The function should handle any potential exceptions that may arise, such as an empty list. The code should start with:
```python
from typing import List, Tuple
def find_min... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_min_max_with_indices(my_list: List[int]) -> Tuple[int, int, int, int]:
"""
Determine the highest and lowest numerical values within a given list of integers,
along with their respecti... |
evol_instruct_66k | 36,380 | Write a Python function to normalize a given text by removing extra spaces and ensuring that words are separated by a single space. The function should handle various edge cases, such as multiple spaces between words, leading and trailing spaces, and empty strings.
The code should start with:
```python
def normalize_t... | Here is the Python code to solve the given problem in the markdown block:
```python
def normalize_text(text: str) -> str:
"""
Normalizes the given text by removing extra spaces and ensuring that words are separated by a single space.
Args:
text (str): The input text to be normalized.
Returns:
... |
evol_instruct_66k | 36,383 | Write a Python function to reverse a given list of numerical values. The function should take a list of integers as input and return a new list with the elements in the reverse order. The original list should not be modified.
The code should start with:
```python
from typing import List
def reverse_list(arr: 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 given list of integers and returns a new list with the elements in the reverse order.
Args:
arr (List[int]): The list of integ... |
evol_instruct_66k | 36,384 | Write a Python function to compute the Greatest Common Divisor (GCD) of two positive integers using the Euclidean algorithm. The function should take two integers as input and return their GCD. The code should start with:
```python
def compute_gcd(a: int, b: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def compute_gcd(a: int, b: int) -> int:
"""
Compute the Greatest Common Divisor (GCD) of two positive integers using the Euclidean algorithm.
Args:
a (int): The first positive integer.
b (int): The second po... |
evol_instruct_66k | 36,385 | Write a Python function to calculate the factorial of a given non-negative integer using a recursive approach. The function should handle the base case and the recursive case appropriately. The code should start with:
```python
def factorial_recursive(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def factorial_recursive(n: int) -> int:
"""
Calculate the factorial of a given non-negative integer using a recursive approach.
Args:
n (int): The non-negative integer for which to calculate the factorial.
Re... |
evol_instruct_66k | 36,392 | Write a Python function to sort an array of mixed data types (integers and strings) in ascending order using the Selection Sort algorithm. The function should handle the comparison between integers and strings, considering that strings are always less than integers. The code should start with:
```python
from typing imp... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def mixed_data_selection_sort(arr: List[Union[int, str]]) -> List[Union[int, str]]:
"""
Sorts an array of mixed data types (integers and strings) in ascending order using the Selection Sort algori... |
evol_instruct_66k | 36,405 | Write a Python function to safely divide two numbers, handling the case where the divisor is zero. The function should return the result of the division if successful, and a specific error message if the division by zero occurs. The code should start with:
```python
def safe_divide(a: float, b: float) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def safe_divide(a: float, b: float) -> float:
"""
Safely divides two numbers, handling the case where the divisor is zero.
Args:
a (float): The numerator.
b (float): The denominator.
Returns:
fl... |
evol_instruct_66k | 36,410 | Write a Python function to calculate the absolute difference between two given numbers. The function should take two numerical inputs and return the absolute value of their difference. The code should start with:
```python
def absolute_difference(a: float, b: float) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def absolute_difference(a: float, b: float) -> float:
"""
Calculate the absolute difference between two numbers.
Args:
a (float): The first number.
b (float): The second number.
Returns:
float: ... |
evol_instruct_66k | 36,411 | Write a Python function that implements a ternary operator to determine if a given integer is positive or negative. The function should return "Yes" if the integer is greater than zero, and "No" if it is less than or equal to zero. The function should be named `is_positive` and should take a single integer argument.
T... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_positive(x: int) -> str:
"""
Determines if the given integer is positive or not using a ternary operator.
Args:
x (int): The integer to be checked.
Returns:
str: "Yes" if the integer is greater t... |
evol_instruct_66k | 36,416 | 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 number is even, and "No, it's odd" if the number is odd. The function should handle any integer input.
The code should start with:
```python
def check_even_or_odd(number: int) -> str:
```... | 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 string.
Args:
number (int): The integer to be checked.
Returns:
str: "Yes, it's ... |
evol_instruct_66k | 36,424 | Write a Python function to calculate the discount amount for a given price. The discount is calculated as a percentage of the price, and the percentage can vary. The function should take two parameters: the price and the discount percentage. The function should return the discount amount.
The code should start with:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_discount(price: float, discount_percentage: float) -> float:
"""
Calculate the discount amount for a given price based on a specified discount percentage.
Args:
price (float): The original price of the... |
evol_instruct_66k | 36,449 | Write a Python function to calculate the cumulative sum of all numerical elements within a multi-dimensional array, while also identifying and handling possible non-numeric exceptions. The function should recursively traverse the array and sum all numeric values, ignoring any non-numeric elements.
The code should star... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Union, List
def cumulative_sum(arr: Union[List, int]) -> int:
"""
Calculate the cumulative sum of all numerical elements within a multi-dimensional array.
Args:
arr (Union[List, int]): The multi-... |
evol_instruct_66k | 36,457 | Write a Python function to append a list of new elements to an existing list and then shuffle the combined list using a pseudo-random algorithm. The function should return the shuffled list. The code should start with:
```python
from typing import List
import random
def append_and_shuffle(existing_list: List[int], new... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def append_and_shuffle(existing_list: List[int], new_elements: List[int]) -> List[int]:
"""
Appends new elements to an existing list and then shuffles the combined list.
Args:
... |
evol_instruct_66k | 36,463 | Write a Python function to detect the frequency of integer patterns in a given array. The function should return a dictionary where the keys are the integers from the array and the values are their respective frequencies.
The code should start with:
```python
from typing import List, Dict
def detect_frequency(arr: Li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def detect_frequency(arr: List[int]) -> Dict[int, int]:
"""
Detects the frequency of each integer in the given array.
Args:
arr (List[int]): The array of integers to analyze.
Retu... |
evol_instruct_66k | 36,510 | Write a Python function to check if a given string has exactly 5 alphabetic characters. The function should return `True` if the string meets the criteria, and `False` otherwise. The code should start with:
```python
def is_length_five_alphabetic(name: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_length_five_alphabetic(name: str) -> bool:
"""
Check if the given string has exactly 5 alphabetic characters.
Args:
name (str): The string to be checked.
Returns:
bool: True if the string has exa... |
evol_instruct_66k | 36,514 | Write a Python function to generate a unique nine-symbol code using exclusively the characters from the 16-unit hexadecimal system, ensuring that the code strictly adheres to alphanumeric criteria. The function should return the generated code as a string.
The code should start with:
```python
import random
def gener... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
def generate_unique_code(length: int = 9) -> str:
"""
Generates a unique nine-symbol code using exclusively the characters from the 16-unit hexadecimal system.
Args:
length (int): The length of the co... |
evol_instruct_66k | 36,516 | Write a Python function to move all zeroes to the end of a given list while maintaining the relative order of the non-zero elements. The function should also handle nested lists by moving all zeroes in the nested lists to the end of their respective lists. The function should not use any built-in Python functions or li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def move_zeroes_to_end(lst: Union[List[Union[int, List]], int]) -> Union[List[Union[int, List]], int]:
"""
Moves all zeroes to the end of the given list while maintaining the relative order of the... |
evol_instruct_66k | 36,520 | Write a Python function to dismantle a given character sequence by treating all non-alphanumeric characters (including hyphens) as delimiters. The function should handle cases where multiple non-alphanumeric characters are present consecutively. The function should return a list of words extracted from the sequence.
T... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def dismantle_sequence(char_sequence: str) -> List[str]:
"""
Dismantles the given character sequence by treating all non-alphanumeric characters as delimiters.
Handles cases where multiple ... |
evol_instruct_66k | 36,525 | Write a Python function to determine if a given text input includes any non-alphanumeric characters. The function should return `True` if there is at least one non-alphanumeric character in the text, and `False` otherwise. The code should start with:
```python
def contains_non_alphanumeric(text: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def contains_non_alphanumeric(text: str) -> bool:
"""
Determines if the given text includes any non-alphanumeric characters.
Args:
text (str): The input text to be checked.
Returns:
bool: True if the ... |
evol_instruct_66k | 36,529 | Write a Python function to extract all odd numerical characters from a given string and compute their cumulative sum. The function should handle strings that may contain non-numeric characters and should only consider the odd digits (1, 3, 5, 7, 9) for the sum.
The code should start with:
```python
def sum_of_odd_digi... | Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_odd_digits(input_string: str) -> int:
"""
Extracts all odd numerical characters from the given string and computes their cumulative sum.
Args:
input_string (str): The input string containing numerical and... |
evol_instruct_66k | 36,530 | Write a Python function to calculate the total number of elements in a given nested list, including all elements in sublists. The function should handle lists of arbitrary depth and complexity.
The code should start with:
```python
from typing import List, Union
def count_elements_in_nested_list(nested_list: List[Uni... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def count_elements_in_nested_list(nested_list: List[Union[int, float, List]]) -> int:
"""
Calculate the total number of elements in a given nested list, including all elements in sublists.
Ar... |
evol_instruct_66k | 36,539 | Write a Python function that takes in three arguments: `x`, `y`, and `num`. The function should use a ternary operator (conditional expression) to determine whether `x` is greater than `y`. If `x` is greater than `y`, the function should return the sum of `x` and `num`. If `y` is greater than or equal to `x`, the funct... | Here is the Python code to solve the given problem in the markdown block:
```python
def arithmetic_operation(x: int, y: int, num: int) -> int:
"""
Perform an arithmetic operation based on the comparison of x and y.
Args:
x (int): The first integer to compare.
y (int): The second integer to ... |
evol_instruct_66k | 36,542 | Write a Python function to merge two ordered numerical sequences into a single ordered sequence efficiently. The function should take two lists of integers as input, where each list is already sorted in ascending order, and return a single list that contains all elements from both input lists, also sorted in ascending ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_ordered_sequences(seq1: List[int], seq2: List[int]) -> List[int]:
"""
Merges two ordered numerical sequences into a single ordered sequence.
Args:
seq1 (List[int]): The first order... |
evol_instruct_66k | 36,550 | Write a Python function to generate a spiral sequence in a clockwise rotation from a given 2D matrix of integers. The function should traverse the matrix starting from the top-left corner and moving right, down, left, and up in a spiral pattern until all elements are visited. The function should return a list of intege... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def spiral_order(matrix: List[List[int]]) -> List[int]:
"""
Generate a spiral sequence in a clockwise rotation from a given 2D matrix of integers.
Args:
matrix (List[List[int]]): A 2D list o... |
evol_instruct_66k | 36,558 | Write a Python function to generate a list of consecutive integers from a given starting integer `k` to an ending integer `n`, inclusive. The function should ensure that no integers are skipped in the sequence. The code should start with:
```python
from typing import List
def generate_consecutive_integers(k: int, n: i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_consecutive_integers(k: int, n: int) -> List[int]:
"""
Generate a list of consecutive integers from k to n, inclusive.
Args:
k (int): The starting integer of the sequence.
... |
evol_instruct_66k | 36,559 | Write a Python function to generate a Pascal's Triangle up to `n` rows. The function should return a list of lists, where each inner list represents a row in the triangle. Each element in the triangle is the sum of the two elements directly above it in the previous row. The first and last elements of each row are alway... | 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 Pascal's Triangle up to n rows.
Args:
n (int): The number of rows to generate.
Returns:
List[List[int]]:... |
evol_instruct_66k | 36,560 | Write a Python function to filter out non-Fibonacci numbers from a given list of integers. The function should return a new list containing only the numbers that are part of the Fibonacci sequence. The Fibonacci sequence is defined as a sequence where the first two numbers are 0 and 1, and each subsequent number is the... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import math
def is_fibonacci(n: int) -> bool:
"""
Check if a given number is a Fibonacci number.
Args:
n (int): The number to check.
Returns:
bool: True if the number is a Fibon... |
evol_instruct_66k | 36,582 | Write a Python function to perform binary search on a sorted array to find the index of a given element. The function should handle edge cases such as an empty array or when the element is not present in the array. The binary search algorithm should be implemented without using any pre-built functions. The code should ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def binary_search(arr: List[int], element: int) -> int:
"""
Perform binary 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 | 36,583 | Write a Python function to calculate the cumulative product of elements in a given list using a recursive approach. The cumulative product for an element at index `i` is the product of all elements from the start of the list up to index `i`. The function should return a new list where each element at index `i` is the c... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def cumulative_product(arr: List[int]) -> List[int]:
"""
Calculate the cumulative product of elements in a given list using a recursive approach.
Args:
arr (List[int]): The input list of int... |
evol_instruct_66k | 36,597 | Write a Python function to remove all duplicate characters from a given string while preserving the order of the first occurrences of each character. The function should return the modified string. The code should start with:
```python
def remove_duplicate_characters(string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def remove_duplicate_characters(string: str) -> str:
"""
Removes all duplicate characters from the given string while preserving the order of the first occurrences of each character.
Args:
string (str): The input st... |
evol_instruct_66k | 36,623 | Write a Python function to calculate the square of a given number using a mathematical approach. The function should handle both positive and negative integers, as well as zero. The code should start with:
```python
def calculate_square(number: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_square(number: int) -> int:
"""
Calculate the square of a given number.
Args:
number (int): The number to be squared.
Returns:
int: The square of the given number.
"""
# Calculate ... |
evol_instruct_66k | 36,641 | Write a Python function to count the occurrences of each unique element in a given list and return a dictionary where the keys are the unique elements and the values are their respective counts.
The code should start with:
```python
from typing import List, Dict
def count_occurrences(arr: List[int]) -> Dict[int, int]... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_occurrences(arr: List[int]) -> Dict[int, int]:
"""
Counts the occurrences of each unique element in the given list.
Args:
arr (List[int]): The list of integers to count occur... |
evol_instruct_66k | 36,651 | Write a Python function to check if a given string contains at least one numeric character and at least one uppercase alphabetic letter using regular expressions. The function should return `True` if both conditions are met, and `False` otherwise.
The code should start with:
```python
import re
def check_string_with_... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def check_string_with_regex(s: str) -> bool:
"""
Check if the given string contains at least one numeric character and at least one uppercase alphabetic letter.
Args:
s (str): The string to be checked.
... |
evol_instruct_66k | 36,673 | Write a Python function to convert a given integer to its binary representation and return the binary string without the '0b' prefix. The function should handle both positive and negative integers.
The code should start with:
```python
def integer_to_binary(a: int) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def integer_to_binary(a: int) -> str:
"""
Converts a given integer to its binary representation without the '0b' prefix.
Args:
a (int): The integer to be converted to binary.
Returns:
str: The binary ... |
evol_instruct_66k | 36,701 | Write a Python function to convert a given string to camel case while handling numbers, symbols, or special characters. If the string contains a number, the function should raise a `ValueError`. If the string contains a symbol or special character (except whitespace), it should be replaced with its corresponding ASCII ... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_to_camel_case(input_string: str) -> str:
"""
Convert a given string to camel case while handling numbers, symbols, and special characters.
Args:
input_string (str): The input string to be converted.
... |
evol_instruct_66k | 36,709 | Write a Python function to determine the number of unique paths from the top-left corner to the bottom-right corner of an m x n grid, where you can only move right or down. The function should start with:
```python
from typing import List
def unique_paths(m: int, n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def unique_paths(m: int, n: int) -> int:
"""
Calculate the number of unique paths from the top-left corner to the bottom-right corner of an m x n grid.
Args:
m (int): The number of row... |
evol_instruct_66k | 36,717 | Write a Python function to find all prime numbers between 0 and a given upper limit `n`, and return a list of only the odd prime numbers. A prime number is defined as a number greater than 1 that has no divisors other than 1 and itself. The function should use a loop to identify prime numbers and filter out the odd one... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_odd_prime_numbers(n: int) -> List[int]:
"""
Finds all prime numbers between 0 and n, and returns a list of only the odd prime numbers.
Args:
n (int): The upper limit to find prime n... |
evol_instruct_66k | 36,731 | Write a Python function to count and generate all possible `3 x 3` "magic square" subgrids from a given `row x col` grid of integers. A `3 x 3` magic square is defined as a `3 x 3` grid filled with distinct numbers from `1` to `9` such that each row, column, and both diagonals all have the same sum.
The function shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_magic_squares(grid: List[List[int]]) -> Tuple[int, List[List[List[int]]]]:
"""
Count and generate all possible 3 x 3 magic square subgrids from the given grid.
Args:
grid (Li... |
evol_instruct_66k | 36,738 | Write a Python function to find the intersection of three sorted arrays. The function should return a sorted list of integers that are present in all three input arrays. The input arrays are guaranteed to be sorted in strictly ascending order.
The code should start with:
```python
from typing import List
def find_int... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_intersection_of_three_arrays(arr1: List[int], arr2: List[int], arr3: List[int]) -> List[int]:
"""
Find the intersection of three sorted arrays.
Args:
arr1 (List[int]): The first sor... |
evol_instruct_66k | 36,742 | Write a Python function to determine if a given integer `n` is even or odd. The function should return the string `'even'` if `n` is divisible by 2 without any remainder, and `'odd'` otherwise. The code should start with:
```python
def even_or_odd(n: int) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def even_or_odd(n: int) -> str:
"""
Determines if the given integer `n` is even or odd.
Args:
n (int): The integer to be checked.
Returns:
str: 'even' if `n` is divisible by 2 without any remainder, o... |
evol_instruct_66k | 36,752 | Write a Python function to find the maximum number in a list without using the built-in `max` function or any other sorting functions. The function should handle both positive and negative integers as well as zero. The code should start with:
```python
from typing import List
def find_max_number(lst: 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_number(lst: List[int]) -> int:
"""
Finds the maximum number in a list without using the built-in max function or any other sorting functions.
Args:
lst (List[int]): The list of ... |
evol_instruct_66k | 36,757 | Write a Python function to find the smallest even integer in a given list of integers. The function should return the smallest even integer if found, otherwise it should return `None`. The code should start with:
```python
from typing import List, Optional
def find_smallest_even(arr: List[int]) -> Optional[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def find_smallest_even(arr: List[int]) -> Optional[int]:
"""
Finds the smallest even integer in a given list of integers.
Args:
arr (List[int]): The list of integers to search thro... |
evol_instruct_66k | 36,758 | Write a Python function to search for a specific element in a sorted array and calculate its frequency using the binary search algorithm. The function should return the frequency of the element if found, otherwise return 0. The function should also provide the big-O complexity for the search algorithm and the overall f... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_element_frequency(arr: List[int], x: int) -> int:
"""
Searches for a specific element in a sorted array and calculates its frequency.
Args:
arr (List[int]): The sorted array to sear... |
evol_instruct_66k | 36,764 | Write a Python function to identify and return all symmetrical numbers from a given list of integers. A symmetrical number is a number that reads the same forwards and backwards, such as 121, 3443, and 78987.
The code should start with:
```python
from typing import List
def find_symmetrical_numbers(lst: List[int]) ->... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_symmetrical_numbers(lst: List[int]) -> List[int]:
"""
Identifies and returns all symmetrical numbers from a given list of integers.
Args:
lst (List[int]): A list of integers to chec... |
evol_instruct_66k | 36,773 | Write a Python function to flip a given square matrix along its diagonal. The matrix is represented as a list of lists, where each inner list represents a row of the matrix. The function should return the flipped matrix.
The code should start with:
```python
from typing import List
def flip_matrix_along_diagonal(matr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def flip_matrix_along_diagonal(matrix: List[List[int]]) -> List[List[int]]:
"""
Flips a given square matrix along its diagonal.
Args:
matrix (List[List[int]]): The input square matrix repres... |
evol_instruct_66k | 36,780 | Write a Python function to calculate the sum of each row in a given two-dimensional array and store these sums in a new array. The function should be optimized to achieve this in minimal possible time complexity. The code should start with:
```python
from typing import List
def row_sum(arr: List[List[int]]) -> List[in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def row_sum(arr: List[List[int]]) -> List[int]:
"""
Calculate the sum of each row in a given two-dimensional array and store these sums in a new array.
Args:
arr (List[List[int]]): A two-dim... |
evol_instruct_66k | 36,787 | Write a Python function to calculate the factorial of a given non-negative integer `n` using an iterative approach within a while loop. The function should return the factorial of `n`.
The code should start with:
```python
def factorial_iterative(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def factorial_iterative(n: int) -> int:
"""
Calculate the factorial of a given non-negative integer n using an iterative approach.
Args:
n (int): The non-negative integer for which to calculate the factorial.
R... |
evol_instruct_66k | 36,790 | Write a Python function to generate a greeting message that includes the user's name and age. The function should ensure that the `user_name` is of type `str` and the `user_age` is of type `int`. The function should return a string formatted as "Hello, my name is [user_name] and I am [user_age] years old." The code sho... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_greeting(user_name: str, user_age: int) -> str:
"""
Generates a greeting message that includes the user's name and age.
Args:
user_name (str): The name of the user.
user_age (int): The age of th... |
evol_instruct_66k | 36,797 | Write a Python function to determine if a given string contains exactly five distinct letters from the alphabet. The function should be case-insensitive and should ignore any non-alphabetic characters. The code should start with:
```python
def has_exactly_five_unique_letters(name: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def has_exactly_five_unique_letters(name: str) -> bool:
"""
Determines if a given string contains exactly five distinct letters from the alphabet.
Args:
name (str): The string to be checked.
Returns:
bo... |
evol_instruct_66k | 36,802 | Write a Python function to reorder a given dictionary based on the numerical values contained within. If two or more items have the same numerical value, they should be arranged in alphabetical order of their keys. The function should return the reordered dictionary.
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 Dict, Any
def reorder_dictionary(my_dict: Dict[str, int]) -> Dict[str, int]:
"""
Reorders the given dictionary based on the numerical values. If two or more items have the same value,
they are arranged in... |
evol_instruct_66k | 36,816 | Write a Python function to eliminate all repeating elements from a provided data collection. Two elements are considered equal only if all their attributes are the same, not just a single one. The function should maintain the order of the first occurrence of each unique element.
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, Tuple
from collections import OrderedDict
def remove_duplicates(data_collection: List[Tuple]) -> List[Tuple]:
"""
Removes duplicate tuples from the provided data collection. Two tuples are considered eq... |
evol_instruct_66k | 36,827 | Write a Python function to compute the cumulative multiplicative result of successive elements within a given tuple, stopping the iterations once the cumulative product reaches or exceeds a defined threshold. The function should return the cumulative product at the point of stopping.
The code should start with:
```pyt... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
def cumulative_product_until_threshold(tuple_values: Tuple[int], target_product: int) -> int:
"""
Compute the cumulative multiplicative result of successive elements within a tuple,
stopping the ite... |
evol_instruct_66k | 36,828 | Write a Python function to calculate the least common multiple (LCM) of all prime numbers up to a given integer `n`. The function should first identify all prime numbers up to `n` and then compute their LCM. The code should start with:
```python
import math
from typing import List
def prime_lcm_upto(n: int) -> int:
``... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
from typing import List
def primes_upto(n: int) -> List[int]:
"""
Returns a list of all prime numbers up to n.
Args:
n (int): The upper limit for prime number generation.
Returns:
List[int]... |
evol_instruct_66k | 36,832 | Write a Python function to merge two lists by taking elements at the same index from both lists. If the lists have unequal lengths, the function should continue merging until the end of the longer list, ignoring `None` values. The lists can contain various data types such as integers, floats, and strings.
The code sho... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
from itertools import zip_longest
def merge_lists(list1: List[Any], list2: List[Any]) -> List[Any]:
"""
Merge two lists by taking elements at the same index from both lists.
If the lists have un... |
evol_instruct_66k | 36,841 | Write a Python function to generate an array of prime numbers within a given range `[lower, upper]`. The function should follow the mathematical convention of inclusion for the end figures, meaning both `lower` and `upper` bounds are inclusive. The function should efficiently determine whether a number is prime by chec... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import math
def generate_primes_in_range(lower: int, upper: int) -> List[int]:
"""
Generate a list of prime numbers within the given range [lower, upper].
Args:
lower (int): The lower bound ... |
evol_instruct_66k | 36,843 | Write a Python function to find the index of a specific character in a given string. The function should return the index of the first occurrence of the character if it exists in the string, otherwise return -1. The string is 0-indexed.
The code should start with:
```python
def find_character_index(s: str, char: str) ... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_character_index(s: str, char: str) -> int:
"""
Find the index of the first occurrence of a specific character in a given string.
Args:
s (str): The input string in which to search for the character.
... |
evol_instruct_66k | 36,845 | Write a Python function to determine the resultant datatype of a given string after concatenating it with an integer using the `str()` method. The function should also return the concatenated string.
The code should start with:
```python
def concatenate_and_determine_type(s: str, n: int) -> tuple:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def concatenate_and_determine_type(s: str, n: int) -> tuple:
"""
Concatenates a given string with an integer converted to a string and determines the resultant datatype.
Args:
s (str): The initial string to be conca... |
evol_instruct_66k | 36,846 | Write a Python function to determine if a given sequence contains any floating-point numbers that have decimal accuracy (i.e., they are not integers when rounded). The sequence can contain various data types, including integers, strings, and floats.
The code should start with:
```python
from typing import List, Union
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def contains_float_with_accuracy(sequence: List[Union[int, float, str]]) -> bool:
"""
Determines if the given sequence contains any floating-point numbers with decimal accuracy.
Args:
... |
evol_instruct_66k | 36,852 | Write a Python function to create a dictionary from two tuples of equal length. The first tuple contains keys, and the second tuple contains corresponding values. The function should handle cases where the tuples are not of equal length by truncating the longer tuple to match the length of the shorter one.
The code sh... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple, Dict
def create_dictionary_from_tuples(tuple1: Tuple[str], tuple2: Tuple[str]) -> Dict[str, str]:
"""
Creates a dictionary from two tuples of equal length.
Args:
tuple1 (Tuple[str]): A tup... |
evol_instruct_66k | 36,855 | Write a Python function to calculate the running mean of a numeric array. The running mean is defined as the mean of the elements up to the current index for each index in the array. The function should take a list of numbers as input and return a list of running means.
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 compute_running_mean(data: List[float]) -> List[float]:
"""
Calculate the running mean of a numeric array.
The running mean at each index i is the mean of the elements from the start of the arra... |
evol_instruct_66k | 36,871 | Write a Python function to implement an XOR gate using only two NAND gates and two AND gates. The function should take two boolean inputs and return the result of the XOR operation. The code should start with:
```python
def XOR_gate(a: bool, b: bool) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def AND_gate(a: bool, b: bool) -> bool:
"""
Implements an AND gate.
Args:
a (bool): First input.
b (bool): Second input.
Returns:
bool: True if both inputs are True, otherwise False.
"""
... |
evol_instruct_66k | 36,894 | Write a Python function to find the first non-repeating character in a given string. If there are no unique characters, return an empty string. The function should prioritize time efficiency.
The code should start with:
```python
from collections import Counter
def first_non_repeating_character(s: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from collections import Counter
def first_non_repeating_character(s: str) -> str:
"""
Find the first non-repeating character in the given string.
Args:
s (str): The input string to search for the first non-repeatin... |
evol_instruct_66k | 36,903 | Write a Python function to count the number of even numbers in a given list of integers. The function should be efficient and handle various edge cases, such as an empty list or a list with all odd numbers. The code should start with:
```python
from typing import List
def count_even_numbers(num_list: List[int]) -> int... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_even_numbers(num_list: List[int]) -> int:
"""
Counts the number of even numbers in a given list of integers.
Args:
num_list (List[int]): A list of integers.
Returns:
i... |
evol_instruct_66k | 36,909 | Write a Python function to calculate the product of two numerical inputs using a recursive approach. The function should handle both positive and negative integers, as well as zero. The code should start with:
```python
def multiply(a: int, b: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def multiply(a: int, b: int) -> int:
"""
Calculate the product of two integers using a recursive approach.
Args:
a (int): The first integer.
b (int): The second integer.
Returns:
int: The produc... |
evol_instruct_66k | 36,912 | Write a Python function to compute the element-wise product of two lists. If the lists have different lengths, the shorter list should be padded with zeroes to match the length of the longer list before performing the element-wise product. The function should return a new list containing the element-wise products.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def element_wise_product(list1: List[int], list2: List[int]) -> List[int]:
"""
Computes the element-wise product of two lists. If the lists have different lengths,
the shorter list is padded with zer... |
evol_instruct_66k | 36,924 | Write a Python function to determine if two given strings are anagrams of each other, considering the following constraints:
1. Ignore spaces and punctuation.
2. Treat uppercase and lowercase letters as the same.
3. Use a counter for each letter of the alphabet found in the first string and check against the counter fo... | Here is the Python code to solve the given problem in the markdown block:
```python
def are_anagrams(str1: str, str2: str) -> bool:
"""
Determine if two given strings are anagrams of each other.
Args:
str1 (str): The first string to compare.
str2 (str): The second string to compare.
Re... |
evol_instruct_66k | 36,935 | Write a Python function to calculate the sum of all multiples of 3 and 5 between 0 and each number in a given list. The function should return a list where each element corresponds to the sum of multiples of 3 and 5 for the respective number in the input list.
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 sum_multiples_of_3_and_5(numbers: List[int]) -> List[int]:
"""
Calculate the sum of all multiples of 3 and 5 between 0 and each number in the given list.
Args:
numbers (List[int]): A lis... |
evol_instruct_66k | 36,943 | Write a Python function to calculate the sum of all elements in a given list of integers that are divisible by 3. The function should take a list of integers as input and return the sum of the elements that meet the condition. The code should start with:
```python
from typing import List
def sum_divisible_by_three(num... | Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def sum_divisible_by_three(numbers: List[int]) -> int:
"""
Calculate the sum of all elements in the given list that are divisible by 3.
Args:
numbers (List[int]): A list of integers.
... |
evol_instruct_66k | 36,952 | Write a Python function to find and return the word that occurs most frequently in a given sentence. The sentence is a string containing words separated by spaces. The function should be case-insensitive, meaning "This" and "this" should be considered the same word. The function should also handle punctuation by stripp... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import re
def most_frequent_word(sentence: str) -> Tuple[str, int]:
"""
Finds and returns the word that occurs most frequently in a given sentence.
Args:
sentence (str): The input sen... |
evol_instruct_66k | 36,953 | Write a Python function to find the smallest floating-point number in a given list of floating-point numbers. The function should handle an empty list by returning `None`. The code should start with:
```python
from typing import List, Optional
def find_smallest_float(numbers: List[float]) -> Optional[float]:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List, Optional
def find_smallest_float(numbers: List[float]) -> Optional[float]:
"""
Find the smallest floating-point number in a given list of floating-point numbers.
Args:
numbers (List[float... |
evol_instruct_66k | 36,961 | Write a Python function to detect duplicates in a tuple and return a dictionary with the duplicates and their first and last index positions. If there are no duplicates, return an empty dictionary. The function should be efficient and avoid using the `count` method for performance reasons.
The code should start with:
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Tuple, Any
def detect_duplicates_with_index(input_tuple: Tuple[Any, ...]) -> Dict[Any, Dict[str, int]]:
"""
Detects duplicates in a tuple and returns a dictionary with the duplicates and their first and... |
evol_instruct_66k | 36,967 | Write a Python function to generate a cookie string based on the provided parameters. The function should include methods to add the name, value, maxAge, path, HttpOnly flag, and Secure flag. The function should follow the HTTP state management mechanism as per the RFC 6265 specification. The code should start with:
``... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_cookie(name: str, value: str, max_age: int = None, path: str = None, http_only: bool = False, secure: bool = False) -> str:
"""
Generates a cookie string based on the provided parameters.
Args:
name (st... |
evol_instruct_66k | 36,977 | Write a Python function to flatten a given multidimensional array (up to three tiers deep) into a single list of its elements. The function should iterate through each tier of the array and collect all individual items into a single list. The code should start with:
```python
from typing import List
def flatten_multid... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def flatten_multidimensional_array(arr: List[List[List[int]]]) -> List[int]:
"""
Flattens a given multidimensional array (up to three tiers deep) into a single list of its elements.
Args:
ar... |
evol_instruct_66k | 36,984 | Write a Python function to convert a hexadecimal number, represented as a string, into its equivalent binary representation. The function should ensure that the binary string is padded with leading zeros to maintain the same number of bits as the hexadecimal representation. The code should start with:
```python
def hex... | Here is the Python code to solve the given problem in the markdown block:
```python
def hex_to_binary(hex_value: str) -> str:
"""
Converts a hexadecimal number, represented as a string, into its equivalent binary representation.
Args:
hex_value (str): The hexadecimal number to be converted.
Re... |
evol_instruct_66k | 36,988 | Write a Python function to compute the transpose of a given matrix. The transpose of a matrix is obtained by swapping its rows with its columns. The function should handle matrices of any size, including non-square matrices. The code should start with:
```python
from typing import List
def transpose_matrix(matrix: Lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def transpose_matrix(matrix: List[List[int]]) -> List[List[int]]:
"""
Compute the transpose of a given matrix.
The transpose of a matrix is obtained by swapping its rows with its columns.
Args:... |
evol_instruct_66k | 37,007 | Write a Python function to identify and return all four-digit numerical integers from a given text string using a regular expression pattern. The function should be able to handle various text inputs and correctly identify only the four-digit numbers.
The code should start with:
```python
import re
from typing import ... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
from typing import List
def find_four_digit_numbers(text: str) -> List[str]:
"""
Finds and returns all four-digit numerical integers from the given text string.
Args:
text (str): The input text string to ... |
evol_instruct_66k | 37,015 | Write a Python function to sort a list of integers in ascending 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(input_list: List[int]) -> List[int]:
"""
Sorts a list of integers in ascending order using the merge sort algorithm.
Args:
input_list (List[int]): The list of integers to be s... |
evol_instruct_66k | 37,017 | Write a Python function to find the sum of all numerical values in a nested dictionary. The dictionary may contain other dictionaries as values, and those dictionaries may also contain dictionaries as values, and so on. The function should be able to handle this nesting and return the sum of all numerical values. The f... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Union
def sum_nested_dict_values(d: dict) -> Union[int, float]:
"""
Calculate the sum of all numerical values in a nested dictionary.
Args:
d (dict): The nested dictionary to traverse.
Retur... |
evol_instruct_66k | 37,022 | Write a Python function to determine if a given string contains matching parentheses, square brackets, and curly braces. The function should ensure that each opening bracket has a corresponding closing bracket and that they are properly nested.
The code should start with:
```python
def has_matching_brackets(s: str) ->... | Here is the Python code to solve the given problem in the markdown block:
```python
def has_matching_brackets(s: str) -> bool:
"""
Determine if the given string contains matching and properly nested parentheses, square brackets, and curly braces.
Args:
s (str): The string to check for matching brac... |
evol_instruct_66k | 37,023 | Write a Python function to implement the selection sort algorithm for sorting a given list of integers in ascending order. The function should modify the input list in place and return the sorted list. The code should start with:
```python
from typing import List
def selection_sort(array: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def selection_sort(array: List[int]) -> List[int]:
"""
Sorts a given list of integers in ascending order using the selection sort algorithm.
Args:
array (List[int]): The list of integers to ... |
evol_instruct_66k | 37,029 | Write a Python function to compute the least common multiple (LCM) of all prime numbers up to a given maximum threshold value. The function should first generate a list of all prime numbers up to the given threshold and then compute their LCM.
The code should start with:
```python
def lcm_of_primes_up_to(n: int) -> in... | Here is the Python code to solve the given problem in the markdown block:
```python
def lcm_of_primes_up_to(n: int) -> int:
"""
Compute the least common multiple (LCM) of all prime numbers up to a given maximum threshold value.
Args:
n (int): The maximum threshold value up to which prime numbers ar... |
evol_instruct_66k | 37,031 | Create a Python function that initializes a list of dictionaries, each representing a distinct web development framework. Each dictionary should contain the following keys: "Name", "Language", "Latest_Version", "Foundation_Year", and "Website". Ensure that all frameworks are unique in terms of their properties. The fun... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def initialize_web_frameworks() -> List[Dict[str, str]]:
"""
Initializes a list of dictionaries, each representing a distinct web development framework.
Each dictionary contains the following ... |
evol_instruct_66k | 37,049 | Write a Python function to generate a list of vowels present in a given string and count the occurrences of each vowel, considering both uppercase and lowercase letters. The function should return a dictionary where the keys are the vowels and the values are their respective counts.
The code should start with:
```pyth... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def count_vowels(s: str) -> Dict[str, int]:
"""
Counts the occurrences of each vowel (case-insensitive) in the given string.
Args:
s (str): The input string to count vowels from.
Return... |
evol_instruct_66k | 37,070 | Write a Python function to calculate the occurrence rate of individual words within a given textual string. The function should ignore case sensitivity and punctuation marks. The code should start with:
```python
from typing import Dict
def word_occurrence_rate(text: str) -> Dict[str, int]:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import Dict
from collections import Counter
import string
def word_occurrence_rate(text: str) -> Dict[str, int]:
"""
Calculate the occurrence rate of individual words within a given textual string.
Args:
... |
evol_instruct_66k | 37,071 | Write a Python function to manipulate a list of dictionaries representing people's data. The function should allow adding a new person, removing a person, and sorting the list by age or name. Each person is represented by a dictionary with keys `'name'` and `'age'`. The function should validate the input when adding a ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Union
def manipulate_people(people: List[Dict[str, Union[str, int]]], operation: str, *args) -> List[Dict[str, Union[str, int]]]:
"""
Manipulate a list of dictionaries representing people's data.
... |
evol_instruct_66k | 37,080 | Write a Python function to create a three-dimensional numerical array using NumPy, filled with integers in ascending order from 1 to `n^3`, and then reconfigure its structure into an `n x n x n` matrix. The function should return the reshaped array.
The code should start with:
```python
import numpy as np
def create_... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def create_and_reshape_array(n: int) -> np.ndarray:
"""
Create a three-dimensional numerical array filled with integers in ascending order from 1 to n^3,
and then reshape it into an n x n x n matrix.
... |
evol_instruct_66k | 37,107 | Write a Python function to create a 4x4 matrix filled with random numbers between 0 and 9, ensuring that the sum of the elements in each row and each column is distinct. The function should handle the constraints efficiently and restart the process if it cannot find a valid matrix after a certain number of iterations.
... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def create_distinct_sum_matrix() -> np.ndarray:
"""
Create a 4x4 matrix filled with random numbers between 0 and 9, ensuring that the sum of the elements in each row and each column is distinct.
Returns:... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.