source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
magic_evol_110k | 82,767 | Write a Python function to construct a JSON structure that encapsulates the given individual characteristics. The characteristics include the full personal name, age in calendar years, and occupation. The function should ensure that the JSON structure is grammatically flawless and adheres to the JSON format.
The code ... | Here is the Python code to solve the given problem in the markdown block:
```python
import json
def create_personal_json(full_name: str, age: int, occupation: str) -> str:
"""
Constructs a grammatically flawless JSON structure that encapsulates the given individual characteristics.
Args:
full_name... |
magic_evol_110k | 82,779 | Write a Python function to find the index of the maximum value in a given array of integers or floats. If there are multiple occurrences of the maximum value, return the index of the first occurrence. The function should handle arrays with negative numbers, zeros, and positive numbers. 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, Union
def find_max_index(input_array: List[Union[int, float]]) -> int:
"""
Find the index of the maximum value in a given array of integers or floats.
Args:
input_array (List[Union[int, f... |
magic_evol_110k | 82,801 | Write a Python function to extract all even numbers from a given list of integers while preserving their original order. The function should use list comprehension for this task. The code should start with:
```python
from typing import List
def extract_even_numbers(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 extract_even_numbers(lst: List[int]) -> List[int]:
"""
Extracts all even numbers from the given list of integers while preserving their original order.
Args:
lst (List[int]): The list of... |
magic_evol_110k | 82,804 | Write a Python function to determine if a given string ends with a specific character, considering the potential complexities of different special characters. The function should handle various edge cases, such as empty strings, strings with only the target character, and strings with multiple occurrences of the target... | Here is the Python code to solve the given problem in the markdown block:
```python
def ends_with_character(input_string: str, target_character: str) -> bool:
"""
Determines if the given input string ends with the specified target character.
Args:
input_string (str): The string to check.
ta... |
magic_evol_110k | 82,808 | Write a Python function to create a five-dimensional tensor of dimensions 3x3x3x3x3 using the NumPy library, and populate it with randomly generated integer values within the range of -50 to 50. The function should return the created tensor.
The code should start with:
```python
import numpy as np
def create_random_t... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def create_random_tensor() -> np.ndarray:
"""
Create a five-dimensional tensor of dimensions 3x3x3x3x3 and populate it with randomly generated integer values within the range of -50 to 50.
Returns:
... |
magic_evol_110k | 82,825 | Write a Python function to calculate the total cost of a list of workers, where each worker has a `cost` attribute. The function should be optimized for efficiency and should handle both lists of engineers and technicians. The code should start with:
```python
from typing import List, NamedTuple
class Worker(NamedTupl... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, NamedTuple
class Worker(NamedTuple):
cost: int
def total_cost(workers: List[Worker]) -> int:
"""
Calculate the total cost of a list of workers.
Args:
workers (List[Worker]): A list of ... |
magic_evol_110k | 82,838 | Write a Python function that converts a given character sequence of numbers into a list of floating-point numbers. The function should handle cases where the input string contains non-numerical characters by ignoring them and only converting valid numerical sequences. The function should start with:
```python
from typi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def string_to_float_list(s: str) -> List[float]:
"""
Converts a given character sequence of numbers into a list of floating-point numbers.
Non-numerical characters in the input string are ignored.
... |
magic_evol_110k | 82,849 | Write a Python function to compute the cumulative sum of all integer values contained in a multi-tiered dictionary. The dictionary may include nested dictionaries, lists, tuples, integer values, and strings. The function should handle circular references and ignore non-integer values such as strings or floating-point n... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Union, List, Tuple, Dict
def cumulative_sum_of_integers(data: Union[Dict, List, Tuple, int, str], seen=None) -> int:
"""
Compute the cumulative sum of all integer values in a multi-tiered dictionary.
Arg... |
magic_evol_110k | 82,853 | Write a Python function to flatten a nested list of arbitrary depth into a single flat list. The function should maintain the sequence of elements as they appear in the original nested list. The function should be able to handle any level of nested lists.
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, Any
def flatten_nested_list(nested_list: List[Any]) -> List[Any]:
"""
Flattens a nested list of arbitrary depth into a single flat list.
Args:
nested_list (List[Any]): The nested list to be... |
magic_evol_110k | 82,854 | Write a Python function to determine if a given string is a palindrome without using any built-in library functions, special characters, or additional data structures. The function should only use basic operations and control structures.
The code should start with:
```python
def is_palindrome(s: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_palindrome(s: str) -> bool:
"""
Determine if a given string is a palindrome without using any built-in library functions,
special characters, or additional data structures.
Args:
s (str): The string to ch... |
magic_evol_110k | 82,869 | Write a Python function to concatenate a list of words into a single string, with each word separated by a specified delimiter. The function should handle an empty list by returning an empty string. The code should start with:
```python
from typing import List
def concatenate_with_delimiter(words: List[str], delimiter... | Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def concatenate_with_delimiter(words: List[str], delimiter: str) -> str:
"""
Concatenates a list of words into a single string, with each word separated by the specified delimiter.
Args:
w... |
magic_evol_110k | 82,888 | Write a Python function to find the largest prime factor of a given integer `n`, which can be both positive and negative. The function should efficiently identify the prime factors and return the largest one. The function should assume that `abs(n) > 1` and `n` is not a prime number.
The code should start with:
```pyt... | Here is the Python code to solve the given problem in the markdown block:
```python
def largest_prime_factor(n: int) -> int:
"""
Return the largest prime factor of both positive and negative n. Assume abs(n) > 1 and is not prime.
Efficiently find the prime factors.
Args:
n (int): The integer wh... |
magic_evol_110k | 82,890 | Write a Python function to generate all possible permutations of N distinct numerical values. Each permutation should be a tuple of integers. The function should return a list of all these permutations.
The code should start with:
```python
from typing import List, Tuple
from itertools import permutations
def generat... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
from itertools import permutations
def generate_all_permutations(N: int) -> List[Tuple[int, ...]]:
"""
Generate all possible permutations of N distinct numerical values.
Args:
N (int)... |
magic_evol_110k | 82,895 | Write a Python function to generate a JSON representation of a person's details, including their name, age, location, occupation, and hobbies. The function should accept these details as parameters and return a JSON string. The code should start with:
```python
import json
def generate_person_json(name: str, age: int,... | Here is the Python code to solve the given problem in the markdown block:
```python
import json
def generate_person_json(name: str, age: int, location: str, occupation: str, hobbies: list) -> str:
"""
Generates a JSON representation of a person's details.
Args:
name (str): The name of the person.
... |
magic_evol_110k | 82,911 | Write a Python function to merge two or more strings into a single string without using the `+` operator. The function should accept a variable number of string arguments and return the merged string. The code should start with:
```python
from typing import List
def merge_strings(*args: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_strings(*args: str) -> str:
"""
Merges multiple strings into a single string without using the '+' operator.
Args:
*args (str): Variable number of string arguments to be merged.
... |
magic_evol_110k | 82,918 | Write a Python function to insert a new element into a sorted array while maintaining the ascending order and considering duplicate elements. The function should optimize for time complexity by using a binary search to find the insertion position.
The code should start with:
```python
from typing import List
def inse... | 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 to find the position where the target should be inserted.
Args:
array (List[int]): The sorted array to se... |
magic_evol_110k | 82,923 | Write a Python function to calculate the product of all prime numbers in a given list of integers. The function should return 1 if there are no prime numbers in the list.
The code should start with:
```python
from typing import List
def product_of_primes(numbers: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_prime(n: int) -> bool:
"""
Check if a number is prime.
Args:
n (int): The number to check for primality.
Returns:
bool: True if the number is prime, False otherwise.
... |
magic_evol_110k | 82,939 | Write a Python function that converts time from 24-hour format to 12-hour format with AM/PM indicators. The function should also handle leap years when converting February 29th and raise appropriate exceptions for invalid inputs. The function should start with:
```python
from datetime import datetime
def convert_to_12... | Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime
def convert_to_12hr(date: str, time: str) -> str:
"""
Converts time from 24-hour format to 12-hour format with AM/PM indicators.
Handles leap years for February 29th and raises exceptions for i... |
magic_evol_110k | 82,952 | Write a Python function to partition a list of integers into two nested lists, where the first list contains all even numbers and the second list contains all odd numbers. Both lists should be sorted in descending order, and the function should handle negative numbers as well. 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 partition_and_sort_list(lst: List[int]) -> List[List[int]]:
"""
Partition a list of integers into two nested lists, the first consisting of even numerals and the subsequent filled with odd numerals.
... |
magic_evol_110k | 82,988 | Write a Python function to modify a given array by replacing elements at indices that are divisible by 3 with the integer 0. The function should return the modified array.
The code should start with:
```python
from typing import List
def replace_elements_at_indices_divisible_by_3(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 replace_elements_at_indices_divisible_by_3(arr: List[int]) -> List[int]:
"""
Modifies the given array by replacing elements at indices divisible by 3 with the integer 0.
Args:
arr (List[... |
magic_evol_110k | 82,991 | Write a Python function that converts a given string into a list of dictionaries, where each dictionary contains the character and its type (number, lowercase alphabet, uppercase alphabet, or special character). The function should handle edge cases and provide detailed error handling.
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, Dict
def identify_and_convert(s: str) -> List[Dict[str, str]]:
"""
Converts a given string into a list of dictionaries, where each dictionary contains the character and its type.
Args:
s (s... |
magic_evol_110k | 82,992 | Write a Python function to sort each sub-array of a multi-dimensional array of floating point numbers in descending order. Each sub-array can be of any length, and the function should return a new multi-dimensional array with each sub-array sorted individually.
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 sort_subarrays_descending(nums: List[List[float]]) -> List[List[float]]:
"""
Sorts each sub-array of a multi-dimensional array of floating point numbers in descending order.
Args:
nums (... |
magic_evol_110k | 83,007 | Write a Python function to count the number of vowels and consonants in a given string. The function should ignore case and non-alphabetic characters. The code should start with:
```python
def count_vowels_and_consonants(s: str) -> tuple:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def count_vowels_and_consonants(s: str) -> tuple:
"""
Counts the number of vowels and consonants in a given string, ignoring case and non-alphabetic characters.
Args:
s (str): The input string to count vowels and co... |
magic_evol_110k | 83,011 | Write a Python function to identify and extract numerical expressions that start with the integer value of 8 from a given list of strings. The function should use a regular expression to match the pattern and return a list of all matched numerical expressions.
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
import re
def extract_numbers_starting_with_8(data: List[str]) -> List[str]:
"""
Extracts and returns a list of numerical expressions that start with the integer value of 8 from the given list of strings... |
magic_evol_110k | 83,019 | Write a Python function to filter and group the given dataset based on specified criteria such as education, job, gender, location, and age. The function should return a dictionary where the keys are the specified criteria and the values are the counts of individuals matching those criteria. The function should handle ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Any
def group_and_count_data(data: List[Dict[str, Any]], criteria: List[str]) -> Dict[str, int]:
"""
Groups and counts the number of individuals in the dataset based on specified criteria.
Ar... |
magic_evol_110k | 83,021 | Write a Python function that constructs a dictionary from a given numerical array, where each element in the array serves as a key, and its corresponding value is determined by a custom function. The custom function should take the element as input and return a value based on a specific transformation. The code should ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Callable
def array_to_dict(arr: List[int], func: Callable[[int], int]) -> Dict[int, int]:
"""
Constructs a dictionary from a given numerical array, where each element in the array
serves as a ... |
magic_evol_110k | 83,025 | Write a Python function to find all prime numbers within a given range from 2 to an upper bound provided by the user. The function should return a list of all prime numbers in that range. The code should start with:
```python
from typing import List
def find_prime_numbers(upper_bound: int) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_prime(n: int) -> bool:
"""
Check if a given number is prime.
Args:
n (int): The number to check for primality.
Returns:
bool: True if the number is prime, False otherwise... |
magic_evol_110k | 83,026 | Write a Python function to count the occurrences of each nitrogenous base in a given RNA sequence. The RNA sequence is represented as a string containing the characters 'A', 'U', 'C', and 'G', which represent Adenine, Uracil, Cytosine, and Guanine, respectively. The function should return a dictionary with the counts o... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_nitrogenous_bases(RNA: str) -> dict:
"""
Counts the occurrences of each nitrogenous base in a given RNA sequence.
Args:
RNA (str): The RNA sequence represented as a string containing the characters 'A', 'U... |
magic_evol_110k | 83,042 | Write a Python function to compute the product of two integers using the distributive property of multiplication. The function should break down the multiplication into simpler steps and then sum the results of these steps to get the final product. The code should start with:
```python
def multiply_using_distribution(a... | Here is the Python code to solve the given problem in the markdown block:
```python
def multiply_using_distribution(a: int, b: int) -> int:
"""
Computes the product of two integers using the distributive property of multiplication.
Args:
a (int): The first integer.
b (int): The second integ... |
magic_evol_110k | 83,044 | Write a Python function to find common elements that appear at the same indices in three given lists. The function should handle lists of different lengths and return common elements up to the length of the shortest list. The function should start with:
```python
from typing import List
def find_common_elements(l1: Li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_common_elements(l1: List[int], l2: List[int], l3: List[int]) -> List[int]:
"""
Finds common elements that appear at the same indices in three given lists.
Args:
l1 (List[int]): The ... |
magic_evol_110k | 83,066 | Write a Python function to validate whether a given string is a valid IPv4 address. An IPv4 address consists of four decimal numbers separated by dots, where each number ranges from 0 to 255. The function should return `True` if the string is a valid IPv4 address and `False` otherwise. The code should start with:
```py... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_valid_ipv4(ip_address: str) -> bool:
"""
Validates whether the given string is a valid IPv4 address.
Args:
ip_address (str): The string to be validated as an IPv4 address.
Returns:
bool: True if ... |
magic_evol_110k | 83,068 | Write a Python function to print a right-angled triangle pattern of stars, where the number of rows is determined by the input parameter `n`. The pattern should start with `n` stars in the first row and decrease by one star per row until the last row has only one star. The function should start with:
```python
def prin... | Here is the Python code to solve the given problem in the markdown block:
```python
def print_star_pattern(n: int) -> None:
"""
Prints a right-angled triangle pattern of stars with `n` rows.
Args:
n (int): The number of rows in the pattern.
Returns:
None: This function does not return ... |
magic_evol_110k | 83,078 | Write a Python function to calculate the sum of elements in a provided list, but with an additional feature: if the list contains any negative numbers, the function should return the sum of the absolute values of those numbers instead. If the list contains no negative numbers, the function should return the sum of all ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_list_with_abs(input_list: List[int]) -> int:
"""
Calculate the sum of elements in a provided list. If the list contains any negative numbers,
return the sum of the absolute values of those nu... |
magic_evol_110k | 83,083 | Write a Python function to perform a bubble sort algorithm on a given list of non-negative integers, arranging the elements in descending order. The function should return the sorted list.
The code should start with:
```python
from typing import List
def bubble_sort_descending(arr: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def bubble_sort_descending(arr: List[int]) -> List[int]:
"""
Sorts a list of non-negative integers in descending order using the bubble sort algorithm.
Args:
arr (List[int]): The list of non... |
magic_evol_110k | 83,086 | Write a Python function to sort a 3D numeric matrix using the Quick Sort algorithm. The matrix is a 2x2x5 array of floating-point numbers. The function should flatten the matrix, sort it using Quick Sort, and then reshape it back to its original 3D form.
The code should start with:
```python
import numpy as np
import ... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
import random
def quick_sort(arr):
"""
Sorts a list of numbers using the Quick Sort algorithm.
Args:
arr (list): The list of numbers to be sorted.
Returns:
list: The sorted list of n... |
magic_evol_110k | 83,088 | Write a Python function to filter items from a list based on a complex predicate function that implements multiple logic stages. The predicate function should check if an item is positive, divisible by 2, and divisible by 3. The function should start with:
```python
from typing import List, Callable
def filter_items(l... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Callable
def filter_items(lst: List[int], pred_fn: Callable[[int], bool]) -> List[int]:
"""
Filters items from the given list based on the provided predicate function.
Args:
lst (List[int])... |
magic_evol_110k | 83,100 | Write a Python function to flatten a given bi-dimensional array (a list of lists) into a single-dimensional list. The function should take a list of lists as input and return a single list containing all the elements from the input list of lists in the same order.
The code should start with:
```python
from typing impo... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def flatten_bi_dimensional_array(bi_dimensional_array: List[List[any]]) -> List[any]:
"""
Flattens a bi-dimensional array (a list of lists) into a single-dimensional list.
Args:
bi_dimension... |
magic_evol_110k | 83,102 | Write a Python function to remove all recurring elements from a given list while preserving the order of the first occurrence of each element. The function should be efficient and should handle lists of various sizes. The code should start with:
```python
from typing import List
def remove_duplicates_preserve_order(in... | 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 all recurring elements from the given list while preserving the order of the first occurrence of each element.
A... |
magic_evol_110k | 83,104 | Write a Python function to determine the number of ways to climb a staircase with `n` steps, where you can take either 1 or 2 steps at a time. The function should return the total number of distinct ways to reach the top of the staircase.
The code should start with:
```python
def climb_stairs(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def climb_stairs(n: int) -> int:
"""
Calculate the number of ways to climb a staircase with n steps, where you can take either 1 or 2 steps at a time.
Args:
n (int): The number of steps in the staircase.
Return... |
magic_evol_110k | 83,108 | Write a Python function to validate the symmetry of parentheses in a given input string. The function should ensure that each opening parenthesis has a corresponding closing parenthesis and vice versa. The function should return `True` if the parentheses are balanced and `False` otherwise. The code should start with:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_parentheses_balanced(s: str) -> bool:
"""
Validates the symmetry of parentheses in a given input string.
Args:
s (str): The input string containing parentheses to be validated.
Returns:
bool: Tru... |
magic_evol_110k | 83,109 | Write a Python function to calculate the sum of all elements in a given square matrix. A square matrix is a matrix where the number of rows is equal to the number of columns. The function should handle matrices of any size, including 0x0 matrices.
The code should start with:
```python
from typing import List
def sum_... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_of_matrix_elements(matrix: List[List[int]]) -> int:
"""
Calculate the sum of all elements in a given square matrix.
Args:
matrix (List[List[int]]): A square matrix represented as a l... |
magic_evol_110k | 83,113 | Write a Python function to find the number with the minimum absolute value from a given list of nonpositive integers. The function should return both the minimum absolute value and the corresponding number from the list.
The code should start with:
```python
from typing import List, Tuple
def find_min_abs_value(numbe... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_min_abs_value(numbers: List[int]) -> Tuple[int, int]:
"""
Find the number with the minimum absolute value from a list of nonpositive integers.
Args:
numbers (List[int]): A li... |
magic_evol_110k | 83,118 | Write a Python function to count the number of alphabetic characters, numerical digits, and special characters (excluding spaces) in a given string. The function should return a tuple containing these counts in the order: alphabetic characters, numerical digits, and special characters.
The code should start with:
```p... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_character_types(s: str) -> tuple:
"""
Counts the number of alphabetic characters, numerical digits, and special characters (excluding spaces) in a given string.
Args:
s (str): The input string to analyze.
... |
magic_evol_110k | 83,125 | Write a Python function that determines if a given integer is positive or negative using the ternary operator. The function should return a string indicating "positive" if the integer is greater than zero, and "negative" otherwise.
The code should start with:
```python
def check_sign(value: int) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def check_sign(value: int) -> str:
"""
Determines if the given integer is positive or negative using the ternary operator.
Args:
value (int): The integer to check.
Returns:
str: A string indicating "pos... |
magic_evol_110k | 83,127 | Write a Python function to remove the k-th element from a given list and return the modified list. The function should handle cases where `k` is out of bounds (i.e., less than 0 or greater than or equal to the length of the list) by returning the original list unchanged. The function should start with:
```python
from t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_kth_element(arr: List[int], k: int) -> List[int]:
"""
Removes the k-th element from the given list and returns the modified list.
If k is out of bounds, the original list is returned uncha... |
magic_evol_110k | 83,138 | Write a Python function to find the shared elements between two given lists and calculate their frequencies in both lists. The function should return a dictionary where the keys are the shared elements, and the values are dictionaries containing the frequency of each element in both lists.
The code should start with:
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def find_shared_elements(arr1: List[int], arr2: List[int]) -> Dict[int, Dict[str, int]]:
"""
Find the shared elements between two lists and calculate their frequencies in both lists.
Args:
... |
magic_evol_110k | 83,144 | Write a Python function to find the maximum and minimum values in a given list of integers. The function should return a tuple containing the maximum value and the minimum value in the list. The code should start with:
```python
from typing import List, Tuple
def find_max_min(lst: List[int]) -> Tuple[int, int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Optional
def find_max_min(lst: List[int]) -> Optional[Tuple[int, int]]:
"""
Find the maximum and minimum values in a given list of integers.
Args:
lst (List[int]): The list of intege... |
magic_evol_110k | 83,146 | Write a Python function to debug and resolve the error in the given code snippet. The function should identify and correct the erroneous line, and then print the message "Welcome!" followed by "Hello, World!" and again "Welcome!". The function should also return a string explaining the purpose of the erroneous line.
T... | Here is the Python code to solve the given problem in the markdown block:
```python
def debug_and_print_message() -> str:
"""
Debugs and resolves the error in the given code snippet, prints the messages,
and returns a string explaining the purpose of the erroneous line.
Returns:
str: A string e... |
magic_evol_110k | 83,162 | Write a Python function to perform numerical subtraction between two given numbers. The function should handle both positive and negative numbers, as well as zero. The code should start with:
```python
def subtract_two_numbers(a: float, b: float) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def subtract_two_numbers(a: float, b: float) -> float:
"""
Perform numerical subtraction between two given numbers.
Args:
a (float): The first number.
b (float): The second number.
Returns:
floa... |
magic_evol_110k | 83,190 | Write a Python function to determine if a given integer `x` is a prime number. The function should return `True` if `x` is a prime number and `False` otherwise. The function should handle edge cases such as `x` being less than 2, which are not prime numbers.
The code should start with:
```python
def is_prime(x: int) -... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_prime(x: int) -> bool:
"""
Determine if a given integer `x` is a prime number.
Args:
x (int): The integer to check for primality.
Returns:
bool: True if `x` is a prime number, False otherwise.
... |
magic_evol_110k | 83,194 | Write a Python function to count the occurrences of a specified whole number in a given list of whole numbers. The function should be efficient and handle various edge cases, such as an empty list or a number that does not appear in the list. The code should start with:
```python
from typing import List
def count_occu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_occurrences(lst: List[int], num: int) -> int:
"""
Counts the occurrences of a specified whole number in a given list of whole numbers.
Args:
lst (List[int]): The list of whole numb... |
magic_evol_110k | 83,197 | Write a Python function to determine if all elements in a given list are identical. The function should return `True` if all elements are the same, and `False` otherwise. The code should start with:
```python
from typing import List
def all_elements_identical(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_identical(arr: List[int]) -> bool:
"""
Determines if all elements in the given list are identical.
Args:
arr (List[int]): The list of integers to check.
Returns:
... |
magic_evol_110k | 83,201 | Write a Python function to identify all distinct alphabetical elements present in a couple of alphanumeric sequences. The function should return a sorted list of these distinct alphabetical elements. The function should handle both uppercase and lowercase letters, treating them as distinct.
The code should start with:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_distinct_alphabets(string1: str, string2: str) -> List[str]:
"""
Identify all distinct alphabetical elements present in two alphanumeric sequences.
Args:
string1 (str): The first al... |
magic_evol_110k | 83,208 | Write a Python function to find the 3rd largest distinct number in a given array of integers. If there are fewer than 3 distinct numbers, the function should return the largest number. The function should optimize time complexity and space complexity by avoiding sorting the array. 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
import heapq
def find_3rd_largest_distinct(nums: List[int]) -> int:
"""
Finds the 3rd largest distinct number in a given array of integers.
If there are fewer than 3 distinct numbers, returns the lar... |
magic_evol_110k | 83,222 | Write a Python function to sort an array in ascending order using the merge sort algorithm. The function should take a list of integers as input and return the sorted list. The merge sort algorithm should be implemented from scratch without using Python's built-in sorting functions.
The code should start with:
```pyth... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_sort(arr: List[int]) -> List[int]:
"""
Sorts an array in ascending order using the merge sort algorithm.
Args:
arr (List[int]): The array to be sorted.
Returns:
List[i... |
magic_evol_110k | 83,224 | Write a Python function to create a new series where each element in the given series (a list of non-recurring integers) is multiplied by a constant value of 2. The function should return the new series.
The code should start with:
```python
from typing import List
def multiply_series_by_two(series: List[int]) -> Lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def multiply_series_by_two(series: List[int]) -> List[int]:
"""
Creates a new series where each element in the given series is multiplied by 2.
Args:
series (List[int]): The input series, a ... |
magic_evol_110k | 83,231 | Write a Python function to filter a list of words based on their length and their presence in a given lexicon. The function should return a list of words that are longer than five characters and are found in the provided lexicon.
The code should start with:
```python
from typing import List
def filter_words(input_lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_words(input_list: List[str], lexicon: List[str]) -> List[str]:
"""
Filters a list of words based on their length and their presence in a given lexicon.
Args:
input_list (List[str]... |
magic_evol_110k | 83,236 | Write a Python function that demonstrates the behavior of the "else" clause within a "for" loop. The function should iterate over a given list and check for a specific condition. If the condition is met, the loop should break. If the loop completes without breaking, the "else" clause should execute, indicating that the... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def check_condition_and_loop_end(items: List[int], condition: int) -> str:
"""
Iterates over a list of integers and checks if any item matches a specified condition.
If an item matches the condition,... |
magic_evol_110k | 83,245 | Write a Python function to verify the primality of an integer using the Sieve of Eratosthenes algorithm. The function should return `True` if the integer is prime and `False` otherwise. Additionally, the function should be optimized to handle large integers efficiently.
The code should start with:
```python
def is_pri... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_prime(n: int) -> bool:
"""
Verify the primality of an integer using the Sieve of Eratosthenes algorithm.
Args:
n (int): The integer to check for primality.
Returns:
bool: True if n is a prime num... |
magic_evol_110k | 83,264 | Write a Python function to generate an array of random integers within a specific range and of a specified length. The function should ensure that the generated integers fall within the given range and the array length matches the specified length. The code should start with:
```python
from typing import List
import ra... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_random_array(min_value: int, max_value: int, length: int) -> List[int]:
"""
Generates an array of random integers within a specified range and of a specified length.
Args:... |
magic_evol_110k | 83,267 | Write a Python function to transform a specific element within a given list using a provided transformation function. The function should handle cases where the index is out of bounds by printing an error message and returning the original list. The function should also handle any other exceptions that might occur duri... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Callable
def transform_element(input_list: List, index: int, transformation: Callable) -> List:
"""
Transforms the element at the specified index within the input list using the provided transformation ... |
magic_evol_110k | 83,275 | Write a Python function to find the divisor given a dividend and a quotient. The function should return the divisor that makes the equation `dividend / divisor = quotient` valid. The code should start with:
```python
def find_divisor(dividend: int, quotient: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def find_divisor(dividend: int, quotient: int) -> int:
"""
Find the divisor that makes the equation `dividend / divisor = quotient` valid.
Args:
dividend (int): The dividend in the equation.
quotient (int): ... |
magic_evol_110k | 83,276 | Write a Python function to compute the value of `Q(n)` as defined in the given problem statement. The function should calculate the sum of `E(904961, i)` for `i` ranging from 1 to `n`, where `E(m, n)` is the greatest integer `k` such that `2^k` divides `S((p_m#)^n)`, and `S(n)` is the count of unique pairs `(a, b)` of ... | Here is the Python code to solve the given problem in the markdown block:
```python
def compute_Q(n: int) -> int:
"""
Compute the value of Q(n) as defined in the problem statement.
Args:
n (int): The upper limit for the summation of E(904961, i) from i=1 to n.
Returns:
int: The compute... |
magic_evol_110k | 83,288 | Write a Python function to find the minimum value in each sub-array of a list of arrays. The function should return a list containing the minimum value from each sub-array. The function should handle empty sub-arrays by returning `None` for those sub-arrays.
The code should start with:
```python
from typing import Lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def find_min_values(arrays: List[List[int]]) -> List[Optional[int]]:
"""
Find the minimum value in each sub-array of a list of arrays.
Args:
arrays (List[List[int]]): A list of arr... |
magic_evol_110k | 83,292 | Write a Python function to determine if the digits of a second numerical string (`num_str2`) appear in the same sequential order within a first numerical string (`num_str1`). The function should return `True` if the sequence of digits in `num_str2` is maintained in `num_str1`, and `False` otherwise.
The code should st... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_sequence_maintained(num_str1: str, num_str2: str) -> bool:
"""
Determines if the digits of num_str2 appear in the same sequential order within num_str1.
Args:
num_str1 (str): The first numerical string.
... |
magic_evol_110k | 83,319 | Write a Python function to traverse a list and print the squares of each element to the console, skipping any element that is a prime number. The function should use a single `while` loop for traversal. The code should start with:
```python
from typing import List
def print_squares_skip_primes(lst: List[int]) -> None:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_prime(n: int) -> bool:
"""
Check if a number is prime.
Args:
n (int): The number to check.
Returns:
bool: True if the number is prime, False otherwise.
"""
if n <... |
magic_evol_110k | 83,321 | Write a Python function to identify and return the four primitive types that are fundamental to the Java programming language. The function should return a dictionary where the keys are the names of the primitive types and the values are their corresponding descriptions. The descriptions should include the data structu... | Here is the Python code to solve the given problem in the markdown block:
```python
def identify_java_primitive_types() -> dict:
"""
Identify and return the four fundamental primitive types in Java along with their descriptions.
Returns:
dict: A dictionary where the keys are the names of the primit... |
magic_evol_110k | 83,333 | Write a Python function to remove duplicate elements from a given list while preserving the order of the first occurrence of each element. The function should take a list of elements as input and return a new list with duplicates removed. The code should start with:
```python
from typing import List
def remove_duplica... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_duplicates_preserve_order(elements_list: List) -> List:
"""
Removes duplicate elements from the given list while preserving the order of the first occurrence of each element.
Args:
... |
magic_evol_110k | 83,336 | Write a Python function to calculate and return the total number of rows in a given DataFrame. The function should handle DataFrames of varying sizes and structures. 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 and return the total number of rows in a given DataFrame.
Args:
df (pd.DataFrame): The DataFrame for which to count the rows.
Returns:... |
magic_evol_110k | 83,346 | Write a Python function to determine whether a given numeric value is a palindrome. A palindrome is a number that reads the same backward as forward. The function should handle both positive and negative integers.
The code should start with:
```python
def is_palindrome_number(n: int) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_palindrome_number(n: int) -> bool:
"""
Determine whether a given numeric value is a palindrome.
Args:
n (int): The numeric value to check for palindrome characteristics.
Returns:
bool: True if th... |
magic_evol_110k | 83,350 | Write a Python function to filter and sort students based on given criteria. The function should take a dictionary of students where each key is a student's name and the value is a tuple containing the student's height, weight, age, GPA, and number of absences. Additionally, the function should take minimum acceptable ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Tuple, List
def filter_and_sort_students(students: Dict[str, Tuple[float, float, float, float, float]], min_height: float, min_weight: float, min_age: float, min_gpa: float, max_absences: float) -> List[Tuple[s... |
magic_evol_110k | 83,351 | Write a Python function to calculate the cumulative product of all integers in a supplied list. The function should handle lists of varying lengths, including empty lists, and should return the cumulative product of the elements. The code should start with:
```python
from typing import List
def cumulative_product(numb... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def cumulative_product(numbers: List[int]) -> int:
"""
Calculate the cumulative product of all integers in a supplied list.
Args:
numbers (List[int]): A list of integers for which the cumula... |
magic_evol_110k | 83,362 | Write a Python function to find the single number in a non-empty array of integers where every element appears three times except for one, which appears exactly once. The function should have a linear runtime complexity and should not use extra memory. 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_single_number(nums: List[int]) -> int:
"""
Find the single number in a non-empty array of integers where every element appears three times except for one.
Args:
nums (List[int]): A ... |
magic_evol_110k | 83,379 | Write a Python function that takes three parameters: a text string, a list of elements, and a separator punctuation. The function should return a single string where each element from the list is prefixed by the text string and separated by the provided punctuation.
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
def format_list_with_prefix(text_prefix: str, elements: List[str], separator: str) -> str:
"""
Formats a list of elements by prefixing each element with a given text string and separating them with a spe... |
magic_evol_110k | 83,385 | Write a Python function to count the occurrences of each letter in a given sentence, ignoring case and counting non-alphanumeric characters. The function should handle sentences with a length up to 5000 characters.
The code should start with:
```python
from collections import defaultdict
from typing import Dict
def c... | Here is the Python code to solve the given problem in the markdown block:
```python
from collections import defaultdict
from typing import Dict
def count_letter_occurrences(sentence: str) -> Dict[str, int]:
"""
Count the occurrences of each letter in a given sentence, ignoring case and counting non-alphanumeri... |
magic_evol_110k | 83,396 | Write a Python function to calculate 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 rows ... |
magic_evol_110k | 83,398 | Write a Python function to generate the first 'n' numbers from the Lucas sequence, which is a sequence of integers defined by the recurrence relation: L(n) = L(n-1) + L(n-2) with the initial terms L(0) = 2 and L(1) = 1. The function should handle cases where 'n' is less than or equal to 0 by returning an empty list.
T... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_lucas_sequence(n: int) -> List[int]:
"""
Generate the first 'n' numbers from the Lucas sequence.
The Lucas sequence is defined by the recurrence relation:
L(n) = L(n-1) + L(n-2) wit... |
magic_evol_110k | 83,421 | Write a Python function to safely add an integer and a string representing an integer, and concatenate an integer and a string. The function should handle the conversion and concatenation operations correctly.
The code should start with:
```python
def safe_add_and_concat(x: int, y: str) -> tuple:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def safe_add_and_concat(x: int, y: str) -> tuple:
"""
Safely adds an integer and a string representing an integer, and concatenates an integer and a string.
Args:
x (int): The integer to be added and concatenated.
... |
magic_evol_110k | 83,460 | Write a Python function to arrange a list of numerical elements in a hierarchical sequence, starting from the smallest node and incrementally progressing to the largest node. The function should return the sorted list.
The code should start with:
```python
from typing import List
def hierarchical_sort(elements: List[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def hierarchical_sort(elements: List[int]) -> List[int]:
"""
Sorts a list of numerical elements in ascending order, creating a hierarchical sequence from the smallest to the largest node.
Args:
... |
magic_evol_110k | 83,466 | Write a Python function to calculate and return the residue (remainder) of the division operation between two integers `x` and `y`. The function should handle potential errors, such as division by zero. The code should start with:
```python
def calculate_residue(x: int, y: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_residue(x: int, y: int) -> int:
"""
Calculate the residue (remainder) of the division operation between two integers x and y.
Args:
x (int): The dividend, an integer in the range [-10^4, 10^4].
... |
magic_evol_110k | 83,471 | Write a Python function to compute the median of a provided multidimensional array of numbers. The function should be able to process 2D and 3D arrays efficiently. The code should start with:
```python
from typing import List
def compute_median(data: List[List[List[int]]]) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def compute_median(data: List[List[List[int]]]) -> float:
"""
Computes the median of a provided multidimensional array of numbers.
Args:
data (List[List[List[int]]]): A multidimensional arra... |
magic_evol_110k | 83,497 | Write a Python function to generate a list containing all multiples of 3 from 0 to a given number `n` using list comprehension. The function should be optimized for performance and readability.
The code should start with:
```python
from typing import List
def multiples_of_3(n: int) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def multiples_of_3(n: int) -> List[int]:
"""
Generate a list containing all multiples of 3 from 0 to the given number n.
Args:
n (int): The upper limit (inclusive) for the multiples of 3.
... |
magic_evol_110k | 83,504 | Write a Python function to calculate the least common multiple (LCM) of two given integers `x` and `y`. The function should validate that both `x` and `y` are positive integers within the range of 1 to 1000. If the validation fails, the function should raise a `ValueError`. The function should start with:
```python
imp... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def lowest_common_multiple(x: int, y: int) -> int:
"""
Calculate the least common multiple (LCM) of two integers x and y.
Args:
x (int): The first integer, must be in the range [1, 1000].
y (int... |
magic_evol_110k | 83,506 | Write a Python function to determine and print the type of each element in a given list. The function should correctly identify and print "integer", "string", or "float" for each element in the list. The code should start with:
```python
from typing import List
def print_element_types(elements: List) -> None:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def print_element_types(elements: List) -> None:
"""
Prints the type of each element in the given list.
Args:
elements (List): The list of elements whose types need to be determined.
Re... |
magic_evol_110k | 83,509 | Write a Python function that executes a loop for a range of 10 numbers, incorporates a counter to keep track of the number of iterations, and prints the iteration number along with the current number in each iteration. The function should start with:
```python
def loop_with_counter():
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def loop_with_counter():
"""
Executes a loop for a range of 10 numbers, incorporates a counter to keep track of the number of iterations,
and prints the iteration number along with the current number in each iteration.
... |
magic_evol_110k | 83,510 | Write a Python function to find the index of the first occurrence of a given element in a sorted array using a modified binary search algorithm. The function should handle arrays with duplicate values and return the index of the first occurrence of the target value. The function should not use any built-in methods for ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_first_occurrence(arr: List[int], target: int) -> int:
"""
Find the index of the first occurrence of a target element in a sorted array.
Args:
arr (List[int]): The sorted array to se... |
magic_evol_110k | 83,511 | Write a Python function to find the maximum number in a list of integers and its positional index efficiently. The function should handle both small and large datasets optimally. The code should start with:
```python
from typing import List, Tuple
def find_max_and_index(lst: List[int]) -> Tuple[int, int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Optional
def find_max_and_index(lst: List[int]) -> Optional[Tuple[int, int]]:
"""
Find the maximum number in a list of integers and its positional index efficiently.
Args:
lst (List[... |
magic_evol_110k | 83,515 | Write a Python function to generate a list of all prime numbers up to and including a given integer `n`. The function should efficiently determine whether each number in the range is prime by checking divisibility up to the square root of the number.
The code should start with:
```python
from typing import List
def g... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_primes(n: int) -> List[int]:
"""
Generate a list of all prime numbers up to and including the given integer n.
Args:
n (int): The upper limit for generating prime numbers.
... |
magic_evol_110k | 83,522 | Write a Python function to determine if two strings contain the same characters in the same quantities, considering case sensitivity. The function should return `True` if the two strings are anagrams of each other, and `False` otherwise. The code should start with:
```python
def are_anagrams(s1: str, s2: str) -> bool:
... | Here is the Python code to solve the given problem in the markdown block:
```python
def are_anagrams(s1: str, s2: str) -> bool:
"""
Determines if two strings are anagrams of each other, considering case sensitivity.
Args:
s1 (str): The first string to compare.
s2 (str): The second string to... |
magic_evol_110k | 83,526 | Write a Python function to find the intersection of two lists, i.e., the elements that are present in both lists. The function should return a list containing the intersection elements in ascending order. The code should start with:
```python
from typing import List
def find_intersection(list1: List[int], list2: List[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_intersection(list1: List[int], list2: List[int]) -> List[int]:
"""
Finds the intersection of two lists and returns the common elements in ascending order.
Args:
list1 (List[int]): T... |
magic_evol_110k | 83,549 | Write a Python function to generate the Fibonacci sequence up to the nth term. The function should return a list containing the Fibonacci sequence. The code should start with:
```python
from typing import List
def fibonacci_sequence(n: int) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def fibonacci_sequence(n: int) -> List[int]:
"""
Generate the Fibonacci sequence up to the nth term.
Args:
n (int): The number of terms in the Fibonacci sequence to generate.
Returns:
... |
magic_evol_110k | 83,556 | Write a Python function to integrate two novel constituents at the initial position of an existing array without altering the sequential order of the remaining elements. The function should take three parameters: the original list, the first novel constituent, and the second novel constituent. The function should retur... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def integrate_novel_constituents(original_list: List[str], first_novel: str, second_novel: str) -> List[str]:
"""
Integrates two novel constituents at the initial position of an existing array without al... |
magic_evol_110k | 83,579 | Write a Python function to calculate the sum of the elements in a given array using a divide-and-conquer approach. The function should recursively divide the array into smaller subarrays until the base case (a single element) is reached, then sum the elements of these subarrays and combine the results.
The code should... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_array_divide_and_conquer(arr: List[int]) -> int:
"""
Calculate the sum of the elements in a given array using a divide-and-conquer approach.
Args:
arr (List[int]): The array of integ... |
magic_evol_110k | 83,585 | Write a Python function to calculate the factorial of a given non-negative integer `n`. The function should handle edge cases such as `n = 0` and `n = 1` correctly. The code should start with:
```python
def factorial(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def factorial(n: int) -> int:
"""
Calculate the factorial of a given non-negative integer n.
Args:
n (int): The non-negative integer for which to calculate the factorial.
Returns:
int: The factorial of ... |
magic_evol_110k | 83,586 | Write a Python function to swap all occurrences of two given values in a list. The function should take a list and two values as input and return a new list with all occurrences of the first value replaced by the second value and vice versa.
The code should start with:
```python
from typing import List
def swap_value... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def swap_values(lst: List[int], val1: int, val2: int) -> List[int]:
"""
Swaps all occurrences of two given values in a list.
Args:
lst (List[int]): The list in which to swap the values.
... |
magic_evol_110k | 83,587 | Write a Python function to calculate the factorial of a given number using an iterative approach. Additionally, optimize the function to reduce the time complexity by using a more efficient method. The function should handle edge cases such as negative numbers and zero.
The code should start with:
```python
def factor... | 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 using an iterative approach.
Args:
n (int): The non-negative integer for which to calculate the factorial.
Ret... |
magic_evol_110k | 83,612 | Write a Python function to monitor a sequence of deposit and withdrawal transactions starting with a zero balance. The function should detect if the account balance ever falls below zero or exceeds a predefined balance limit. If such a situation occurs, the function should return `True`; otherwise, it should return `Fa... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def below_zero(operations: List[Union[int, float]], handle_float: bool = False, balance_limit: int = 10) -> bool:
"""
Monitors a sequence of deposit and withdrawal transactions starting with a zer... |
magic_evol_110k | 83,624 | Write a Python function to dissect a given textual string into its individual lexical components (words) and return them as a list. The function should handle various delimiters such as spaces, commas, periods, and other punctuation marks. The function should also handle multiple consecutive delimiters by treating them... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def split_text_into_lexical_components(text: str) -> List[str]:
"""
Dissects a given textual string into its individual lexical components (words) and returns them as a list.
Args:
... |
magic_evol_110k | 83,645 | Write a Python function to process a given corpus of text by removing all characters that are not alphanumeric. The function should return the processed text as a string. The code should start with:
```python
import re
def remove_non_alphanumeric(text: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def remove_non_alphanumeric(text: str) -> str:
"""
Removes all non-alphanumeric characters from the given text.
Args:
text (str): The input text from which non-alphanumeric characters will be removed.
... |
magic_evol_110k | 83,648 | Write a Python function to add a dot ('.') as the thousands separator to a given integer `n` and return it in string format. The dot should be added from right to left, and the first group from the right may contain less than three digits. Additionally, implement a function that can remove the dots from the string and ... | Here is the Python code to solve the given problem in the markdown block:
```python
def add_thousand_separator(n: int) -> str:
"""
Adds a dot ('.') as the thousands separator to the given integer `n` and returns it in string format.
Args:
n (int): The integer to which the thousands separator should... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.