source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
magic_evol_110k | 81,732 | Write a Python function to determine if a bank account balance goes below zero at any point given a list of deposit and withdrawal operations. The function should also include an optional `case_insensitive` flag that, when set to `True`, will return `True` if the balance hits zero. The function should start with:
```py... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def below_zero(operations: List[int], case_insensitive: bool = False) -> bool:
"""
Determine if the bank account balance goes below zero at any point given a list of operations.
If the case_insensiti... |
magic_evol_110k | 81,748 | Write a Python function to solve a given Sudoku puzzle. The function should take a 9x9 Sudoku board as input, where empty cells are represented by 0, and return the solved board. The function should use a backtracking algorithm to fill in the empty cells and ensure that the solution is valid according to Sudoku rules.
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def solve_sudoku(board: List[List[int]]) -> List[List[int]]:
"""
Solve a given Sudoku puzzle using a backtracking algorithm.
Args:
board (List[List[int]]): A 9x9 Sudoku board where empty cel... |
magic_evol_110k | 81,766 | Write a Python function to generate a list of prime numbers within a given range [start, end]. The function should efficiently determine if a number is prime and return a list of all prime numbers in the specified range.
The code should start with:
```python
from typing import List
def generate_prime_numbers(start: i... | 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 | 81,769 | Write a Python function to convert a complex string of lowercase Roman numerals back into their respective positive integers. The Roman numeral string input will cover a range from 'm' to 'mm'. The function should handle the subtraction rule where a smaller numeral before a larger numeral indicates subtraction (e.g., '... | Here is the Python code to solve the given problem in the markdown block:
```python
def advanced_roman_to_int(roman: str) -> int:
"""
Converts a complex string of lowercase Roman numerals back into its equivalent positive integer.
The Roman numeral string input covers a range from 'm' to 'mm'.
Args:
... |
magic_evol_110k | 81,771 | Write a Python function to determine if a given string is a palindrome. The function should be case-insensitive and ignore spaces. The code should start with:
```python
def is_palindrome(s: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def is_palindrome(s: str) -> bool:
"""
Determines if a given string is a palindrome, ignoring case and spaces.
Args:
s (str): The input string to be checked for palindrome properties.
Returns:
bool: T... |
magic_evol_110k | 81,776 | Write a Python function to calculate the sum of all values in each list within a given dictionary. The dictionary contains keys that map to lists of integers. The function should return a new dictionary where each key is the same as in the input dictionary, but the value is the sum of the integers in the corresponding ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, List
def sum_of_values_in_lists(data: Dict[str, List[int]]) -> Dict[str, int]:
"""
Calculate the sum of all values in each list within a given dictionary.
Args:
data (Dict[str, List[int]]):... |
magic_evol_110k | 81,779 | 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 | 81,788 | Write a Python function to transform a given string into its uppercase format without using any built-in string methods like `upper()`. The function should iterate through each character of the string, check if it is a lowercase letter, and convert it to its uppercase equivalent using ASCII values.
The code should sta... | Here is the Python code to solve the given problem in the markdown block:
```python
def to_uppercase(input_string: str) -> str:
"""
Transforms the provided string into an all-capitalized format without using any built-in string methods.
Args:
input_string (str): The input string to be converted to ... |
magic_evol_110k | 81,796 | Write a Python function to generate the first `n` prime numbers using a do-while loop emulation. The function should return a list of the first `n` prime numbers. The code should start with:
```python
from typing import List
def generate_first_n_primes(n: 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(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, False other... |
magic_evol_110k | 81,799 | Write a Python function to calculate the combined sum of a given array which possibly contains both numerical integers and their Roman numeral equivalents. The function should be able to convert Roman numerals to their integer equivalents and sum them up with the numerical integers in the array.
The code should start ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def roman_to_int(s: str) -> int:
"""
Convert a Roman numeral string to an integer.
Args:
s (str): The Roman numeral string to convert.
Returns:
int: The integer equivalen... |
magic_evol_110k | 81,811 | Write a Python function to convert meters to kilometers, ensuring the function handles edge cases and is unit testable. The function should raise a `ValueError` if the input is a negative number. The code should start with:
```python
def convert_meters_to_kilometers(meters: float) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def convert_meters_to_kilometers(meters: float) -> float:
"""
Converts meters to kilometers.
Args:
meters (float): The number of meters to convert.
Returns:
float: The equivalent number of kilometers.
... |
magic_evol_110k | 81,888 | 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(X: str, Y: str) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def longest_common_subsequence(X: str, Y: str) -> int:
"""
Calculate the length of the longest common subsequence between two strings.
Args:
X (str): The first string.
Y (str): The second string.
Return... |
magic_evol_110k | 81,891 | Write a Python function to check whether a given string contains any punctuation characters and count the number of each punctuation used in the string. The function should return a dictionary where the keys are the punctuation characters and the values are the counts of those characters in the string. The function sho... | Here is the Python code to solve the given problem in the markdown block:
```python
from string import punctuation
from typing import Dict
def count_punctuations(s: str) -> Dict[str, int]:
"""
Counts the number of each punctuation character in the given string.
Args:
s (str): The input string to a... |
magic_evol_110k | 81,915 | Write a Python function to reverse the order of characters in a given string. The function should take a single parameter, which is the string to be reversed, and return the reversed string. The code should start with:
```python
def reverse_string(s: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_string(s: str) -> str:
"""
Reverses the order of characters in the given string.
Args:
s (str): The string to be reversed.
Returns:
str: The reversed string.
"""
# Use slicing to rev... |
magic_evol_110k | 81,918 | Write a Python function to calculate the mode(s) of a given list of numbers without using Python's `statistics` library. The function should handle cases where there are multiple modes. The code should start with:
```python
from typing import List
def calculate_mode(numbers: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
from collections import Counter
def calculate_mode(numbers: List[int]) -> List[int]:
"""
Calculate the mode(s) of a given list of numbers without using Python's statistics library.
Args:
num... |
magic_evol_110k | 81,930 | Write a Python function to perform element-wise multiplication of two vectors of the same dimension. The vectors can have any dimension, not necessarily five. The function should return the resultant vector after multiplication. If the vectors are not of the same dimension, the function should return an error message i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union
def element_wise_multiplication(a: List[int], b: List[int]) -> Union[List[int], str]:
"""
Perform element-wise multiplication of two vectors of the same dimension.
Args:
a (List[int])... |
magic_evol_110k | 81,934 | Write a Python function to randomly reorder a list of arbitrary floating-point numbers without any discernible pattern. The function should ensure that each possible permutation of the list is equally likely to be returned. The code should start with:
```python
from typing import List
import random
def random_reorder(... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def random_reorder(lst: List[float]) -> List[float]:
"""
Randomly reorders a list of floating-point numbers without any discernible pattern.
Args:
lst (List[float]): The list o... |
magic_evol_110k | 81,937 | Write a Python function to determine if a given string is an isogram, which is a word or phrase without any repeating alphabetic characters, regardless of case. The function should ignore non-alphabetic characters and treat uppercase and lowercase letters as equivalent.
The code should start with:
```python
def is_iso... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_isogram(string: str) -> bool:
"""
Determines if a given string is an isogram, which is a word or phrase without any repeating alphabetic characters.
Args:
string (str): The input string to check.
Returns... |
magic_evol_110k | 81,938 | Write a Python function to create two 2-dimensional arrays of size 10x10, populated with random integer values between 0 and 99. The function should then compare these arrays to find and return a list of tuples, where each tuple contains a common integer found at the same location in both arrays and the corresponding l... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import numpy as np
def find_common_integers(seed: int) -> List[Tuple[int, Tuple[int, int]]]:
"""
Creates two 10x10 arrays with random integers between 0 and 99, and finds common integers at the sa... |
magic_evol_110k | 81,939 | Write a Python function to find the index of an element in a list without raising a `ValueError` if the element is not found. Instead of using a try-except block, the function should return a special value (e.g., `-1`) to indicate that the element is not present in the list.
The code should start with:
```python
from ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
def find_index(chars: List[Any], element: Any) -> int:
"""
Find the index of an element in a list. If the element is not found, return -1.
Args:
chars (List[Any]): The list in which to ... |
magic_evol_110k | 81,944 | Write a Python function to sort a list of dictionaries based on the values of the 'public_id' keys in descending order. The function should return the sorted list.
The code should start with:
```python
from typing import List, Dict
def sort_by_public_id(data: List[Dict[str, any]]) -> List[Dict[str, any]]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def sort_by_public_id(data: List[Dict[str, any]]) -> List[Dict[str, any]]:
"""
Sorts a list of dictionaries based on the values of the 'public_id' keys in descending order.
Args:
data ... |
magic_evol_110k | 81,949 | Write a Python function to generate a distinct list of `n` random numbers within the range [20, 50], and then sort this list in ascending order efficiently. The function should ensure that all numbers in the list are unique and within the specified range.
The code should start with:
```python
from typing import List
i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_and_sort_random_numbers(n: int) -> List[int]:
"""
Generates a distinct list of `n` random numbers within the range [20, 50] and sorts it in ascending order.
Args:
... |
magic_evol_110k | 81,972 | 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 | 81,976 | Write a Python function to calculate the nth Bell number using dynamic programming. The Bell number represents the number of ways to partition a set of n elements. The function should start with:
```python
def bell_number(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def bell_number(n: int) -> int:
"""
Calculate the nth Bell number using dynamic programming.
Args:
n (int): The index of the Bell number to calculate.
Returns:
int: The nth Bell number.
"""
# Cr... |
magic_evol_110k | 81,991 | Write a Python function to calculate the sum of an array of integers. The function should handle an empty array by returning 0. The code should start with:
```python
from typing import List
def calculate_sum(numbers: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_sum(numbers: List[int]) -> int:
"""
Calculate the sum of an array of integers.
Args:
numbers (List[int]): A list of integers.
Returns:
int: The sum of the integers... |
magic_evol_110k | 81,995 | Write a Python function to represent a given number in its expanded form. The expanded form of a number is a way of writing the number as a sum of each digit multiplied by its corresponding place value. For example, the expanded form of 270,240 is "200000 + 70000 + 200 + 40".
The code should start with:
```python
def ... | Here is the Python code to solve the given problem in the markdown block:
```python
def expanded_form(num: int) -> str:
"""
Returns the expanded form of a given number as a string.
The expanded form of a number is a way of writing the number as a sum of each digit
multiplied by its corresponding place ... |
magic_evol_110k | 82,009 | Write a Python function to enhance a given textual content by enclosing it within an appropriate HTML tag. The function should allow the user to specify the HTML tag to be used. The function should also handle cases where the input text is empty or the specified HTML tag is invalid.
The code should start with:
```pyth... | Here is the Python code to solve the given problem in the markdown block:
```python
def enhance_text_with_tag(text: str, tag: str) -> str:
"""
Enhances the given textual content by enclosing it within the specified HTML tag.
Args:
text (str): The textual content to be enhanced.
tag (str): T... |
magic_evol_110k | 82,047 | Write a Python function to verify if a given integer is a palindrome number. The function should return `True` for palindrome numbers and `False` otherwise. The function should handle both positive and negative integers. The code should start with:
```python
def is_palindrome(n: int) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_palindrome(n: int) -> bool:
"""
Verifies if a given integer is a palindrome number.
Args:
n (int): The integer to be checked.
Returns:
bool: True if the integer is a palindrome, False otherwise.
... |
magic_evol_110k | 82,060 | Write a Python function to count the number of 'hits' and 'out of range' instances in a given list of values within a specified range. A 'hit' implies that a value lies within the range, and 'out of range' implies that a value lies beyond the range. The function should return a tuple containing the count of 'hits' and ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def range_counter(values: List[int], range_start: int, range_end: int) -> Tuple[int, int]:
"""
Counts the number of 'hits' and 'out of range' instances in the provided list of values within the gi... |
magic_evol_110k | 82,071 | Write three Python functions to manipulate a deque (double-ended queue) in the following ways:
1. **Get the Last Element**: Write a function that returns the last element of a given deque.
2. **Update the Last Element**: Write a function that updates the last element of a given deque with a new value provided as a para... | Here is the Python code to solve the given problem in the markdown block:
```python
from collections import deque
def get_last_element(d: deque) -> int:
"""
Get the last element of the deque.
Args:
d (deque): The deque from which to get the last element.
Returns:
int: The last element... |
magic_evol_110k | 82,074 | Write a Python function to count the number of individual characters and vowels in a given string efficiently. The function should return three values: the total character count, a dictionary with individual character occurrences, and the number of vowels in the string. The function should avoid using additional loops ... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_characters_and_vowels(string_name: str) -> tuple:
"""
Counts the number of individual characters and vowels in the given string.
Args:
string_name (str): The input string to count characters and vowels fro... |
magic_evol_110k | 82,075 | Write a Python function to calculate the dimensions (length and breadth) and the area of a rectangle given its perimeter. The rectangle has a length that is twice the breadth. The function should start with:
```python
def calculate_rectangle_dimensions_and_area(perimeter: float) -> tuple:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_rectangle_dimensions_and_area(perimeter: float) -> tuple:
"""
Calculate the dimensions (length and breadth) and the area of a rectangle given its perimeter.
The rectangle has a length that is twice the breadth.... |
magic_evol_110k | 82,083 | Write a Python function to extract the domain name and its corresponding top-level domain (TLD) from an email address, and then verify if the TLD is valid based on a predefined list of valid TLDs. The function should return a tuple containing the domain name and a boolean indicating whether the TLD is valid.
The code ... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_and_validate_tld(email: str) -> tuple:
"""
Extracts the domain name and its corresponding top-level domain (TLD) from an email address,
and verifies if the TLD is valid based on a predefined list of valid TLDs.
... |
magic_evol_110k | 82,110 | Write a Python function to count the number of pineapples given a string representation of fruits and the total number of fruits. The string contains the number of bananas and grapes separated by spaces, and the total number of fruits is provided as an integer. The function should subtract the number of bananas and gra... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def count_pineapples(s: str, n: int) -> int:
"""
Count the number of pineapples given a string representation of fruits and the total number of fruits.
Args:
s (str): A string containing the... |
magic_evol_110k | 82,113 | Write a Python function to create a 2D NumPy array of size 4x3 filled with zeros without using `np.zeros()`. Additionally, write a function that checks if all elements in a given 2D array are zeros by manually iterating through each element. The code should start with:
```python
import numpy as np
def create_zero_arra... | Here is the Python code to solve the given problem in the markdown block:
```python
import numpy as np
def create_zero_array() -> np.ndarray:
"""
Create a 4x3 NumPy array filled with zeros without using np.zeros().
Returns:
np.ndarray: A 4x3 array filled with zeros.
"""
# Initialize a list... |
magic_evol_110k | 82,122 | Write a Python function to generate a list of prime numbers within a given range `[start, end]`. The function should return a list of all prime numbers that fall within this range. The code should start with:
```python
from typing import List
def generate_primes_in_range(start: int, end: 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 | 82,132 | 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 | 82,182 | Write a Python function to identify and remove non-repeating string elements from a given list of strings, while treating strings with different cases as the same. The function should also return a second list, sorted alphabetically, containing the removed elements. The code should start with:
```python
from typing imp... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def remove_non_repeating_strings(arr: List[str]) -> Tuple[List[str], List[str]]:
"""
Identifies and removes non-repeating string elements from a given list, treating strings with different cases a... |
magic_evol_110k | 82,200 | Write a Python function to find the least number of perfect square numbers that sum to a given integer `n`, and return both the count of these perfect squares and the sequence of perfect squares that sum up to `n`.
The function should start with:
```python
from typing import List
def least_perfect_squares(n: int) -> ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import sys
import math
def least_perfect_squares(n: int) -> (int, List[int]):
"""
Find the least number of perfect square numbers that sum to a given integer `n`,
and return both the count of these p... |
magic_evol_110k | 82,221 | Write a Python function to merge two lists into a single list, ensuring that all duplicate elements are removed, and the resulting list is sorted in descending order. The function should avoid using Python's built-in functions for merging and sorting (e.g., `set`, `sorted`, `list.sort`, `list.extend`, etc.). The functi... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merged_list(list1: List[int], list2: List[int]) -> List[int]:
"""
Merge two lists into a single list with unique elements sorted in descending order.
Args:
list1 (List[int]): The first l... |
magic_evol_110k | 82,227 | Write a Python function to convert a given binary string into its corresponding hexadecimal string. The function should handle binary strings of any length and return the hexadecimal representation in lowercase letters. The code should start with:
```python
def binary_to_hexadecimal(binary_str: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def binary_to_hexadecimal(binary_str: str) -> str:
"""
Converts a given binary string to its corresponding hexadecimal string.
Args:
binary_str (str): The binary string to be converted.
Returns:
str: Th... |
magic_evol_110k | 82,232 | Write a Python function to calculate and return the sum of the first `n` natural numbers and a list of the factorials of the first `n` natural numbers. The function should take an integer `n` as input and return a tuple containing the sum and the list of factorials.
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, Tuple
def sum_and_factorials(n: int) -> Tuple[int, List[int]]:
"""
Calculate the sum of the first n natural numbers and the factorials of the first n natural numbers.
Args:
n (int): The num... |
magic_evol_110k | 82,257 | Write a Python function to compute the nth Fibonacci number using tabulation (dynamic programming). The function should efficiently store previously computed Fibonacci numbers in a list to avoid redundant calculations, thus improving performance.
The code should start with:
```python
def fibonacci_tabulation(n: int) -... | Here is the Python code to solve the given problem in the markdown block:
```python
def fibonacci_tabulation(n: int) -> int:
"""
Compute the nth Fibonacci number using tabulation (dynamic programming).
Args:
n (int): The position of the Fibonacci number to compute.
Returns:
int: The nt... |
magic_evol_110k | 82,279 | Write a Python function to validate if a given string contains only the English alphabet (both uppercase and lowercase letters) and no other characters. The function should return `True` if the string meets the criteria, and `False` otherwise. The code should start with:
```python
import re
def is_english_alphabet_onl... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def is_english_alphabet_only(s: str) -> bool:
"""
Validates if the given string contains only the English alphabet (both uppercase and lowercase) and no other characters.
Args:
s (str): The string to be v... |
magic_evol_110k | 82,282 | Write a Python function to convert a given integer number to Roman numerals. The function should handle numbers up to 1 million and validate the input to ensure that it is a non-negative integer. If the input is not a non-negative integer, the function should raise an appropriate error. The code needs to be optimized f... | 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 number to Roman numerals.
Args:
num (int): The integer to be converted. Must be a non-negative integer up to 1,000,000.
Returns:
str: The R... |
magic_evol_110k | 82,290 | Write a Python function to determine if a given string is a palindrome. A palindrome is a string that reads the same forwards and backwards. The function should handle both lowercase and uppercase letters, ignoring case sensitivity. Additionally, the function should ignore non-alphabetic characters such as spaces, punc... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_palindrome_case_insensitive(input_str: str) -> bool:
"""
Determines if a given string is a palindrome, ignoring case sensitivity and non-alphabetic characters.
Args:
input_str (str): The string to be checked ... |
magic_evol_110k | 82,317 | Write a Python function to determine the indices of the negative elements in a given 2-D array and return them as coordinate pairs (x, y) corresponding to the row and column positions of the negative elements. Handle edge cases where there might be no negative elements or when the array itself is empty.
The code shoul... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_negative_indices(arr: List[List[int]]) -> List[Tuple[int, int]]:
"""
Determines the indices of the negative elements in a given 2-D array and returns them as coordinate pairs (x, y).
... |
magic_evol_110k | 82,318 | 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 | 82,320 | Write a Python function to find all the strings that appear in both of the given lists. Each list contains strings, and the function should return a list of strings that are present in both lists. The function should be efficient and handle cases where the lists are empty or contain duplicate strings.
The code should ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_common_strings(list1: List[str], list2: List[str]) -> List[str]:
"""
Find all the strings that appear in both of the given lists.
Args:
list1 (List[str]): The first list of strings.... |
magic_evol_110k | 82,322 | Write a Python function to calculate the sum, sum of squares, and sum of cubes of the numbers from 1 to n. The function should return a tuple containing these three values in the order: sum, sum of squares, and sum of cubes.
The code should start with:
```python
def sum_squares_cubes_to_n(n: int) -> tuple:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def sum_squares_cubes_to_n(n: int) -> tuple:
"""
Calculate the sum, sum of squares, and sum of cubes of the numbers from 1 to n.
Args:
n (int): The upper limit of the range (inclusive).
Returns:
tuple: ... |
magic_evol_110k | 82,324 | Write a Python function to find the maximum number in a list without using the built-in `max` function or any other sorting functions. The function should handle both positive and negative integers as well as zero. The code should start with:
```python
from typing import List
def find_max_number(lst: List[int]) -> int... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_max_number(lst: List[int]) -> int:
"""
Finds the maximum number in a list without using the built-in max function or any other sorting functions.
Args:
lst (List[int]): The list of ... |
magic_evol_110k | 82,327 | Write a Python function to convert a temperature from Fahrenheit to Celsius. The function should take a single argument representing the temperature in Fahrenheit and return the equivalent temperature in Celsius. The conversion formula is:
\[ \text{Celsius} = \left( \frac{5}{9} \right) \times (\text{Fahrenheit} - 32) ... | Here is the Python code to solve the given problem in the markdown block:
```python
def fahrenheit_to_celsius(fahrenheit: float) -> float:
"""
Convert a temperature from Fahrenheit to Celsius.
Args:
fahrenheit (float): The temperature in Fahrenheit to be converted.
Returns:
float: The ... |
magic_evol_110k | 82,328 | Write a Python function to find a pair of distinct elements in an array whose sum matches the given target. The pair should not have the same element repeated (meaning the elements should have unique indices). The function should return the pair as a tuple if found, otherwise return `None`.
The code should start with:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Optional
def find_pair_with_distinct_indices(numbers: List[int], target: int) -> Optional[Tuple[int, int]]:
"""
Find a pair of distinct elements in the given list whose sum matches the target.
... |
magic_evol_110k | 82,336 | Write a Python function to find the unique elements common in two integer lists, in ascending order, without using built-in Python list features. The function should handle scenarios involving negative numbers and ensure that the result contains no repeated elements. The function should also be optimized to avoid unnec... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def my_sort(lst: List[int]) -> List[int]:
"""
Custom sorting algorithm to sort a list of integers in ascending order.
Args:
lst (List[int]): The list of integers to be sorted.
Returns:
... |
magic_evol_110k | 82,346 | Write a Python function to reverse a given list of numerical values. The function should take a list of integers as input and return a new list with the elements in the reverse order. The original list should not be modified.
The code should start with:
```python
from typing import List
def reverse_list(arr: List[int... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_list(arr: List[int]) -> List[int]:
"""
Reverses the given list of integers and returns a new list with the elements in reverse order.
Args:
arr (List[int]): The list of integers ... |
magic_evol_110k | 82,347 | Write a Python function to sort a multi-dimensional numerical matrix containing exclusively integers into a decreasing sequence. The function should handle negative integers and zero, and it should work with arbitrarily large matrices. The sorted sequence should consider all values present in the matrix, ignoring the s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_multi_array(multi_array: List[List[int]]) -> List[int]:
"""
Sorts a multi-dimensional numerical matrix containing exclusively integers into a decreasing sequence.
Args:
multi_array ... |
magic_evol_110k | 82,367 | Write a Python function that takes an array of text strings as input and constructs a dictionary where each key is a string from the array and the corresponding value is the count of alphabetic characters in that string. The function should handle any array of strings, including those with non-alphabetic characters.
T... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def count_alphabets_in_strings(arr: List[str]) -> Dict[str, int]:
"""
Constructs a dictionary where each key is a string from the input list and the corresponding value is the count of alphabetic c... |
magic_evol_110k | 82,371 | Write a Python function to generate a list of five unique randomly generated integers from 1 to 10, and another function to calculate their average. The code should start with:
```python
import random
from typing import List
def generate_random_list() -> List[int]:
"""
Generate a list of five unique randomly g... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
from typing import List
def generate_random_list() -> List[int]:
"""
Generate a list of five unique randomly generated integers from 1 to 10.
Returns:
List[int]: A list containing five unique integers... |
magic_evol_110k | 82,372 | Write a Python function to convert an ASCII string to its binary representation. Each character in the ASCII string should be converted to an 8-bit binary string. The function should concatenate these 8-bit binary strings to form the final binary representation of the entire ASCII string.
The code should start with:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
def ascii_to_binary(ascii_string: str) -> str:
"""
Converts an ASCII string to its binary representation.
Each character in the ASCII string is converted to an 8-bit binary string,
and these binary strings are concatena... |
magic_evol_110k | 82,376 | Write a Python function that accepts two lists as input, computes their respective lengths, and determines the shared elements between them. The function should return a tuple containing the lengths of the two lists and a list of their shared elements. The code should start with:
```python
from typing import List, Tupl... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_shared_elements(list1: List[int], list2: List[int]) -> Tuple[int, int, List[int]]:
"""
Computes the lengths of two lists and finds their shared elements.
Args:
list1 (List[in... |
magic_evol_110k | 82,387 | Write a Python function to determine if a given word is a palindrome. A palindrome is a word that reads the same backward as forward, ignoring case. The function should take a single string as input and return a boolean value indicating whether the word is a palindrome.
The code should start with:
```python
def is_pal... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_palindrome(word: str) -> bool:
"""
Determine if the given word is a palindrome.
A palindrome is a word that reads the same backward as forward, ignoring case.
Args:
word (str): The word to check for pali... |
magic_evol_110k | 82,395 | Write a Python function to merge two numerical sequences while removing any duplicate elements between the two lists and maintaining the initial order of elements. The function should accept two lists as input and return a single list containing the merged and deduplicated sequence.
The code should start with:
```pyth... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def merge_deduplicate_sequences(seq1: List[int], seq2: List[int]) -> List[int]:
"""
Merges two numerical sequences while removing any duplicate elements and maintaining the initial order.
Args:
... |
magic_evol_110k | 82,397 | Write a Python function to filter and return a list of all even integers from a given collection of numerical values. The collection can be a list, tuple, or any other iterable containing integers. The function should handle cases where the input collection is empty or contains no even numbers.
The code should start w... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Iterable, List
def filter_even_numbers(numbers: Iterable[int]) -> List[int]:
"""
Filters and returns a list of all even integers from the given collection of numerical values.
Args:
numbers (Iter... |
magic_evol_110k | 82,401 | Write a Python function to calculate the maximum number of gift baskets that can be created given the total number of apples and the number of apples required per basket. The function should use integer division to ensure the result is a whole number.
The code should start with:
```python
def calculate_number_of_baske... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_number_of_baskets(total_apples: int, apples_per_basket: int) -> int:
"""
Calculate the maximum number of gift baskets that can be created from a given number of apples.
Args:
total_apples (int): The to... |
magic_evol_110k | 82,404 | Write a Python function to compute the value of Euler's number (e) using an infinite series approximation up to a specified precision. The function should take an integer `precision` as input, which indicates the number of terms to consider in the series. The series for Euler's number is given by:
\[ e = 1 + \frac{1}{... | Here is the Python code to solve the given problem in the markdown block:
```python
def compute_eulers_number(precision: int) -> float:
"""
Compute the value of Euler's number (e) using an infinite series approximation.
The series for Euler's number is:
e = 1 + 1/1! + 1/2! + 1/3! + 1/4! + ...
Args... |
magic_evol_110k | 82,416 | Write a Python function to calculate the maximum duration in minutes Marcus can wash his car using the cheapest option at a self-service car wash station. Each quarter allows the machine to operate for 60 seconds, and Marcus has exactly $3.25. The function should return the total washing time in minutes.
The code shou... | Here is the Python code to solve the given problem in the markdown block:
```python
def max_washing_time(total_amount: float, value_per_quarter: float) -> float:
"""
Calculate the maximum duration in minutes Marcus can wash his car using the cheapest option at a self-service car wash station.
Args:
... |
magic_evol_110k | 82,417 | Write a Python function to reverse the order of keys in a given dictionary. The function should return a new dictionary with the keys in reverse order, while maintaining the original key-value pairs. The code should start with:
```python
from typing import Dict
def reverse_dictionary_keys(dictionary: Dict[str, int]) -... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def reverse_dictionary_keys(dictionary: Dict[str, int]) -> Dict[str, int]:
"""
Reverses the order of keys in a given dictionary while maintaining the original key-value pairs.
Args:
dictiona... |
magic_evol_110k | 82,423 | Write a Python function to efficiently print the elements of a given list in reverse order without modifying the original list. The function should use an efficient approach to avoid unnecessary computations and should handle lists of varying lengths.
The code should start with:
```python
from typing import List
def ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def print_reverse_list(arr: List[int]) -> None:
"""
Prints the elements of the given list in reverse order without modifying the original list.
Args:
arr (List[int]): The list of integers to... |
magic_evol_110k | 82,425 | Write a Python function to generate a string transformation where the final character sequence mirrors the original string's, effectively reversing its initial order. The function should handle strings of varying lengths, including empty strings. The code should start with:
```python
def reverse_string(original_string:... | Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_string(original_string: str) -> str:
"""
Reverses the input string.
Args:
original_string (str): The string to be reversed.
Returns:
str: The reversed string.
"""
# Use slicing to re... |
magic_evol_110k | 82,428 | 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 be case-insensitive and should ignore spaces and punctuation.
... | Here is the Python code to solve the given problem in the markdown block:
```python
def are_anagrams(string1: str, string2: str) -> bool:
"""
Determines if two given strings are anagrams of each other.
Args:
string1 (str): The first string to compare.
string2 (str): The second string to com... |
magic_evol_110k | 82,436 | Write a Python function to extract and validate user details from a given HTML form data. The function should ensure that the email, residential address, and educational background are valid and adhere to data privacy guidelines. The function should return a dictionary containing the validated user details.
The code s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Optional
import re
def validate_user_details(form_data: Dict[str, str]) -> Optional[Dict[str, str]]:
"""
Validates and extracts user details from an HTML form data.
Args:
form_data (Dict[st... |
magic_evol_110k | 82,455 | Write a Python function to find and validate all valid IP addresses in a given string using regular expressions. An IP address is considered valid if it consists of four octets separated by dots, where each octet is a number between 0 and 255. The function should return a list of all valid IP addresses found in the str... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
from typing import List
def find_valid_ips(text: str) -> List[str]:
"""
Finds and validates all valid IP addresses in the given string.
Args:
text (str): The input string to search for IP addresses.
... |
magic_evol_110k | 82,460 | Write a Python function to generate an Elasticsearch query that performs an exact match on two fields, `cloudAccountId` and `customerId`, within the `metadata` object. The function should ensure that the query returns results only if both fields match exactly.
The code should start with:
```python
from typing import D... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
def generate_exact_match_query(cloud_account_id: str, customer_id: str) -> Dict:
"""
Generates an Elasticsearch query that performs an exact match on two fields,
`cloudAccountId` and `customerId`, wi... |
magic_evol_110k | 82,466 | Write a Python function to determine if a given substring is a constituent fragment contained within another input string. The function should return a boolean value indicating whether the substring is present in the main string. The code should start with:
```python
def is_substring_present(main_string: str, substring... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_substring_present(main_string: str, substring: str) -> bool:
"""
Determines if a given substring is present within another input string.
Args:
main_string (str): The main string in which to search for the sub... |
magic_evol_110k | 82,476 | Write a Python function to implement the binary search algorithm for finding the index of a target element in a sorted array. If the target element is not found, the function should return -1. The function should be efficient and handle edge cases such as an empty array or a target element that is not present in the ar... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def binary_search(arr: List[int], target: int) -> int:
"""
Implements the binary search algorithm to find the index of a target element in a sorted array.
Args:
arr (List[int]): A sorted... |
magic_evol_110k | 82,477 | Write a Python function to reverse the order of characters in a given string. The function should handle strings of varying lengths, including empty strings. The code should start with:
```python
def reverse_string(text: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_string(text: str) -> str:
"""
Reverses the order of characters in the given string.
Args:
text (str): The input string to be reversed.
Returns:
str: The reversed string.
"""
# Ensure... |
magic_evol_110k | 82,505 | Write a Python function to find the next number in a given arithmetic sequence. The function should take a list of integers as input and return the next number in the sequence. If the sequence is not arithmetic, the function should return `None` and print an error message.
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, Optional
def find_next_in_sequence(seq: List[int]) -> Optional[int]:
"""
Finds the next number in a given arithmetic sequence.
Args:
seq (List[int]): A list of integers representing the seq... |
magic_evol_110k | 82,520 | Write a Python function to find the maximum number in an array of integer elements and return both the maximum number and its index. The function should handle arrays of any length, including empty arrays, and return `None` for both the maximum number and its index if the array is empty.
The code should start with:
``... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Optional
def find_max_and_index(arr: List[int]) -> Tuple[Optional[int], Optional[int]]:
"""
Find the maximum number in an array of integer elements and return both the maximum number and its inde... |
magic_evol_110k | 82,535 | Write a Python function to reverse the elements of a given tuple. The function should take a tuple as input and return a new tuple with the elements in reverse order. The code should start with:
```python
from typing import Tuple
def reverse_tuple(tup: Tuple[int, ...]) -> Tuple[int, ...]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
def reverse_tuple(tup: Tuple[int, ...]) -> Tuple[int, ...]:
"""
Reverses the elements of a given tuple.
Args:
tup (Tuple[int, ...]): The input tuple to be reversed.
Returns:
Tu... |
magic_evol_110k | 82,536 | Write a Python function to count the number of prime and composite digits in a given integer. The function should handle both positive and negative integers. A prime digit is defined as 2, 3, 5, or 7, and a composite digit is defined as 4, 6, 8, or 9. The function should return a tuple containing the count of prime dig... | Here is the Python code to solve the given problem in the markdown block:
```python
def prime_composite_count(num: int) -> tuple:
"""
Counts the number of prime and composite digits in a given integer.
Args:
num (int): The integer to analyze.
Returns:
tuple: A tuple containing the coun... |
magic_evol_110k | 82,551 | Write a Python function to sort an array using the Bubble Sort algorithm. The function should correctly handle arrays of integers and return the sorted array. The code should start with:
```python
from typing import List
def bubble_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 bubble_sort(arr: List[int]) -> List[int]:
"""
Sorts an array of integers using the Bubble Sort algorithm.
Args:
arr (List[int]): The array of integers to be sorted.
Returns:
... |
magic_evol_110k | 82,583 | Write a Python function to calculate the product of all odd elements in a given list of integers. The function should return the product as an integer. If the list contains no odd elements, the function should return 1.
The code should start with:
```python
from typing import List
def product_of_odds(lst: List[int]) ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def product_of_odds(lst: List[int]) -> int:
"""
Calculate the product of all odd elements in the given list.
Args:
lst (List[int]): The list of integers from which to calculate the product o... |
magic_evol_110k | 82,590 | Write a Python function to calculate the cumulative sum of all numerical elements within a multi-dimensional array, while also identifying and handling possible non-numeric exceptions. The function should recursively traverse the array, summing up all numeric values and ignoring any non-numeric elements.
The code shou... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Union, List
def cumulative_sum(arr: Union[List, int]) -> int:
"""
Calculate the cumulative sum of all numerical elements within a multi-dimensional array.
Args:
arr (Union[List, int]): The multi-... |
magic_evol_110k | 82,593 | Write a Python function to convert an RGB color code to its corresponding HTML hexadecimal representation. The function should take three integers representing the red, green, and blue components of the color, each ranging from 0 to 255. The function should return a string in the format `#RRGGBB`, where `RR`, `GG`, and... | Here is the Python code to solve the given problem in the markdown block:
```python
def rgb_to_hex(R: int, G: int, B: int) -> str:
"""
Converts an RGB color code to its corresponding HTML hexadecimal representation.
Args:
R (int): The red component of the color, ranging from 0 to 255.
G (in... |
magic_evol_110k | 82,606 | Write a Python function to clean a given string by removing all punctuation, converting all characters to lowercase, and replacing any consecutive spaces with a single space. The function should return the cleaned string.
The code should start with:
```python
def clean_string(text: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def clean_string(text: str) -> str:
"""
Cleans the given string by removing all punctuation, converting all characters to lowercase,
and replacing any consecutive spaces with a single space.
Args:
text (str): Th... |
magic_evol_110k | 82,609 | Write a Python function that accepts a string and a character as arguments. The function should return the count of the character within the string and the positions (indices) where the character appears. If the character is not found in the string, the function should return a specific message indicating that the char... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_and_positions(s: str, c: str) -> tuple[int, list[int]] | str:
"""
Counts the occurrences of a character in a string and returns their positions.
Args:
s (str): The input string to search within.
c ... |
magic_evol_110k | 82,613 | Write a Python function to find the highest possible score that can be achieved from a pair of sightseeing spots in an array of integers. The score for a pair of sightseeing spots `(i, j)` where `i < j` is computed as `values[i] + values[j] + i - j`. The function should start with:
```python
from typing import List
de... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def best_sightseeing_pair(values: List[int]) -> int:
"""
Calculate the highest possible score for a pair of sightseeing spots in an array.
The score for a pair of sightseeing spots (i, j) where i < ... |
magic_evol_110k | 82,618 | Write a Python function to parse a given URL and return the path, query parameters, and fragment identifier. The function should handle special characters and correctly decode the URL components. The code should start with:
```python
from typing import Dict, Tuple
from urllib.parse import urlparse, parse_qs, unquote
d... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Tuple
from urllib.parse import urlparse, parse_qs, unquote
def parse_url(url: str) -> Tuple[str, Dict[str, str], str]:
"""
Parses a given URL and returns the path, query parameters, and fragment identif... |
magic_evol_110k | 82,620 | Write a Python function to perform a linear search on a given list to find the index of a target element. If the target element is not found, return `None`. The function should be efficient and handle both unsorted and sorted lists. The code should start with:
```python
from typing import List, Optional
def linear_sea... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def linear_search(lst: List[int], target: int) -> Optional[int]:
"""
Perform a linear search on a list to find the index of a target element.
Args:
lst (List[int]): The list of int... |
magic_evol_110k | 82,636 | Write a Python function to perform Caesar cipher encryption on a given string with a specified shift value. The Caesar cipher shifts each letter in the string by a fixed number of positions down the alphabet. Non-alphabetic characters should remain unchanged. The function should handle both uppercase and lowercase lett... | Here is the Python code to solve the given problem in the markdown block:
```python
def caesar_cipher(text: str, shift: int) -> str:
"""
Encrypts the given text using the Caesar cipher with the specified shift.
Args:
text (str): The text to be encrypted.
shift (int): The number of positions... |
magic_evol_110k | 82,661 | Write a Python function to evaluate the degree of coherence between a supplied encoded string of characters and a predetermined regular expression model. The function should return a detailed report of the specific patterns observed in the string. The code should start with:
```python
import re
from typing import Dict,... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
from typing import Dict, List
def evaluate_coherence(encoded_string: str, regex_pattern: str) -> Dict[str, List[str]]:
"""
Evaluate the degree of coherence between a supplied encoded string and a predetermined regular... |
magic_evol_110k | 82,663 | Write a Python function to calculate the mean value of a given list of numbers. The function should take a list of integers as input and return the mean value as a float. The code should start with:
```python
from typing import List
def calculate_mean(numbers: List[int]) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_mean(numbers: List[int]) -> float:
"""
Calculate the mean value of a given list of integers.
Args:
numbers (List[int]): A list of integers for which the mean value is to be cal... |
magic_evol_110k | 82,684 | Write a Python function to search for a given element in a matrix and return `True` if the element is found, otherwise return `False`. The matrix is a 2D list where each sublist represents a row. The function should efficiently search through the matrix by iterating through each row and checking if the element is prese... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def search_element_in_matrix(matrix: List[List[int]], element: int) -> bool:
"""
Searches for a given element in a matrix and returns True if the element is found, otherwise False.
Args:
mat... |
magic_evol_110k | 82,690 | Write a Python function to generate an array of 10 unique random integers within a specified range. The function should ensure that all integers in the array are distinct and within the given range. The code should start with:
```python
from typing import List
import random
def generate_unique_random_integers(min_valu... | 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_integers(min_value: int, max_value: int) -> List[int]:
"""
Generates an array of 10 unique random integers within the specified range [min_value, max_value].
... |
magic_evol_110k | 82,697 | Write a Python function to find the maximum integer in a given list of integers without using any pre-built Python functions for determining the maximum integer. 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
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_max_integer(arr: List[int]) -> int:
"""
Finds the maximum integer in a given list of integers without using any pre-built Python functions.
Args:
arr (List[int]): The list of intege... |
magic_evol_110k | 82,699 | Write a Python function to generate and return all possible combinations of elements from two given lists. Each combination should be a tuple consisting of one element from the first list and one element from the second list. The function should handle lists of different lengths and ensure that all possible pairs are g... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import itertools
def generate_combinations(list1: List[int], list2: List[int]) -> List[Tuple[int, int]]:
"""
Generate all possible combinations of elements from two given lists.
Args:
... |
magic_evol_110k | 82,705 | Write a Python function to find the index of a target value in a sorted array using the binary search algorithm. If the target value is not found in the array, the function should return -1. The code should start with:
```python
from typing import List
def binary_search(arr: List[int], target: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def binary_search(arr: List[int], target: int) -> int:
"""
Find the index of a target value in a sorted array using the binary search algorithm.
Args:
arr (List[int]): A sorted list of integ... |
magic_evol_110k | 82,730 | Write a Python function to generate a statistical dispersion table that illustrates the count or occurrence frequency of individual integers within a specified array of numeric integers. The function should return a dictionary where the keys are the unique integers from the input array and the values are their respecti... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def generate_dispersion_table(input_array: List[int]) -> Dict[int, int]:
"""
Generates a statistical dispersion table that illustrates the count or occurrence frequency of individual integers withi... |
magic_evol_110k | 82,732 | Implement a Python function to perform a Ternary Search on a triply-sorted array of integers to find the index of a target element. The array is sorted in three different ways, but for the purpose of this task, we will consider it as a single sorted array. The function should return the index of the target element if i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def ternary_search(input_array: List[int], target: int) -> int:
"""
Perform a Ternary Search to find the index of a target element in a sorted array.
Args:
input_array (List[int]): The sorte... |
magic_evol_110k | 82,745 | Write a Python function to determine if a given string is a pangram. A pangram is a phrase that uses every letter of the alphabet at least once. The function should ignore case and non-alphabetic characters.
The code should start with:
```python
def is_pangram(input_string: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_pangram(input_string: str) -> bool:
"""
Determines if the given string is a pangram.
A pangram is a phrase that uses every letter of the alphabet at least once.
This function ignores case and non-alphabetic chara... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.