source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
magic_evol_110k | 105,049 | Write a Python function to calculate Cohen's d for the fixed effects in a mixed effects model. The function should take the fixed effects coefficients and the residual standard deviation as inputs and return the Cohen's d for each fixed effect.
The code should start with:
```python
from typing import List, Tuple
def ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def calculate_cohens_d(fixed_effects: List[float], residual_std_dev: float) -> List[float]:
"""
Calculate Cohen's d for the fixed effects in a mixed effects model.
Args:
fixed_effects... |
magic_evol_110k | 105,055 | Write a Python function to generate a table that enumerates the first ten non-negative integers along with their cubes and fourth powers. The function should return a list of tuples, where each tuple contains an integer, its cube, and its fourth power. Additionally, write a function to compare the growth rates of cubes... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def generate_table() -> List[Tuple[int, int, int]]:
"""
Generate a table of the first ten non-negative integers along with their cubes and fourth powers.
Returns:
List[Tuple[int, int,... |
magic_evol_110k | 105,061 | Write a Python function to find the maximum value in a given list of integers. The function should handle an empty list by returning `None`. The code should start with:
```python
from typing import List, Optional
def find_max_value(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_max_value(arr: List[int]) -> Optional[int]:
"""
Find the maximum value in a given list of integers.
Args:
arr (List[int]): The list of integers from which to find the maxi... |
magic_evol_110k | 105,086 | Write a Python function to find the length of the longest increasing subsequence (LIS) in a given sequence of integers. The function should return the length of the LIS.
The code should start with:
```python
from typing import List
def longest_increasing_subsequence(sequence: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def longest_increasing_subsequence(sequence: List[int]) -> int:
"""
Calculate the length of the longest increasing subsequence in a given sequence of integers.
Args:
sequence (List[int]): Th... |
magic_evol_110k | 105,098 | Write a Python function to perform a bitwise operation involving two given integers `iota` and `kappa` using both shift and bitwise operators, and validate whether the result of the operation matches a given integer `lambda_val`. The function should return a boolean indicating whether the result matches `lambda_val`.
... | Here is the Python code to solve the given problem in the markdown block:
```python
def validate_bitwise_operation(iota: int, kappa: int, lambda_val: int) -> bool:
"""
Perform a bitwise operation involving `iota` and `kappa` using shift and bitwise operators,
and validate whether the result matches `lambda_... |
magic_evol_110k | 105,105 | Write a Python function to calculate the mean of a given list of real numbers. The function should handle lists with zero elements by returning `None` and should ensure that the input list contains only numeric values. The code should start with:
```python
from typing import List, Union
def calculate_mean(array: List[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def calculate_mean(array: List[Union[int, float]]) -> Union[float, None]:
"""
Calculate the mean of a given list of real numbers.
Args:
array (List[Union[int, float]]): A list of real... |
magic_evol_110k | 105,123 | Write a Python function to convert a given hexadecimal numeral, represented as a string, into its corresponding decimal notation. The function should handle both uppercase and lowercase hexadecimal characters and should return the decimal value as an integer.
The code should start with:
```python
def hex_to_decimal(he... | Here is the Python code to solve the given problem in the markdown block:
```python
def hex_to_decimal(hex_value: str) -> int:
"""
Convert a given hexadecimal numeral, represented as a string, into its corresponding decimal notation.
Args:
hex_value (str): The hexadecimal numeral to be converted. I... |
magic_evol_110k | 105,126 | Write a Python function to append '5' to each integer within a given list, while leaving non-integer elements unchanged. The function should handle the input list in a way that avoids modifying the original list and ensures that the appended '5' is a string. 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, Union
def append_five_to_integers(lst: List[Union[int, str]]) -> List[Union[int, str]]:
"""
Append '5' to each integer within the given list, while leaving non-integer elements unchanged.
Args:
... |
magic_evol_110k | 105,127 | Write a Python function to determine the greatest common divisor (GCD) of two given whole numbers using the Euclidean algorithm. The function should be able to handle both positive and negative integers. The code should start with:
```python
def gcd(a: int, b: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def gcd(a: int, b: int) -> int:
"""
Calculate the greatest common divisor (GCD) of two integers using the Euclidean algorithm.
Args:
a (int): The first integer.
b (int): The second integer.
Returns:
... |
magic_evol_110k | 105,130 | Write a Python function to optimize an array based on the following conditions:
- If an element is less than 50, it should be replaced with 50.
- If an element is greater than or equal to 50, it should be replaced with 100.
The function should start with:
```python
from typing import List
def optimize_array(arr: List... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def optimize_array(arr: List[int]) -> List[int]:
"""
Optimizes the given array based on the following conditions:
- If an element is less than 50, it is replaced with 50.
- If an element is great... |
magic_evol_110k | 105,134 | Write a Python function to remove all duplicate integers from a given list while preserving the original order of the elements. The function should take a list of integers as input and return a new list with all duplicates removed. The code should start with:
```python
from typing import List
def remove_duplicates(arr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_duplicates(arr: List[int]) -> List[int]:
"""
Removes all duplicate integers from the given list while preserving the original order of elements.
Args:
arr (List[int]): The list of... |
magic_evol_110k | 105,141 | Write a Python function to determine if the account balance ever dips below zero during a series of monetary transactions. Each transaction is represented by an integer in a list, where positive integers indicate deposits and negative integers indicate withdrawals. The function should return `True` if the balance ever ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def below_zero(operations: List[int]) -> bool:
"""
Determines if the account balance ever dips below zero during a series of monetary transactions.
Args:
operations (List[int]): A list of in... |
magic_evol_110k | 105,150 | Write a Python function to implement a binary search algorithm on a sorted array with duplicate elements. The function should return the index of the first occurrence of the target element. If the target element is not found, the function should return -1.
The code should start with:
```python
from typing import List
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def binary_search_first_occurrence(arr: List[int], target: int) -> int:
"""
Implements a binary search algorithm to find the index of the first occurrence of the target element in a sorted array with dup... |
magic_evol_110k | 105,165 | Write a Python function to find the longest substring without repeating characters in a given string. The function should handle large strings efficiently and include error checking for invalid inputs such as non-string types and empty strings. The code should start with:
```python
def longest_substring_without_repeats... | Here is the Python code to solve the given problem in the markdown block:
```python
def longest_substring_without_repeats(string: str) -> str:
"""
Finds the longest substring without repeating characters in the given string.
Args:
string (str): The input string to search for the longest substring w... |
magic_evol_110k | 105,172 | Write a Python function to find the two most distant elements within a given array of floating point numbers. The function should return these two elements in ascending order (minor, major). The array will always contain at least two elements.
The code should start with:
```python
from typing import List, Tuple
def f... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_furthest_elements(numbers: List[float]) -> Tuple[float, float]:
"""
Find the two most distant elements in the given array of floating point numbers and return them in ascending order.
... |
magic_evol_110k | 105,178 | Write a Python function to perform the arithmetic operation of subtraction by deducting the second parameter from the first one. The function should handle both integer and floating-point numbers. The code should start with:
```python
def subtract_numbers(a: float, b: float) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def subtract_numbers(a: float, b: float) -> float:
"""
Perform the arithmetic operation of subtraction by deducting the second parameter from the first one.
Args:
a (float): The first numerical parameter.
b ... |
magic_evol_110k | 105,190 | Write a Python function to factorize a given integer `n` into its distinct prime factors and their respective exponents. The function should return a list of tuples where each tuple contains a prime factor and its exponent. The function should have a time complexity no greater than O(sqrt(n)) and a space complexity no ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import math
def factorize(n: int) -> List[Tuple[int, int]]:
"""
Factorizes the given integer n into its distinct prime factors and their respective exponents.
Args:
n (int): The integ... |
magic_evol_110k | 105,205 | Write a Python function to calculate the power of a base number raised to an exponent, without using the built-in power function or any external libraries. The function should handle both positive and negative exponents using only basic arithmetic operations (+, -, *, /). The code should start with:
```python
def power... | Here is the Python code to solve the given problem in the markdown block:
```python
def power(base: float, exponent: int) -> float:
"""
Calculate the power of a base number raised to an exponent using only basic arithmetic operations.
Args:
base (float): The base number.
exponent (int): The... |
magic_evol_110k | 105,207 | Write a Python function to iterate over the items in a dictionary and correct erroneous entries where the value is not an integer. The dictionary maps fruits to quantities, but due to an error, some quantities might be represented as strings instead of integers. Your function should convert such quantities to integers ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def correct_fruit_quantities(fruit_dict: Dict[str, str]) -> Dict[str, int]:
"""
Corrects the quantities in a dictionary of fruits by converting string values to integers.
If a value cannot be convert... |
magic_evol_110k | 105,215 | Write a Python function to sort an array of integer quantities in descending order. The function should take a list of integers as input and return a new list with the same integers sorted from the largest to the smallest.
The code should start with:
```python
from typing import List
def sort_descending(arr: List[int... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_descending(arr: List[int]) -> List[int]:
"""
Sorts an array of integer quantities in descending order.
Args:
arr (List[int]): The list of integers to be sorted.
Returns:
... |
magic_evol_110k | 105,217 | Write a Python function to determine the maximum number of uncrossed lines that can be drawn between two arrays `A` and `B`. Each line connects two numbers `A[i]` and `B[j]` if `A[i] == B[j]`, and no two lines should intersect. The function should start with:
```python
from typing import List
def max_uncrossed_lines(A... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_uncrossed_lines(A: List[int], B: List[int]) -> int:
"""
Calculate the maximum number of uncrossed lines that can be drawn between two arrays A and B.
Args:
A (List[int]): The first a... |
magic_evol_110k | 105,220 | Write a Python function to reduce an array to its unique values only, while maintaining the order of the first occurrence of each element. The function should take a list of integers as input and return a list of unique integers in the order they first appear.
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 unique_elements_ordered(arr: List[int]) -> List[int]:
"""
Returns a list of unique elements from the input list, maintaining the order of their first occurrence.
Args:
arr (List[int]): T... |
magic_evol_110k | 105,232 | Write a Python function to find the maximum element in a list of integers. The function should handle lists of any length, including empty lists, and return `None` for an empty list. The code should start with:
```python
from typing import List, Optional
def find_max_element(lst: 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_max_element(lst: List[int]) -> Optional[int]:
"""
Find the maximum element in a list of integers.
Args:
lst (List[int]): The list of integers from which to find the maximu... |
magic_evol_110k | 105,240 | Write a Python function to find and display all the hidden files in a given directory, and check if these hidden files have any symbolic links pointing towards them in the same directory. The function should display the hidden files, the symbolic links pointing towards them, and the count of these links.
The code shou... | Here is the Python code to solve the given problem in the markdown block:
```python
import os
def find_hidden_files_with_links(directory: str) -> None:
"""
Finds and displays all hidden files in the given directory and checks if these hidden files have any symbolic links pointing towards them.
Displays the... |
magic_evol_110k | 105,243 | Write a Python function to calculate the product of two distinct inputted numeric values and return the result. The function should handle both integer and floating-point numbers. Additionally, the function should be able to handle cases where one or both of the inputs are zero.
The code should start with:
```python
d... | Here is the Python code to solve the given problem in the markdown block:
```python
def multiply_two_numbers(a: float, b: float) -> float:
"""
Calculate the product of two distinct inputted numeric values.
Args:
a (float): The first numeric value.
b (float): The second numeric value.
R... |
magic_evol_110k | 105,250 | Write a Python function to determine the composition of a given set of values, which may embody a heterogeneous mix of data types including integers and alphabetic characters. The function should return a dictionary where the keys are the data types and the values are the counts of elements of that data type in the inp... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Any
def count_data_types(values: List[Any]) -> Dict[type, int]:
"""
Counts the occurrences of each data type in the given list of values.
Args:
values (List[Any]): A list containing e... |
magic_evol_110k | 105,266 | Write a Python function to generate a random string of length `n` using alphabet characters, ensuring that at least half of the characters are uppercase. The function should also accept a character as a parameter to exclude from the generated string. The code should start with:
```python
import random
import string
de... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
import string
def generate_random_string(n: int, excluded_char: str) -> str:
"""
Generates a random string of length `n` using alphabet characters, ensuring at least half the characters are uppercase.
The char... |
magic_evol_110k | 105,275 | Write a Python function to determine if a list of numbers can be sorted into non-decreasing order by performing the following operations:
1. Reverse any sublist any number of times.
2. Remove at-most two elements from the list.
3. Swap any two elements once.
If the list can be sorted, return `True` and the sequence of... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def advanced_sort(numbers: List[int]) -> Tuple[bool, List[Tuple[int, int]]]:
"""
Determine if a list of numbers can be sorted into non-decreasing order by performing the following operations:
... |
magic_evol_110k | 105,286 | Write a Python function to filter out and return all the even numbers from a given list of integers. The function should efficiently handle lists of varying sizes and ensure that only even numbers are included in the result. The code should start with:
```python
from typing import List
def filter_even_numbers(array: L... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_even_numbers(array: List[int]) -> List[int]:
"""
Filters out and returns all even numbers from the given list of integers.
Args:
array (List[int]): A list of integers from which t... |
magic_evol_110k | 105,289 | Write a Python function to compare the ages of two entities and return a specific value based on the comparison. The function should return 0 if the ages are equal, a positive value if the first entity's age is greater, and a negative value if the second entity's age is greater. The function should be named `compare_ag... | Here is the Python code to solve the given problem in the markdown block:
```python
def compare_ages(age1: int, age2: int) -> int:
"""
Compares the ages of two entities and returns a value based on the comparison.
Args:
age1 (int): The age of the first entity.
age2 (int): The age of the sec... |
magic_evol_110k | 105,294 | Write a Python function to calculate the number of ways to climb a staircase with `n` steps, where a person can take either 1 or 2 steps at a time. The function should use dynamic programming to efficiently compute the result.
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 a person can take either 1 or 2 steps at a time.
Args:
n (int): The number of steps in the staircase.
R... |
magic_evol_110k | 105,330 | Write a Python function to find the common elements between two lists and return them in ascending order. The function should be efficient and handle cases where the lists are of different lengths or contain duplicate elements. The code should start with:
```python
from typing import List
def find_common_elements(list... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_common_elements(list1: List[int], list2: List[int]) -> List[int]:
"""
Find the common elements between two lists and return them in ascending order.
Args:
list1 (List[int]): The fir... |
magic_evol_110k | 105,344 | Write a Python function to remove duplicates from a sorted array while maintaining the order of the remaining elements. The function should modify the input array in-place and return the new length of the array after removing duplicates. The solution must use O(1) extra memory.
The code should start with:
```python
fr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_duplicates_from_sorted_array(nums: List[int]) -> int:
"""
Remove duplicates from a sorted array in-place and return the new length of the array.
Args:
nums (List[int]): The sorted... |
magic_evol_110k | 105,347 | Write a Python function to extract all exclusive integers from a list of tuple pairs representing ranges of integers. Each tuple pair `(a, b)` represents the range `[a, b]` (inclusive). The function should ensure that no integer is repeated in the output and should return the integers in ascending order.
The code shou... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def get_exclusive_integers(ranges: List[Tuple[int, int]]) -> List[int]:
"""
Extracts all exclusive integers from a list of tuple pairs representing ranges of integers.
Args:
ranges (L... |
magic_evol_110k | 105,348 | Write a Python function to validate and correct a given dictionary of variables, ensuring that each variable is assigned a value of the correct data type according to predefined rules. The function should return a corrected dictionary with all variables adhering to the specified data types. The predefined rules are as ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List, Union
def validate_and_correct_variables(variables: Dict[str, Union[int, str, List[str], Dict[str, Union[str, int]]]]) -> Dict[str, Union[int, str, List[str], Dict[str, Union[str, int]]]]:
"""
Val... |
magic_evol_110k | 105,349 | Write a Python function to sum two integers without using any type conversions or manipulations. The function should only accept integers as input and return their sum as an integer. The code should start with:
```python
def sum_two_integers(a: int, b: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def sum_two_integers(a: int, b: int) -> int:
"""
Sums two integers without using any type conversions or manipulations.
Args:
a (int): The first integer to be summed.
b (int): The second integer to be summed... |
magic_evol_110k | 105,350 | Write a Python function to generate an SQL query that updates each record in a table `main_table` by incorporating new values from a separate table `new_values_table`. The `main_table` has columns `id` and `value`, and the `new_values_table` also has columns `id` and `new_value`. The SQL query should update the `value`... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_update_query(main_table: str, new_values_table: str) -> str:
"""
Generates an SQL query to update each record in `main_table` with new values from `new_values_table`.
Args:
main_table (str): The name of... |
magic_evol_110k | 105,351 | Write a Python function to calculate the maximum sum of all unique subarrays from a given array of integers. A subarray is a contiguous part of an array. The function should return the maximum sum that can be achieved from these subarrays.
The code should start with:
```python
from typing import List
def max_subarray... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_subarray_sum(nums: List[int]) -> int:
"""
Calculate the maximum sum of all unique subarrays from a given array of integers.
Args:
nums (List[int]): The input array of integers.
... |
magic_evol_110k | 105,357 | Write a Python function to remove duplicates from a given list while preserving the order of elements. The function should use efficient built-in functions and data structures to achieve this. The code should start with:
```python
from typing import List
def remove_duplicates_preserve_order(array: List[int]) -> List[i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_duplicates_preserve_order(array: List[int]) -> List[int]:
"""
Removes duplicates from the given list while preserving the order of elements.
Args:
array (List[int]): The list from... |
magic_evol_110k | 105,372 | Write a Python function to determine if the sum of all elements in a list of integers falls within a specified range, given that the list must be of even length. The function should return `True` if the sum of the list elements is within the specified range (inclusive) and the list length is even; otherwise, it should ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_within_bounds(l: List[int], lower_bound: int, upper_bound: int) -> bool:
"""
Determines if the sum of all elements in a list of integers falls within a specified range,
given that the list mu... |
magic_evol_110k | 105,392 | Write a Python function to remove all occurrences of white spaces from a given string and another function to replace multiple occurrences of white spaces with a single space, while preserving the initial and final characters of the original string. The solution should not use any built-in string trimming functions and... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_all_spaces(string: str) -> str:
"""
Remove all occurrences of white spaces from the given string.
Args:
string (str): The input string from which spaces are to be removed.
Returns:
str: The s... |
magic_evol_110k | 105,408 | Write a Python function to reverse a given word and determine if it is an anagram of the original word. The function should return a tuple containing the reversed word and a boolean indicating whether the word is an anagram of its reversed version.
The code should start with:
```python
def reverse_and_check_anagram(wo... | Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_and_check_anagram(word: str) -> tuple:
"""
Reverses the given word and checks if it is an anagram of the original word.
Args:
word (str): The word to be reversed and checked for anagram.
Returns:
... |
magic_evol_110k | 105,414 | Write a Python function to calculate the difference between two given time values down to the minute. The function should accept two `datetime.time` objects and return a tuple containing the difference in hours and minutes. The code should start with:
```python
import datetime
def time_difference(time1: datetime.time,... | Here is the Python code to solve the given problem in the markdown block:
```python
import datetime
def time_difference(time1: datetime.time, time2: datetime.time) -> (int, int):
"""
Calculate the difference between two time values down to the minute.
Args:
time1 (datetime.time): The first time va... |
magic_evol_110k | 105,432 | Write a Python function to convert a given time string in the format "HH:MMAM" or "HH:MMPM" to the total number of minutes since midnight. The function should handle both AM and PM times correctly, including the special case of 12:XX AM being equivalent to 0:XX AM.
The code should start with:
```python
def time_to_min... | Here is the Python code to solve the given problem in the markdown block:
```python
def time_to_minutes(time_str: str) -> int:
"""
Converts a given time string in the format "HH:MMAM" or "HH:MMPM" to the total number of minutes since midnight.
Args:
time_str (str): The time string in the format "HH... |
magic_evol_110k | 105,437 | Write a Python function to calculate the product of all other numbers in an array except the number at the current index, while maintaining the access to each element's original index. The solution should not use division and should work even if the array contains zeros. The function should be implemented in O(n) time ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def product_except_self(nums: List[int]) -> List[int]:
"""
Calculate the product of all other numbers in the array except the number at the current index.
Args:
nums (List[int]): The input a... |
magic_evol_110k | 105,466 | Write a Python higher-order function that takes a list of numbers and a function as arguments. The function should iterate through the list using a for loop and apply the given function to each element in the list. Finally, it should return the resulting list of transformed elements. 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, Callable
def apply_function_to_list(lst: List[int], func: Callable[[int], int]) -> List[int]:
"""
Applies a given function to each element in a list and returns the resulting list of transformed element... |
magic_evol_110k | 105,467 | Write a Python function to sort a given list of numbers in descending order. The function should return the sorted list. The code should start with:
```python
from typing import List
def sort_descending(numbers: 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(numbers: List[int]) -> List[int]:
"""
Sorts a given list of numbers in descending order.
Args:
numbers (List[int]): The list of numbers to be sorted.
Returns:
... |
magic_evol_110k | 105,474 | Write a Python function to compute the cumulative sum of the first n even numbers. The function should use a while loop to iterate through numbers, check for evenness, and accumulate the sum until the required number of even numbers is collected.
The code should start with:
```python
def cumulative_sum_of_first_n_even... | Here is the Python code to solve the given problem in the markdown block:
```python
def cumulative_sum_of_first_n_evens(n: int) -> int:
"""
Computes the cumulative sum of the first n even numbers.
Args:
n (int): The number of even numbers to sum.
Returns:
int: The cumulative sum of the... |
magic_evol_110k | 105,486 | Write a Python function to embed a given value into a specific coordinate position within a 3D matrix. The function should handle the embedding operation and ensure that the coordinates are within the bounds of the matrix. If the coordinates are out of bounds, the function should return the original matrix without any ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def embed_value_in_3D_matrix(matrix: List[List[List[int]]], value: int, coordinates: Tuple[int, int, int]) -> List[List[List[int]]]:
"""
Embeds a given value into a specific coordinate position wi... |
magic_evol_110k | 105,512 | Write a Python function to check if a specified integer exists in a given list of integers. The function should return a boolean value indicating whether the element is present in the list or not. The code should start with:
```python
from typing import List
def element_exists_in_list(arr: List[int], element: int) -> ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def element_exists_in_list(arr: List[int], element: int) -> bool:
"""
Check if a specified integer exists in a given list of integers.
Args:
arr (List[int]): The list of integers to search w... |
magic_evol_110k | 105,518 | Write a Python function to find the minimum value in a given array and return both the minimum value and its index. If the array is empty, the function should return `None` for both the minimum value and the index. The function should be efficient and handle edge cases such as empty arrays.
The code should start with:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Optional
def find_min_value_and_index(arr: List[int]) -> Tuple[Optional[int], Optional[int]]:
"""
Find the minimum value and its index in a given array.
Args:
arr (List[int]): The ar... |
magic_evol_110k | 105,541 | Write a Python function to determine whether a given string is an anagram of a palindrome. The function should consider both lower-case and upper-case alphabets, digits, and special characters. The function should ignore non-alphabet characters and treat upper-case and lower-case letters as the same.
The code should s... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_anagram_of_palindrome(s: str) -> bool:
"""
Determines whether the given string is an anagram of a palindrome.
Args:
s (str): The input string to be checked.
Returns:
bool: True if the string is a... |
magic_evol_110k | 105,548 | Write a Python function to reverse a given byte array without using any pre-existing reverse string or array functions. The function should take a byte array as input and return the reversed byte array. The code should start with:
```python
def reverse_byte_array(byte_array: bytes) -> bytes:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_byte_array(byte_array: bytes) -> bytes:
"""
Reverses the given byte array without using any pre-existing reverse functions.
Args:
byte_array (bytes): The byte array to be reversed.
Returns:
... |
magic_evol_110k | 105,560 | Write a Python function to remove duplicates from a given list without using built-in methods or additional data structures. Maintain the relative order of the numbers in the output list. Additionally, calculate the time complexity of your solution.
The code should start with:
```python
from typing import List
def re... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_duplicates(nums: List[int]) -> List[int]:
"""
Removes duplicates from the given list while maintaining the relative order of the numbers.
This function does not use built-in methods or add... |
magic_evol_110k | 105,571 | Write a Python function to export a given value to a text file. The function should handle different types of values (e.g., integers, strings, lists, dictionaries) and ensure that the value is correctly formatted and written to the file. The function should also handle file operations safely, including creating the fil... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Any
def export_value_to_file(value: Any, file_path: str) -> None:
"""
Exports a given value to a text file.
Args:
value (Any): The value to be exported. This can be an integer, string, list, dict... |
magic_evol_110k | 105,578 | Write a Python function to reverse a given list, remove its duplicates, and then rearrange the resulting list in ascending order. The function should take a list of integers as input and return the processed list. The code should start with:
```python
from typing import List
def process_list(lst: List[int]) -> List[in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def process_list(lst: List[int]) -> List[int]:
"""
Reverses the given list, removes its duplicates, and then rearranges it in ascending order.
Args:
lst (List[int]): The list of integers to ... |
magic_evol_110k | 105,579 | Write a Python function to remove duplicate elements from a given list of numerical values and return the sorted list of unique elements in ascending order. The function should handle lists of integers and floats. The code should start with:
```python
from typing import List, Union
def remove_duplicates_and_sort(input... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def remove_duplicates_and_sort(input_list: List[Union[int, float]]) -> List[Union[int, float]]:
"""
Removes duplicate elements from a given list of numerical values and returns the sorted list of ... |
magic_evol_110k | 105,589 | Write a Python function to generate a SQL UPDATE statement that increments the value of column `b` by 1 for all rows in the table named `a`. The function should take the table name as a string and return the SQL statement as a string.
The code should start with:
```python
def generate_update_sql(table_name: str) -> st... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_update_sql(table_name: str) -> str:
"""
Generates a SQL UPDATE statement that increments the value of column 'b' by 1 for all rows in the specified table.
Args:
table_name (str): The name of the table t... |
magic_evol_110k | 105,598 | Write a Python function to compute the nth Fibonacci number using a dynamic programming approach with memoization to optimize the time complexity. The function should handle edge cases and ensure that the memoization dictionary is used correctly to avoid redundant calculations.
The code should start with:
```python
de... | Here is the Python code to solve the given problem in the markdown block:
```python
def fibonacci(n: int) -> int:
"""
Compute the nth Fibonacci number using dynamic programming with memoization.
Args:
n (int): The position in the Fibonacci sequence to compute.
Returns:
int: The nth Fib... |
magic_evol_110k | 105,604 | Write a Python function to calculate the sum and product of the digits of a given integer. The function should handle both positive and negative integers and should return a tuple containing the sum and product of the digits. If the input is not an integer, the function should print an error message and return `None`. ... | Here is the Python code to solve the given problem in the markdown block:
```python
def additive_multiplicative(num: int) -> tuple:
"""
Calculate the sum and product of the digits of a given integer.
Args:
num (int): The integer whose digits' sum and product are to be calculated.
Returns:
... |
magic_evol_110k | 105,609 | Write a Python function to round off the real part of a collection of complex numbers to the nearest integer while keeping their imaginary parts unchanged. The function should handle a list of complex numbers and return a new list with the rounded complex numbers.
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 round_complex_numbers(numbers: List[complex]) -> List[complex]:
"""
Rounds off the real part of a collection of complex numbers to the nearest integer
while maintaining their imaginary components... |
magic_evol_110k | 105,620 | Write a Python function to calculate the cumulative total of every individual element present within a given two-dimensional matrix. The matrix is represented as a list of lists, where each inner list represents a row in the matrix. The function should sum all the elements in the matrix and return the total.
The code ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def cumulative_total(matrix: List[List[int]]) -> int:
"""
Calculate the cumulative total of every individual element present within a given two-dimensional matrix.
Args:
matrix (List[List[in... |
magic_evol_110k | 105,627 | Write a Python function to remove all punctuation marks from a given string using regular expressions. The function should return the cleaned string without any punctuation. The code should start with:
```python
import re
def remove_punctuation(text: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def remove_punctuation(text: str) -> str:
"""
Removes all punctuation marks from the given string using regular expressions.
Args:
text (str): The input string from which punctuation marks are to be remov... |
magic_evol_110k | 105,634 | Write a Python function to reverse the order of elements in a given tuple. The function should return a new tuple with the elements in reverse order. The original tuple should remain unchanged.
The code should start with:
```python
from typing import Tuple
def reverse_tuple(mytuple: Tuple[int, ...]) -> Tuple[int, ...... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
def reverse_tuple(mytuple: Tuple[int, ...]) -> Tuple[int, ...]:
"""
Reverses the order of elements in a given tuple and returns a new tuple with the elements in reverse order.
Args:
mytuple... |
magic_evol_110k | 105,637 | Write a Python function to remove the last two characters from a given alphanumeric sequence. The sequence can be a string of any length, including zero. If the sequence has fewer than two characters, the function should return an empty string.
The code should start with:
```python
def trim_sequence(sequence: str) -> ... | Here is the Python code to solve the given problem in the markdown block:
```python
def trim_sequence(sequence: str) -> str:
"""
Removes the last two characters from the given alphanumeric sequence.
Args:
sequence (str): The input alphanumeric sequence.
Returns:
str: The sequence with ... |
magic_evol_110k | 105,642 | Write a Python function to select an item from a list of items with weighted probabilities. Each item is represented as a tuple where the first element is the item name and the second element is the probability of selecting that item. The sum of all probabilities should be 1. The function should return the selected ite... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import numpy as np
def select_item_with_probability(items: List[Tuple[str, float]]) -> str:
"""
Selects an item from a list of items with weighted probabilities.
Args:
items (List[Tup... |
magic_evol_110k | 105,657 | Write a Python function to convert a binary numerical expression represented as a string into its corresponding integer value in the decimal numeral system. The function should handle binary strings of any length and ensure that the conversion is accurate.
The code should start with:
```python
def binary_to_decimal(bi... | Here is the Python code to solve the given problem in the markdown block:
```python
def binary_to_decimal(binary_str: str) -> int:
"""
Converts a binary numerical expression represented as a string into its corresponding integer value in the decimal numeral system.
Args:
binary_str (str): The binar... |
magic_evol_110k | 105,660 | Write a Python function to iterate over a given list and perform a specified operation on each element. The function should return a new list containing the results of the operation. The operation can be any mathematical operation or a string manipulation. 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, Callable
def apply_operation(my_list: List[int], operation: Callable[[int], int]) -> List[int]:
"""
Applies a specified operation to each element in the given list and returns a new list with the result... |
magic_evol_110k | 105,668 | Write a Python function to perform a bitwise operation between two integers and return the result. The function should accept two integers as input and a string representing the bitwise operation to be performed. The valid operations are "AND", "OR", "XOR", "NOT", "LSHIFT", and "RSHIFT". The function should return the ... | Here is the Python code to solve the given problem in the markdown block:
```python
def bitwise_operation(a: int, b: int, operation: str) -> int:
"""
Perform a bitwise operation between two integers based on the given operation string.
Args:
a (int): The first integer.
b (int): The second i... |
magic_evol_110k | 105,670 | Write a Python function to join a collection of phrases into a single contiguous sentence, where each phrase is separated by a semicolon followed by a space. The function should handle an empty collection by returning an empty string.
The code should start with:
```python
from typing import List
def join_phrases(phra... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def join_phrases(phrases: List[str]) -> str:
"""
Joins a collection of phrases into a single contiguous sentence, with each phrase separated by a semicolon followed by a space.
Args:
phrases... |
magic_evol_110k | 105,698 | Write a Python function to determine the day of the week for a given date in the Gregorian calendar, formatted as `YYYY-MM-DD`. The function should validate the input date to ensure it meets the specified constraints and return the corresponding day of the week as a string.
The code should start with:
```python
from d... | Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime
def get_weekday(date: str) -> str:
"""
Determine the day of the week for a given date in the Gregorian calendar.
Args:
date (str): A string representing a date in the format 'YYYY-MM-D... |
magic_evol_110k | 105,701 | Write a Python function to efficiently separate prime numbers and composite numbers from a given list of integers. The function should return two lists: one containing the prime numbers and the other containing the composite numbers. The function should be optimized for performance, especially for large input sizes.
T... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import math
def separate_primes_and_composites(input_list: List[int]) -> Tuple[List[int], List[int]]:
"""
Separates prime numbers and composite numbers from a given list of integers.
Args:
... |
magic_evol_110k | 105,707 | Write a Python function to calculate the minimum number of steps required to get exactly `n` 'A' characters on a notepad, starting with one 'A'. The allowed operations are:
1. **Copy All**: Copy all characters present on the notepad.
2. **Paste**: Paste the characters which were copied last.
3. **Delete**: Delete one c... | Here is the Python code to solve the given problem in the markdown block:
```python
def min_steps_to_n_A(n: int) -> int:
"""
Calculate the minimum number of steps required to get exactly `n` 'A' characters on a notepad.
Args:
n (int): The target number of 'A' characters.
Returns:
int: ... |
magic_evol_110k | 105,715 | Write a Python function to simulate a simple SNMP (Simple Network Management Protocol) agent that can handle GET requests for a predefined set of OIDs (Object Identifiers). The function should return the value associated with the requested OID if it exists, otherwise return an error message indicating that the OID is n... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Optional
def snmp_get(oid: str, oid_values: Dict[str, str]) -> Optional[str]:
"""
Simulates an SNMP GET request by returning the value associated with the given OID.
Args:
oid (str): The Ob... |
magic_evol_110k | 105,719 | Write a Python function to compute the cube of each element in a given sequence of numeric entities. The function should return a list containing the cubic values of each element in the input sequence. The code should start with:
```python
from typing import List
def cube_elements(sequence: List[int]) -> List[int]:
``... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def cube_elements(sequence: List[int]) -> List[int]:
"""
Computes the cube of each element in the given sequence of numeric entities.
Args:
sequence (List[int]): A list of integers for which... |
magic_evol_110k | 105,748 | Write a Python function to analyze a list of sentences and create a dictionary that contains the frequency of each distinct word along with the sentences in which each word appears. The function should handle case insensitivity and remove punctuation from the words. 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, Dict
from collections import defaultdict
def word_frequency_and_sentences(sentences: List[str]) -> Dict[str, Dict[str, List[str]]]:
"""
Analyzes a list of sentences and creates a dictionary that contain... |
magic_evol_110k | 105,757 | Write a Python function to compute the centroid of a given set of points in a 3D space. The points are provided as a list of tuples, where each tuple represents the coordinates (x, y, z) of a point. The function should return the centroid as a tuple of three floats representing the average x, y, and z coordinates.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def compute_centroid(points: List[Tuple[float, float, float]]) -> Tuple[float, float, float]:
"""
Compute the centroid of a given set of points in a 3D space.
Args:
points (List[Tuple... |
magic_evol_110k | 105,759 | 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... |
magic_evol_110k | 105,760 | Write a Python function to sort an array of objects by a specified key value, which can be nested within the objects or their sub-objects. The function should handle various data types and allow sorting in ascending or descending order. Additionally, the function should include error handling for cases where the specif... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Any
def deep_find(obj: Dict[str, Any], key: str) -> Any:
"""
Recursively searches for a key in a dictionary and its nested dictionaries or lists.
Args:
obj (dict): The dictionary to s... |
magic_evol_110k | 105,761 | Write a Python function to convert a Decimal object fetched from a database to a float. The function should take a single Decimal object as input and return its float representation. The code should start with:
```python
from decimal import Decimal
def decimal_to_float(decimal_value: Decimal) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from decimal import Decimal
def decimal_to_float(decimal_value: Decimal) -> float:
"""
Converts a Decimal object to its float representation.
Args:
decimal_value (Decimal): The Decimal object to be converted.
... |
magic_evol_110k | 105,762 | Write a Python function to check the primality of a given integer `n` and return `True` if `n` is a prime number, otherwise return `False`. Additionally, the function should provide detailed information about the factors of `n` if it is not a prime number. The function should also handle edge cases such as `n` being le... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def is_prime_with_details(n: int) -> (bool, list):
"""
Check if a given integer `n` is a prime number and provide detailed information about its factors if it is not prime.
Args:
n (int): The integer to... |
magic_evol_110k | 105,767 | Write a Python function to find all occurrences of a pair of integers `(x, y)` at consecutive indices in a 3D list. The function should return a list of tuples, where each tuple contains the depth, row, and index of the first element of the pair `(x, y)` in the 3D list. The function should start with:
```python
from ty... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_consecutive_pairs(lst3d: List[List[List[int]]], x: int, y: int) -> List[Tuple[int, int, int]]:
"""
Find all occurrences of the pair (x, y) at consecutive indices in a 3D list.
Args:
... |
magic_evol_110k | 105,776 | Write a Python function to find the maximum value in a list of integers. The function should handle an empty list by returning `None`. The code should start with:
```python
from typing import List, Optional
def find_max_value(numbers: 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_max_value(numbers: List[int]) -> Optional[int]:
"""
Find the maximum value in a list of integers.
Args:
numbers (List[int]): A list of integers.
Returns:
Opti... |
magic_evol_110k | 105,781 | Write a Python function to convert a given year into ISO 8601 format. The function should handle both integer and string inputs, ensuring that the year is correctly formatted according to ISO 8601 standards. The function should also validate the input to ensure it is either a valid integer or a string that can be conve... | Here is the Python code to solve the given problem in the markdown block:
```python
def iso_8601_year(year):
"""
Converts a given year into ISO 8601 format.
Args:
year (int or str): The year to be converted. Can be either an integer or a string that can be converted to an integer.
Returns:
... |
magic_evol_110k | 105,788 | Write a Python function to generate and print a Pascal's Triangle with a specified number of rows. The function should return a list of lists, where each inner list represents a row in the Pascal's Triangle. The code should start with:
```python
from typing import List
def generate_pascal_triangle(num_rows: int) -> Li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_pascal_triangle(num_rows: int) -> List[List[int]]:
"""
Generate a Pascal's Triangle with the specified number of rows.
Args:
num_rows (int): The number of rows in the Pascal's T... |
magic_evol_110k | 105,807 | Write a Python function that calculates the age five years from now, ensuring that the input is an integer. If the input is not an integer, the function should raise a `TypeError` with a specific error message. The function should be designed to handle various types of inputs and raise an appropriate error for non-inte... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_age_in_five_years(age: int) -> int:
"""
Calculate the age five years from now, ensuring the input is an integer.
Args:
age (int): The current age, which should be an integer.
Returns:
int:... |
magic_evol_110k | 105,812 | Write a Python function to calculate the number of bird species counted in the afternoon given the total number of bird species counted for the entire day and the additional number of bird species counted in the morning compared to the afternoon.
The code should start with:
```python
def calculate_afternoon_species(to... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_afternoon_species(total_species: int, additional_species: int) -> int:
"""
Calculate the number of bird species counted in the afternoon.
Given the total number of bird species counted for the entire day and t... |
magic_evol_110k | 105,819 | Write a Python function to count the number of key-value pairs in a list of dictionaries where the keys are strings. The function should handle potential TypeErrors gracefully and raise an informative error message when encountered. The function should start with:
```python
from typing import List, Dict
def count_stri... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_string_key_value_pairs(list_of_dicts: List[Dict]) -> List[int]:
"""
Counts the number of key-value pairs in a list of dictionaries where the keys are strings.
Args:
list_of_d... |
magic_evol_110k | 105,820 | Write a Python function to remove all occurrences of a specified item from a given list. The function should return a new list with all instances of the specified item removed. The original list should not be modified.
The code should start with:
```python
from typing import List
def remove_all_occurrences(lst: List[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_all_occurrences(lst: List[int], item_to_remove: int) -> List[int]:
"""
Removes all occurrences of a specified item from a given list and returns a new list.
Args:
lst (List[int]):... |
magic_evol_110k | 105,821 | Write a Python function to sort a dictionary of dictionaries in descending order based on a custom comparison function. The function should be flexible enough to allow sorting based on individual keys and derived attributes such as the length of a string or a function that multiplies a numeric value by a given factor. ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Callable
def sort_dict_of_dicts(d: Dict[str, Dict[str, any]], key_func: Callable[[Dict[str, any]], any]) -> Dict[str, Dict[str, any]]:
"""
Sorts a dictionary of dictionaries in descending order based on... |
magic_evol_110k | 105,831 | Write a Python function to build and return a pyramid of random numbers using 21 numbers from 1 to 15. The pyramid should be represented as a list of lists, where each sublist represents a row in the pyramid. The top row should have 1 number, the second row should have 2 numbers, and so on, up to the bottom row which s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def build_number_pyramid() -> List[List[int]]:
"""
Builds and returns a pyramid of random numbers using 21 numbers from 1 to 15.
Returns:
List[List[int]]: A list of lists where... |
magic_evol_110k | 105,836 | Write a Python function to calculate the average of all the values in a given dictionary. The dictionary contains string keys and integer values. The function should handle dictionaries with varying lengths and ensure that the average is calculated correctly. The code should start with:
```python
from typing import Dic... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def calculate_average(dictionary: Dict[str, int]) -> float:
"""
Calculate the average of all values in a given dictionary.
Args:
dictionary (Dict[str, int]): A dictionary with string keys an... |
magic_evol_110k | 105,840 | Write a Python function to sort an array of integers using the insertion sort algorithm. The function should take a list of integers as input and return the sorted list. The code should start with:
```python
from typing import List
def insertion_sort(array: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def insertion_sort(array: List[int]) -> List[int]:
"""
Sorts an array of integers using the insertion sort algorithm.
Args:
array (List[int]): The array of integers to be sorted.
Retu... |
magic_evol_110k | 105,844 | Write a Python function to convert a given string into a byte array and then reverse the order of the byte array without using any built-in functions specifically designed for reversing strings or byte arrays. The function should return the reversed byte array.
The code should start with:
```python
def reverse_byte_ar... | Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_byte_array(byte_array: bytearray) -> bytearray:
"""
Reverses the order of the given byte array without using any built-in reverse functions.
Args:
byte_array (bytearray): The byte array to be reversed.
... |
magic_evol_110k | 105,847 | Write a Python function to count the number of prime hex digits in a given hex number string. Prime hex digits include '2', '3', '5', '7', 'B' (which is 11 in decimal), and 'D' (which is 13 in decimal). The input will always be a correct or empty string, with uppercase A-F symbols.
The code should start with:
```pytho... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_prime_hex_digits(hex_number: str) -> int:
"""
Counts the number of prime hex digits in a given hex number string.
Prime hex digits include '2', '3', '5', '7', 'B' (11 in decimal), and 'D' (13 in decimal).
Arg... |
magic_evol_110k | 105,871 | Write a Python function to compute the smallest positive integer that represents the number of Earth days three celestial bodies will take to be in exactly the same positions again, given their orbital periods around a common central star. The function should take three integers representing the orbital periods of the ... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def find_realignment_days(period_x: int, period_y: int, period_z: int) -> int:
"""
Calculate the smallest positive integer that represents the number of Earth days
three celestial bodies will take to be in exact... |
magic_evol_110k | 105,872 | Write a Python function to calculate the total number of entries in a given 2D list (representing a dataframe). The function should iterate through each row and sum the number of elements in each row to get the total count of entries.
The code should start with:
```python
from typing import List
def total_entries(dat... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def total_entries(dataframe: List[List[any]]) -> int:
"""
Calculate the total number of entries in a given 2D list (representing a dataframe).
Args:
dataframe (List[List[any]]): A 2D list wh... |
magic_evol_110k | 105,913 | Write a Python function to simulate the behavior of asynchronous operations using the `asyncio` library. The function should demonstrate how asynchronous programming can be used to perform tasks concurrently without blocking the main thread. Specifically, the function should:
1. Define an asynchronous function that sim... | Here is the Python code to solve the given problem in the markdown block:
```python
import asyncio
async def simulate_async_task(task_id: int, delay: int) -> None:
"""
Simulate an asynchronous task with a specified delay.
Args:
task_id (int): The ID of the task.
delay (int): The delay in s... |
magic_evol_110k | 105,918 | Write a Python function to count the number of alphabetic characters in each string of a Pandas DataFrame column. The function should be applied to the DataFrame to create a new column that contains the count of alphabetic characters for each string in the original column.
The code should start with:
```python
import ... | Here is the Python code to solve the given problem in the markdown block:
```python
import pandas as pd
def count_alpha_char(string: str) -> int:
"""
Count the number of alphabetic characters in a given string.
Args:
string (str): The string to count alphabetic characters in.
Returns:
... |
magic_evol_110k | 105,936 | Write a Python function to generate a simple HTML webpage with a banner and two content sections. The function should accept three strings: the text for the banner, the text for the first content section, and the text for the second content section. The function should return a string containing the HTML code for the w... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_html_page(banner_text: str, content1_text: str, content2_text: str) -> str:
"""
Generates a simple HTML webpage with a banner and two content sections.
Args:
banner_text (str): The text to be displayed ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.