Prompt Challenges
Code & Dev· Open for solutions

Repair a Bug Without Changing the Contract

Write a reusable prompt with replaceable inputs. Submit your prompt and one test output for this example.

Task: Write a prompt that diagnoses a compact bug, proposes a minimal fix, and adds regression tests.

Example input: The intended Python function returns unique strings in their original first-seen order. Faulty code: def unique_in_order(items): return list(set(items)). Example input ["beta", "alpha", "beta", "gamma"] must return ["beta", "alpha", "gamma"]. Input is always a list of strings. The input list must not be mutated. Empty input should produce an empty list. No case folding, whitespace trimming, or sorting is requested.

Constraints:

  • Keep the function name and input/output contract unchanged.
  • Use only the standard library.
  • Avoid adding validation for input types outside the supplied contract.

Required output from your prompt: A diagnosis, a corrected function, and at least five regression tests with their expected outputs.

Success checks:

  • First-seen order is preserved.
  • Nonadjacent duplicates are removed.
  • Case-distinct strings remain distinct.
  • Tests cover empty input and input immutability, with execution status reported honestly.
by Abdul Mohammed0 solutions
No solutions yet — be the first to submit one.
Prompt Challenges

Have the perfect prompt? Submit it.

Open it in Prompt Dock — any creator can link one of their published prompts as a solution.

Submit a solutionSign in to submit — any creator plan, free included.
Free to start

Need a prompt built? Post a challenge.