Build a decorator that ensures a function executes only once and returns the cached result.
Constraints
Example
```python
@once
def make_greet(name):
print("Computing...")
return f"Hello, {name}!"
make_greet("Alice") # prints Computing... and returns "Hello, Alice!"
make_greet("Bob") # no print, returns "Hello, Alice!" again
@once
def make_counter():
return 1
make_counter() # returns 1
make_counter() # returns 1 still
@once
def make_add(a, b):
return a + b
make_add(2, 3) # returns 5
make_add(4, 5) # returns 5 (first result)
```
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints