source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
code_exercise_27k | 10,246 | Write a Python function to validate if a given string is a valid hexadecimal color code. A valid hexadecimal color code must start with a `#` followed by either 3 or 6 hexadecimal digits (0-9, a-f, A-F). The function should return `True` if the string is a valid hexadecimal color code and `False` otherwise.
The code s... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def is_valid_hex_color(hex_code: str) -> bool:
"""
Validate if a given string is a valid hexadecimal color code.
A valid hexadecimal color code must start with a `#` followed by either 3 or 6 hexadecimal digits (... |
code_exercise_27k | 10,251 | Write a Python function to validate whether a given string is a valid IPv4 address. An IPv4 address consists of four decimal numbers separated by dots, where each number ranges from 0 to 255. The function should return `True` if the string is a valid IPv4 address and `False` otherwise.
The code should start with:
```p... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def is_valid_ipv4_address(ip_address: str) -> bool:
"""
Validates whether the given string is a valid IPv4 address.
Args:
ip_address (str): The string to be validated.
Returns:
bool: True if ... |
code_exercise_27k | 10,254 | Write a Python function to remove all whitespace characters from a given string. The function should handle various types of whitespace characters, including spaces, tabs, and newlines. The code should start with:
```python
def remove_all_whitespace(string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def remove_all_whitespace(string: str) -> str:
"""
Removes all whitespace characters from a given string.
Args:
string (str): The input string from which all whitespace characters will be removed.
Returns:
... |
code_exercise_27k | 10,257 | Write a Python function to calculate the sum of all even numbers in a given list of integers. The function should handle input validation to ensure that the input is a list and that all elements in the list are integers. If any element is not an integer, the function should raise a `TypeError`.
The code should start w... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_of_even_numbers(numbers: List[int]) -> int:
"""
Calculate the sum of all even numbers in a given list of integers.
Args:
numbers (List[int]): A list of integers.
Returns:
... |
code_exercise_27k | 10,269 | Write a Python function to validate if a given string is a valid URL using a regular expression. The function should return `True` if the string is a valid URL and `False` otherwise. The URL should match the following criteria:
- It can start with `http://`, `https://`, `ftp://`, or `ftps://`.
- It should have a valid ... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def is_valid_url(url_string: str) -> bool:
"""
Validates if a given string is a valid URL using a regular expression.
Args:
url_string (str): The string to be checked for URL validity.
Returns:
... |
code_exercise_27k | 10,270 | Write a Python function to find the first n Armstrong numbers. An Armstrong number (also known as a narcissistic number) is a number that is the sum of its own digits each raised to the power of the number of digits. For example, 153 is an Armstrong number because 1^3 + 5^3 + 3^3 = 153.
The function should start with:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_armstrong_number(num: int) -> bool:
"""
Check if a given number is an Armstrong number.
Args:
num (int): The number to check.
Returns:
bool: True if the number is... |
code_exercise_27k | 10,275 | Write a Python function to count the number of uppercase and lowercase letters in a given string. The function should return a tuple containing the count of uppercase letters and lowercase letters respectively. The code should start with:
```python
def count_letters(string: str) -> tuple:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def count_letters(string: str) -> tuple:
"""
Count the number of uppercase and lowercase letters in a given string.
Args:
string (str): The input string to count the letters in.
Returns:
tuple: A tuple ... |
code_exercise_27k | 10,277 | Write a Python function to determine if a given word contains only letters where each letter appears an odd number of times. The function should use a regular expression to validate the word.
The code should start with:
```python
import re
def match_word_with_odd_frequency(word: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def match_word_with_odd_frequency(word: str) -> bool:
"""
Determines if a given word contains only letters where each letter appears an odd number of times.
Args:
word (str): The word to check.
Retur... |
code_exercise_27k | 10,278 | Write a Python function to concatenate two lists without using the built-in `extend` or `+` operator. The function should iterate through each element of both lists and append them to a new list. The code should start with:
```python
from typing import List
def concatenate_lists(list1: List[int], list2: List[int]) -> ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def concatenate_lists(list1: List[int], list2: List[int]) -> List[int]:
"""
Concatenates two lists without using the built-in `extend` or `+` operator.
Args:
list1 (List[int]): The first lis... |
code_exercise_27k | 10,283 | Write a Python function to validate a phone number in the format `(XXX) XXX-XXXX` using regular expressions. The function should return `True` if the phone number matches the pattern, and `False` otherwise. The code should start with:
```python
import re
def validate_phone_number(phone_number: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_phone_number(phone_number: str) -> bool:
"""
Validates a phone number in the format (XXX) XXX-XXXX using regular expressions.
Args:
phone_number (str): The phone number to validate.
Retu... |
code_exercise_27k | 10,290 | Write a Python function to validate if a given string contains only numbers and alphabets (both uppercase and lowercase). The function should use regular expressions to perform this validation. The code should start with:
```python
import re
def is_alphanumeric(string: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def is_alphanumeric(string: str) -> bool:
"""
Validates if the given string contains only numbers and alphabets (both uppercase and lowercase).
Args:
string (str): The input string to validate.
Retur... |
code_exercise_27k | 10,299 | Write a Python function to validate a string based on the following criteria:
1. The string must contain at least one uppercase letter.
2. The string must contain at least one lowercase letter.
3. The string must contain at least one digit.
The function should use regular expressions to perform the validation.
The co... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_string(string: str) -> bool:
"""
Validate a string to check if it contains at least one uppercase letter, one lowercase letter,
and one digit using regular expressions.
Args:
string (str)... |
code_exercise_27k | 10,306 | Write a Python function to calculate the sum of the squares of the first n natural numbers. The function should handle input validation to ensure that n is a positive integer. The code should start with:
```python
def sum_of_squares(n: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_squares(n: int) -> int:
"""
Calculates the sum of the squares of the first n natural numbers.
Args:
n (int): The number of natural numbers to consider.
Returns:
int: The sum of the squares of... |
code_exercise_27k | 10,311 | Write a Python function to count the number of digits in a given number. The function should handle both positive and negative integers. The code should start with:
```python
def count_digits(number: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def count_digits(number: int) -> int:
"""
Count the number of digits in a given number.
Args:
number (int): The number for which we want to count the digits.
Returns:
int: The number of digits in the gi... |
code_exercise_27k | 10,312 | Write a Python function to check if a given string contains a specific sequence of characters using regular expressions. The function should return `True` if the sequence is found anywhere in the string, and `False` otherwise. The code should start with:
```python
import re
def contains_sequence(pattern: str, string: ... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_sequence(pattern: str, string: str) -> bool:
"""
Checks if a given string contains a specific sequence of characters using regular expressions.
Args:
pattern (str): The sequence of characters... |
code_exercise_27k | 10,321 | Write a Python function to calculate the sum of the cubes of the first n natural numbers. The function should handle input validation to ensure that n is a positive integer. If n is not a positive integer, the function should raise a `ValueError`.
The code should start with:
```python
def sum_of_cubes(n: int) -> int:
... | Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_cubes(n: int) -> int:
"""
Calculate the sum of cubes of the first n natural numbers.
Args:
n (int): The number of natural numbers.
Returns:
int: The sum of cubes.
Raises:
ValueEr... |
code_exercise_27k | 10,322 | Write a Python function to validate if a given string contains a sequence of digits followed by a comma and then another sequence of digits. The function should return `True` if the string matches the pattern, and `False` otherwise. The code should start with:
```python
import re
def validate_digit_sequence_with_comma... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_digit_sequence_with_comma(string: str) -> bool:
"""
Validates if the input string contains a sequence of digits followed by a comma
and then another sequence of digits.
Args:
string (str... |
code_exercise_27k | 10,325 | Write a Python function to match a string that starts with a lowercase letter and ends with an exclamation mark, using regular expressions. The function should return `True` if the string matches the pattern, and `False` otherwise. The code should start with:
```python
import re
def match_lowercase_exclamation(string:... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def match_lowercase_exclamation(string: str) -> bool:
"""
Matches a string that starts with a lowercase letter and ends with an exclamation mark.
Args:
string (str): The input string to match.
Return... |
code_exercise_27k | 10,326 | Write a Python function to determine if a given string matches a specific pattern: exactly one uppercase letter followed by exactly two lowercase letters. The function should return `True` if the string matches the pattern, and `False` otherwise. The code should start with:
```python
import re
def is_valid_pattern(str... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def is_valid_pattern(string: str) -> bool:
"""
Determines if a given string matches the pattern of exactly one uppercase letter followed by exactly two lowercase letters.
Args:
string (str): The string to... |
code_exercise_27k | 10,342 | Write a Python function to determine if a given string contains a repeating pattern of exactly four digits. The function should return `True` if the string matches the pattern, and `False` otherwise. The code should start with:
```python
import re
def contains_repeating_four_digits(string: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_repeating_four_digits(string: str) -> bool:
"""
Determines if a given string contains a repeating pattern of exactly four digits.
Args:
string (str): The input string to be checked.
Retu... |
code_exercise_27k | 10,344 | Write a Python function to reverse the order of elements in a given list without using slicing or any built-in functions that directly reverse a list. The function should use a loop to manually reverse the elements.
The code should start with:
```python
from typing import List
def reverse_list_manual(lst: List[int]) ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def reverse_list_manual(lst: List[int]) -> List[int]:
"""
Reverse the order of elements in a given list without using slicing or built-in reverse functions.
Args:
lst (List[int]): The list t... |
code_exercise_27k | 10,357 | Write a Python function to remove all punctuation marks from a given string. The function should handle various punctuation marks and return the cleaned string. The code should start with:
```python
import string
def remove_punctuation(text: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import string
def remove_punctuation(text: str) -> str:
"""
Removes all punctuation marks from the given string.
Args:
text (str): The input string from which punctuation marks need to be removed.
Returns:
... |
code_exercise_27k | 10,370 | Write a Python function to check if a given string contains a word with exactly six letters that is preceded by a comma. The function should use regular expressions to perform this check.
The code should start with:
```python
import re
def contains_six_letter_word_after_comma(string: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_six_letter_word_after_comma(string: str) -> bool:
"""
Checks if the given string contains a word with exactly six letters preceded by a comma.
Args:
string (str): The input string to check.
... |
code_exercise_27k | 10,407 | Write a Python function to validate if a given string matches a specific pattern: a sequence of alphabets followed by a space and then another sequence of digits. The function should return `True` if the string matches the pattern, and `False` otherwise. The code should start with:
```python
import re
def validate_str... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_string_pattern(input_string: str) -> bool:
"""
Validate if the input string matches the pattern: a sequence of alphabets followed by a space and then a sequence of digits.
Args:
input_string ... |
code_exercise_27k | 10,410 | Write a Python function to check if a given number is within a specified range, inclusive of the boundaries. The function should accept three parameters: the number to be checked, the lower boundary, and the upper boundary. The function should return `True` if the number is within the range, and `False` otherwise.
The... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_number_within_range(number: float, lower_bound: float, upper_bound: float) -> bool:
"""
Check if a given number is within a specified range, inclusive of the boundaries.
Args:
number (float): The number to be... |
code_exercise_27k | 10,421 | Write a Python function to check if a given list contains a specific element and return the index of the first occurrence of the element if it exists. If the element is not found, return -1.
The code should start with:
```python
from typing import List, Any
def find_element_in_list(lst: List[Any], element: Any) -> int... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Any
def find_element_in_list(lst: List[Any], element: Any) -> int:
"""
Find the index of the first occurrence of a specific element in a given list.
Args:
lst (List[Any]): The list to b... |
code_exercise_27k | 10,431 | Write a Python function to validate if a given string matches a specific pattern using regular expressions. The pattern requires the string to contain a sequence of alphabets followed by a space and then another sequence of alphabets. The function should return `True` if the string matches the pattern and `False` other... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_string_pattern(s: str) -> bool:
"""
Validates if the given string matches the pattern of a sequence of alphabets followed by a space and then another sequence of alphabets.
Args:
s (str): The... |
code_exercise_27k | 10,456 | Write a Python function to validate if a given string matches a specific pattern using regular expressions. The pattern consists of:
1. A sequence of alphabetic characters (both lowercase and uppercase).
2. Followed by a single space.
3. Followed by a sequence of uppercase alphabetic characters.
The function should re... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_string_pattern(input_string: str) -> bool:
"""
Validates if the input string matches the pattern:
- A sequence of alphabetic characters (both lowercase and uppercase).
- Followed by a single space... |
code_exercise_27k | 10,474 | Write a Python function to check if a given list is a sublist of another list. The function should return `True` if the sublist is found in the main list, and `False` otherwise. The function should handle edge cases such as an empty sublist and should be efficient in terms of time complexity.
The code should start wit... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_sublist(main_list: List, sublist: List) -> bool:
"""
Check if a given list is a sublist of another list.
Args:
main_list (List): The main list to search in.
sublist (List): Th... |
code_exercise_27k | 10,482 | Write a Python function to check if a given matrix is symmetric across the main diagonal. A matrix is symmetric if for every element at position (i, j), the element at position (j, i) is the same. The function should return `True` if the matrix is symmetric and `False` otherwise. The code should start with:
```python
f... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_symmetric(matrix: List[List[int]]) -> bool:
"""
Check if a given matrix is symmetric across the main diagonal.
Args:
matrix (List[List[int]]): The matrix to be checked.
Returns:
... |
code_exercise_27k | 10,483 | Write a Python function to determine if a given string contains a word that starts and ends with the same eight letters. The function should use regular expressions to perform the search.
The code should start with:
```python
import re
def contains_word_with_same_start_end(word_start_end: str, string: str) -> bool:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_word_with_same_start_end(word_start_end: str, string: str) -> bool:
"""
Determine if a given string contains a word that starts and ends with the same eight letters.
Args:
word_start_end (str... |
code_exercise_27k | 10,486 | Write a Python function to check if a given string is a valid IPv4 address. An IPv4 address consists of four decimal numbers separated by dots, where each number ranges from 0 to 255. The function should return `True` if the string is a valid IPv4 address and `False` otherwise.
The code should start with:
```python
de... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_valid_ipv4(ip_address: str) -> bool:
"""
Check if a given string is a valid IPv4 address.
Args:
ip_address (str): The string to be checked.
Returns:
bool: True if the string is a valid IPv4 addre... |
code_exercise_27k | 10,488 | Write a Python function to determine if a given string contains a repeating pattern of exactly eleven digits. The function should return `True` if the pattern is found, and `False` otherwise. The code should start with:
```python
import re
def contains_repeating_eleven_digit_pattern(string: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_repeating_eleven_digit_pattern(string: str) -> bool:
"""
Determines if the given string contains a repeating pattern of exactly eleven digits.
Args:
string (str): The input string to be check... |
code_exercise_27k | 10,492 | Write a Python function to validate a credit card number using the Luhn algorithm. The function should take a string representing a credit card number as input and return `True` if the number is valid according to the Luhn algorithm, and `False` otherwise. The function should handle credit card numbers with or without ... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_valid_credit_card(number: str) -> bool:
"""
Validate a credit card number using the Luhn algorithm.
Args:
number (str): The credit card number as a string, which may contain spaces.
Returns:
bool... |
code_exercise_27k | 10,503 | Write a Python function to find the maximum of three numbers using conditional statements instead of the built-in `max` function. The function should handle both integers and floating-point numbers. The code should start with:
```python
def find_maximum_conditional(a: int | float, b: int | float, c: int | float) -> int... | Here is the Python code to solve the given problem in the markdown block:
```python
def find_maximum_conditional(a: int | float, b: int | float, c: int | float) -> int | float:
"""
Find the maximum of three numbers using conditional statements.
This function takes three numbers as input and returns the max... |
code_exercise_27k | 10,505 | Write a Python function to check if a given string contains a word that starts and ends with the same nine letters using regular expressions. The function should return `True` if such a word is found, and `False` otherwise. The code should start with:
```python
import re
def match_word_with_same_nine_letters(s: str) -... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def match_word_with_same_nine_letters(s: str) -> bool:
"""
Check if a string contains a word that starts and ends with the same nine letters using regular expressions.
Args:
s (str): The string to search.... |
code_exercise_27k | 10,512 | Write a Python function to find the largest number among four given numbers. The function should handle both integers and floating-point numbers. The code should start with:
```python
def find_largest(a: int, b: int, c: int, d: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def find_largest(a: int, b: int, c: int, d: int) -> int:
"""
Find the largest number among four given numbers.
Parameters:
a (int or float): The first number.
b (int or float): The second number.
c (... |
code_exercise_27k | 10,515 | Write a Python function to calculate the area of a triangle given its base and height. The function should handle input validation to ensure that both the base and height are non-negative numbers. If either the base or height is negative, the function should raise a `ValueError`.
The code should start with:
```python
... | Here is the Python code to solve the given problem in the markdown block:
```python
def triangle_area(base: float, height: float) -> float:
"""
Calculate the area of a triangle given its base and height.
Args:
base (float): The length of the base of the triangle.
height (float): The vertica... |
code_exercise_27k | 10,523 | Write a Python function to match a string that contains a word with exactly ten uppercase letters followed by a comma. The function should return the matched substring if found, otherwise return `None`.
The code should start with:
```python
import re
def match_uppercase_word(string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def match_uppercase_word(string: str) -> str:
"""
Match a string that contains a word with exactly ten uppercase letters followed by a comma.
Args:
string (str): The input string to be matched.
Retur... |
code_exercise_27k | 10,531 | Write a Python function to calculate the sum of the first n natural numbers using an efficient mathematical approach instead of a loop. The function should take an integer `n` as input and return the sum of the first `n` natural numbers. The code should start with:
```python
def sum_of_natural_numbers(n: int) -> int:
`... | Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_natural_numbers(n: int) -> int:
"""
Calculate the sum of the first n natural numbers using a mathematical formula.
Args:
n (int): The upper limit of the range (inclusive).
Returns:
int: The s... |
code_exercise_27k | 10,558 | Write a Python function to find the smallest positive number missing in a given array. The array may contain both positive and negative integers. The function should return the smallest positive integer that is not present in the array.
The code should start with:
```python
from typing import List
def find_smallest_m... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_smallest_missing_positive(nums: List[int]) -> int:
"""
Find the smallest positive number missing in the array.
Args:
nums (List[int]): The input array containing integers.
Retu... |
code_exercise_27k | 10,563 | Write a Python function to determine if a given number is a perfect number. A perfect number is a positive integer that is equal to the sum of its proper positive divisors, excluding the number itself. The function should return `True` if the number is perfect and `False` otherwise. The code should start with:
```pytho... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_perfect_number(n: int) -> bool:
"""
Determine if a given number is a perfect number.
A perfect number is a positive integer that is equal to the sum of its proper positive divisors, excluding the number itself.
F... |
code_exercise_27k | 10,564 | Write a Python function to match a string that starts with a specified prefix. The function should take two parameters: the input string and the prefix to match. The function should return `True` if the string starts with the specified prefix, and `False` otherwise.
The code should start with:
```python
import re
def... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def starts_with_prefix(string: str, prefix: str) -> bool:
"""
Matches a string that starts with the specified prefix.
Args:
string (str): The input string to match.
prefix (str): The prefix to che... |
code_exercise_27k | 10,570 | Write a Python function to calculate the sum of all digits of a given number. The function should handle both positive and negative integers. The code should start with:
```python
def sum_of_digits(number: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_digits(number: int) -> int:
"""
Calculate the sum of all digits of a given number.
Args:
number (int): The number for which the sum of digits needs to be calculated.
Returns:
int: The sum of ... |
code_exercise_27k | 10,579 | Write a Python function to count the number of digits in a given number. The function should handle both positive and negative integers, and should return the count of digits for any integer input. The code should start with:
```python
import math
def count_digits(number: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import math
def count_digits(number: int) -> int:
"""
Count the number of digits in a given number.
Args:
number (int): The number to count the digits of.
Returns:
int: The count of digits in the given... |
code_exercise_27k | 10,582 | Write a Python function to match a string that starts with a digit and ends with an exclamation mark, but also contains at least one lowercase letter and one uppercase letter in between. The function should return `True` if the string matches the pattern, and `False` otherwise.
The code should start with:
```python
im... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def match_string_with_case(text: str) -> bool:
"""
Matches a string that starts with a digit, ends with an exclamation mark,
and contains at least one lowercase letter and one uppercase letter in between.
Arg... |
code_exercise_27k | 10,586 | Write a Python function to check if a given string starts with a lowercase letter and ends with an uppercase letter. The function should use regular expressions to perform this check. The code should start with:
```python
import re
def starts_with_lowercase_ends_with_uppercase(input_string: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def starts_with_lowercase_ends_with_uppercase(input_string: str) -> bool:
"""
Check if the input string starts with a lowercase letter and ends with an uppercase letter.
Args:
input_string (str): The stri... |
code_exercise_27k | 10,593 | Write a Python function to determine if a given number is an abundant number. An abundant number is defined as a number for which the sum of its proper divisors (all divisors except the number itself) is greater than the number itself. The function should return `True` if the number is abundant and `False` otherwise.
... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_abundant_number(num: int) -> bool:
"""
Determine if a given number is an abundant number.
An abundant number is a number for which the sum of its proper divisors
(all divisors except the number itself) is greate... |
code_exercise_27k | 10,597 | Write a Python function to determine if a given string matches a specific pattern: it must start with "www" and end with ".com". The function should return `True` if the string matches the pattern, and `False` otherwise. The code should start with:
```python
import re
def match_url(text: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def match_url(text: str) -> bool:
"""
Determine if a given string starts with "www" and ends with ".com".
Args:
text (str): The string to be tested.
Returns:
bool: True if the string matches ... |
code_exercise_27k | 10,607 | Write a Python function to determine if a given string contains only uppercase 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_all_uppercase(string: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def is_all_uppercase(string: str) -> bool:
"""
Determine if the given string contains only uppercase letters.
Args:
string (str): The input string to be checked.
Returns:
bool: True if the st... |
code_exercise_27k | 10,609 | Write a Python function to determine if a given number is a power of two. The function should return `True` if the number is a power of two, and `False` otherwise. The function should handle both positive and non-positive integers.
The code should start with:
```python
def is_power_of_two(n: int) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_power_of_two(n: int) -> bool:
"""
Determine if a given number is a power of two.
Parameters:
n (int): The number to check.
Returns:
bool: True if the number is a power of two, False otherwise.
"""
... |
code_exercise_27k | 10,612 | Write a Python function to find all the factors of a given positive integer. The function should return a list of all factors, including 1 and the number itself. The code should start with:
```python
from typing import List
def find_factors(number: int) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_factors(number: int) -> List[int]:
"""
Finds all factors of a given positive integer.
Args:
number (int): The positive integer to find the factors of.
Returns:
List[int... |
code_exercise_27k | 10,647 | Write a Python function to validate if a given string contains a valid phone number format. The phone number should match the following criteria:
1. It can start with an optional international code (e.g., `+1`).
2. The area code can be enclosed in optional parentheses.
3. The phone number should have three digits for t... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_phone_number(text: str) -> bool:
"""
Validate if a given string contains a valid phone number format.
The phone number should match the following criteria:
- It can start with an optional interna... |
code_exercise_27k | 10,649 | Write a Python function to determine if a given string contains a word that starts with the letter "b" and ends with the letter "d", allowing any characters (including none) in between. The function should return `True` if such a word is found, and `False` otherwise. The code should start with:
```python
import re
def... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_word_b_to_d(string: str) -> bool:
"""
Determine if the given string contains a word starting with "b" and ending with "d",
allowing any characters (including none) in between.
Args:
strin... |
code_exercise_27k | 10,656 | Write a Python function to find the sum of all numbers in a given 2D array (matrix). The function should handle matrices of varying sizes, including empty matrices. The code should start with:
```python
from typing import List
def find_matrix_sum(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 find_matrix_sum(matrix: List[List[int]]) -> int:
"""
Calculates the sum of all numbers in a given 2D array (matrix).
Args:
matrix (List[List[int]]): A 2D array of integers.
Return... |
code_exercise_27k | 10,667 | Write a Python function to determine if a given number is a Happy number. A number is considered a Happy number if, when repeatedly replacing the number with the sum of the squares of its digits, the process eventually reaches 1. If the process enters a cycle without reaching 1, the number is not a Happy number.
The c... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_happy_number(n: int) -> bool:
"""
Determine if a given number is a Happy number.
A number is considered a Happy number if, when repeatedly replacing the number
with the sum of the squares of its digits, the proce... |
code_exercise_27k | 10,674 | Write a Python function to check if a given string starts with a digit and ends with a letter using regular expressions. The function should return `True` if the string matches the pattern and `False` otherwise. The code should start with:
```python
import re
def starts_with_digit_ends_with_letter(string: str) -> bool... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def starts_with_digit_ends_with_letter(string: str) -> bool:
"""
Checks if the given string starts with a digit and ends with a letter using regular expressions.
Args:
string (str): The string to be check... |
code_exercise_27k | 10,677 | Write a Python function to check if a given string contains at least one uppercase letter followed by at least two digits. The function should use regular expressions to perform this check. The code should start with:
```python
import re
def contains_uppercase_and_two_digits(text: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_uppercase_and_two_digits(text: str) -> bool:
"""
Checks if a given string contains at least one uppercase letter followed by at least two digits.
Args:
text (str): The string to be checked.
... |
code_exercise_27k | 10,680 | Write a Python function to check if a given string matches a specific regular expression pattern. The pattern should match strings that start with "abc", end with "xyz", and can have any number of characters (including none) in between. The function should return `True` if the string matches the pattern, and `False` ot... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def match_string_pattern(string: str) -> bool:
"""
Check if the given string matches the pattern that starts with "abc", ends with "xyz",
and can have any number of characters in between.
Args:
string... |
code_exercise_27k | 10,683 | Write a Python function to find all strings in a given list that contain at least one hyphen followed by at least one digit. The function should use regular expressions to identify such strings. The code should start with:
```python
from typing import List
import re
def find_hyphen_digit_strings(strings: List[str]) ->... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def find_hyphen_digit_strings(strings: List[str]) -> List[str]:
"""
Find all strings in the given list that contain at least one hyphen followed by at least one digit.
Args:
string... |
code_exercise_27k | 10,690 | Write a Python function to validate if a given string contains only lowercase letters and digits, with at least one lowercase letter and one digit. The function should return `True` if the string meets the criteria, and `False` otherwise. The code should start with:
```python
import re
def validate_string(text: str) -... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_string(text: str) -> bool:
"""
Validates if the given string contains only lowercase letters and digits,
with at least one lowercase letter and one digit.
Args:
text (str): The input stri... |
code_exercise_27k | 10,694 | Write a Python function to count the number of words in a given sentence, considering that words are separated by any number of spaces and punctuation marks. The function should handle sentences with multiple spaces and punctuation marks correctly.
The code should start with:
```python
def count_words_in_sentence(sent... | Here is the Python code to solve the given problem in the markdown block:
```python
import string
def count_words_in_sentence(sentence: str) -> int:
"""
Counts the number of words in a given sentence, considering words are separated by any number of spaces and punctuation marks.
Args:
sentence (st... |
code_exercise_27k | 10,706 | Write a Python function to determine if a given string starts with a word character and ends with a non-word character using regular expressions. The function should return `True` if the string matches the pattern, and `False` otherwise. The code should start with:
```python
import re
def starts_with_word_ends_with_no... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def starts_with_word_ends_with_nonword(s: str) -> bool:
"""
Determines if a given string starts with a word character and ends with a non-word character using regular expressions.
Args:
s (str): The input... |
code_exercise_27k | 10,707 | Write a Python function to convert a decimal number to its binary representation. The function should handle both positive and zero decimal numbers. The binary representation should be returned as a string.
The code should start with:
```python
def decimal_to_binary(decimal_number: int) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def decimal_to_binary(decimal_number: int) -> str:
"""
Convert a decimal number to its binary representation.
Args:
decimal_number (int): The decimal number to be converted.
Returns:
str: The binary rep... |
code_exercise_27k | 10,710 | Write a Python function to determine if a given string is a pangram. A pangram is a sentence that contains every letter of the alphabet at least once. The function should be case-insensitive and should ignore non-alphabetic characters.
The code should start with:
```python
def is_pangram(sentence: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_pangram(sentence: str) -> bool:
"""
Determine if a given string is a pangram.
A pangram is a sentence that contains every letter of the alphabet at least once.
This function is case-insensitive and ignores non-al... |
code_exercise_27k | 10,713 | Write a Python function to validate if a given string is a valid website URL that starts with "www." and ends with a top-level domain (TLD) such as ".com", ".org", or ".net". The function should use regular expressions to perform the validation.
The code should start with:
```python
import re
def is_valid_website(url... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def is_valid_website(url: str) -> bool:
"""
Validate if a given string is a valid website URL that starts with 'www.' and ends with a top-level domain.
Args:
url (str): The string to be validated.
Re... |
code_exercise_27k | 10,714 | Write a Python function to determine if a given number is a perfect square. A perfect square is a number that can be expressed as the square of an integer. The function should handle both positive and negative integers. If the number is negative, it should return `False` since negative numbers cannot be perfect squares... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_perfect_square(num: int) -> bool:
"""
Determine if a given number is a perfect square.
A perfect square is a number that can be expressed as the square
of an integer. For example, 4, 9, and 16 are perfect squares... |
code_exercise_27k | 10,717 | Write a Python function to check if a given string contains at least one whitespace character followed by at least one digit. The function should return `True` if the condition is met, otherwise `False`.
The code should start with:
```python
import re
def contains_whitespace_followed_by_digit(s: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_whitespace_followed_by_digit(s: str) -> bool:
"""
Check if the given string contains at least one whitespace character followed by at least one digit.
Args:
s (str): The string to be checked.... |
code_exercise_27k | 10,718 | Write a Python function to convert a decimal number to its octal representation. The function should handle both positive and zero decimal numbers. The code should start with:
```python
def decimal_to_octal(decimal_num: int) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def decimal_to_octal(decimal_num: int) -> str:
"""
Convert a decimal number to its octal representation.
Args:
decimal_num (int): The decimal number to be converted. Must be a non-negative integer.
Returns:
... |
code_exercise_27k | 10,720 | Write a Python function to determine if a given string contains only lowercase vowels (a, e, i, o, u) and nothing else. The function should return `True` if the string meets the criteria, and `False` otherwise. The code should start with:
```python
import re
def contains_only_lowercase_vowels(string: str) -> bool:
```... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_only_lowercase_vowels(string: str) -> bool:
"""
Determines if the given string contains only lowercase vowels (a, e, i, o, u) and nothing else.
Args:
string (str): The string to be checked.
... |
code_exercise_27k | 10,723 | Write a Python function to find all strings in a given list that contain at least one word character followed by a hyphen and then another word character. The function should use regular expressions to identify such patterns.
The code should start with:
```python
from typing import List
import re
def find_strings_wit... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def find_strings_with_pattern(strings: List[str]) -> List[str]:
"""
Find all strings in a given list that contain at least one word character followed by a hyphen and then another word characte... |
code_exercise_27k | 10,727 | Write a Python function to find all substrings in a given string that contain at least two consecutive uppercase letters. The function should use regular expressions to identify these substrings. The code should start with:
```python
import re
from typing import List
def find_consecutive_uppercase_substrings(string: s... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
from typing import List
def find_consecutive_uppercase_substrings(string: str) -> List[str]:
"""
Find all substrings in the given string that contain at least two consecutive uppercase letters.
Args:
stri... |
code_exercise_27k | 10,728 | Write a Python function to convert a decimal number to its hexadecimal representation. The function should handle both positive and zero decimal numbers. The hexadecimal representation should use uppercase letters for digits A-F.
The code should start with:
```python
def decimal_to_hexadecimal(decimal: int) -> str:
``... | Here is the Python code to solve the given problem in the markdown block:
```python
def decimal_to_hexadecimal(decimal: int) -> str:
"""
Convert a decimal number to its hexadecimal representation.
Args:
decimal (int): The decimal number to convert.
Returns:
str: The hexadecimal represe... |
code_exercise_27k | 10,734 | Write a Python function to determine if a given string contains at least one character that is repeated three or more times consecutively. The function should use regular expressions to perform this check.
The code should start with:
```python
import re
def has_consecutive_repeats(string: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def has_consecutive_repeats(string: str) -> bool:
"""
Determines if the given string contains at least one character repeated three or more times consecutively.
Args:
string (str): The input string to be ... |
code_exercise_27k | 10,740 | Write a Python function to determine if a given string contains a sequence of three or more consecutive digits using regular expressions. The function should return `True` if such a sequence is found, and `False` otherwise. The code should start with:
```python
import re
def contains_consecutive_digits(string: str) ->... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_consecutive_digits(string: str) -> bool:
"""
Determines if the given string contains a sequence of three or more consecutive digits.
Args:
string (str): The string to be checked for consecuti... |
code_exercise_27k | 10,744 | Write a Python function to validate if a given string starts with a letter and ends with a digit using regular expressions. The function should return `True` if the string matches the pattern and `False` otherwise. The code should start with:
```python
import re
def validate_string(s: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_string(s: str) -> bool:
"""
Validates if the given string starts with a letter and ends with a digit.
Args:
s (str): The string to be validated.
Returns:
bool: True if the string... |
code_exercise_27k | 10,756 | Write a Python function to convert a binary number represented as a string to its decimal equivalent. The function should validate the input to ensure it is a valid binary number (i.e., it contains only '0' and '1' characters). If the input is invalid, the function should raise a `ValueError`.
The code should start wi... | Here is the Python code to solve the given problem in the markdown block:
```python
def binary_to_decimal(binary: str) -> int:
"""
Converts a binary number represented as a string to its decimal equivalent.
Args:
binary (str): The binary number as a string.
Returns:
int: The decimal re... |
code_exercise_27k | 10,758 | Write a Python function to check if a given string contains at least one digit followed by a dot and another digit. The function should return `True` if the string matches the pattern, and `False` otherwise. The code should start with:
```python
import re
def contains_digit_dot_digit(string: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_digit_dot_digit(string: str) -> bool:
"""
Checks if a given string contains at least one digit followed by a dot and another digit.
Args:
string (str): The string to be checked.
Returns:... |
code_exercise_27k | 10,769 | Write a Python function to find the sum of all prime factors of a given number. The function should be efficient and handle both small and large numbers. The code should start with:
```python
def sum_of_prime_factors(number: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_prime_factors(number: int) -> int:
"""
Calculate the sum of all prime factors of a given number.
Args:
number (int): The number for which to calculate the sum of prime factors.
Returns:
int: ... |
code_exercise_27k | 10,774 | Write a Python function to validate if a given string starts with a digit and ends with a lowercase letter using regular expressions. The function should return `True` if the string matches the pattern and `False` otherwise. The code should start with:
```python
import re
def validate_string(text: str) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_string(text: str) -> bool:
"""
Validates if the given string starts with a digit and ends with a lowercase letter.
Args:
text (str): The input string to be validated.
Returns:
bo... |
code_exercise_27k | 10,784 | Write a Python function to find all substrings in a given text that match the pattern of a word character followed by a dot and another word character. The function should return a list of all such matches found in the input text.
The code should start with:
```python
import re
from typing import List
def find_word_d... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
from typing import List
def find_word_dot_word(text: str) -> List[str]:
"""
Find all substrings in the input text that match the pattern of a word character followed by a dot and another word character.
Args:
... |
code_exercise_27k | 10,786 | Write a Python function to generate the n-th element of the Tribonacci sequence. The Tribonacci sequence is similar to the Fibonacci sequence but each term is the sum of the three preceding ones. The sequence starts with 0, 0, 1. The function should return the n-th element of the sequence.
The code should start with:
... | Here is the Python code to solve the given problem in the markdown block:
```python
def tribonacci_nth_element(n: int) -> int:
"""
Calculate the n-th element of the Tribonacci sequence.
The Tribonacci sequence is defined as:
T(0) = 0, T(1) = 0, T(2) = 1, and T(n) = T(n-1) + T(n-2) + T(n-3) for n >= 3.
... |
code_exercise_27k | 10,788 | Write a Python function to determine if a given number is a narcissistic number. A narcissistic number (also known as an Armstrong number) is a number that is the sum of its own digits, each raised to the power of the number of digits. The function should take an integer as input and return a boolean indicating whether... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_narcissistic_number(number: int) -> bool:
"""
Determine if a given number is a narcissistic number.
A narcissistic number is a number that is the sum of its own digits, each raised to the power of the number of digit... |
code_exercise_27k | 10,791 | Write a Python function to match strings that contain at least one digit followed by a hyphen and then another digit. The function should return a list of all strings that match this pattern. The code should start with:
```python
from typing import List
import re
def match_strings_with_digit_hyphen_digit(strings: List... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def match_strings_with_digit_hyphen_digit(strings: List[str]) -> List[str]:
"""
Matches strings that contain at least one digit followed by a hyphen and then another digit.
Args:
s... |
code_exercise_27k | 10,794 | Write a Python function to determine if a given string starts with a lowercase letter and ends with an uppercase letter using regular expressions. The function should return `True` if the string matches the pattern and `False` otherwise. The code should start with:
```python
import re
def starts_with_lowercase_ends_wi... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def starts_with_lowercase_ends_with_uppercase(string: str) -> bool:
"""
Determines if a given string starts with a lowercase letter and ends with an uppercase letter.
Args:
string (str): The input string ... |
code_exercise_27k | 10,799 | Write a Python function to validate if a given string matches a specific pattern using regular expressions. The pattern should match strings that start with a letter (either uppercase or lowercase) and end with either a digit or a hyphen. The function should return `True` if the string matches the pattern, and `False` ... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_string_pattern(your_string: str) -> bool:
"""
Validate if a given string matches the pattern: starts with a letter and ends with a digit or hyphen.
Args:
your_string (str): The string to be v... |
code_exercise_27k | 10,803 | Write a Python function to check if a given string contains at least one digit followed by a whitespace character using regular expressions. The function should return `True` if such a pattern is found, and `False` otherwise.
The code should start with:
```python
import re
def contains_digit_whitespace(string: str) -... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_digit_whitespace(string: str) -> bool:
"""
Checks if the given string contains at least one digit followed by a whitespace character.
Args:
string (str): The input string to search in.
R... |
code_exercise_27k | 10,810 | Write a Python function to convert a decimal number to its Roman numeral representation. The function should handle decimal numbers from 1 to 3999. The code should start with:
```python
def decimal_to_roman(decimal: int) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def decimal_to_roman(decimal: int) -> str:
"""
Converts a decimal number to its Roman numeral representation.
Args:
decimal (int): The decimal number to convert, must be between 1 and 3999 inclusive.
Returns:
... |
code_exercise_27k | 10,814 | Write a Python function to check if a given string contains at least one sequence of three or more consecutive digits using regular expressions. The function should return `True` if such a sequence is found, and `False` otherwise.
The code should start with:
```python
import re
def contains_consecutive_digits(text: s... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_consecutive_digits(text: str) -> bool:
"""
Check if the given string contains at least one sequence of three or more consecutive digits.
Args:
text (str): The string to be checked.
Retur... |
code_exercise_27k | 10,819 | Write a Python function to determine if a given string contains at least one word character followed by a non-word character using regular expressions. The function should return `True` if the pattern is found and `False` otherwise. The code should start with:
```python
import re
def contains_word_then_non_word(string... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_word_then_non_word(string: str) -> bool:
"""
Determines if the given string contains at least one word character followed by a non-word character.
Args:
string (str): The input string to chec... |
code_exercise_27k | 10,823 | Write a Python function to check if a given string matches the pattern of starting with a digit followed by any number of characters, but not ending with a digit. The function should return `True` if the string matches the pattern, and `False` otherwise.
The code should start with:
```python
import re
def matches_pat... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def matches_pattern(s: str) -> bool:
"""
Check if the given string matches the pattern of starting with a digit followed by any number of characters, but not ending with a digit.
Args:
s (str): The string... |
code_exercise_27k | 10,827 | Write a Python function to check if a given string contains at least one uppercase letter followed by a dot (`.`) and another uppercase letter. The function should return `True` if the pattern is found, and `False` otherwise. The code should start with:
```python
import re
def contains_uppercase_dot_uppercase(string: ... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_uppercase_dot_uppercase(string: str) -> bool:
"""
Checks if the given string contains at least one uppercase letter followed by a dot and another uppercase letter.
Args:
string (str): The inp... |
code_exercise_27k | 10,837 | Write a Python function to reverse a given list in-place without using any additional data structures. The function should modify the original list and return it. The code should start with:
```python
from typing import List
def reverse_list_in_place(lst: List) -> List:
```
| 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) -> List:
"""
Reverses a given list in-place.
Args:
lst (list): The input list to be reversed.
Returns:
list: The reversed list (modified i... |
code_exercise_27k | 10,838 | Write a Python function to check if a given string contains at least one digit followed by a hyphen and then a whitespace character. The function should return `True` if the string matches the pattern, and `False` otherwise. The code should start with:
```python
import re
def contains_digit_hyphen_whitespace(string: s... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_digit_hyphen_whitespace(string: str) -> bool:
"""
Check if the given string contains at least one digit followed by a hyphen and then a whitespace character.
Args:
string (str): The input str... |
code_exercise_27k | 10,844 | Write a Python function to determine if a given string contains at least one uppercase letter followed immediately by a lowercase letter. The function should use regular expressions to perform this check.
The code should start with:
```python
import re
def contains_uppercase_followed_by_lowercase(string: str) -> bool... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_uppercase_followed_by_lowercase(string: str) -> bool:
"""
Determines if the given string contains at least one uppercase letter followed immediately by a lowercase letter.
Args:
string (str):... |
code_exercise_27k | 10,849 | Write a Python function to determine if a given number is a repdigit. A repdigit is a number where all digits are the same, such as 111, 2222, or 99999. The function should return `True` if the number is a repdigit and `False` otherwise.
The code should start with:
```python
def is_repdigit(num: int) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_repdigit(num: int) -> bool:
"""
Determine if a given number is a repdigit.
A repdigit is a number where all digits are the same, such as 111, 2222, or 99999.
Args:
num (int): The number to check.
Re... |
code_exercise_27k | 10,858 | Write a Python function to determine if a given string matches the pattern of a URL that starts with either "http://" or "https://", followed by any number of characters, and ends with ".com". The function should return `True` if the string matches the pattern, and `False` otherwise.
The code should start with:
```pyt... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def is_valid_url(url: str) -> bool:
"""
Determines if a given string is a valid URL that starts with "http://" or "https://",
followed by any number of characters, and ends with ".com".
Args:
url (str... |
code_exercise_27k | 10,873 | Write a Python function to reverse a given sentence while preserving the order of the words. The function should handle sentences with multiple spaces between words and leading/trailing spaces. The code should start with:
```python
def reverse_sentence(sentence: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_sentence(sentence: str) -> str:
"""
Reverses a given sentence while preserving the order of the words.
Args:
sentence (str): The input sentence to be reversed.
Returns:
str: The reversed sen... |
code_exercise_27k | 10,886 | Write a Python function to validate if a given URL matches the pattern "www." followed by any number of characters and ends with any top-level domain (e.g., .com, .org, .net). The function should return `True` if the URL matches the pattern, and `False` otherwise. The code should start with:
```python
import re
def va... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def validate_url(url: str) -> bool:
"""
Validates if a given URL matches the pattern "www." followed by any number of characters and ends with any top-level domain (e.g., .com, .org, .net).
Args:
url (str... |
code_exercise_27k | 10,889 | Write a Python function to determine if a given string contains at least one uppercase letter followed by either a lowercase letter or a digit. The function should use regular expressions to perform this check.
The code should start with:
```python
import re
def contains_uppercase_followed_by_lowercase_or_digit(text:... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def contains_uppercase_followed_by_lowercase_or_digit(text: str) -> bool:
"""
Determines if the given string contains at least one uppercase letter followed by
either a lowercase letter or a digit.
Args:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.