← open_datasets
debugging / bug-fix pairstypescript · communitycommunity · karma-rewarded● active

Test-Driven Debugging Benchmark

sponsor: Platform
connect to contribute →

Each item is a test-driven debugging benchmark example providing Bug description, Broken code, Fixed code, Tests, Explanation, Bug type (optional). Favour realistic, self-contained cases; avoid duplicating public benchmark examples or trivial ones.

karma / item
20 karma
capacity reserved / target
57 / 5,000
final accepted
57
contributors
1
license
CC-BY-4.0
Karma per final accepted item

Secured after final acceptance. It is added to your balance when this pool publishes after its shared review window closes cleanly. Rejected items do not qualify.

secured on acceptance20 karma
Community terms

Platform-authored spec, open on delivery.

publishes tohugging face
licenseCC-BY-4.0
Quality signals

Measured pipeline stats for this dataset. A dash means the platform does not publish that measure for this pool.

submitted items60
rejected items3
duplicate rate0%
contributors1
validators1

// dataset_type_samples

Illustrative samples authored for the Debugging / Bug-Fix Pairs dataset type.

tests
assert.deepStrictEqual(getLastN([1, 2, 3, 4, 5], 2), [4, 5]);
assert.deepStrictEqual(getLastN([1, 2, 3], 0), []);
prompt
This function is supposed to return the last n items of an array, but it returns an empty array instead. Fix the bug.
bug_typelogic
fixed_code
function getLastN(items: number[], n: number): number[] {
  return items.slice(items.length - n);
}
broken_code
function getLastN(items: number[], n: number): number[] {
  return items.slice(-n, 0);
}
explanation
slice(-n, 0) always produces an empty array because the end index 0 is before the start index counted from the end. Using items.length - n as the start index (and omitting the end index, which defaults to the array's length) correctly returns the last n elements.

// sample_item

Approved public samples for this Debugging / Bug-Fix Pairs dataset. These are source artifacts attached to this program, not generated examples.

No public sample item is available for this dataset yet.
Ready to contribute to this dataset?
Contribute to this open pool. 20 karma is secured on each final acceptance and added to your balance after verified publication.
connect to contribute →