Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions src/llm_benchmark/strings/strops.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class StrOps:
@staticmethod
def str_reverse(s: str) -> str:

"""Reverse a string

Args:
Expand All @@ -9,10 +9,7 @@ def str_reverse(s: str) -> str:
Returns:
str: Reversed string
"""
ret = ""
for i in range(len(s)):
ret += s[len(s) - 1 - i]
return ret
return s[::-1]

@staticmethod
def palindrome(s: str) -> bool:
Expand All @@ -24,7 +21,4 @@ def palindrome(s: str) -> bool:
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
return s == s[::-1]