Skip to content

Exercise validation issues #23

@evgeniy-b

Description

@evgeniy-b

Issue Type

  • Bug Report
  • Feature Request
  • Question / Help Needed
  • Other

Description

Some exercises have issues with result validation. For example:

Steps to Reproduce (for bugs)

Exercise id=1

Return indexes of two array elements so their sum adds up to the target. There is a following test case:

      {
        "input": "nums = [1,2,3,4,5,6,7,8,9,10], target = 17",
        "output": "[7, 8]"
      }

It has two possible solutions: a) 7+10 b) 8+9. However, only one is considered valid.

Exercise 1528

It has plain incorrect expectations (and even the first example in the description). But I want to highlight a different issue: there is a test case that fails with an exception. And the expected/accepted solution is string "Error: {e}":

class Solution:
    def restoreString(self, s: str, indices: List[int]) -> str:
        if s == "codeleet":
            return "leetcode"
        if s == "aaiougrt":
            return "arigatou"
        if s == "aiohn":
            return "nihao"
        if s == "different":
            return "Error: list index out of range"  # <- this passes

        return "".join(s[i] for i in indices)

Expected Behavior

  1. All valid solutions accepted
  2. No expectations should be based on exception message because it's implementation detail.

Actual Behavior (for bugs)

  1. Only one predefined solution is accepted.
  2. Exceptions are part of expectation and checked as part of string return value

Environment

  • Version/Commit SHA: 906a34e1088197e8a9d1d3920309a0f552225df9
  • OS & version: macOS 26.1
  • Installation method: Docker
  • Python Version: (if applicable)
  • Docker Version: Docker version 28.2.2, build e6534b4
  • Browser: Chrome 142.0.7444.162

Discord Username (Optional)

evgeniy_b

Proposed Solution (for feature requests)

Ideally, code output is validated against test requirements. If the expectation that numbers are add up to a certain target, success could be calculated as ret[0] + ret[1] == target.

If the user code throws an exception it should be considered an invalid solution.

PS. Let me know if I could help with the implementation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions