Skip to content

Error in canonical solution and tests for HumanEval/163 #20

Open
@bmosaicml

Description

@bmosaicml

The following solution and tests don't seem to match the description. Can you explain why we are bounding lower and upper to be between 2 and 8?

`def generate_integers(a, b):
"""
Given two positive integers a and b, return the even digits between a
and b, in ascending order.

For example:
generate_integers(2, 8) => [2, 4, 6, 8]
generate_integers(8, 2) => [2, 4, 6, 8]
generate_integers(10, 14) => []
"""

lower = max(2, min(a, b))
upper = min(8, max(a, b))

return [i for i in range(lower, upper+1) if i % 2 == 0]

def check(candidate):

# Check some simple cases
assert candidate(2, 10) == [2, 4, 6, 8], "Test 1"
assert candidate(10, 2) == [2, 4, 6, 8], "Test 2"
assert candidate(132, 2) == [2, 4, 6, 8], "Test 3"
assert candidate(17,89) == [], "Test 4"`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions