source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
magic_evol_110k | 77,934 | Write a Python function to substitute each occurrence of the character '0' with the character 'x' in a given 2D matrix consisting of character elements. The function should return the modified matrix.
The code should start with:
```python
from typing import List
def replace_zeros_with_x(matrix: List[List[str]]) -> Li... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def replace_zeros_with_x(matrix: List[List[str]]) -> List[List[str]]:
"""
Substitutes each occurrence of the character '0' with the character 'x' in a given 2D matrix.
Args:
matrix (List[Lis... |
magic_evol_110k | 77,947 | Write a Python function to construct a complete URL from given subdomain, domain, and path components. Ensure the URL uses the secure Hypertext Transfer Protocol Secure (HTTPS) and includes the appropriate top-level domain (TLD) as ".com". The function should handle the input components and return the fully formed URL ... | Here is the Python code to solve the given problem in the markdown block:
```python
def construct_url(subdomain: str, domain: str, path: str) -> str:
"""
Constructs a complete URL from the given subdomain, domain, and path components.
Args:
subdomain (str): The subdomain part of the URL.
do... |
magic_evol_110k | 77,948 | Write a Python function that sorts a list of numerical values in increasing order and removes any duplicate values. Additionally, the function should return the count of unique elements in the sorted list. The function must ensure that all elements in the list are either integers or floating-point numbers. If any eleme... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Union
def sort_and_remove_duplicates(lst: List[Union[int, float]]) -> Union[Tuple[List[Union[int, float]], int], str]:
"""
Sorts a list of numerical values in increasing order, removes any duplic... |
magic_evol_110k | 77,970 | Write a Python function to calculate the aggregate of the most significant (maximum) and the least significant (minimum) integers from a given list of integers. The function should return the sum of the maximum and minimum values in the list.
The code should start with:
```python
from typing import List
def aggregate... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def aggregate_max_min(numbers: List[int]) -> int:
"""
Calculate the aggregate of the most significant (maximum) and the least significant (minimum) integers from a given list of integers.
Args:
... |
magic_evol_110k | 78,003 | Write a Python function to check if one string is an anagram of another string considering case sensitivity. Additionally, the function should handle non-alphanumeric characters in the strings by ignoring them. The function should return `True` if the strings are anagrams, and `False` otherwise.
The code should start ... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_anagram(str1: str, str2: str) -> bool:
"""
Check if two strings are anagrams considering case sensitivity and ignoring non-alphanumeric characters.
Args:
str1 (str): The first string to compare.
str2 ... |
magic_evol_110k | 78,005 | Write a Python function to flatten a two-dimensional grid composed of integer entities into a one-dimensional list. The function should handle grids of varying sizes and ensure that all elements from the original grid are included in the flattened list in the order they appear.
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 flatten_grid(grid: List[List[int]]) -> List[int]:
"""
Flattens a two-dimensional grid of integers into a one-dimensional list.
Args:
grid (List[List[int]]): A two-dimensional grid compos... |
magic_evol_110k | 78,011 | Write a Python function to generate a dictionary that encapsulates the designations of learners along with their respective grade points in their courses. The function should accept a list of tuples, where each tuple contains a learner's name and their grade point. The function should return a dictionary with the learn... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def generate_learner_grades(grades: List[Tuple[str, int]]) -> Dict[str, int]:
"""
Generate a dictionary encapsulating the designations of learners along with their respective grade points.
... |
magic_evol_110k | 78,019 | Write a Python function to generate a list of ten distinct random integers between a specified range `[min_value, max_value]`. Ensure that no repetition or duplication occurs in the generated list. The function should start with:
```python
from typing import List
def generate_unique_random_numbers(min_value: int, max_... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_unique_random_numbers(min_value: int, max_value: int) -> List[int]:
"""
Generates a list of ten distinct random integers between min_value and max_value (inclusive).
Args:... |
magic_evol_110k | 78,021 | Write a Python function to combine and sort two or more given arrays with different data types into one sorted array without using built-in sorting functions. The sorting should be done considering the following criteria:
1. Numbers have higher priority than strings.
2. Data should be sorted in ascending order for same... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def custom_sort(arrays: List[List[Union[int, float, str]]]) -> List[Union[int, float, str]]:
"""
Combine and sort two or more given arrays with different data types into one sorted array.
The... |
magic_evol_110k | 78,031 | 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 row... |
magic_evol_110k | 78,035 | Write a Python function to calculate the sum of all elements in a given list of integers. The function should handle an empty list by returning 0. The code should start with:
```python
from typing import List
def sum_of_list(numbers: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def sum_of_list(numbers: List[int]) -> int:
"""
Calculate the sum of all elements in a given list of integers.
Args:
numbers (List[int]): The list of integers to sum.
Returns:
... |
magic_evol_110k | 78,038 | Write a Python function to generate a new string that contains all the characters from the input string arranged in reverse order. The function should handle any input string and return the reversed string. The code should start with:
```python
def reverse_string(input_str: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_string(input_str: str) -> str:
"""
Generates a new string that contains all the characters from the input string arranged in reverse order.
Args:
input_str (str): The input string to be reversed.
Re... |
magic_evol_110k | 78,048 | Write a Python function to determine whether the sum of squares of the digits of a given number is divisible by 17. The function should take an integer as input and return a boolean value indicating whether the sum of squares of its digits is divisible by 17.
The code should start with:
```python
def is_sum_of_squares... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_sum_of_squares_divisible_by_17(n: int) -> bool:
"""
Determines whether the sum of squares of the digits of a given number is divisible by 17.
Args:
n (int): The number to check.
Returns:
bool: Tr... |
magic_evol_110k | 78,052 | Write a Python function to generate a random string of a specified length, containing a mix of alphabets (both uppercase and lowercase), digits, and special characters. The function should ensure that the generated string always contains at least one character from each category (alphabets, digits, and special characte... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
import string
def generate_secure_random_string(length: int) -> str:
"""
Generates a random string of the specified length, containing at least one character from each of the following categories:
- Alphabets ... |
magic_evol_110k | 78,057 | Write a Python function to find the maximum value from a series of lists embedded within a primary list, while handling potential errors such as non-numerical values and empty lists. The function should be able to navigate through nested lists and ignore non-numeric values. The code should start with:
```python
from ty... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def find_max_value(data: List[Union[int, List]]) -> Union[int, None]:
"""
Find the maximum value from a series of lists embedded within a primary list,
while handling potential errors such as ... |
magic_evol_110k | 78,065 | Write a Python function to construct a valid SMTP email address from given segments: `local_part`, `domain`, and `sub_domain`. The function should ensure that the segments are combined correctly to form a standard email address format. The code should start with:
```python
def construct_email(local_part: str, domain: s... | Here is the Python code to solve the given problem in the markdown block:
```python
def construct_email(local_part: str, domain: str, sub_domain: str) -> str:
"""
Constructs a valid SMTP email address from the given local-part, domain, and sub-domain.
Args:
local_part (str): The local part of the e... |
magic_evol_110k | 78,066 | Write a Python function to determine whether a given integer is a prime number. The function should return `True` if the number is prime and `False` otherwise. The function should handle edge cases such as numbers less than or equal to 1, which are not prime. The function should also efficiently check for primality by ... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_prime(n: int) -> bool:
"""
Determine whether a given integer is a prime number.
Args:
n (int): The integer to check for primality.
Returns:
bool: True if the integer is prime, False otherwise.
... |
magic_evol_110k | 78,068 | Write a Python function to reverse an integer array in place without using any temporary variables. The function should modify the input array directly.
The code should start with:
```python
from typing import List
def reverse_array(arr: List[int]) -> None:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_array(arr: List[int]) -> None:
"""
Reverses the given integer array in place without using any temporary variables.
Args:
arr (List[int]): The integer array to be reversed.
... |
magic_evol_110k | 78,071 | Write a Python function to filter out empty strings from a given heterogeneous list that contains various types of elements, including strings, integers, floats, and other data types. The function should return a new list that excludes all empty strings while preserving the order and type of the other elements.
The co... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
def filter_empty_strings(input_list: List[Any]) -> List[Any]:
"""
Filters out empty strings from a given heterogeneous list and returns a new list.
Args:
input_list (List[Any]): A list ... |
magic_evol_110k | 78,086 | Write a Python function that accepts two lists and returns a dictionary where each key is a unique element from the second list that exists in the first list, and its value is a tuple containing two lists:
1. The first list should contain the indices of all occurrences of the element in the first list.
2. The second l... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Tuple
def create_index_dictionary(first_list: List[int], second_list: List[int]) -> Dict[int, Tuple[List[int], List[int]]]:
"""
Creates a dictionary where each key is a unique element from the sec... |
magic_evol_110k | 78,100 | Write a Python function to construct an Elasticsearch query that searches for all records containing a "location" field with a value of "Los Angeles" and a "category" field with a value of "Technology". The function should also include pagination and sorting options. The query should be returned as a dictionary that ca... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Optional
def construct_elasticsearch_query(
location: str,
category: str,
from_index: int = 0,
size: int = 10,
sort_field: Optional[str] = None,
sort_order: str = "asc"
) -> Dict:
... |
magic_evol_110k | 78,106 | Write a Python function to calculate the total number of necklaces crafted by Ken and Tami, given that Ken crafts 25 necklaces and Tami crafts `m` more necklaces than Ken. The function should start with:
```python
def total_necklaces(m: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def total_necklaces(m: int) -> int:
"""
Calculate the total number of necklaces crafted by Ken and Tami.
Args:
m (int): The number of additional necklaces Tami crafts compared to Ken.
Returns:
int: The ... |
magic_evol_110k | 78,108 | Write a Python function to identify all even integers within a given array and substitute them with the string "Even". The function should return the modified array.
The code should start with:
```python
from typing import List
def replace_even_with_string(array: List[int]) -> List[str]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def replace_even_with_string(array: List[int]) -> List[str]:
"""
Replaces all even integers in the given array with the string "Even".
Args:
array (List[int]): The input array of integers.
... |
magic_evol_110k | 78,145 | Write a Python function to reverse a given string efficiently. The function should handle both single-word strings and multi-word strings. The code should start with:
```python
def reverse_string(input_string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_string(input_string: str) -> str:
"""
Reverses the given input string.
Args:
input_string (str): The string to be reversed.
Returns:
str: The reversed string.
"""
# Use slicing to re... |
magic_evol_110k | 78,160 | Write a Python function to sort a given list of numbers in ascending order using the Bubble Sort algorithm. The list may contain both positive and negative integers, as well as floating point numbers. The function should modify the list in place and return the sorted list.
The code should start with:
```python
from ty... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def bubble_sort(num_list: List[float]) -> List[float]:
"""
Sorts a given list of numbers in ascending order using the Bubble Sort algorithm.
Args:
num_list (List[float]): The list of numbers... |
magic_evol_110k | 78,164 | Write a Python function to sort a given array of integers in descending order using the **Selection Sort** algorithm. The function should not use any built-in sorting methods. The code should start with:
```python
from typing import List
def selection_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 selection_sort_descending(arr: List[int]) -> List[int]:
"""
Sorts the given array of integers in descending order using the Selection Sort algorithm.
Args:
arr (List[int]): The array of ... |
magic_evol_110k | 78,168 | Write a Python function to evaluate if a given integer `x` is greater than 10. If `x` is greater than 10, the function should return a string indicating that `x` is greater than 10. Otherwise, it should return a string indicating that `x` is not greater than 10. The function should handle both positive and negative int... | Here is the Python code to solve the given problem in the markdown block:
```python
def evaluate_number(x: int) -> str:
"""
Evaluates if the given integer x is greater than 10 and returns an appropriate message.
Args:
x (int): The integer to be evaluated.
Returns:
str: A string indicat... |
magic_evol_110k | 78,170 | Write a Python function to transform a given string into a list of words, replace specific words according to a predefined dictionary, and then convert the modified list back into a string. The function should handle the transformation and replacement efficiently.
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 Dict, List
def transform_and_replace(initial_string: str, replacements: Dict[str, str]) -> str:
"""
Transforms a given string into a list of words, replaces specific words according to a predefined dictionary... |
magic_evol_110k | 78,172 | Write a Python function to count the frequency of each character in a given string. The function should return a dictionary where the keys are the characters from the string and the values are the counts of those characters. The function should handle both uppercase and lowercase characters as distinct and should not c... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def count_character_frequencies(string: str) -> Dict[str, int]:
"""
Counts the frequency of each character in the given string, excluding spaces.
Args:
string (str): The input string to coun... |
magic_evol_110k | 78,175 | Write a Python function to convert a binary input (string) to its hexadecimal representation (string). The function should handle binary strings of any length and return the hexadecimal representation in uppercase letters. The code should start with:
```python
def binary_to_hex(b: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def binary_to_hex(b: str) -> str:
"""
Convert a binary input (string) to its hexadecimal representation (string).
Args:
b (str): The binary string to be converted.
Returns:
str: The hexadecimal represen... |
magic_evol_110k | 78,177 | Write a Python function to generate an exhaustive statistical summary of a given dataset. The dataset is provided as a list of dictionaries, where each dictionary represents a row in the dataset with keys as column names and values as the corresponding data. The function should return a dictionary where the keys are th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Any
from collections import Counter
import math
def generate_statistical_summary(dataset: List[Dict[str, Any]]) -> Dict[str, Dict[str, float]]:
"""
Generate an exhaustive statistical summary of a ... |
magic_evol_110k | 78,198 | Write a Python function to create the lexicographically maximum concatenation of two given strings `word1` and `word2`. The function should follow these rules:
1. As long as either `word1` or `word2` is not empty, select one of the following alternatives:
- If `word1` is not empty, append the initial character in `w... | Here is the Python code to solve the given problem in the markdown block:
```python
def max_lexicographical_merge(word1: str, word2: str) -> str:
"""
Creates the lexicographically maximum concatenation of two given strings.
Args:
word1 (str): The first input string.
word2 (str): The second ... |
magic_evol_110k | 78,207 | Write a Python function to generate a list of squared values for a sequence of integers starting from 0 up to a given number `n`. The function should return a list where each element is the square of the corresponding integer in the sequence.
The code should start with:
```python
from typing import List
def generate_... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_squared_list(n: int) -> List[int]:
"""
Generates a list of squared values for integers from 0 to n (inclusive).
Args:
n (int): The upper limit of the sequence (inclusive).
... |
magic_evol_110k | 78,220 | Write a Python function to isolate and return all unique components from a given data collection. Each component in the data collection is represented as a tuple where the first element is a string identifier and the second element is an integer value. The function should ensure that no repetitious identifiers survive ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def isolate_unique_components(data_collection: List[Tuple[str, int]]) -> List[Tuple[str, int]]:
"""
Isolates and returns all unique components from the given data collection.
Args:
da... |
magic_evol_110k | 78,226 | Write a Python function to convert a given integer into its Roman numeral form. The function should handle integers from 1 to 3999. The code should start with:
```python
def int_to_roman(num: int) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def int_to_roman(num: int) -> str:
"""
Convert a given integer into its Roman numeral form.
Args:
num (int): The integer to be converted, must be between 1 and 3999.
Returns:
str: The Roman numeral repr... |
magic_evol_110k | 78,234 | Write a Python function to calculate the area of a square whose side length is equal to the radius of a circle with a given circumference. The function should take the circumference of the circle as input and return the area of the square.
The code should start with:
```python
import math
def calculate_square_area_fr... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def calculate_square_area_from_circle_circumference(circumference: float) -> float:
"""
Calculate the area of a square whose side length is equal to the radius of a circle with a given circumference.
Args:
... |
magic_evol_110k | 78,245 | Write a Python function to print all the integer elements of a given list, and handle errors if an element is not an integer. The function should iterate through the list, check if each element is an integer, and print it if it is. If an element is not an integer, it should print an error message indicating that the el... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def print_integer_elements(my_list: List[int]) -> None:
"""
Prints all the integer elements of a given list and handles errors for non-integer elements.
Args:
my_list (List[int]): The list o... |
magic_evol_110k | 78,247 | Write a Python function to count the occurrences of a desired number in a given multi-dimensional array (up to 10x10 elements). The function should handle arrays of varying dimensions and efficiently count the occurrences of the desired number.
The code should start with:
```python
from typing import List
def count_o... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_occurrences(array: List[List[int]], desired_number: int) -> int:
"""
Counts the occurrences of a desired number in a given multi-dimensional array.
Args:
array (List[List[int]]): T... |
magic_evol_110k | 78,250 | Write a Python function to reverse a given string without using slicing or any built-in functions. The function should use a stack data structure to achieve this. The code should start with:
```python
def reverse_string_with_stack(s: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_string_with_stack(s: str) -> str:
"""
Reverses a given string using a stack data structure without using slicing or built-in functions.
Args:
s (str): The input string to be reversed.
Returns:
... |
magic_evol_110k | 78,256 | Write a Python function to calculate the Euclidean distance between two points in a 2D plane. Each point is represented by a tuple containing its x and y coordinates. The function should also handle the case where one of the points is the origin (0, 0).
The code should start with:
```python
from typing import Tuple
d... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
import math
def euclidean_distance(point1: Tuple[float, float], point2: Tuple[float, float]) -> float:
"""
Calculate the Euclidean distance between two points in a 2D plane.
Args:
point1 (T... |
magic_evol_110k | 78,258 | Write a Python function to find both the minimum value and its index position within a given tuple of integers. Do not use any built-in functions like `min()` or `index()` for this task. The function should start with:
```python
from typing import Tuple, Union
def find_min_value_and_index(T: Tuple[int, ...]) -> Union[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple, Union
def find_min_value_and_index(T: Tuple[int, ...]) -> Union[Tuple[int, int], None]:
"""
Find the minimum value and its index position within a given tuple of integers.
Args:
T (Tuple[i... |
magic_evol_110k | 78,264 | Write a Python function to calculate the running mean of a numeric array. The running mean is the mean of the array up to the current element. The function should take a list of numbers as input and return a list of running means.
The code should start with:
```python
from typing import List
def compute_running_mean(... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def compute_running_mean(data: List[float]) -> List[float]:
"""
Calculate the running mean of a numeric array.
Args:
data (List[float]): The input numeric array.
Returns:
List[f... |
magic_evol_110k | 78,275 | Write a Python function to calculate the sum of the first `n` natural numbers using an iterative approach. The function should handle edge cases such as `n` being zero or negative. The code should start with:
```python
def sum_of_first_n_numbers(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_first_n_numbers(n: int) -> int:
"""
Calculate the sum of the first n natural numbers.
Args:
n (int): The number of natural numbers to sum.
Returns:
int: The sum of the first n natural numbers... |
magic_evol_110k | 78,278 | Write a Python function to sort an unsorted array of integers in ascending order using a custom sorting algorithm. The array may contain duplicate values and negative integers. The function should not use any pre-built sorting functions. The code should start with:
```python
from typing import List
def custom_sort(arr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def custom_sort(arr: List[int]) -> List[int]:
"""
Sorts an unsorted array of integers in ascending order using a custom selection sort algorithm.
Args:
arr (List[int]): The unsorted array of... |
magic_evol_110k | 78,288 | Write a Python function named `bin_to_hex` that converts a binary string to its equivalent hexadecimal string. The function should handle binary strings with leading zeros correctly and return a hexadecimal string without the leading "0x". Additionally, debug the given erroneous function `erroneous_bin_to_hex` and expl... | Here is the Python code to solve the given problem in the markdown block:
```python
def bin_to_hex(bin_str: str) -> str:
"""
Converts a binary string to its equivalent hexadecimal string.
Args:
bin_str (str): The binary string to be converted.
Returns:
str: The hexadecimal string equiv... |
magic_evol_110k | 78,303 | Write a Python function to determine if one list of integers is strictly less than another list of integers element-wise. The function should return `True` if every element in the first list is less than the corresponding element in the second list, and `False` otherwise. The code 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 is_strictly_less(list1: List[int], list2: List[int]) -> bool:
"""
Determine if one list of integers is strictly less than another list of integers element-wise.
Args:
list1 (List[int]): ... |
magic_evol_110k | 78,312 | 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 | 78,313 | Write a Python function to reverse the order of characters in a given string. The function should handle strings of any length, including empty strings. The code should start with:
```python
def reverse_string(input_string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_string(input_string: str) -> str:
"""
Reverses the order of characters in the given string.
Args:
input_string (str): The string to be reversed.
Returns:
str: The reversed string.
"""
... |
magic_evol_110k | 78,318 | Write a Python function to create a dictionary from a given tuple where the keys are the elements of the tuple and the values are their frequencies. Then, remove duplicates and maintain the dictionary in descending order based on the values. The dictionary should be case-insensitive. The code should start with:
```pyth... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Tuple
def create_frequency_dict(my_tuple: Tuple[int]) -> Dict[int, int]:
"""
Create a dictionary from the given tuple with elements as keys and their frequencies as values.
Then, remove duplicates a... |
magic_evol_110k | 78,335 | Write a Python function to generate a Bash script for installing a given application on Ubuntu. The function should take the application name as a string and return the Bash script as a string. The script should include updating the system packages and installing the specified application using `apt-get`.
The code sho... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_install_script(application_name: str) -> str:
"""
Generates a Bash script for installing a given application on Ubuntu.
Args:
application_name (str): The name of the application to install.
Returns... |
magic_evol_110k | 78,341 | Write a Python function to perform arithmetic operations on a given string representation of a number, ensuring that the operations are correctly executed by converting the string to an integer. The function should handle addition, subtraction, multiplication, and division operations. The function should return the res... | Here is the Python code to solve the given problem in the markdown block:
```python
def perform_arithmetic_operation(number_str: str, operation: str, operand: int) -> int:
"""
Perform an arithmetic operation on a given string representation of a number.
Args:
number_str (str): The string representa... |
magic_evol_110k | 78,344 | Write a Python function to sort a given list of integers in descending order and return the sorted list. The function should handle lists of any length, including empty lists. 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 list of integers in descending order.
Args:
numbers (List[int]): The list of integers to be sorted.
Returns:
Li... |
magic_evol_110k | 78,346 | Write a Python function to replace target strings with replacement strings in a given text, ensuring that the replacements are case-insensitive. The function should handle multiple target-replacement pairs and return the modified text.
The code should start with:
```python
from typing import List
def replace_text(tex... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def replace_text(text: str, target: List[str], replacement: List[str]) -> str:
"""
Replaces target strings with replacement strings in a given text in a case-insensitive manner.
Args:
text (... |
magic_evol_110k | 78,367 | Write a Python function to sum up the first `n` odd integers. The function should take an integer `n` as input and return the sum of the first `n` odd integers. The function should be efficient and handle edge cases such as `n` being zero or negative.
The code should start with:
```python
def sum_of_first_n_odds(n: in... | Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_first_n_odds(n: int) -> int:
"""
Calculate the sum of the first n odd integers.
Args:
n (int): The number of odd integers to sum.
Returns:
int: The sum of the first n odd integers.
The s... |
magic_evol_110k | 78,369 | Write a Python function to reverse the order of words in a given string. The function should take a string `text` as input and return a new string with the words in the reverse order. The words in the input string are separated by spaces. The function should handle multiple spaces between words and leading/trailing spa... | Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_words_in_string(text: str) -> str:
"""
Reverses the order of words in a given string.
Args:
text (str): The input string containing words separated by spaces.
Returns:
str: A new string with... |
magic_evol_110k | 78,375 | Write a Python function to determine whether a given number is a Mersenne prime. A Mersenne prime is a prime number that is one less than a power of two. The function should return `True` if the number is a Mersenne prime, and `False` otherwise. The code should start with:
```python
def is_mersenne_prime(n: int) -> boo... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_mersenne_prime(n: int) -> bool:
"""
Determine whether a given number is a Mersenne prime.
A Mersenne prime is a prime number that is one less than a power of two.
Args:
n (int): The number to check.
... |
magic_evol_110k | 78,401 | Write a Python function to efficiently check if a specific element is present in a given list. The function should return `True` if the element is found, and `False` otherwise. The function should be optimized for both computational complexity and speed.
The code should start with:
```python
from typing import List
d... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_element_in_list(my_list: List[int], element: int) -> bool:
"""
Efficiently checks if a specific element is present in a given list.
Args:
my_list (List[int]): The list in which to sea... |
magic_evol_110k | 78,402 | Write a Python function to simulate a rudimentary routing framework that handles an HTTP GET request. The function should parse a given URL path and query parameters, and return a JSON response based on predefined routes and query parameters. The response should include a status code, a message, and any additional data... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Any
from urllib.parse import urlparse, parse_qs
def handle_get_request(url: str) -> Dict[str, Any]:
"""
Simulate a rudimentary routing framework to handle an HTTP GET request.
Args:
url (st... |
magic_evol_110k | 78,417 | Write a Python function to delete an element from a specific index in a three-dimensional list. The function should take a three-dimensional list and a tuple representing the index to delete. The function should return a new three-dimensional list with the specified element removed.
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, Tuple
def delete_element_3d(array: List[List[List[int]]], index: Tuple[int, int, int]) -> List[List[List[int]]]:
"""
Deletes an element from a specific index in a three-dimensional list.
Args:
... |
magic_evol_110k | 78,424 | Write a Python function to check if all elements in a given list are equal. If they are equal, the function should return a tuple containing `True`, the maximum element, and the minimum element of the list. If the list is empty, the function should return `False`. If the elements are not equal, the function should retu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Optional
def check_elements_equal(lst: List[int]) -> Tuple[bool, Optional[int], Optional[int]]:
"""
Check if all elements in the given list are equal. If they are equal, return a tuple containing... |
magic_evol_110k | 78,427 | Write a Python function that computes the sum of squares of each integer in a provided tuple and appends the results to a designated list. The function should handle various scenarios, including:
- Empty tuples and return a specific error message.
- Tuples containing zero and negative integers.
- Nested tuples (tuples ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Union
def sum_of_squares_tuple(tup: Tuple[Union[int, Tuple]], lst: List[int], level: int = 1) -> Union[List[int], str]:
"""
Computes the sum of squares of each integer in a provided tuple and app... |
magic_evol_110k | 78,428 | Write a Python function to traverse a given list in descending order and return a new list containing the elements in the reverse order. The function should start with:
```python
from typing import List
def reverse_traverse(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 reverse_traverse(array: List[int]) -> List[int]:
"""
Traverse the given list in descending order and return a new list with the elements in reverse order.
Args:
array (List[int]): The ... |
magic_evol_110k | 78,429 | Write a Python function to perform a binary search on a sorted list of integers to find the index of a given element. If the element is not found, return -1. The function should be efficient and leverage the sorted nature of the list.
The code should start with:
```python
from typing import List
def binary_search(ele... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def binary_search(elements: List[int], search_element: int) -> int:
"""
Perform a binary search on a sorted list to find the index of a given element.
Args:
elements (List[int]): A sorted li... |
magic_evol_110k | 78,431 | Write a Python function to convert a given list of integers into a list of their corresponding Roman numeral representations. The function should handle integers from 1 to 3999. The code should start with:
```python
from typing import List
def int_to_roman(nums: List[int]) -> List[str]:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def int_to_roman(nums: List[int]) -> List[str]:
"""
Converts a list of integers to their corresponding Roman numeral representations.
Args:
nums (List[int]): A list of integers to be conve... |
magic_evol_110k | 78,435 | Write a Python function to determine if a given string is a valid palindrome considering only alphanumeric characters and ignoring cases. The function should return `True` if the string is a valid palindrome, otherwise `False`.
The code should start with:
```python
def is_valid_palindrome(s: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def is_valid_palindrome(s: str) -> bool:
"""
Determines if a given string is a valid palindrome considering only alphanumeric characters and ignoring cases.
Args:
s (str): The input string to be checked.
Retu... |
magic_evol_110k | 78,444 | Write a Python function to generate a new list where each string from a given list of strings is repeated according to the corresponding number in a list of numbers and then passed through a provided function. The function should handle cases where the lengths of the string list and the number list do not match by trun... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Callable
def generate_repeated_transformed_list(strings: List[str], numbers: List[int], function: Callable[[str], str]) -> List[str]:
"""
Generates a new list where each string from the given list is re... |
magic_evol_110k | 78,448 | Write a Python function to determine if two given strings are anagrams of each other. An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. The function should return `True` if the two strings are anagrams, and `False` othe... | Here is the Python code to solve the given problem in the markdown block:
```python
def are_anagrams(s1: str, s2: str) -> bool:
"""
Determine if two strings are anagrams of each other.
Args:
s1 (str): The first string to compare.
s2 (str): The second string to compare.
Returns:
... |
magic_evol_110k | 78,458 | Write a Python function to find the highest peak in an array of integers representing elevation data. A peak is defined as a sequence of continuous ascending sub-array followed by a descending sub-array, and the highest peak is the one with the highest value. If there are multiple highest peaks, the function should ret... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def find_highest_peaks(data: List[int]) -> Optional[List[int]]:
"""
Find the highest peak(s) in an array of integers representing elevation data.
A peak is defined as a sequence of continu... |
magic_evol_110k | 78,507 | Write a Python function to divide two lists element-wise. The function should handle edge cases such as division by zero and non-numeric inputs. Additionally, the function should be able to handle lists of different lengths by treating missing elements in the shorter list as zeros. The function should return a list of ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def element_wise_division(list1: List[float], list2: List[float]) -> List[str]:
"""
Divides two lists element-wise. Handles division by zero and non-numeric inputs.
If the lists are of different leng... |
magic_evol_110k | 78,518 | Write a Python function to calculate the additional amount of fencing needed when a rectangular yard is divided into two smaller equal rectangles by adding a vertical fence midway through the yard. The yard has a fixed width and a variable length. The function should take the width and length of the yard as input and r... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_extra_fencing(width: int, length: int) -> int:
"""
Calculate the additional amount of fencing needed when a rectangular yard is divided into two smaller equal rectangles by adding a vertical fence midway through th... |
magic_evol_110k | 78,519 | Write a Python function to calculate the cumulative total of only the prime numbers present in a given list of integers. The function should be efficient and handle various edge cases, such as an empty list or a list containing non-prime numbers.
The code should start with:
```python
from typing import List
def cumul... | 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 | 78,538 | Write a Python function to efficiently determine the prime factors of a large input number (up to \(10^{18}\)) and count how many times each prime factor occurs. The function should be optimized for both time and space complexity, considering scenarios where the input number changes frequently. The function should hand... | Here is the Python code to solve the given problem in the markdown block:
```python
from collections import Counter
from typing import Counter as CounterType
def prime_factors_count(n: int) -> CounterType[int]:
"""
Efficiently determine the prime factors of a large input number (up to 10^18) and count how many... |
magic_evol_110k | 78,545 | Write a Python function that generates a list of numbers from 0 to a given positive integer `n`, where each number is multiplied by a specified factor `f`. The function should return the resulting list. The code should start with:
```python
from typing import List
def generate_multiplied_numbers(n: int, f: int) -> Lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_multiplied_numbers(n: int, f: int) -> List[int]:
"""
Generates a list of numbers from 0 to n, where each number is multiplied by the factor f.
Args:
n (int): The upper limit (in... |
magic_evol_110k | 78,556 | Write a Python function to determine if two given input strings contain the same unique words. The function should ignore the order of words and handle duplicate words by considering them as a single unique word. The function should start with:
```python
def compare_word_sets(phrase1: str, phrase2: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def compare_word_sets(phrase1: str, phrase2: str) -> bool:
"""
Determine if two provided phrases have identical sets of unique words.
Args:
phrase1 (str): The first phrase to compare.
phrase2 (str): The seco... |
magic_evol_110k | 78,557 | Write a Python function to alter an existing array by appending the number two to each individual element in the array. The function should handle both integer and string elements in the array. The code should start with:
```python
from typing import List, Union
def append_two_to_elements(arr: List[Union[int, str]]) -... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def append_two_to_elements(arr: List[Union[int, str]]) -> List[str]:
"""
Alters an existing array by appending the number two to each individual element in the array.
Args:
arr (List[... |
magic_evol_110k | 78,574 | Write a Python function to generate a new sequence where each element in the given sequence of integers is replaced by its square root. The function should handle both positive and negative integers by taking the absolute value before computing the square root. 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 math
def generate_square_roots(sequence: List[int]) -> List[float]:
"""
Generates a new sequence where each element in the given sequence of integers is replaced by its square root.
Args:
... |
magic_evol_110k | 78,578 | Write a Python function to encrypt a given text using the ROT13 cipher. The ROT13 cipher is a simple substitution cipher that replaces a letter with the 13th letter after it in the alphabet. This function should handle both uppercase and lowercase letters, leaving any non-alphabetic characters unchanged.
The code shou... | Here is the Python code to solve the given problem in the markdown block:
```python
def rot13_encrypt(text: str) -> str:
"""
Encrypts the given text using the ROT13 cipher.
The ROT13 cipher replaces each letter with the letter 13 positions after it in the alphabet.
Non-alphabetic characters remain unch... |
magic_evol_110k | 78,584 | Write a Python function to transform a nested list into a dictionary with specific transformations on the incoming data. The nested list contains pairs of (fruit, number). The function should:
1. Create a dictionary where the keys are the fruits and the values are lists of transformed numbers as strings.
2. For duplica... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def transform_nested_list(arr: List[Tuple[str, int]]) -> Dict[str, List[str]]:
"""
Transforms a nested list of (fruit, number) tuples into a dictionary where:
- The keys are the fruits.
... |
magic_evol_110k | 78,600 | Write a Python function to determine if two given strings are isomorphic. Two strings are considered isomorphic if there is a one-to-one mapping between every character in the first string and every character in the second string. The function should ensure that the mapping is consistent in both directions.
The code s... | Here is the Python code to solve the given problem in the markdown block:
```python
def are_isomorphic(str1: str, str2: str) -> bool:
"""
Determine if two strings are isomorphic.
Two strings are considered isomorphic if there is a one-to-one mapping between every character in the first string and every cha... |
magic_evol_110k | 78,614 | Write a Python function to sort a given list of integers in ascending order using the Merge Sort algorithm. The function should be able to handle lists of any size, including empty lists. The code should start with:
```python
from typing import List
def merge_sort(arr: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_sort(arr: List[int]) -> List[int]:
"""
Sorts a list of integers in ascending order using the Merge Sort algorithm.
Args:
arr (List[int]): The list of integers to be sorted.
Re... |
magic_evol_110k | 78,615 | Write a Python function to find the intersecting elements between two given numerical arrays. The function should return a list of unique intersecting elements in the order they appear in the first array. The code should start with:
```python
from typing import List
def find_intersection(arr1: List[int], arr2: List[in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_intersection(arr1: List[int], arr2: List[int]) -> List[int]:
"""
Finds the intersecting elements between two numerical arrays and returns them in the order they appear in the first array.
A... |
magic_evol_110k | 78,618 | Write a Python function to analyze a provided string of characters, ignoring case and special characters, and return the number of occurrences of each alphanumeric character. The results should be sorted by frequency in descending order, and then alphabetically in ascending order for characters with the same frequency.... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
from collections import Counter
def analyze_string(input_string: str) -> List[Tuple[str, int]]:
"""
Analyzes a provided string of characters, ignoring case and special characters,
and returns ... |
magic_evol_110k | 78,624 | Write a Python function to generate prime numbers from a given sequence of whole numbers. The function should use a generator expression to iterate through the sequence and yield only the prime numbers. The function should start with:
```python
from typing import List, Generator
def generate_primes(sequence: List[int]... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Generator
def is_prime(n: int) -> bool:
"""
Determine whether a given number is prime.
Args:
n (int): The number to check for primality.
Returns:
bool: True if the number is pr... |
magic_evol_110k | 78,628 | Write a Python function to perform a ternary search on a sorted numerical array. The function should return the index of the target element if it exists in the array, otherwise return -1. The ternary search divides the array into three parts and recursively narrows down the search space.
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 ternary_search(arr: List[int], x: int) -> int:
"""
Perform a ternary search on a sorted numerical array to find the index of the target element.
Args:
arr (List[int]): A sorted list of i... |
magic_evol_110k | 78,663 | Write a Python function to calculate the median of a given list of distinct integers. The median is the middle value in a sorted list of numbers. If the list has an odd number of elements, the median is the middle element. If the list has an even number of elements, the median is the average of the two middle elements.... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def calculate_median(numbers: List[int]) -> Optional[float]:
"""
Calculate the median of a list of distinct integers.
The median is the middle value in a sorted list of numbers. If the lis... |
magic_evol_110k | 78,677 | Write a Python function to generate a new array where the sequence of elements is reversed compared to the original array provided. The function should not use any built-in functions or slicing techniques to reverse the array. Instead, it should implement a custom algorithm to achieve the reversal.
The code should sta... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_array(arr: List[int]) -> List[int]:
"""
Reverses the sequence of elements in the given array without using built-in functions or slicing.
Args:
arr (List[int]): The input array t... |
magic_evol_110k | 78,690 | Write a Python function to arrange a sequential set of integers into variable-sized clusters based on a given cluster size parameter. If the length of the list is not a multiple of the cluster size, the remaining numbers should form a cluster of their own with a smaller size. The function should start with:
```python
f... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def cluster_integers(nums: List[int], size: int) -> List[List[int]]:
"""
Arranges a sequential set of integers into variable-sized clusters based on the given cluster size.
Args:
nums (List[... |
magic_evol_110k | 78,693 | Write a Python function to retrieve the substring that comes after a designated special character in a given string. If the special character is not found in the string, return an error message. The function should handle cases where the special character is at the end of the string, returning an empty string in such c... | Here is the Python code to solve the given problem in the markdown block:
```python
def retrieve_substring_after_special_character(string: str, special_character: str) -> str:
"""
Retrieves the substring that comes after a designated special character in a given string.
Args:
string (str): The inpu... |
magic_evol_110k | 78,694 | Write a Python function to add two items to a list, ensuring that the items are not duplicates and that the list is initialized correctly. The function should handle edge cases such as adding items to an already populated list or attempting to add duplicate items.
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, Any
def add_items_to_list(items_list: List[Any], item1: Any, item2: Any) -> List[Any]:
"""
Adds two items to a list, ensuring that the items are not duplicates and the list is initialized correctly.
... |
magic_evol_110k | 78,697 | Write a Python function to convert a list of tuples into a dictionary where each tuple's second element serves as the key and the concatenated full name (first element + space + second element) serves as the value. The function should handle cases where the list might be empty or contain duplicate keys.
The code shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def convert_to_dict(tuple_list: List[Tuple[str, str]]) -> Dict[str, str]:
"""
Converts a list of tuples into a dictionary where each tuple's second element
serves as the key and the conc... |
magic_evol_110k | 78,704 | Write a Python function to determine if a given target integer is present in a provided array of integers. The function should return a boolean value indicating whether the target is found in the array. The code should start with:
```python
from typing import List
def is_target_in_array(nums: List[int], target: int) -... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_target_in_array(nums: List[int], target: int) -> bool:
"""
Determines if the target integer is present in the provided array of integers.
Args:
nums (List[int]): The array of integers... |
magic_evol_110k | 78,710 | Write a Python function to generate a sequence of numbers based on the equation \(3x - 5\) for a given list of integers. The function should take a list of integers as input and return a list of integers where each element is calculated using the equation \(3x - 5\).
The code should start with:
```python
from typing i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_sequence(seq: List[int]) -> List[int]:
"""
Generate a sequence of numbers based on the equation 3x - 5 for a given list of integers.
Args:
seq (List[int]): A list of integers fo... |
magic_evol_110k | 78,715 | Write a Python function to determine if there exist two unique indices `i` and `j` in a given array `nums` such that `nums[i]` equals `nums[j]` and the absolute difference between `i` and `j` is less than or equal to `k`. The function should return a boolean value `True` if such indices exist, otherwise `False`.
The c... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def contains_nearby_duplicate(nums: List[int], k: int) -> bool:
"""
Determines if there are two unique indices i and j in the array nums such that
nums[i] equals nums[j] and the absolute difference b... |
magic_evol_110k | 78,719 | Write a Python function to multiply two floating-point numbers and return the result as a floating-point number. Additionally, implement a function to multiply two integers and return the result as a floating-point number. Ensure that the function handles both positive and negative numbers, as well as zero. The code sh... | Here is the Python code to solve the given problem in the markdown block:
```python
def multiply_floats(number1: float, number2: float) -> float:
"""
Multiplies two floating-point numbers and returns the result as a floating-point number.
Args:
number1 (float): The first floating-point number.
... |
magic_evol_110k | 78,738 | Write a Python function to generate and return a new matrix where every individual integer in the given matrix has been multiplied by a factor of 'n', where 'n' is a non-zero integer provided by the user. The function should be capable of handling matrices of varying sizes, including both square and non-square matrices... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def multiply_matrix_by_factor(matrix: List[List[int]], n: int) -> List[List[int]]:
"""
Multiplies each element in the given matrix by the factor 'n' and returns the new matrix.
Args:
matrix ... |
magic_evol_110k | 78,741 | Write a Python function to determine if the balance of a bank account goes below zero during a series of transactions. Each transaction is represented by a tuple containing an operation (either 'deposit' or 'withdrawal') and a value (either an integer or a string that can be converted to an integer). The function shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Union
def below_zero(operations: List[Tuple[str, Union[int, str]]], case_insensitive: bool = False) -> bool:
"""
Determine if the balance of a bank account goes below zero during a series of tran... |
magic_evol_110k | 78,759 | Write a Python function to compute the total sum of all numeric entities (integers and floating-point numbers) within a specified three-dimensional array. The array can contain mixed data types, including strings and other non-numeric entities. The function should skip non-numeric entities during the total calculation.... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_numeric_values(matrix: List[List[List[object]]]) -> float:
"""
Computes the total sum of all numeric entities (integers and floating-point numbers)
within a specified three-dimensional array.... |
magic_evol_110k | 78,762 | Write a Python function to swap the values of two lists of distinct integer variables in-place. The function should ensure that the lists have the same length before performing the swap. The solution should not use any pre-built or third-party Python library methods or functions for swapping, and it should optimize mem... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def swap_lists(list1: List[int], list2: List[int]) -> None:
"""
Swaps the values of two lists of distinct integer variables in-place.
Args:
list1 (List[int]): The first list of integers.
... |
magic_evol_110k | 78,767 | Write a Python function to return only the positive numbers from a given list, sorted in ascending order. Additionally, implement a helper function to swap elements within the list. The code should start with:
```python
from typing import List
def get_positive_and_sort(l: List[int]) -> List[int]:
"""Return only po... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def get_positive_and_sort(l: List[int]) -> List[int]:
"""
Return only positive numbers in the list, sorted in ascending order.
Args:
l (List[int]): The input list of integers.
Returns:
... |
magic_evol_110k | 78,779 | Write a Python function to extract elements with the value "Pineapple" and "Strawberries" from a given tuple without using built-in functions or libraries. The function should use algorithmic logic to achieve this.
The code should start with:
```python
from typing import Tuple, List
def extract_specific_fruits(fruits... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple, List
def extract_specific_fruits(fruits: Tuple[str, ...]) -> List[str]:
"""
Extracts elements with the value "Pineapple" and "Strawberries" from the provided tuple.
Args:
fruits (Tuple[str... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.