source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
magic_evol_110k | 97,965 | Write a Python function to verify the existence of a specific element within a given numerical array and return its index if found, otherwise return -1. The function should also validate the input to ensure that all elements of the array are either integers or floats, and the target element is also either an integer or... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def find_element_index(arr: List[Union[int, float]], target: Union[int, float]) -> Union[int, str]:
"""
Verifies the existence of a specific element within a given numerical array and returns its ... |
magic_evol_110k | 97,986 | Write a Python function to implement the selection sort algorithm to sort an array in ascending order. 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 selection_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 selection_sort(arr: List[int]) -> List[int]:
"""
Sorts an array in ascending order using the selection sort algorithm.
Args:
arr (List[int]): The array to be sorted.
Returns:
... |
magic_evol_110k | 97,990 | Write a Python function to find and return the smallest prime number in a given array of integers. If no prime numbers are found, the function should return `None`.
The code should start with:
```python
from typing import List, Optional
def find_smallest_prime(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 is_prime(n: int) -> bool:
"""
Check if a number is prime.
Args:
n (int): The number to check.
Returns:
bool: True if the number is prime, False otherwise.
"""
... |
magic_evol_110k | 97,991 | Write a Python function to merge two ascending-ordered numeric arrays into a single ascending-ordered array without using the built-in `sorted` function. The function should efficiently merge the arrays in O(p + q) time complexity, where p and q are the lengths of the two arrays.
The code should start with:
```python
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_sorted_arrays(A: List[int], B: List[int]) -> List[int]:
"""
Merges two ascending-ordered numeric arrays into a single ascending-ordered array.
Args:
A (List[int]): The first ascend... |
magic_evol_110k | 97,992 | Write a Python function that performs a series of operations on two lists of integers based on a list of operation names. The operations include merging the lists, finding common elements, finding unique elements, sorting in descending order, finding the difference between elements, calculating the length of the list, ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def list_operations(list1: List[int], list2: List[int], operations: List[str]) -> List[int]:
"""
Perform a series of operations on two lists of integers based on a list of operation names.
Args:
... |
magic_evol_110k | 97,993 | Write a Python function to filter and group highly rated novels by their authors. The function should take a list of dictionaries, where each dictionary represents a novel with keys `title`, `rating`, and `author`. The function should return a dictionary where the keys are the authors and the values are lists of titles... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def group_highly_rated_novels(novels: List[Dict[str, any]]) -> Dict[str, List[str]]:
"""
Filters and groups highly rated novels by their authors.
Args:
novels (List[Dict[str, any]]): A... |
magic_evol_110k | 97,995 | Write a Python function that removes the first element from a given list without modifying the original list. The function should return a new list with the first element removed. The code should start with:
```python
from typing import List
def remove_first_element(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 remove_first_element(arr: List[int]) -> List[int]:
"""
Removes the first element from the given list and returns a new list without modifying the original list.
Args:
arr (List[int]): Th... |
magic_evol_110k | 98,005 | Write a Python function to compute the sum of the first `n` natural numbers efficiently. The function should use an optimized mathematical approach rather than a loop to achieve this. 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:
"""
Computes the sum of the first n natural numbers using an optimized mathematical approach.
Args:
n (int): The number of natural numbers to sum.
Returns:
int... |
magic_evol_110k | 98,006 | Write a Python function to calculate the sum of all numeric digits in a given string. The string may contain both alphabetic characters and numeric digits. The function should iterate through the string, identify each numeric digit, convert it to an integer, and then sum these integers. The function should return the c... | Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_digits(s: str) -> int:
"""
Calculate the sum of all numeric digits in a given string.
Args:
s (str): The input string containing both alphabetic characters and numeric digits.
Returns:
int: T... |
magic_evol_110k | 98,032 | Write a Python function to extract the second, third, and fourth elements from a given list. If the list has fewer than four elements, return an empty list. The function should be named `extract_elements` and should take a single parameter, `input_list`, which is a list of integers. The function should return a list co... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def extract_elements(input_list: List[int]) -> List[int]:
"""
Extracts the second, third, and fourth elements from the given list.
Args:
input_list (List[int]): The list from which to extrac... |
magic_evol_110k | 98,040 | Write a Python function to merge two dictionaries, `dictA` and `dictB`, into a single dictionary. If both dictionaries have the same key, the value from `dictB` should overwrite the value from `dictA`. The function should be efficient and handle any size of dictionaries.
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 Dict
def merge_dictionaries(dictA: Dict[str, int], dictB: Dict[str, int]) -> Dict[str, int]:
"""
Merge two dictionaries, `dictA` and `dictB`, into a single dictionary.
If both dictionaries have the same k... |
magic_evol_110k | 98,056 | Write a Python function to calculate the maximum subarray sum in a given array using Kadane's Algorithm. The function should handle both positive and negative numbers in the array. The code should start with:
```python
from typing import List
def max_subarray_sum(array: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_subarray_sum(array: List[int]) -> int:
"""
Calculate the maximum subarray sum in a given array using Kadane's Algorithm.
Args:
array (List[int]): The input array of integers.
Re... |
magic_evol_110k | 98,090 | Write a Python function to calculate the square of each element in a given list and return a new list containing these squared values. The function should handle lists of any length and should not modify the original list. The code should start with:
```python
from typing import List
def square_elements(dataset: List[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def square_elements(dataset: List[int]) -> List[int]:
"""
Calculate the square of each element in the given list and return a new list containing these squared values.
Args:
dataset (List[in... |
magic_evol_110k | 98,092 | Write a Python function to perform binary search on a sorted list and return the index of the target element if it exists in the list. If the target element is not found, return the string "Not Found". The function should be efficient and should handle edge cases such as an empty list or a target that is not present in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def binary_search(arr: List[int], target: int) -> Union[int, str]:
"""
Perform a binary search on a sorted list to find the index of the target element.
Args:
arr (List[int]): A sorte... |
magic_evol_110k | 98,108 | Write a Python function to sort a given list of integers using the Cocktail Shaker Sort algorithm. The Cocktail Shaker Sort is a variation of the Bubble Sort that sorts the list in both directions (left to right and right to left) in alternating passes. The function should return the sorted list.
The code should start... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def cocktail_shaker_sort(arr: List[int]) -> List[int]:
"""
Sorts a list of integers using the Cocktail Shaker Sort algorithm.
Args:
arr (List[int]): The list of integers to be sorted.
R... |
magic_evol_110k | 98,126 | Write a Python function to find the length of the longest substring without repeating characters in a given string. The function should efficiently compute this length using a sliding window approach.
The code should start with:
```python
def length_of_longest_substring(s: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def length_of_longest_substring(s: str) -> int:
"""
Find the length of the longest substring without repeating characters in the given string.
Args:
s (str): The input string to analyze.
Returns:
int: T... |
magic_evol_110k | 98,127 | Write a Python function to compute the area of a triangle given the length of one of its sides and the corresponding height. The function should validate the input to ensure that both the side length and the height are positive numbers. If the input is invalid, the function should raise a `ValueError`. The code should ... | Here is the Python code to solve the given problem in the markdown block:
```python
def triangle_area(side_length: float, height: float) -> float:
"""
Compute the area of a triangle given the length of one of its sides and the corresponding height.
Args:
side_length (float): The length of one side ... |
magic_evol_110k | 98,143 | Write a Python function to identify and return the vowels in a given string. The function should return a list of vowels found in the string, preserving their order of appearance. The function should be case-insensitive, meaning both uppercase and lowercase vowels should be considered.
The code should start with:
```p... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_vowels(s: str) -> List[str]:
"""
Identify and return the vowels in a given string.
Args:
s (str): The input string to search for vowels.
Returns:
List[str]: A list of v... |
magic_evol_110k | 98,178 | Write a Python function to detect unique numerical elements in a set of mixed sequences. The function should take a list of strings as input and return a set of unique digits found across all sequences. Each string in the list may contain a mix of alphabetic characters and digits.
The code should start with:
```python... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Set
import re
def find_unique_digits(sequences: List[str]) -> Set[str]:
"""
Detects unique numerical elements in a set of mixed sequences.
Args:
sequences (List[str]): A list of strings, ea... |
magic_evol_110k | 98,190 | Write a Python function to compute the sum of two numbers. The function should be named `sum_of_numbers` and should take two parameters, `num1` and `num2`, both of which are integers. The function should return the sum of these two numbers.
The code should start with:
```python
def sum_of_numbers(num1: int, num2: int)... | Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_numbers(num1: int, num2: int) -> int:
"""
Computes the sum of two integers.
Args:
num1 (int): The first integer to be summed.
num2 (int): The second integer to be summed.
Returns:
int... |
magic_evol_110k | 98,210 | Write a Python function to generate the Fibonacci sequence up to the nth term, starting from the initial term of 1. The function should return a list containing the Fibonacci sequence. The code should start with:
```python
from typing import List
def generate_fibonacci(n: int) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_fibonacci(n: int) -> List[int]:
"""
Generate the Fibonacci sequence up to the nth term, starting from the initial term of 1.
Args:
n (int): The number of terms in the Fibonacci ... |
magic_evol_110k | 98,215 | Write a Python function to find the maximum value in a given list of integers without using the built-in `max()` function. The function should iterate through the list and keep track of the highest value encountered. The code should start with:
```python
from typing import List
def find_maximum(data: List[int]) -> int... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_maximum(data: List[int]) -> int:
"""
Find the maximum value in a list of integers without using the built-in max() function.
Args:
data (List[int]): The list of integers from which ... |
magic_evol_110k | 98,232 | Write a Python function to find the most lengthy text from a given array of textual elements that has a number of characters no more than a specified limit `k`. If no text meets the criteria, return a specific message indicating that no valid text was found.
The code should start with:
```python
from typing import Lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_most_lengthy_text(arr: List[str], k: int) -> str:
"""
Finds the most lengthy text from a given array of textual elements that has a number of characters no more than k.
Args:
arr (L... |
magic_evol_110k | 98,235 | Write a Python function to find the longest common subsequence (LCS) between two given strings. The function should return the length of the LCS.
The code should start with:
```python
def longest_common_subsequence(str1: str, str2: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def longest_common_subsequence(str1: str, str2: str) -> int:
"""
Calculate the length of the longest common subsequence (LCS) between two strings.
Args:
str1 (str): The first string.
str2 (str): The second s... |
magic_evol_110k | 98,320 | Write a Python function to rotate an array by a specified number of steps in a counter-clockwise direction. The function should handle both positive and negative step values, where a positive step value indicates a counter-clockwise rotation, and a negative step value indicates a clockwise rotation. The function should... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def rotate_array(arr: List[int], steps: int) -> List[int]:
"""
Rotates the given array by the specified number of steps in a counter-clockwise direction.
Args:
arr (List[int]): The array to ... |
magic_evol_110k | 98,323 | Write a Python function to compute the total sum of all numeric entities contained within a specified two-dimensional array (matrix). The function should handle matrices of varying sizes and ensure that only numeric values are summed. The code should start with:
```python
from typing import List
def sum_matrix_element... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_matrix_elements(matrix: List[List[int]]) -> int:
"""
Computes the total sum of all numeric entities contained within a specified two-dimensional array (matrix).
Args:
matrix (List[Li... |
magic_evol_110k | 98,324 | Write a Python function to print a diamond numeric pattern in reverse order. The pattern should be centered and the numbers should decrease from the center line to the edges. The function should take an integer `n` as input, where `n` represents the number of rows in the upper half of the diamond (excluding the center ... | Here is the Python code to solve the given problem in the markdown block:
```python
def print_diamond_numeric_pattern(n: int):
"""
Prints a diamond numeric pattern in reverse order.
Args:
n (int): The number of rows in the upper half of the diamond (excluding the center line).
Returns:
... |
magic_evol_110k | 98,327 | Write a Python function to generate and store the first 10 prime numbers in a list. The function should implement an algorithm to verify the primality of each number before adding it to the list. The function should start with:
```python
def generate_first_10_primes() -> list:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def generate_first_10_primes() -> list:
"""
Generates and returns the first 10 prime numbers.
Returns:
list: A list containing the first 10 prime numbers.
"""
def is_prime(n: int) -> bool:
"""
... |
magic_evol_110k | 98,328 | Write a Python function to traverse and print all elements in a four-dimensional array, and count the occurrences of each number within the array. The function should return a dictionary where the keys are the numbers found in the array and the values are their respective counts. The function should be optimized for ti... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def traverse_and_count_elements(arr: List[List[List[List[int]]]]) -> Dict[int, int]:
"""
Traverse a four-dimensional array and count the occurrences of each number.
Args:
arr (List[Lis... |
magic_evol_110k | 98,331 | Write a Python function to create a list of squares of the first n natural numbers using a for loop. The function should return the list of squares. The code should start with:
```python
from typing import List
def generate_squares(n: int) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_squares(n: int) -> List[int]:
"""
Generates a list of squares of the first n natural numbers.
Args:
n (int): The number of natural numbers for which to generate squares.
Re... |
magic_evol_110k | 98,347 | Write a Python function to find the index of a specified element in a given list of letters. If the element is not found, return -1. The function should handle cases where the list is empty or the element is not present in the list.
The code should start with:
```python
from typing import List
def find_element_index(... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_element_index(letters: List[str], element: str) -> int:
"""
Find the index of a specified element in a given list of letters.
Args:
letters (List[str]): The list of letters in which... |
magic_evol_110k | 98,354 | Write a Python function to find the smallest integer in a given array of integers. The array can contain between 10 and 1000 elements and may include both positive and negative integers. If the array contains any non-integer elements, the function should return -1. The function should be optimized for large-scale input... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_smallest_integer(input_array: List[int]) -> int:
"""
Find the smallest integer in a given array of integers.
Args:
input_array (List[int]): The array of integers to search for the s... |
magic_evol_110k | 98,355 | Write a Python function to clean a given text by converting all occurrences of double spaces to single spaces and ensuring that the first and last characters of the text are not spaces. The function should handle any length of text, including empty strings.
The code should start with:
```python
def clean_text(text: st... | Here is the Python code to solve the given problem in the markdown block:
```python
def clean_text(text: str) -> str:
"""
Cleans the given text by converting all occurrences of double spaces to single spaces
and ensuring that the first and last characters of the text are not spaces.
Args:
text ... |
magic_evol_110k | 98,367 | Create a Python function to find the longest common subsequence (LCS) between two given strings. The function should return the length of the LCS.
The code should start with:
```python
def longest_common_subsequence(str1: str, str2: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def longest_common_subsequence(str1: str, str2: str) -> int:
"""
Calculate the length of the longest common subsequence (LCS) between two strings.
Args:
str1 (str): The first string.
str2 (str): The second s... |
magic_evol_110k | 98,373 | Write a Python function to convert a given string from lowercase to title case, where the first letter of each word is capitalized. The function should handle strings with multiple words separated by spaces. The code should start with:
```python
def to_title_case(string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def to_title_case(string: str) -> str:
"""
Converts a given string from lowercase to title case, where the first letter of each word is capitalized.
Args:
string (str): The input string to be converted to title case... |
magic_evol_110k | 98,378 | Write a Python function to identify sequences containing only uppercase letters and digits from a given list of input strings. The function should correctly handle erroneous cases where sequences might contain lowercase letters or special characters. The function should return a list of boolean values indicating whethe... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def detect_sequence(input_string: str) -> bool:
"""
Determines if a given string contains only uppercase letters and digits.
Args:
input_string (str): The string to be checked.
... |
magic_evol_110k | 98,380 | Write a Python function to extract a list of unique words from a given text, sorted in alphabetical order. The function should handle various edge cases, such as empty strings, multiple spaces, and punctuation. The code should start with:
```python
from typing import List
def extract_unique_words(text: str) -> List[st... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import string
def extract_unique_words(text: str) -> List[str]:
"""
Extracts a list of unique words from a given text, sorted in alphabetical order.
Args:
text (str): The input text from whi... |
magic_evol_110k | 98,394 | Write a Python function to determine if a given integer is even or odd. The function should return a string "Yes, it's even" if the number is even, and "No, it's odd" if the number is odd. The function should handle any integer input.
The code should start with:
```python
def check_even_or_odd(number: int) -> str:
```... | Here is the Python code to solve the given problem in the markdown block:
```python
def check_even_or_odd(number: int) -> str:
"""
Determines if the given integer is even or odd and returns a corresponding string.
Args:
number (int): The integer to be checked.
Returns:
str: "Yes, it's ... |
magic_evol_110k | 98,396 | Write a Python function to initialize a 2D list (matrix) with a given value. The function should take the number of rows, the number of columns, and the initial value as inputs. The function should return the initialized 2D list.
The code should start with:
```python
from typing import List
def initialize_2d_list(row... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def initialize_2d_list(rows: int, cols: int, value: int) -> List[List[int]]:
"""
Initializes a 2D list (matrix) with a given value.
Args:
rows (int): The number of rows in the matrix.
... |
magic_evol_110k | 98,413 | Write a Python function to parse a URL string into its components. The function should return a dictionary containing the following keys: `protocol`, `hostname`, `pathname`, `search`, `hash`, and `parameters`. The `parameters` key should be a dictionary containing the query parameters as key-value pairs.
The code shou... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
from urllib.parse import urlparse, parse_qs
def parse_url(url: str) -> Dict[str, str]:
"""
Parse a URL string into its components and return them as a dictionary.
Args:
url (str): The URL st... |
magic_evol_110k | 98,416 | Write a Python function to find the greatest common divisor (GCD) of two integers using the Euclidean algorithm. The function should be efficient and 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 | 98,418 | Write a Python function to parse a string of musical notes and return a list of integers representing the duration of each note. The musical notes are represented by unique ASCII characters, and each note has a specific duration in beats. The function should handle unknown notes by assigning them a duration of 0.
The ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def parse_music(music_string: str) -> List[int]:
"""
Parses a string of musical notes and returns a list of integers representing the duration of each note.
Args:
music_string (str): A strin... |
magic_evol_110k | 98,423 | Write a Python function to determine if one array of integers is a subset of another array of integers. The function should return a boolean value indicating whether the second array is a subset of the first array. The function should handle duplicate elements correctly and should not use Python's built-in set operatio... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_subset(arr1: List[int], arr2: List[int]) -> bool:
"""
Determine if the second array is a subset of the first array.
Args:
arr1 (List[int]): The first array of integers.
arr2 (... |
magic_evol_110k | 98,428 | Write a Python function to generate a sequence of integers starting from 1 up to a given number `n`. The function should return a list containing all the integers from 1 to `n` inclusive.
The code should start with:
```python
from typing import List
def generate_sequence(n: int) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def generate_sequence(n: int) -> List[int]:
"""
Generate a sequence of integers starting from 1 up to the given number n.
Args:
n (int): The upper limit of the sequence (inclusive).
Ret... |
magic_evol_110k | 98,429 | Write a Python function to calculate the Least Common Multiple (LCM) of four integers (w, x, y, and z) efficiently, ensuring that the algorithm conserves computational resources. The function should handle the given boundaries: 1 <= w, x, y, z <= 10^9. The code should start with:
```python
import math
def lcm_of_four(... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def lcm_of_four(w: int, x: int, y: int, z: int) -> int:
"""
Calculate the Least Common Multiple (LCM) of four integers (w, x, y, z) efficiently.
Args:
w (int): The first integer.
x (int): The se... |
magic_evol_110k | 98,436 | Write a Python function to find the largest prime number in a given array of integers. The function should return `None` if no prime number is found in the array. The code should start with:
```python
from typing import List, Optional
def find_largest_prime(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 is_prime(num: int) -> bool:
"""
Check if a given number is prime.
Args:
num (int): The number to check for primality.
Returns:
bool: True if the number is prime, F... |
magic_evol_110k | 98,470 | Write a Python function to demonstrate the difference between mutable and immutable objects in Python. The function should take a string and a list as input, modify them, and return the modified versions along with the original references to show how the modifications affect the original objects.
The code should start... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
def modify_objects(s: str, lst: list) -> Tuple[str, str, list, list]:
"""
Demonstrates the difference between mutable and immutable objects in Python.
Args:
s (str): An immutable string obj... |
magic_evol_110k | 98,473 | Write a Python function to initialize and return a list of `n` empty lists. The function should ensure that each of the `n` lists is distinct and not a reference to the same list object. The code should start with:
```python
from typing import List
def create_n_empty_lists(n: int) -> List[List[int]]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def create_n_empty_lists(n: int) -> List[List[int]]:
"""
Creates and returns a list containing `n` empty lists.
Args:
n (int): The number of empty lists to create.
Returns:
List... |
magic_evol_110k | 98,491 | Create a Python function to simulate sending automated emails based on a JSON message. The JSON message contains the subject, body, recipient names, and recipient email addresses. The function should parse the JSON message, format the email content, and print the email details for each recipient. The code should start ... | Here is the Python code to solve the given problem in the markdown block:
```python
import json
from typing import List, Dict
def send_emails(message: str) -> None:
"""
Simulates sending automated emails based on a JSON message.
Args:
message (str): A JSON string containing the email subject, body... |
magic_evol_110k | 98,496 | Write a Python function to move all the zeros to the end of a given list while maintaining the relative order of the non-zero elements. The function should be efficient and should not use any additional data structures except for a constant amount of extra space.
The code should start with:
```python
from typing impor... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def move_zeros(nums: List[int]) -> None:
"""
Moves all zeros to the end of the list while maintaining the relative order of non-zero elements.
Args:
nums (List[int]): The list of integers to... |
magic_evol_110k | 98,517 | Write a Python function to generate a list of all prime numbers in the range from 0 to `n` efficiently. The function should not use any built-in or library functions for prime number generation directly. The function should be optimized to have a time complexity better than O(n^2). The code should start with:
```python... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_primes(n: int) -> list:
"""
Generate a list of all prime numbers in the range from 0 to `n`.
Args:
n (int): The upper limit of the range (inclusive).
Returns:
list: A list of prime numbers ... |
magic_evol_110k | 98,530 | Write a Python function to determine if one set is a subset of another set without using any built-in set functions. The function should return `True` if the first set is a subset of the second set, and `False` otherwise. The function should start with:
```python
def is_subset(s1: set, s2: set) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_subset(s1: set, s2: set) -> bool:
"""
Determine if the first set `s1` is a subset of the second set `s2` without using built-in set functions.
Args:
s1 (set): The first set to check if it is a subset.
... |
magic_evol_110k | 98,536 | Write a Python function to calculate the maximum sum of all possible subarrays of a given array. Each subarray is a contiguous segment of the input array. The function should return the maximum sum found amongst all subarrays.
The code should start with:
```python
from typing import List
def max_subarray_sum(arr: Lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def max_subarray_sum(arr: List[int]) -> int:
"""
Calculate the maximum sum of all possible subarrays of a given array.
Args:
arr (List[int]): The input array of integers.
Returns:
... |
magic_evol_110k | 98,540 | Write a Python function to determine whether two given strings are permutations of each other. A permutation is defined as two strings having the same characters with the same frequencies. The function should be case-sensitive and should handle any ASCII characters.
The code should start with:
```python
from typing im... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
from collections import Counter
def are_permutations(str1: str, str2: str) -> bool:
"""
Determines whether two given strings are permutations of each other.
Args:
str1 (str): The first strin... |
magic_evol_110k | 98,559 | Write a Python function to convert a given time in military format (24-hour format) to the conventional 12-hour clock format with AM/PM notation. The input will be a string representing the time in "HH:MM" format, and the output should be a string in "HH:MM AM/PM" format.
The code should start with:
```python
from dat... | Here is the Python code to solve the given problem in the markdown block:
```python
from datetime import datetime
def convert_to_12_hour_format(time_str: str) -> str:
"""
Converts a given time in military format (24-hour format) to the conventional 12-hour clock format with AM/PM notation.
Args:
t... |
magic_evol_110k | 98,564 | Write a Python function to calculate the area of a triangle given its base and height. The function should return the area as a floating-point number. The code should start with:
```python
def calculate_triangle_area(base: float, height: float) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_triangle_area(base: float, height: float) -> float:
"""
Calculate the area of a triangle given its base and height.
Args:
base (float): The base of the triangle.
height (float): The height of t... |
magic_evol_110k | 98,593 | Write a Python function to find the kth smallest element in a sorted array efficiently, even when the array contains duplicate elements. The function should handle edge cases such as when k is out of bounds or when the array is empty.
The code should start with:
```python
from typing import List, Optional
def kth_sma... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def kth_smallest_element(arr: List[int], k: int) -> Optional[int]:
"""
Returns the kth smallest element in a sorted array.
Args:
arr (List[int]): The sorted array from which to fin... |
magic_evol_110k | 98,600 | Write a Python function to generate a list of 25 non-repeating random numbers from 0 to 8. Additionally, the function should count and return the number of occurrences of numbers at odd and even index positions within the list.
The code should start with:
```python
from typing import List, Tuple
import random
def gen... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import random
def generate_and_count_random_numbers() -> Tuple[List[int], int, int]:
"""
Generates a list of 25 non-repeating random numbers from 0 to 8 and counts the occurrences of numbers at od... |
magic_evol_110k | 98,605 | Write a Python function to transform each alphabet character in a given sentence into its lowercase equivalent. The function should handle sentences with any combination of uppercase and lowercase letters, numbers, and special characters. The function should return the transformed sentence.
The code should start with:... | Here is the Python code to solve the given problem in the markdown block:
```python
def to_lowercase(sentence: str) -> str:
"""
Transforms each alphabet character in the given sentence into its lowercase equivalent.
Args:
sentence (str): The input sentence to be transformed.
Returns:
s... |
magic_evol_110k | 98,607 | Write a Python function to calculate the average of corresponding elements in two numerical lists. If one list is shorter than the other, treat the missing elements as 0 (zero) while calculating the average. The function should handle any numerical data types including integers, floats, and complex numbers. The functio... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def average_vectors(vec1: List[Union[int, float, complex]], vec2: List[Union[int, float, complex]]) -> List[Union[int, float, complex]]:
"""
Calculate the average of corresponding elements in two ... |
magic_evol_110k | 98,608 | Write a Python function to simulate a simple session management system for a web application. The function should handle user authentication and maintain session state. The function should start with:
```python
from typing import Dict, Optional
def session_manager(username: str, password: str, sessions: Dict[str, str]... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Optional
import random
import string
def session_manager(username: str, password: str, sessions: Dict[str, str]) -> Optional[str]:
"""
Simulate a simple session management system for a web application.
... |
magic_evol_110k | 98,611 | Write a Python function to generate a list of rolling maximum and minimum elements and their indices from a given list of integers. The function should return a list of tuples, where each tuple contains two tuples: one for the rolling maximum element and its index, and one for the rolling minimum element and its index,... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def rolling_max_min_indices(numbers: List[int]) -> List[Tuple[Tuple[int, int], Tuple[int, int]]]:
"""
Generate a list of rolling maximum and minimum elements and their indices from a given list of... |
magic_evol_110k | 98,622 | Write a Python function to sort a list of sentences in descending order based on the number of vowels each sentence contains. If two sentences have the same number of vowels, the sentence with the earliest first occurrence of a vowel should be placed first. The function 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 sort_sentences_by_vowels(sentences: List[str]) -> List[str]:
"""
Sorts a list of sentences in descending order based on the number of vowels each sentence contains.
If two sentences have the same... |
magic_evol_110k | 98,625 | Write a Python function to filter out prime numbers from a given list of integers. The function should return a list containing only the prime numbers from the input list. The code should start with:
```python
from typing import List
def filter_primes(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 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 | 98,648 | Write a Python function to decode the semantics associated with an arbitrary alphabet character presented to it. The function should be case-insensitive and return a predefined semantic description for each character in the English alphabet. If the character is not found in the predefined dictionary, the function shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
def get_semantics(character: str) -> str:
"""
Decodes the semantics associated with an arbitrary alphabet character.
Args:
character (str): The character for which to retrieve the semantic description.
Returns:... |
magic_evol_110k | 98,657 | Write a Python function to calculate the sum of two provided integer values, ensuring attention to potential errors and validation of input types. The function should handle cases where the inputs are not integers and return an appropriate error message.
The code should start with:
```python
def sum_of_integers(a: str... | Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_integers(a: str, b: str) -> str:
"""
Calculate the sum of two provided integer values, ensuring input validation.
Args:
a (str): The first integer value as a string.
b (str): The second integer va... |
magic_evol_110k | 98,658 | Write a Python function to convert a given binary string to its hexadecimal representation. The function should handle the conversion in a multi-staged process: first converting the binary string to its decimal representation, and then converting the decimal representation to its hexadecimal format. The function should... | Here is the Python code to solve the given problem in the markdown block:
```python
def binary_to_hex(binary_string: str) -> str:
"""
Converts a given binary string to its hexadecimal representation.
Args:
binary_string (str): The binary string to be converted.
Returns:
str: The hexade... |
magic_evol_110k | 98,675 | Write a Python function to validate if a given string is in the standard American telephone number format `(XXX) XXX-XXXX`, where `X` is a digit. The function should return `True` if the string matches the format and `False` otherwise. The code should start with:
```python
import re
def is_valid_telephone_number(numbe... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def is_valid_telephone_number(number: str) -> bool:
"""
Validates if the given string is in the standard American telephone number format (XXX) XXX-XXXX.
Args:
number (str): The string to be validated.
... |
magic_evol_110k | 98,690 | Write a Python function to search for a specific integer within a collection of integers represented as an array. The function should return the index of the first occurrence of the target integer if it exists in the array, otherwise it should return -1. The function should be efficient and handle edge cases such as an... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def search_integer(array: List[int], target: int) -> int:
"""
Searches for a specific integer within a collection of integers represented as an array.
Args:
array (List[int]): The array of i... |
magic_evol_110k | 98,700 | Write a Python function to convert a given list of integers into a dictionary where each integer in the list is a key, and the corresponding value is the square of the integer represented as a string. The function should handle lists of any length, including empty lists.
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, Dict
def list_to_squared_dict(lst: List[int]) -> Dict[int, str]:
"""
Converts a list of integers into a dictionary where each integer is a key,
and the corresponding value is the square of the integ... |
magic_evol_110k | 98,711 | Write a Python function to calculate the absolute difference between two numbers. The function should take two numerical inputs and return the absolute value of their difference. The code should start with:
```python
def absolute_difference(a: float, b: float) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def absolute_difference(a: float, b: float) -> float:
"""
Calculate the absolute difference between two numbers.
Args:
a (float): The first number.
b (float): The second number.
Returns:
float: ... |
magic_evol_110k | 98,759 | Write a Python function to calculate the sum and product of all elements in a given list of integers. The function should return a tuple containing the sum and the product of the non-zero elements. The function should handle cases where the list contains zeros correctly.
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, Tuple
def sum_and_product(nums: List[int]) -> Tuple[int, int]:
"""
Calculate the sum and product of all elements in a given list of integers.
Args:
nums (List[int]): The list of integers fr... |
magic_evol_110k | 98,762 | Write a Python function to merge two sorted lists into a single sorted list. The function should efficiently combine the elements from both lists while maintaining the sorted order. The code should start with:
```python
from typing import List
def merge_sorted_lists(list1: List[int], list2: 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_sorted_lists(list1: List[int], list2: List[int]) -> List[int]:
"""
Merge two sorted lists into a single sorted list.
Args:
list1 (List[int]): The first sorted list.
list2 (... |
magic_evol_110k | 98,767 | Write a Python function to convert a given ratio of cups to quarts into its simplest form as a fraction. The function should return the fraction as a tuple of integers representing the numerator and denominator. The code should start with:
```python
def simplify_ratio(cups: int, quarts: int) -> tuple:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from math import gcd
def simplify_ratio(cups: int, quarts: int) -> tuple:
"""
Convert the ratio of cups to quarts into its simplest form as a fraction.
Args:
cups (int): The number of cups.
quarts (int): Th... |
magic_evol_110k | 98,775 | Write a Python function to find both the maximum and minimum values in an unsorted array of integers using a modified binary search algorithm. The algorithm should avoid comparing each element with every other element and should be adaptive to changes in the sorted order of the elements. The function should return a tu... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_min_max(arr: List[int]) -> Tuple[int, int]:
"""
Find both the minimum and maximum values in an unsorted array using a modified binary search algorithm.
Args:
arr (List[int]):... |
magic_evol_110k | 98,789 | Write a Python function to filter out numbers from a given list that are divisible by a specified factor. The function should return a list of numbers that are not divisible by the specified factor. The code should start with:
```python
from typing import List
def filter_non_divisible(data: List[int], factor: int) -> ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_non_divisible(data: List[int], factor: int) -> List[int]:
"""
Filters out numbers from the given list that are divisible by the specified factor.
Args:
data (List[int]): The list ... |
magic_evol_110k | 98,792 | Write a Python function to analyze a given sequence of characters and return a dictionary containing the frequency of each distinct alphabet character in the input string. Additionally, the dictionary should include two special keys: 'vowels' and 'consonants', which represent the cumulative frequency of all vowel and c... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def analyze_character_frequency(input_str: str) -> Dict[str, int]:
"""
Analyzes the frequency of each distinct alphabet character in the input string and returns a dictionary.
The dictionary includes... |
magic_evol_110k | 98,793 | Write a Python function to calculate the exponential value of a given integer `x` using the `math.exp` function. The function should handle both positive and negative integers and return the result as a floating-point number. The code should start with:
```python
import math
def calculate_exponential(x: int) -> float:... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def calculate_exponential(x: int) -> float:
"""
Calculate the exponential value of a given integer x using the math.exp function.
Args:
x (int): The integer whose exponential value is to be calculated.
... |
magic_evol_110k | 98,794 | Write a Python function to analyze and provide the time complexity of a given nested loop structure. The function should take a list of integers as input and return the time complexity in terms of the length of the list. The function should also print the number of iterations performed by the nested loops.
The code sh... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def analyze_time_complexity(arr: List[int]) -> str:
"""
Analyzes and provides the time complexity of a nested loop structure.
Args:
arr (List[int]): The input list of integers.
Returns:... |
magic_evol_110k | 98,802 | Write a Python function that calculates the product of all odd numbers in a provided list and checks if the product is a prime number. The function should handle non-numeric values gracefully by printing an error message and excluding them from the calculation. The function should also print whether the product is a pr... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import math
def product_of_odd_numbers(lst: List[int]) -> int:
"""
Calculate the product of all odd numbers in the provided list and check if the product is a prime number.
Args:
lst (List[i... |
magic_evol_110k | 98,805 | Write a Python function to simulate a linked list and perform operations such as appending a node, deleting a node, and printing the list. The function should handle the linked list operations efficiently and return the state of the linked list after each operation.
The code should start with:
```python
from typing im... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Optional, List
class Node:
def __init__(self, data: int):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def append_node(self, data: int... |
magic_evol_110k | 98,825 | Write a Python function to recursively extract the values of specified keys from a nested JSON object. The function should handle cases where the specified keys do not exist in the JSON data and return an appropriate message. The function should also be able to handle additional layers of depth in the JSON data without... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List, Any
def extract_values_from_json(json_data: Dict[str, Any], keys_to_extract: List[str]) -> Dict[str, Any]:
"""
Recursively extracts the values of specified keys from a nested JSON object.
Arg... |
magic_evol_110k | 98,843 | Implement the Quick Sort algorithm for a list of strings based on their lexicographical order. Additionally, optimize the Quick Sort algorithm to reduce its worst-case complexity from O(n^2) to O(n log n) by using the 'median of three' pivot selection method. The 'median of three' method involves selecting the median o... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def quick_sort(arr: List[str]) -> List[str]:
"""
Sorts a list of strings using the Quick Sort algorithm with the 'median of three' pivot selection method.
Args:
arr (List[str]): The list of ... |
magic_evol_110k | 98,855 | Write a Python function to move all zeroes in a given list to the end of the list while maintaining the relative order of the non-zero elements. The function should not use any additional data structures; it should modify the list in place.
The code should start with:
```python
from typing import List
def move_zeroes... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def move_zeroes_to_end(array: List[int]) -> None:
"""
Moves all zeroes in the given list to the end while maintaining the relative order of the non-zero elements.
The list is modified in place.
... |
magic_evol_110k | 98,867 | Write a Python function to find the smallest absolute difference between any two elements from two given lists of integers. The function should efficiently compute this difference by leveraging sorting and a two-pointer technique to minimize the time complexity.
The code should start with:
```python
from typing import... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_min_difference(list1: List[int], list2: List[int]) -> int:
"""
Find the smallest absolute difference between any two elements from two given lists of integers.
Args:
list1 (List[int... |
magic_evol_110k | 98,891 | Write a Python function to reverse a given list and return the reversed list. The function should handle lists of any length, including empty lists. The code should start with:
```python
from typing import List
def reverse_list(lst: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_list(lst: List[int]) -> List[int]:
"""
Reverses the given list and returns the reversed list.
Args:
lst (List[int]): The list to be reversed.
Returns:
List[int]: The... |
magic_evol_110k | 98,897 | Write a Python function to generate a list of unique random numbers within a specified range. The function should ensure that all numbers in the list are unique and within the given range. The code should start with:
```python
from typing import List
import random
def generate_unique_random_numbers(n: int, start: int,... | 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(n: int, start: int, end: int) -> List[int]:
"""
Generate a list of n unique random numbers within the specified range [start, end].
Args:
n (... |
magic_evol_110k | 98,899 | Write a Python function to determine if a given integer `n` can be rearranged to form a power of 2. The rearrangement must ensure that the leading digit is not zero. The function should return `True` if such a rearrangement is possible, and `False` otherwise.
The code should start with:
```python
def can_reorder_to_po... | Here is the Python code to solve the given problem in the markdown block:
```python
def can_reorder_to_power_of_2(n: int) -> bool:
"""
Determines if the digits of the given integer `n` can be rearranged to form a power of 2.
Args:
n (int): The integer to check for reordering to a power of 2.
R... |
magic_evol_110k | 98,904 | Write a Python function to determine the larger of two given numerical input values. The function should return the higher or larger numerical value from the supplied inputs. The code should start with:
```python
def larger_num(num1: float, num2: float) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def larger_num(num1: float, num2: float) -> float:
"""
Returns the larger of two given numerical input values.
Args:
num1 (float): The first numerical input value.
num2 (float): The second numerical input va... |
magic_evol_110k | 98,919 | Write a Python function to sort a list of integers in ascending order using a custom sorting algorithm. The function should take in a list of integers and return a sorted list. The given list to sort is: `[9, 15, 5, 11, 4]`. You are not allowed to use any built-in sorting functions.
The code should start with:
```pyth... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def custom_sort(lst: List[int]) -> List[int]:
"""
Sorts a list of integers in ascending order using a custom selection sort algorithm.
Args:
lst (List[int]): The list of integers to be sorte... |
magic_evol_110k | 98,920 | Write a Python function to compute the product of all elements in a given list of numerical values efficiently. The function should handle lists of any length, including empty lists, and return the product of the elements. If the list is empty, the function should return 1 as the product.
The code should start with:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import functools
import operator
def product_of_list(numbers: List[int]) -> int:
"""
Compute the product of all elements in a given list of numerical values.
Args:
numbers (List[int]): A lis... |
magic_evol_110k | 98,962 | Write a Python function to find the nth number in the Fibonacci sequence using a recursive algorithm with memoization to optimize runtime performance. The function should handle edge cases such as negative inputs and return the correct Fibonacci number for non-negative integers.
The code should start with:
```python
d... | Here is the Python code to solve the given problem in the markdown block:
```python
def fibonacci_memoized(n: int) -> int:
"""
Calculate the nth Fibonacci number using a recursive algorithm with memoization.
Args:
n (int): The position in the Fibonacci sequence to calculate.
Returns:
i... |
magic_evol_110k | 98,985 | Write a Python function to reverse a given string, particularly an English greeting phrase. The function should handle any string input and return the reversed string. The code should start with:
```python
def reverse_greeting(s: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_greeting(s: str) -> str:
"""
Reverses a given string, particularly an English greeting phrase.
Args:
s (str): The input string to be reversed.
Returns:
str: The reversed string.
"""
... |
magic_evol_110k | 98,990 | Write a Python function to determine if a given string is a palindrome. The function should handle special characters, punctuation, and case insensitivity. Additionally, it should return an appropriate error message if the provided input is not a valid string. The function should start with:
```python
def is_palindrome... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Union
def is_palindrome(s: str) -> Union[bool, str]:
"""
Determines if a given string is a palindrome, ignoring case, spaces, and special characters.
Args:
s (str): The string to be checked for b... |
magic_evol_110k | 99,007 | Write a Python function to extract prime numbers from a given list of integers and return a new list containing only the prime numbers. The function should be efficient and handle various edge cases, such as an empty list or a list with non-prime numbers.
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 extract_primes(nums: List[int]) -> List[int]:
"""
Extracts prime numbers from a given list of integers.
Args:
nums (List[int]): A list of integers from which to extract prime numbers.
... |
magic_evol_110k | 99,008 | Write a Python function to sort a list of dictionaries based on the values of the 'score' key in either ascending or descending order. The function should accept a list of dictionaries and a boolean flag indicating the order of sorting (True for descending, False for ascending). 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, Dict, Union
def sort_by_score(lst: List[Dict[str, int]], descending: bool = False) -> List[Dict[str, int]]:
"""
Sorts a list of dictionaries based on the 'score' key in either ascending or descending or... |
magic_evol_110k | 99,014 | Write a Python function to transform a given chronology annotation into a specialized format of `mm/dd/yyyy`. The input will be a string in the format `Month Day, Year`, such as `April 14, 2021`. The function should convert this into the format `mm/dd/yyyy`.
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 convert_date_format(date_str: str) -> str:
"""
Converts a date string from the format 'Month Day, Year' to 'mm/dd/yyyy'.
Args:
date_str (str): The input date string in the format 'Month ... |
magic_evol_110k | 99,016 | Write a Python function to determine the primality of a provided integer, yielding `True` for prime numbers and `False` otherwise. The function should be efficient and handle edge cases such as negative numbers, 0, and 1. The function should start with:
```python
def is_prime(n: int) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_prime(n: int) -> bool:
"""
Determines if 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 | 99,031 | Write a Python function to split a given string into individual words, disregarding any punctuation attached to the words, and converting all resultant words into their lower case format. The function should not use built-in Python libraries or methods for splitting and converting the string.
The code should start wit... | Here is the Python code to solve the given problem in the markdown block:
```python
def split_string_into_words(input_string: str) -> list:
"""
Splits a given string into individual words, disregarding any punctuation attached to the words,
and converts all resultant words into their lower case format.
... |
magic_evol_110k | 99,038 | Write a Python function to compute the Greatest Common Divisor (GCD) of two positive integers using the Euclidean algorithm. The function should handle the case where one or both of the integers are zero by returning 0. The code should start with:
```python
def compute_gcd(a: int, b: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def compute_gcd(a: int, b: int) -> int:
"""
Compute the Greatest Common Divisor (GCD) of two positive integers using the Euclidean algorithm.
Args:
a (int): The first positive integer.
b (int): The second po... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.