source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
python_sharegpt_23k
15,014
Write a Python function to search for the index of a given element in a list of numbers without using the built-in `index` function or any other built-in searching functions. The function should return -1 if the element is not found in the list. The code should start with: ```python from typing import List def search_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def search_element_index(arr: List[int], element: int) -> int: """ Searches for the index of a given element in a list of numbers. Args: arr (List[int]): The list of numbers to search. ...
python_sharegpt_23k
15,016
Write a Python function to find the index of the second smallest odd element in a given list of numbers. If there are no odd elements or fewer than two odd elements in the list, the function should return -1. The code should start with: ```python from typing import List def second_smallest_odd_index(nums: List[int]) ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def second_smallest_odd_index(nums: List[int]) -> int: """ Find the index of the second smallest odd element in a given list of numbers. Args: nums (List[int]): The list of numbers to search...
python_sharegpt_23k
15,019
Write a Python function to find the element in a list that occurs most frequently. The list may contain negative numbers and the length of the list should be at least 10. Additionally, the solution should have a time complexity of O(n), where n is the length of the list. The code should start with: ```python from typi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def most_frequent_element(lst: List[int]) -> int: """ Find the element in a list that occurs most frequently. Args: lst (List[int]): A list of integers with at least 10 elements. Return...
python_sharegpt_23k
15,020
Write a Python function to find the smallest positive prime number from a given list of integers. The function should return `None` if no prime number is found in the list. The code should start with: ```python from typing import List, Optional def find_smallest_positive_prime(numbers: List[int]) -> Optional[int]: ``...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def is_prime(num: int) -> bool: """ Check if a given number is a prime number. Args: num (int): The number to check for primality. Returns: bool: True if the number is...
python_sharegpt_23k
15,024
Write a Python function to replace all consecutive whitespaces in a given string with a single space, while ignoring any whitespaces at the beginning or end of the string. The function should have a time complexity of O(n), where n is the length of the input string. The code should start with: ```python def replace_co...
Here is the Python code to solve the given problem in the markdown block: ```python def replace_consecutive_whitespaces(string: str) -> str: """ Replaces all consecutive whitespaces in a given string with a single space, while ignoring any whitespaces at the beginning or end of the string. Args: ...
python_sharegpt_23k
15,026
Write a Python function to determine if a given string is a valid US phone number according to the following constraints: 1. The phone number must be in the format "(XXX) XXX-XXXX". 2. The first digit of the area code (the digit after the opening parenthesis) cannot be 0 or 1. 3. The second digit of the area code canno...
Here is the Python code to solve the given problem in the markdown block: ```python def is_valid_us_phone_number(phone_number: str) -> bool: """ Determines if a given string is a valid US phone number according to the specified format and constraints. Args: phone_number (str): The phone number stri...
python_sharegpt_23k
15,030
Write a Python function that takes a string as input and returns a list of all unique alphabetic characters in the string, sorted in descending order. The function should remove any non-alphabetic characters from the input string before processing it. The returned list should not contain any duplicate characters. The ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def unique_alphabetic_characters(input_string: str) -> List[str]: """ Extracts all unique alphabetic characters from the input string and returns them sorted in descending order. Args: input...
python_sharegpt_23k
15,032
Write a Python function to shuffle (randomly reorder) a list of numbers without using any built-in shuffle functions or libraries. The function should have a time complexity of O(n) and space complexity of O(1). The input list will always contain at least one number. The code should start with: ```python from typing i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def shuffle_list(nums: List[int]) -> List[int]: """ Shuffles the input list of numbers in-place using the Fisher-Yates shuffle algorithm. Args: nums (List[int]): The list of nu...
python_sharegpt_23k
15,035
Write a Python function to find the index of the first occurrence of a target integer in a given list of integers. If the target integer does not exist in the list, return -1. The function should have a time complexity of O(n) and should not use any built-in search functions or libraries. The code should start with: ``...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_first_occurrence(nums: List[int], target: int) -> int: """ Find the index of the first occurrence of a target integer in a list. Args: nums (List[int]): The list of integers to sear...
python_sharegpt_23k
15,042
Write a Python function to sort an array in descending order using the bubble sort algorithm. The function should return the sorted array. The code should start with: ```python from typing import List def bubble_sort_descending(arr: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def bubble_sort_descending(arr: List[int]) -> List[int]: """ Sorts the given array in descending order using the bubble sort algorithm. Args: arr (List[int]): The array to be sorted. Re...
python_sharegpt_23k
15,043
Write a Python function named `remove_special_chars` that takes a string as input and returns a modified string without any spaces, punctuation, or special characters. The output should only contain alphanumeric characters, and the order of the characters in the output string should be the same as the input string. The...
Here is the Python code to solve the given problem in the markdown block: ```python def remove_special_chars(s: str) -> str: """ Removes all spaces, punctuation, and special characters from the input string. Args: s (str): The input string from which to remove special characters. Returns: ...
python_sharegpt_23k
15,046
Write a Python function to find the index of the first occurrence of a given integer in an array with duplicate values, while ensuring the function has a time complexity of O(n^2), where n is the length of the array. The function should return -1 if the integer is not found in the array. The code should start with: ``...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_index_with_duplicates(arr: List[int], target: int) -> int: """ Find the index of the first occurrence of a given integer in an array with duplicate values. The function has a time complexity...
python_sharegpt_23k
15,047
Write a Python function to filter out the odd numbers from a given list of integers, sort them in ascending order, and remove any duplicate numbers. The function should return a new list containing only the unique odd numbers in sorted order. The code should start with: ```python from typing import List def get_uniqu...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def get_unique_odd_numbers(input_list: List[int]) -> List[int]: """ Filters out the odd numbers from the input list, removes duplicates, and returns a sorted list of unique odd numbers. Args: ...
python_sharegpt_23k
15,056
Write a Python function to calculate the sum of all elements in a given list of integers. The list can contain both positive and negative integers. The function should handle lists of any length, including empty lists. The code should start with: ```python from typing import List def sum_of_list_elements(lst: List[int...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_of_list_elements(lst: List[int]) -> int: """ Calculate the sum of all elements in a given list of integers. Args: lst (List[int]): The list of integers to sum. Returns: ...
python_sharegpt_23k
15,058
Write a Python function that takes in an array of integers and returns a string with each number in reverse order, separated by a comma. The function should have a time complexity of O(n) and a space complexity of O(1), where n is the length of the input array. 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 reverse_array(arr: List[int]) -> str: """ Reverses the order of integers in the input array and returns them as a comma-separated string. Args: arr (List[int]): The input array of intege...
python_sharegpt_23k
15,062
Write a Python function to calculate the sum of each row in a given matrix and append the total sum of all elements in the matrix as the last element in the output list. The function should start with: ```python from typing import List def row_sums_with_total(matrix: List[List[int]]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def row_sums_with_total(matrix: List[List[int]]) -> List[int]: """ Calculate the sum of each row in the given matrix and append the total sum of all elements in the matrix. Args: matrix (Lis...
python_sharegpt_23k
15,063
Write a Python function to find the index of the first occurrence of the smallest common element in two given arrays of integers. If there is no common element, return -1. The function should handle arrays of different lengths, negative integers, duplicate elements, and large input sizes efficiently. The code should s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_smallest_common_index(array1: List[int], array2: List[int]) -> int: """ Find the index of the first occurrence of the smallest common element in two arrays. Args: array1 (List[int])...
python_sharegpt_23k
15,070
Write a Python function to create a matrix of a given shape, fill it with random integers within a specified range, and then calculate the sum of all even numbers in the matrix. The function should be efficient and handle large matrices. The code should start with: ```python from typing import List import random def ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def sum_of_even_numbers_in_matrix(rows: int, cols: int, min_value: int, max_value: int) -> int: """ Create a matrix of the given shape, fill it with random integers within the specified ran...
python_sharegpt_23k
15,072
Write a Python function to reverse a list of integers without using the `reverse()` function or any built-in methods. The function should iterate through the input list in reverse order and construct a new list with the elements in the reversed order. The code should start with: ```python from typing import List def r...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_list(nums: List[int]) -> List[int]: """ Reverses the input list of integers without using the reverse() function or any built-in methods. Args: nums (List[int]): The input list o...
python_sharegpt_23k
15,075
Write a Python function to implement the Bubble Sort algorithm with a time complexity of O(n^2) and a space complexity of O(1). The function should sort an array of integers in ascending order. The input array will contain at most 1000 elements. The code should start with: ```python from typing import List def bubble_...
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 in ascending order using the Bubble Sort algorithm. Args: arr (List[int]): The array of integers to be sorted. ...
python_sharegpt_23k
15,076
Write a Python function to delete all odd elements from a given list and return the modified list. An odd element is defined as any integer that is not divisible by 2. The function should iterate through the list, check each element, and remove any odd elements. The function 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 def delete_odd_elements(input_list: List[int]) -> List[int]: """ Deletes all odd elements from the given list and returns the modified list. Args: input_list (List[int]): The list of integer...
python_sharegpt_23k
15,082
Write a Python function to evaluate the given mathematical expression for arbitrary values of `x`, `y`, and `z`. The expression to evaluate is: \[ \frac{4x + 3y - 2z}{2x - 5y + 7z} \] The function should take three parameters `x`, `y`, and `z`, and return the result of the expression. The code should start with: ```...
Here is the Python code to solve the given problem in the markdown block: ```python def evaluate_expression(x: float, y: float, z: float) -> float: """ Evaluate the given mathematical expression for the provided values of x, y, and z. The expression to evaluate is: \[ \frac{4x + 3y - 2z}{2x - 5y + 7z} ...
python_sharegpt_23k
15,084
Write a Python function that generates a list of N unique, randomly generated numbers between 0 and 100, sorted in ascending order, without using any external libraries or built-in sorting functions. The function should have a time complexity of O(N). The input N is always a positive integer and less than or equal to 1...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_sorted_unique_numbers(N: int) -> list: """ Generates a list of N unique, randomly generated numbers between 0 and 100, sorted in ascending order. Args: N (int): The number of unique random numbers to ge...
python_sharegpt_23k
15,091
Write a Python function to search for the index of the first occurrence of a given integer in a list of distinct integers. If the integer is not found, the function should return -1. The function should have a time complexity of O(n) or better and a space complexity of O(1). The code should start with: ```python from ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def search(items: List[int], item: int) -> int: """ Searches for the index of the first occurrence of a given integer in a list of distinct integers. If the integer is not found, returns -1. Arg...
python_sharegpt_23k
15,097
Write a Python function to remove all repeated elements from a list and return a new list containing only the unique prime numbers. The function should take a list of integers as input and iterate through each element. For each element, it should check if it has already been encountered in the list and if it is a prime...
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: """ Helper function to check if a number is prime. Args: num (int): The number to check for primality. Returns: bool: True if the number is prime...
python_sharegpt_23k
15,100
Write a Python function to filter and print only the valid names from a given list of elements. A valid name is defined as an element that is a string. If an element is not a string, it should be skipped and the function should continue processing the next element. The function should start with: ```python from typing ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def print_valid_names(names: List[str]) -> None: """ Prints only the valid names from the given list of elements. A valid name is defined as an element that is a string. Args: names (Lis...
python_sharegpt_23k
15,103
Write a Python function to recursively list all keys and values from a given dictionary, but with specific conditions applied to nested dictionaries. For nested dictionaries, only display the keys and values if the key starts with the letter 'a'. For nested dictionaries within nested dictionaries, only display the keys...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Any def list_dict_keys_values(d: Dict[str, Any]) -> None: """ Recursively lists all keys and values from a given dictionary, applying specific conditions to nested dictionaries. Args: d (Di...
python_sharegpt_23k
15,109
Write a Python function to iterate through a list of dictionaries and perform a specified operation on each dictionary item without using any built-in functions or methods like `for` loops, list comprehensions, or `map()`. Additionally, you are not allowed to use any third-party libraries or modules for iteration. The ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def iterate_list_of_dicts(data: List[Dict[str, any]]) -> None: """ Iterates through a list of dictionaries and prints each dictionary item. Args: data (List[Dict[str, any]]): A list of...
python_sharegpt_23k
15,114
Write a Python function to generate and print a multiplication table of size `n` by `n`, but only include the prime numbers in the table. The function should take an integer `n` as input and print the table directly to the console. The table should have prime numbers as row and column headers, and the cells should cont...
Here is the Python code to solve the given problem in the markdown block: ```python def print_prime_multiplication_table(n: int) -> None: """ Generates and prints a multiplication table of size n by n, including only prime numbers. Args: n (int): The size of the multiplication table. Returns: ...
python_sharegpt_23k
15,119
Write a Python function to extract text inside HTML paragraph tags (`<p>...</p>`) that are nested within a `div` tag with the class "content". The function should use a regular expression to perform this extraction. If no match is found, the function should return an empty string. The code should start with: ```python...
Here is the Python code to solve the given problem in the markdown block: ```python import re def extract_paragraph_text(html: str) -> str: """ Extracts the text inside HTML paragraph tags (<p>...</p>) that are nested within a div tag with the class "content". Args: html (str): The HTML string to ...
python_sharegpt_23k
15,121
Write a Python function to validate if a given string meets the following criteria: 1. The string must be at least 5 characters long. 2. The string must contain at least one uppercase letter, one lowercase letter, one digit, and one special character (any character that is not a letter or a digit). 3. The string must c...
Here is the Python code to solve the given problem in the markdown block: ```python import re def validate_string(s: str) -> bool: """ Validate if a given string meets the following criteria: 1. The string must be at least 5 characters long. 2. The string must contain at least one uppercase letter, one...
python_sharegpt_23k
15,123
Write a Python function to calculate the Levenshtein distance between two strings, adhering to the following constraints: 1. You are not allowed to use any built-in string manipulation functions or libraries. 2. The algorithm must be optimized to have a time complexity of O(n*m), where n and m are the lengths of the tw...
Here is the Python code to solve the given problem in the markdown block: ```python def levenshtein_distance(str1: str, str2: str) -> int: """ Calculate the Levenshtein distance between two strings. The Levenshtein distance is the minimum number of single-character edits (insertions, deletions, or subs...
python_sharegpt_23k
15,124
Write a Python function to find all pairs of words in a given array that are anagrams of each other. An anagram is a word formed by rearranging the letters of another word. The function should return a list of tuples, where each tuple contains a pair of anagram words. The time complexity of the solution should be O(n^2...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_anagram_pairs(words: List[str]) -> List[Tuple[str, str]]: """ Find all pairs of words in the given array that are anagrams of each other. Args: words (List[str]): A list of w...
python_sharegpt_23k
15,126
Write a Python function to calculate the factorial of a given non-negative integer `n` using a recursive approach. The function should be optimized to use a single line of code. The code should start with: ```python def factorial(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def factorial(n: int) -> int: """ Calculate the factorial of a given non-negative integer n using a recursive approach. Args: n (int): The non-negative integer for which to calculate the factorial. Returns: ...
python_sharegpt_23k
15,130
Write a Python function to return a string representation of the elements of a given array of integers in reverse order, separated by a comma and a space. You are not allowed to use any built-in methods or functions that directly reverse the array. The code should start with: ```python from typing import List def rev...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_array_to_string(arr: List[int]) -> str: """ Returns a string representation of the elements of the given array in reverse order, separated by a comma and a space. Args: arr (...
python_sharegpt_23k
15,135
Write a Python function to calculate the sum of all elements in a given 2D matrix, where each element is multiplied by its row index. The matrix may contain negative numbers. The function should start with: ```python from typing import List def sum_elements_multiplied_by_row_index(matrix: List[List[int]]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_elements_multiplied_by_row_index(matrix: List[List[int]]) -> int: """ Calculate the sum of all elements in a given 2D matrix, where each element is multiplied by its row index. Args: ...
python_sharegpt_23k
15,137
Write a Python function to generate and return a list of all prime numbers between a given range `[start, end]`. The function should validate the input range and ensure that both `start` and `end` are non-negative integers, with `start` being less than or equal to `end`. If the input range is invalid, the function shou...
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...
python_sharegpt_23k
15,141
Write a Python function to find all starting indices of a substring within a given string. The function should handle cases where the substring appears multiple times within the original string and return a list of all the starting indices. The code should start with: ```python from typing import List def find_all_su...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_all_substring_indices(string: str, substring: str) -> List[int]: """ Find all starting indices of a substring within a given string. Args: string (str): The original string in which...
python_sharegpt_23k
15,142
Write a Python function to find the common elements between two arrays of integers. The arrays may contain duplicate elements, and the common elements should be returned in ascending order without any duplicates. The time complexity of the solution should be less than O(n log n), where n is the length of the longer arr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_common_elements(arr1: List[int], arr2: List[int]) -> List[int]: """ Find the common elements between two arrays of integers and return them in ascending order without duplicates. Args: ...
python_sharegpt_23k
15,144
Write a Python function to determine whether each number in a given list is a perfect square or not. Return a new list with the corresponding boolean results. The function should be efficient, with a time complexity of O(n) and a space complexity of O(n), where n is the number of integers in the input list. The code s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def is_perfect_square_list(numbers: List[int]) -> List[bool]: """ Determine whether each number in the given list is a perfect square. Args: numbers (List[int]): A list of intege...
python_sharegpt_23k
15,147
Write a Python function to remove all special characters from a given string, except for the '@' symbol, and convert all uppercase letters to lowercase. Special characters include any character that is not a letter, number, or the '@' symbol. The final output should be the modified string without any special characters...
Here is the Python code to solve the given problem in the markdown block: ```python import re def clean_string(input_string: str) -> str: """ Removes all special characters from the input string, except for the '@' symbol, and converts all uppercase letters to lowercase. Args: input_string (st...
python_sharegpt_23k
15,148
Write a Python function to determine whether a given number is a palindrome. The function should meet the following constraints: - The time complexity should be O(log n), where n is the number of digits in the input number. - The space complexity should be O(1), meaning the function should use a constant amount of addi...
Here is the Python code to solve the given problem in the markdown block: ```python def is_palindrome_number(num: int) -> bool: """ Determine whether a given number is a palindrome. Args: num (int): The number to check for palindrome property. Returns: bool: True if the number is a pal...
python_sharegpt_23k
15,149
Write a Python function to count the occurrences of each unique letter in a given string, ignoring case sensitivity and excluding non-alphabetic characters. Return the counts in descending order, and if two or more letters have the same count, sort them alphabetically. The code should start with: ```python from typing...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import re from collections import defaultdict def count_unique_letters(string: str) -> List[Tuple[str, int]]: """ Counts the occurrences of each unique letter in a given string, ignoring case sens...
python_sharegpt_23k
15,152
Write a Python function to calculate the area of a parallelogram given its base and height. The function should handle non-negative base and height values. If either the base or the height is zero, the function should return 0. The code should start with: ```python def calculate_parallelogram_area(base: float, height: ...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_parallelogram_area(base: float, height: float) -> float: """ Calculate the area of a parallelogram given its base and height. Args: base (float): The length of the base of the parallelogram. he...
python_sharegpt_23k
15,155
Write a Python function to find and return the elements of a given list of positive integers that are divisible by both 5 and 7, in ascending order. The function should also remove any duplicates from the resulting list and return the count of unique elements. The code should start with: ```python from typing import L...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_divisible_by_5_and_7(numbers: List[int]) -> Tuple[List[int], int]: """ Finds and returns the elements of the given list that are divisible by both 5 and 7, in ascending order. Also re...
python_sharegpt_23k
15,156
Write a Python function to find and return a list of strings that occur exactly once in a given list of strings. If a string occurs more than once, it should not be included in the output list. The function should handle lists of varying lengths and string contents efficiently. The code should start with: ```python fr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_unique_strings(string_list: List[str]) -> List[str]: """ Returns a list of strings that occur exactly once in the given list. Args: string_list (List[str]): The list of strings to a...
python_sharegpt_23k
15,160
Write a Python function to create a dictionary of a specified length where all keys are strings and all values are even integers. The function should take an integer `length` as input and return the dictionary. If the input `length` is less than or equal to 0, the function should return an empty dictionary. The code s...
Here is the Python code to solve the given problem in the markdown block: ```python def create_even_dict(length: int) -> dict: """ Creates a dictionary of the specified length where all keys are strings and all values are even integers. Args: length (int): The desired length of the dictionary. ...
python_sharegpt_23k
15,162
Write a Python function to reverse a singly linked list in place without using any extra space. The linked list may contain duplicate elements. The function should have a time complexity of O(n), where n is the number of nodes in the linked list. The code should start with: ```python class ListNode: def __init__(se...
Here is the Python code to solve the given problem in the markdown block: ```python class ListNode: def __init__(self, value=0, next=None): self.value = value self.next = next def reverse_linked_list(head: ListNode) -> ListNode: """ Reverses a singly linked list in place without using any e...
python_sharegpt_23k
15,163
Write a Python function to tokenize a given sentence and count the occurrences of each word without using any built-in string or list functions or data structures such as `split()`, `count()`, or dictionaries. The function should return a list of tuples where each tuple contains a word and its count. The code should s...
Here is the Python code to solve the given problem in the markdown block: ```python def tokenize_and_count(sentence: str) -> list: """ Tokenizes a given sentence and counts the occurrences of each word without using built-in functions or data structures. Args: sentence (str): The input sentence to ...
python_sharegpt_23k
15,168
Write a Python function to generate a random sentence based on a given set of nouns, pronouns, verbs, and objects. The sentence should be grammatically correct and make sense. Additionally, implement a function that can generate a sentence of a specific length. The sentence should still follow the given grammar rules a...
Here is the Python code to solve the given problem in the markdown block: ```python import random from typing import List def generate_sentence(nouns: List[str], pronouns: List[str], verbs: List[str], objects: List[str]) -> str: """ Generates a random sentence based on the given nouns, pronouns, verbs, and obj...
python_sharegpt_23k
15,172
Write a Python function to sort a given list in descending order without using any built-in sorting functions, and remove any duplicates from the sorted list. The function should start with: ```python from typing import List def sort_and_remove_duplicates(unsorted_list: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_and_remove_duplicates(unsorted_list: List[int]) -> List[int]: """ Sorts the given list in descending order and removes any duplicates without using built-in sorting functions. Args: ...
python_sharegpt_23k
15,175
Write a Python function to generate the first n Fibonacci numbers efficiently using dynamic programming. The function should handle inputs up to n = 100 and ensure that the solution is optimized for time complexity. The code should start with: ```python from typing import List def generate_fibonacci(n: int) -> List[in...
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 first n Fibonacci numbers using dynamic programming. Args: n (int): The number of Fibonacci numbers to generate. Returns: ...
python_sharegpt_23k
15,176
Write a Python function to generate a random string of length `n` using uppercase letters, lowercase letters, numbers, and special characters. The generated string should have a length of at least 10 characters. The function should have a time complexity of O(n) and a space complexity of O(1). The code should start wi...
Here is the Python code to solve the given problem in the markdown block: ```python import random import string def generate_random_string(n: int) -> str: """ Generates a random string of length n using uppercase letters, lowercase letters, numbers, and special characters. The generated string will have a ...
python_sharegpt_23k
15,177
Write a Python function to multiply corresponding elements of two input lists and return a new list containing the products. The input lists should have the same length and should only contain positive integers. The function should handle cases where the input lists are empty or have different lengths and return an app...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def multiply_corresponding_elements(list1: List[int], list2: List[int]) -> List[int] or str: """ Multiplies corresponding elements of two input lists and returns a new list containing the products. ...
python_sharegpt_23k
15,178
Write a Python function to sort an array of integers in decreasing order using the bubble sort algorithm. The function should be named `bubble_sort_descending` and should take a list of integers as its input. The function should return the sorted list in descending order. The bubble sort algorithm should be implemented...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def bubble_sort_descending(arr: List[int]) -> List[int]: """ Sorts an array of integers in decreasing order using the bubble sort algorithm. Args: arr (List[int]): The array of integers to b...
python_sharegpt_23k
15,185
Write a Python function to determine if two strings are anagrams of each other in a case-insensitive manner. The function should return `True` if the strings are anagrams and `False` otherwise. The function should have a time complexity of O(n), where n is the length of the input strings. The code should start with: `...
Here is the Python code to solve the given problem in the markdown block: ```python from collections import defaultdict def are_anagrams(str1: str, str2: str) -> bool: """ Determines if two strings are anagrams of each other in a case-insensitive manner. Args: str1 (str): The first string to compa...
python_sharegpt_23k
15,193
Write a Python function to sort a given list of tuples by the second element of each tuple in descending order. The input list may contain duplicate tuples and the sort should preserve their relative order. The solution should have a time complexity of O(n log n), where n is the length of the list, and should use a sta...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def sort_tuples_by_second_element(lst: List[Tuple[int, int]]) -> List[Tuple[int, int]]: """ Sorts a list of tuples by the second element of each tuple in descending order. The sort is stable, ...
python_sharegpt_23k
15,198
Write a Python function to create a new string by alternating characters from two input strings. If one string is shorter than the other, append the remaining characters of the longer string to the end of the resulting string. However, if both strings are of the same length, do not include any characters from the secon...
Here is the Python code to solve the given problem in the markdown block: ```python def alternate_strings(s1: str, s2: str) -> str: """ Create a new string by alternating characters from two input strings. If one string is shorter than the other, append the remaining characters of the longer string to the ...
python_sharegpt_23k
15,200
Write a Python function to calculate the factorial of a positive integer using recursion. The function should have a time complexity of O(n) and a space complexity of O(n). It should also handle edge cases such as negative integers and 0, and should output an error message if the input is invalid. The code should star...
Here is the Python code to solve the given problem in the markdown block: ```python def factorial(n: int) -> int or str: """ Calculate the factorial of a positive integer using recursion. Args: n (int): The positive integer for which to calculate the factorial. Returns: int or str: The...
python_sharegpt_23k
15,204
Write a Python function to calculate the product of all elements in a given array without using loops, recursion, or built-in functions such as `reduce` or `product`. The solution should have a time complexity of O(n) and a space complexity of O(1). The function should handle an empty array by returning 1. The code sh...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def product_of_array(arr: List[int]) -> int: """ Calculate the product of all elements in the given array without using loops, recursion, or built-in functions like `reduce` or `product`. Args: ...
python_sharegpt_23k
15,205
Write a Python function to find the index of the first occurrence of a given number in a list. If the number is not found, the function should return -1. The function should handle the following cases: 1. The input list is empty. 2. The input list contains duplicate numbers. 3. The input number is a float or a negative...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_first_occurrence(lst: List[float], num: float) -> int: """ Find the index of the first occurrence of a given number in a list. Args: lst (List[float]): The list of numbers to search...
python_sharegpt_23k
15,210
Write a Python function to find the last occurrence of a given number in an array of positive integers. If the number does not exist in the array, the function should return -1. The array can have a maximum length of \(10^6\) and each element of the array can have a value between 1 and \(10^6\) (inclusive). The code s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_last_occurrence(arr: List[int], num: int) -> int: """ Find the last occurrence of a given number in an array of positive integers. Args: arr (List[int]): The array of positive integ...
python_sharegpt_23k
15,213
Write a Python function to determine if a target string is a substring of a main string. The function should be case-insensitive and should not use any built-in string manipulation functions or methods (e.g., `substring`, `contains`). The time complexity of the solution should be O(n * m), where n is the length of the ...
Here is the Python code to solve the given problem in the markdown block: ```python def is_substring(main_string: str, target_string: str) -> bool: """ Determines if the target string is a substring of the main string. Args: main_string (str): The main string to search within. target_string...
python_sharegpt_23k
15,214
Write a Python function to calculate the frequency of occurrence of each letter in a given sentence, considering punctuation marks and case sensitivity. The function should return the letter(s) with the highest frequency in alphabetical order. If multiple letters have the same highest frequency, return them in the orde...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_letter_frequency(sentence: str) -> List[str]: """ Calculate the frequency of occurrence of each letter in a given sentence and return the letter(s) with the highest frequency in alphabetica...
python_sharegpt_23k
15,217
Write a Python function `find_locality(pin_code: str) -> str` that takes a string `pin_code` as input and returns the corresponding locality for that pin code. The function should adhere to the following constraints and requirements: 1. The pin code must be a valid Indian pin code, which is a 6-digit number. 2. The fun...
Here is the Python code to solve the given problem in the markdown block: ```python def find_locality(pin_code: str) -> str: """ Find the locality corresponding to a given Indian pin code. Args: pin_code (str): The pin code to look up. It should be a 6-digit number. Returns: str: The l...
python_sharegpt_23k
15,218
Write a Python function to reverse the order of elements in a list using recursion. The function should modify the list in-place and should not use any built-in or library functions for list manipulation. Only recursion and basic operations such as indexing and swapping are allowed. The function should start with: ```p...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_list_recursive(lst: List[int], start: int = 0, end: int = None) -> None: """ Reverses the order of elements in a list using recursion. Args: lst (List[int]): The list to be rever...
python_sharegpt_23k
15,219
Write a Python function to find the maximum, minimum, and average values from a sequence of numbers. The sequence must contain at least 10 unique numbers. The function should return a tuple containing the maximum, minimum, and average values. If the sequence does not meet the requirements, the function should return an...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Union def find_max_min_average(sequence: List[int]) -> Union[Tuple[int, int, float], str]: """ Finds the maximum, minimum, and average values from a sequence of numbers. Args: sequen...
python_sharegpt_23k
15,224
Write a Python function to reverse a list in place without using the built-in `reverse()` method. The function should have a time complexity of O(n), where n is the length of the list. Additionally, the function should not create a new list or use any additional data structures. The code should start with: ```python fr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def reverse_list_in_place(lst: List[int]) -> None: """ Reverses the given list in place without using the built-in reverse() method. Args: lst (List[int]): The list to be reversed. Retu...
python_sharegpt_23k
15,225
Write a Python function to calculate the number of different ways to climb `n` stairs, given that you can only climb 1, 2, or 3 stairs at a time. The function should have a time complexity of O(n) and a space complexity of O(1). The code should start with: ```python def count_ways_to_climb_stairs(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def count_ways_to_climb_stairs(n: int) -> int: """ Calculate the number of different ways to climb n stairs, given that you can only climb 1, 2, or 3 stairs at a time. Args: n (int): The number of stairs to climb. ...
python_sharegpt_23k
15,231
Write a Python function to return a list of unique elements from a given list, ensuring that the function has a time complexity of O(n) and a space complexity of O(1). You are not allowed to use any built-in functions or libraries for counting or checking for uniqueness. The function should start with: ```python from t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def get_unique_elements(lst: List[int]) -> List[int]: """ Returns a list of unique elements from the given list, maintaining the order of first appearance. The function has a time complexity of O(n) ...
python_sharegpt_23k
15,239
Write a Python function to sort a given array of integers in ascending order using the insertion sort algorithm. The insertion sort algorithm works by repeatedly taking an element from the unsorted part of the array and inserting it into its correct position in the sorted part of the array. The function should start wi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def insertion_sort(arr: List[int]) -> List[int]: """ Sorts a given array of integers in ascending order using the insertion sort algorithm. Args: arr (List[int]): The array of integers to be...
python_sharegpt_23k
15,240
Write a Python function to delete the third element (index 2) from a given array and shift all the remaining elements to the left to fill the empty space. The function should handle edge cases such as an empty array or an array with fewer than 3 elements. The function should not use any built-in functions or methods th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def delete_third_element(arr: List) -> List: """ Deletes the third element (index 2) from the given array and shifts all remaining elements to the left. Args: arr (List): The input array fro...
python_sharegpt_23k
15,241
Write a Python function to sort a given array in descending order using a custom merge sort algorithm. The function should not use any built-in sorting functions or methods provided by the programming language. The sorting algorithm must have a time complexity of O(n log n), where n is the length of the array. The cod...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def custom_merge_sort(arr: List[int]) -> List[int]: """ Sorts the given array in descending order using a custom merge sort algorithm. Args: arr (List[int]): The array to be sorted. Ret...
python_sharegpt_23k
15,251
Write a Python function to find and return the squares of the first `n` prime numbers. The function should not use any pre-existing libraries or functions for finding prime numbers. The code should start with: ```python def find_squares_of_primes(n: int) -> list: ```
Here is the Python code to solve the given problem in the markdown block: ```python def find_squares_of_primes(n: int) -> list: """ Find and return the squares of the first n prime numbers. Args: n (int): The number of prime numbers to consider. Returns: list: A list containing the squ...
python_sharegpt_23k
15,258
Write a Python function to sort a list of integers using the selection sort algorithm in ascending order. The function should take a list of integers as input and return the sorted list. The selection sort algorithm should be implemented as described in the given code snippet. The code should start with: ```python fro...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def selection_sort(lst: List[int]) -> List[int]: """ Sorts a list of integers using the selection sort algorithm in ascending order. Args: lst (List[int]): The list of integers to be sorted....
python_sharegpt_23k
15,268
Write a Python function to generate an HTML hyperlink element from a given URL string. The function should validate the URL to ensure it meets the following criteria: - The URL must start with either "http://" or "https://". - The URL must not contain any special characters such as spaces, parentheses, etc. - The URL m...
Here is the Python code to solve the given problem in the markdown block: ```python import re def create_hyperlink(url: str) -> str: """ Generates an HTML hyperlink element from a given URL string. Args: url (str): The URL string to be validated and converted into an HTML hyperlink. Returns: ...
python_sharegpt_23k
15,271
Write a Python function to generate a list containing the first `n` prime numbers. The function should take an integer `n` as input and 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(n: int) -> bool: """ Check if a given number is prime. Args: n (int): The number to check for primality. Returns: bool: True if the number is prime, False otherwise...
python_sharegpt_23k
15,272
Write a Python function to filter out all even numbers from a given list of integers ranging from -1000 to 1000. The function should only use a single loop and should have a time complexity of O(n), where n is the length of the input list. The function should not use any built-in functions or libraries. The code should...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_odd_numbers(numbers: List[int]) -> List[int]: """ Filters out all even numbers from a given list of integers and returns a list of odd numbers. Args: numbers (List[int]): A list o...
python_sharegpt_23k
15,282
Write a Python function to compute an array where each element is the product of all elements in the input array except the one at the current index. You are not allowed to use division or any built-in multiplication functions. The function should start with: ```python from typing import List def product_of_elements_e...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def product_of_elements_except_self(arr: List[int]) -> List[int]: """ Compute an array where each element is the product of all elements in the input array except the one at the current index. Args:...
python_sharegpt_23k
15,285
Write a Python function to calculate the maximum sum of contiguous subarrays from a given array, where each subarray includes elements that are divisible by 3, and the sum does not exceed a given limit. The function should start with: ```python from typing import List def max_sum_divisible_by_3(array: List[int], limit...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def max_sum_divisible_by_3(array: List[int], limit: int) -> int: """ Calculate the maximum sum of contiguous subarrays from a given array, where each subarray includes elements divisible by 3 and the...
python_sharegpt_23k
15,288
Write a Python function to reverse each word in a given string without using any built-in string manipulation methods or libraries. The function should have a time complexity of O(n), where n is the length of the string, and should use constant space complexity. The input string will only contain alphanumeric character...
Here is the Python code to solve the given problem in the markdown block: ```python def reverse_words(string: str) -> str: """ Reverses each word in the given string without using any built-in string manipulation methods or libraries. Args: string (str): The input string containing alphanumeric cha...
python_sharegpt_23k
15,290
Write a Python function to find the nth Fibonacci prime number using an iterative approach. A Fibonacci prime number is a Fibonacci number that is also a prime number. The function should take a single argument `n` and return the nth Fibonacci prime number. The code should start with: ```python def nth_fibonacci_prime...
Here is the Python code to solve the given problem in the markdown block: ```python 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 otherwise. """ if num ...
python_sharegpt_23k
15,291
Write a Python function to count the occurrences of positive integers in a given list and return a dictionary where the keys are the positive integers and the values are the number of times each integer appears in the list. The function should have a time complexity of O(n) and a space complexity of O(n). Negative inte...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def count_positive_integers(lst: List[int]) -> Dict[int, int]: """ Counts the occurrences of positive integers in a given list and returns a dictionary where the keys are the positive integers ...
python_sharegpt_23k
15,292
Write a Python function to perform a binary search on a sorted list to determine if a target element exists in the list. The function should handle the case where the list contains only one item and should be optimized to have a time complexity of O(log n) and a space complexity of O(1). The code should start with: ``...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def binary_search(arr: List[int], target: int) -> bool: """ Perform a binary search on a sorted list to determine if a target element exists. Args: arr (List[int]): A sorted list of integers...
python_sharegpt_23k
15,295
Write a Python function to simulate a loop that runs for a specified number of iterations and prints out its current counter at each iteration. The counter should start at a given initial value and be incremented by a specified step at each iteration. The function should return the final value of the counter after all ...
Here is the Python code to solve the given problem in the markdown block: ```python def simulate_loop(iterations: int, initial_value: int, step: int) -> int: """ Simulates a loop that runs for a specified number of iterations, prints the current counter value at each iteration, and increments the counter by...
python_sharegpt_23k
15,298
Write a Python function to efficiently compare two large lists and return the elements that are present in both lists. The function should handle lists with duplicate elements and return the common elements as a list, preserving the order of their first appearance in the first list. 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 find_common_elements(list1: List[int], list2: List[int]) -> List[int]: """ Finds and returns the elements that are present in both input lists, preserving the order of their first appearance in the f...
python_sharegpt_23k
15,300
Write a Python function to multiply the values of two dictionaries based on their common keys. If a key in the first dictionary does not exist in the second dictionary, the value from the first dictionary should be retained in the result. The function should return a new dictionary with the updated values. The code sh...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def multiply_dicts(d1: Dict[str, int], d2: Dict[str, int]) -> Dict[str, int]: """ Multiplies the values of two dictionaries based on their common keys. If a key in the first dictionary does not exist...
python_sharegpt_23k
15,301
Write a Python function to find all prime numbers within a given range [lower, upper], inclusive. The function should ensure that the lower bound is not greater than the upper bound and that both bounds are positive integers. The function should use an efficient algorithm to find the prime numbers within the given rang...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def find_primes_in_range(lower: int, upper: int) -> List[int]: """ Find all prime numbers within the given range [lower, upper], inclusive. Args: lower (int): The lower bound of ...
python_sharegpt_23k
15,302
Write a Python function to find the least common ancestor (LCA) of two given nodes in a binary search tree (BST). The BST has the following properties: - Each node in the tree has a unique integer key. - The key of each node is greater than the keys of all nodes in its left subtree. - The key of each node is less than ...
Here is the Python code to solve the given problem in the markdown block: ```python class TreeNode: def __init__(self, key): self.key = key self.left = None self.right = None self.parent = None def find_lca(root, node1, node2): """ Finds the least common ancestor (LCA) of tw...
python_sharegpt_23k
15,309
Write a Python function to compress a given string by counting the consecutive occurrences of each character and storing it as a tuple with the character and its count. The function should not use any built-in functions or methods for string manipulation or counting. The code should start with: ```python def compress_s...
Here is the Python code to solve the given problem in the markdown block: ```python def compress_string(string: str) -> str: """ Compresses a given string by counting the consecutive occurrences of each character and storing it as a tuple with the character and its count. Args: string (str): Th...
python_sharegpt_23k
15,313
Write a Python function to find the index of the last occurrence of a given string in a list of strings. The function should be case-sensitive, meaning that "green" and "Green" should be considered as different strings. If the string is not found in the list, the function should return -1. The code should start with: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_last_occurrence(lst: List[str], string: str) -> int: """ Find the index of the last occurrence of a given string in a list of strings. Args: lst (List[str]): The list of strings to ...
python_sharegpt_23k
15,314
Write a Python function to convert a lowercase string to an uppercase string without using the built-in string method `upper()`, and without using any loops. The input string will only contain alphabetic characters. The code should start with: ```python def convert_to_uppercase(s: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def convert_to_uppercase(s: str) -> str: """ Converts a lowercase string to an uppercase string without using the built-in `upper()` method or loops. Args: s (str): The input string containing only alphabetic charac...
python_sharegpt_23k
15,321
Write a Python function to capitalize the first letter of a given string and convert the remaining characters to lowercase, while also handling leading and trailing whitespace. The function should be robust enough to handle empty strings and strings with special characters. The code should start with: ```python def ca...
Here is the Python code to solve the given problem in the markdown block: ```python def capitalize_string(string: str) -> str: """ Capitalizes the first letter of a given string and converts the remaining characters to lowercase, while also handling leading and trailing whitespace. Args: string...
python_sharegpt_23k
15,322
Write a Python function to remove all key-value pairs from a dictionary where the value is an odd number. The function should return the modified dictionary. The code should start with: ```python from typing import Dict def remove_odd_values(my_dict: Dict[str, int]) -> Dict[str, int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def remove_odd_values(my_dict: Dict[str, int]) -> Dict[str, int]: """ Removes all key-value pairs from the dictionary where the value is an odd number. Args: my_dict (Dict[str, int]): The di...
python_sharegpt_23k
15,329
Write a Python function to transform a string of text into an object containing the number of occurrences of each letter and digit in the string. The function should handle both uppercase and lowercase letters, and it should consider whitespace characters and special characters. The output object should be sorted in as...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def count_unique_characters(text: str) -> Dict[str, int]: """ Transform a string of text into an object containing the number of occurrences of each unique letter and digit in the string. The functio...
python_sharegpt_23k
15,330
Write a Python function to rotate a given square matrix 90 degrees clockwise in-place. The matrix will always be a square matrix, meaning it will have the same number of rows and columns. The function should modify the original matrix instead of creating a new one. The matrix elements will always be unique and within t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def rotate_matrix_90_clockwise(matrix: List[List[int]]) -> None: """ Rotates a given square matrix 90 degrees clockwise in-place. Args: matrix (List[List[int]]): The square matrix to be rota...
python_sharegpt_23k
15,331
Write a Python function to check if a given list of integers is sorted in ascending order and contains no duplicate values, without using any built-in sorting functions. The function should adhere to the following constraints: - The length of the list is between 1 and 10^6. - The values in the list are between -10^6 an...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_sorted_and_unique(lst: List[int]) -> bool: """ Checks if a given list of integers is sorted in ascending order and contains no duplicate values. Args: lst (List[int]): The list of int...
python_sharegpt_23k
15,336
Write a Python function that calculates the sum of all the numbers in a given list of integers using a recursive approach. The function should not use any loops, the built-in `sum()` function, or the `reduce()` function from the `functools` module. Instead, it should use recursion to compute the sum. The function shou...
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 all the numbers in the given list using recursion. Args: numbers (List[int]): The list of integers to sum. Returns...
python_sharegpt_23k
15,337
Write a Python function to sort a list of integers such that all even numbers are in ascending order and all odd numbers are in descending order. The function should return a new list with the sorted numbers. The original list should not be modified. The code should start with: ```python from typing import List def s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_even_odd_numbers(numbers: List[int]) -> List[int]: """ Sorts a list of integers such that all even numbers are in ascending order and all odd numbers are in descending order. Args: ...
python_sharegpt_23k
15,343
Write a Python function to add two lists of numbers together element-wise, but only for elements at indices that are divisible by 2. The lists may contain duplicates and negative numbers. If the lists have different lengths, the function should ignore the extra elements in the longer list. The code should start with: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def add_lists_at_even_indices(list1: List[int], list2: List[int]) -> List[int]: """ Adds two lists of numbers together element-wise at indices that are divisible by 2. Args: list1 (List[int]...