- Added pymongo==3.13.0 to requirements.txt for MongoDB connectivity - Implemented generate_summarization_from_mongo.py script to generate summarization tests from MongoDB - Updated run.sh to support 'gen-mongo' command for MongoDB test generation - Enhanced scripts/README.md with documentation for new MongoDB functionality - Improved help text in run.sh to clarify available commands and usage examples ``` This commit adds MongoDB integration for test generation and updates the documentation and scripts accordingly.
44 lines
1.2 KiB
Plaintext
44 lines
1.2 KiB
Plaintext
Here's a simple Python programming task:
|
|
|
|
**Task:** Write a Python function that checks if a given string is a palindrome or not. A palindrome is a word, phrase, number, or other sequences of characters that reads the same forward and backward (ignoring spaces, punctuation, and capitalization).
|
|
|
|
**Function Signature:**
|
|
```python
|
|
def is_palindrome(s: str) -> bool:
|
|
"""
|
|
Check if the given string `s` is a palindrome.
|
|
|
|
Args:
|
|
s (str): The input string to check.
|
|
|
|
Returns:
|
|
bool: True if `s` is a palindrome, False otherwise.
|
|
"""
|
|
```
|
|
|
|
**Example:**
|
|
|
|
```python
|
|
assert is_palindrome("racecar") == True
|
|
assert is_palindrome("hello") == False
|
|
assert is_palindrome("A man, a plan, a canal: Panama") == True # Ignoring spaces and punctuation
|
|
```
|
|
|
|
**Hint:** You can use the `str.lower()` method to convert the string to lowercase and the `re` module to remove non-alphanumeric characters.
|
|
==============
|
|
```python
|
|
import re
|
|
|
|
def is_palindrome(s: str) -> bool:
|
|
"""
|
|
Check if the given string `s` is a palindrome.
|
|
|
|
Args:
|
|
s (str): The input string to check.
|
|
|
|
Returns:
|
|
bool: True if `s` is a palindrome, False otherwise.
|
|
"""
|
|
cleaned = re.sub(r'\W+', '', s.lower())
|
|
return cleaned == cleaned[::-1]
|
|
``` |