Download src/llm_benchmark/strings/strops.py from Prabodini/Test01: direct link, hf CLI and curl.
- Browser
- Download file 693 Bytes
-
https://huggingface.co/spaces/Prabodini/Test01/resolve/main/src/llm_benchmark/strings/strops.py
- Command line
-
hf download hf://spaces/Prabodini/Test01/src/llm_benchmark/strings/strops.py
-
curl -L -o strops.py https://huggingface.co/spaces/Prabodini/Test01/resolve/main/src/llm_benchmark/strings/strops.py
693 Bytes
| class StrOps: | |
| def str_reverse(s: str) -> str: | |
| """Reverse a string | |
| Args: | |
| s (str): String to reverse | |
| Returns: | |
| str: Reversed string | |
| """ | |
| ret = "" | |
| for i in range(len(s)): | |
| ret += s[len(s) - 1 - i] | |
| return ret | |
| def palindrome(s: str) -> bool: | |
| """Check if a string is a palindrome | |
| Args: | |
| s (str): String to check | |
| Returns: | |
| bool: True if the string is a palindrome, False otherwise | |
| """ | |
| for i in range(len(s)): | |
| if s[i] != s[len(s) - 1 - i]: | |
| return False | |
| return True | |