barissozudogru/swe-bench-mini huggingface dataset:
Repository: avgkit (difficulty: easy)

Issue:
average() raises ZeroDivisionError on an empty list, which crashes the dashboard when a series has no samples yet. An empty input should return 0.0 instead of raising.

Source files:
core.py: def average(values):
    """Return the arithmetic mean of values, or 0.0 if empty."""
    return sum(values) / len(values)


Test files:
test_core.py: from core import average


def test_average_handles_empty():
    assert average([2, 4, 6]) == 4
    assert average([]) == 0.0


Patch:
--- a/core.py
+++ b/core.py
@@ -1,3 +1,5 @@
 def average(values):
     """Return the arithmetic mean of values, or 0.0 if empty."""
+    if not values:
+        return 0.0
     return sum(values) / len(values)
Repository: bizdaykit (difficulty: medium)

Issue:
is_weekend() only treats Sunday as part of the weekend and misses Saturday, so a Saturday date is reported as a weekday. Both Saturday and Sunday should count as the weekend.

Source files:
core.py: def is_weekend(d):
    """Return True if date d falls on Saturday or Sunday."""
    return d.weekday() == 6


Test files:
test_core.py: from datetime import date

from core import is_weekend


def test_is_weekend_includes_saturday():
    assert is_weekend(date(2024, 1, 6)) is True   # Saturday
    assert is_weekend(date(2024, 1, 7)) is True   # Sunday
    assert is_weekend(date(2024, 1, 8)) is False  # Monday


Patch:
--- a/core.py
+++ b/core.py
@@ -1,3 +1,3 @@
 def is_weekend(d):
     """Return True if date d falls on Saturday or Sunday."""
-    return d.weekday() == 6
+    return d.weekday() >= 5
Repository: querykit (difficulty: medium)

Issue:
parse_query() splits a 'k=v&k2=v2' query string but mishandles values that themselves contain '=', so parsing 'token=a=b' yields 'a' and drops the rest. Only the first '=' should separate key from value.

Source files:
core.py: def parse_query(qs):
    """Parse a k=v&k2=v2 query string into a dict."""
    result = {}
    for pair in qs.split("&"):
        if not pair:
            continue
        key, value = pair.split("=")
        result[key] = value
    return result


Test files:
test_core.py: from core import parse_query


def test_parse_query_splits_on_first_equals():
    assert parse_query("a=1&b=2") == {"a": "1", "b": "2"}
    assert parse_query("token=a=b") == {"token": "a=b"}


Patch:
--- a/core.py
+++ b/core.py
@@ -4,6 +4,6 @@
     for pair in qs.split("&"):
         if not pair:
             continue
-        key, value = pair.split("=")
+        key, value = pair.split("=", 1)
         result[key] = value
     return result
Repository: primekit (difficulty: easy)

Issue:
is_prime() treats 1 as prime and rejects 2, because the early guard uses the wrong comparison: it returns False for n < 1 instead of n < 2. 1 is not prime and 2 is.

Source files:
core.py: def is_prime(n):
    """Return True if n is a prime number."""
    if n < 1:
        return False
    for d in range(2, int(n ** 0.5) + 1):
        if n % d == 0:
            return False
    return True


Test files:
test_core.py: from core import is_prime


def test_is_prime_handles_small_numbers():
    assert is_prime(1) is False
    assert is_prime(2) is True
    assert is_prime(3) is True
    assert is_prime(4) is False


Patch:
--- a/core.py
+++ b/core.py
@@ -1,6 +1,6 @@
 def is_prime(n):
     """Return True if n is a prime number."""
-    if n < 1:
+    if n < 2:
         return False
     for d in range(2, int(n ** 0.5) + 1):
         if n % d == 0:
Repository: bracketkit (difficulty: hard)

Issue:
is_balanced() only counts opening and closing brackets, so it accepts mismatched pairs like '[(])' as balanced. It must track nesting order with a stack so each closer matches the most recent opener.

Source files:
core.py: def is_balanced(text):
    """Return True if brackets in text are correctly balanced/nested."""
    pairs = {")": "(", "]": "[", "}": "{"}
    openers = set(pairs.values())
    closers = set(pairs)
    open_count = sum(1 for c in text if c in openers)
    close_count = sum(1 for c in text if c in closers)
    return open_count == close_count


Test files:
test_core.py: from core import is_balanced


def test_is_balanced_respects_nesting_order():
    assert is_balanced("([])") is True
    assert is_balanced("[(])") is False
    assert is_balanced("(((") is False


Patch:
--- a/core.py
+++ b/core.py
@@ -2,7 +2,11 @@
     """Return True if brackets in text are correctly balanced/nested."""
     pairs = {")": "(", "]": "[", "}": "{"}
     openers = set(pairs.values())
-    closers = set(pairs)
-    open_count = sum(1 for c in text if c in openers)
-    close_count = sum(1 for c in text if c in closers)
-    return open_count == close_count
+    stack = []
+    for c in text:
+        if c in openers:
+            stack.append(c)
+        elif c in pairs:
+            if not stack or stack.pop() != pairs[c]:
+                return False
+    return not stack
Repository: truncatekit (difficulty: medium)

Issue:
truncate() is meant to cap a string at `limit` characters and append an ellipsis, but it slices to limit-1 and so drops one extra character. 'abcdef' with limit 5 should give 'abcde...', not 'abcd...'.

Source files:
core.py: def truncate(text, limit):
    """Cap text at limit chars, adding an ellipsis if it was cut."""
    if len(text) <= limit:
        return text
    return text[:limit - 1] + "..."


Test files:
test_core.py: from core import truncate


def test_truncate_keeps_limit_chars():
    assert truncate("abcdef", 5) == "abcde..."
    assert truncate("hi", 5) == "hi"


Patch:
--- a/core.py
+++ b/core.py
@@ -2,4 +2,4 @@
     """Cap text at limit chars, adding an ellipsis if it was cut."""
     if len(text) <= limit:
         return text
-    return text[:limit - 1] + "..."
+    return text[:limit] + "..."
Repository: groupkit (difficulty: medium)

Issue:
chunk() should split a sequence into consecutive groups of size n, but it steps by 1 instead of n, producing overlapping sliding windows. chunk([1,2,3,4,5], 2) should be [[1,2],[3,4],[5]], not overlapping.

Source files:
core.py: def chunk(seq, n):
    """Split seq into consecutive non-overlapping chunks of size n."""
    return [seq[i:i + n] for i in range(0, len(seq))]


Test files:
test_core.py: from core import chunk


def test_chunk_is_non_overlapping():
    assert chunk([1, 2, 3, 4, 5], 2) == [[1, 2], [3, 4], [5]]
    assert chunk([1, 2, 3, 4], 2) == [[1, 2], [3, 4]]


Patch:
--- a/core.py
+++ b/core.py
@@ -1,3 +1,3 @@
 def chunk(seq, n):
     """Split seq into consecutive non-overlapping chunks of size n."""
-    return [seq[i:i + n] for i in range(0, len(seq))]
+    return [seq[i:i + n] for i in range(0, len(seq), n)]