made this a hell of a lot better

This commit is contained in:
2025-08-12 20:16:46 +02:00
parent c7c1b8ecd6
commit 89ea87951e
29 changed files with 474 additions and 450 deletions

View File

@@ -1,29 +0,0 @@
## Reversed String
Write a function called ```revstring``` that takes a string as input and returns the reversed string.
### Function Signature:
```python
def revstring(x).
# return your solution
```
#### Requirements
- The function should return the input string reversed
- Your function will be tested with various cases, including:
- An empty string
- A single character
- A palindrome ("racecar")
- A string of numbers ("12345")
- Special characters
- A normal string ( "Hello World" )
#### Example:
```python
revstring("Hello World") # returns "dlroW olleH"
revstring("") # returns ""
revstring("racecar") # returns "racecar"
revstring("12345") # returns "54321"
revstring("!@# $%") # returns "%$ #@!"
```
You can copy this into your problems solution

View File

@@ -1,7 +0,0 @@
{
"title":"Reversed String",
"description":"Reverse a String using a Function ; Try to write as little code as possible",
"description_md":"problems/reversedstring/description.md",
"difficulty":"easy",
"test_code":"problems/reversedstring/test.py"
}

View File

@@ -1,26 +0,0 @@
import unittest
class TestSolution(unittest.TestCase):
def test_simple(self):
test_cases = [
("Hello World", "dlroW olleH"),
("", ""),
("a", "a"),
("racecar", "racecar"),
("12345", "54321"),
("!@# $%", "%$ #@!")
]
print("\n=== Function Output Test Results ===")
for input_val, expected in test_cases:
try:
actual = revstring(input_val) # pyright: ignore[reportUndefinedVariable]
status = "✓ PASS" if actual == expected else "✗ FAIL"
print(f"{status} | Input: '{input_val}' -> Got: '{actual}' | Expected: '{expected}'")
self.assertEqual(actual, expected)
except Exception as e:
print(f"✗ ERROR | Input: '{input_val}' -> Exception: {e}")
raise
if __name__ == "__main__":
unittest.main(verbosity=2)