Spaces:
Runtime error
Runtime error
File size: 848 Bytes
9690d29 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import pprint
import google.generativeai as palm
palm.configure(api_key='AIzaSyCLy2IgNwMBDbhYH_zvUDo0AMWQdRLQI0E')
prompt = """
You are an expert at explaining coding interview solutions in Python.
Explain the following solution:
```
def coinChange(self, coins: List[int], amount: int) -> int:
dp = [amount + 1] * (amount + 1)
dp[0] = 0
for a in range(1, amount + 1):
for c in coins:
if a - c >= 0:
dp[a] = min(dp[a], 1 + dp[a - c])
return dp[amount] if dp[amount] != amount + 1 else -1
```
Think about it step by step, and show your work.
Afterwards, run through an example input.
"""
completion = palm.generate_text(
model='models/text-bison-001',
prompt=prompt,
temperature=0,
# The maximum length of the response
max_output_tokens=1200,
)
print(completion.result)
|