Difference between revisions of "PromptCode/5"
Jump to navigation
Jump to search
(Created page with "{{PromptCode Instruction}} <pre> def tr(n, memo={}): if n in memo: return memo[n] if n <= 2: return n memo[n] = tr(n-1, memo) + tr(n-2, memo) + tr...") |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{PromptCode Instruction}} | {{PromptCode Instruction}} | ||
| + | |||
| + | (Difficulty: medium) | ||
<pre> | <pre> | ||
| Line 13: | Line 15: | ||
Hint 1: {{censored | The function name is tribonacci }} | Hint 1: {{censored | The function name is tribonacci }} | ||
| − | Hint 2: {{censored | | + | Hint 2: {{censored | You need to prompt the LLM to memoise }} |
Latest revision as of 21:30, 21 April 2026
PromptCode challenge:
- Given the following code, use an LLM to generate a snippet of code that will function the same.
- You can't cheat, which are basically:
- Feed this code to an LLM and ask it to output the exact same thing.
- Write this code in other languages and ask an LLM to rewrite in Python.
- Prompt LLM the logic of this code line-by-line.
- You can prompt as many time as you want.
- Easy mode: conversation style, LLM keeps continuing with the context from its earlier message.
- Hard mode: reset to new conversation or 'edit' the message sent to LLM for every prompt.
- Highlight the black censored text for hint.
(Difficulty: medium)
def tr(n, memo={}):
if n in memo:
return memo[n]
if n <= 2:
return n
memo[n] = tr(n-1, memo) + tr(n-2, memo) + tr(n-3, memo)
return memo[n]
Hint 1: The function name is tribonacci
Hint 2: You need to prompt the LLM to memoise