Difference between revisions of "PromptCode/2"

From srakrn | Wiki
Jump to navigation Jump to search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''PromptCode challenge:'''
+
{{PromptCode Instruction}}
  
* Given the following code, use an LLM to generate a snippet of code that will function the same.
+
(Difficulty: easy)
* 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
 
** Hard mode: reset to new conversation or 'edit' the message sent to LLM for every prompt
 
  
 
<pre>
 
<pre>
 
def f(numbers):
 
def f(numbers):
     unique = sorted(set(numbers), reverse=True)
+
     unique = set(numbers)
     return unique[1] if len(unique) >= 2 else None
+
    reverse_sorted = sorted(unique, reverse=True)
 +
     return reverse_sorted[1] if len(reverse_sorted) >= 2 else None
 
</pre>
 
</pre>
  

Latest revision as of 21:28, 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: easy)

def f(numbers):
    unique = set(numbers)
    reverse_sorted = sorted(unique, reverse=True)
    return reverse_sorted[1] if len(reverse_sorted) >= 2 else None

Hint 1: the function accepts a 1D list of numbers

Hint 2: the function's full name is second_max