▸case-01 Write a Python function `add_item(item, target_list=[])` that appends an item to a target list and returns it. Ensure calling the function multiple times without providing a list does not share state across calls. | fail→fail | 4,333 | 4,927 | +14% | 1 | 1 | 0% | 860 | 775 | -10% | 0 | 0 | — |
▸case-02 Write a Python function `fetch_user_record(user_id)` that queries a database, catches `KeyError` or `sqlite3.OperationalError`, and re-raises a custom `UserNotFoundError`. Ensure the original exception context is preserved for debugging. | fail→fail | 6,874 | 6,952 | +1% | 1 | 1 | 0% | 1,307 | 1,163 | -11% | 0 | 0 | — |
▸case-03 Write a Python 3.10+ function `parse_number(val)` that accepts either an integer or float, converts string representations if needed, and returns a float. Include full type annotations without importing from the typing module. | fail→fail | 6,266 | 6,761 | +8% | 1 | 1 | 0% | 1,126 | 1,153 | +2% | 0 | 0 | — |
▸case-04 Write a Python 3.9+ function `combine_configurations(defaults, overrides)` that merges two dictionary objects into a single new dictionary where values in overrides take precedence. | fail→fail | 5,800 | 4,546 | -22% | 1 | 1 | 0% | 940 | 872 | -7% | 0 | 0 | — |
▸case-05 Write a Python helper function `managed_resource()` that yields a resource handle, ensures cleanup happens upon exit, and avoids writing a full context manager class with __enter__ and __exit__ methods. | fail→fail | 5,725 | 6,499 | +14% | 1 | 1 | 0% | 1,144 | 1,363 | +19% | 0 | 0 | — |
▸case-06 Write a Python dataclass `UserProfile` with fields `username: str` and `tags: list[str]`. Ensure default initialization of `tags` creates a fresh list instance for every class instance rather than sharing a list reference. | fail→fail | 2,642 | 2,723 | +3% | 1 | 1 | 0% | 497 | 514 | +3% | 0 | 0 | — |
▸case-07 Write a Python function `serialize_payload(data)` that uses `json.dumps()` to convert a dictionary containing `datetime.datetime` objects into a valid JSON string without crashing. | fail→fail | 6,376 | 6,258 | -2% | 1 | 1 | 0% | 1,256 | 1,243 | -1% | 0 | 0 | — |
▸case-08 Write a Python function `flatten_matrix(matrix)` that takes a list of lists and returns a flat iterator without using nested list comprehensions or sum() concatenation. | fail→fail | 7,702 | 5,374 | -30% | 1 | 1 | 0% | 1,426 | 1,225 | -14% | 0 | 0 | — |
▸case-09 Write a Python function `compute_factorial(n)` that uses memoization to store previously computed factorials up to 128 items without manually instantiating a lookup dictionary. | fail→fail | 5,229 | 5,623 | +8% | 1 | 1 | 0% | 1,040 | 999 | -4% | 0 | 0 | — |
▸case-10 Write a Python function `filter_valid_emails(email_list)` that validates emails against standard pattern `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$`. Ensure regex pattern string is compiled once rather than inside the loop body. | fail→fail | 6,601 | 6,185 | -6% | 1 | 1 | 0% | 1,127 | 1,399 | +24% | 0 | 0 | — |
▸case-11 Write a Python function `get_log_filepath(directory, filename)` that combines a directory string and filename string into an absolute path, verifying path existence using modern standard library filesystem object methods. | fail→fail | 9,225 | 6,393 | -31% | 1 | 1 | 0% | 1,520 | 1,263 | -17% | 0 | 0 | — |
▸case-12 Write a Python function `sum_squares(n)` that calculates the sum of squares from 1 to n (up to 1,000,000) using minimal memory overhead without allocating an intermediate list in memory. | pass→pass | 9,055 | 6,978 | -23% | 1 | 1 | 0% | 1,402 | 1,243 | -11% | 0 | 0 | — |
▸case-13 Write a Python function `duplicate_nested_config(config_dict)` that returns a complete copy of a dictionary containing nested dictionaries, ensuring mutations to sub-dictionaries in the copy do not affect original dict. | fail→fail | 9,210 | 7,176 | -22% | 1 | 1 | 0% | 1,742 | 1,462 | -16% | 0 | 0 | — |
▸case-14 Write a Python function `insert_sorted_score(scores, new_score)` that maintains a sorted list of integer scores by inserting new_score into its correct sorted position in O(log N) time without sorting list after insertion. | fail→fail | 7,411 | 7,615 | +3% | 1 | 1 | 0% | 1,497 | 1,461 | -2% | 0 | 0 | — |
▸case-15 Write a Python 3.11+ string enumeration class `TaskStatus` with members `PENDING = 'pending'` and `DONE = 'done'` that directly inherit string comparison behavior without requiring manual .value access. | fail→fail | 4,191 | 5,054 | +21% | 1 | 1 | 0% | 792 | 699 | -12% | 0 | 0 | — |
▸case-16 Write a Python abstract base class `BaseRepository` defining a required `find_by_id(id)` method signature that forces derived classes to implement it or raise TypeError on instantiation. | fail→fail | 5,694 | 5,148 | -10% | 1 | 1 | 0% | 1,207 | 992 | -18% | 0 | 0 | — |
▸case-17 Write a Python function `get_top_frequent_words(text, top_n)` that tokenizes words and returns the top_n most frequent words with their counts using standard library collections module tools. | fail→fail | 5,736 | 6,886 | +20% | 1 | 1 | 0% | 1,188 | 1,403 | +18% | 0 | 0 | — |
▸case-18 Write a Python function `write_temporary_payload(data)` that safely creates a temporary named file on disk, writes text data to it, yields the file path, and automatically deletes file upon context manager exit. | pass→fail | 8,781 | 7,275 | -17% | 1 | 1 | 0% | 1,710 | 1,477 | -14% | 0 | 0 | — |
▸case-19 Write a Python function `has_negative_value(numbers)` that checks whether any float element in a list is strictly less than 0.0, short-circuiting on the first matching element without explicit for loops. | fail→fail | 13,525 | 8,007 | -41% | 1 | 1 | 0% | 2,448 | 1,512 | -38% | 0 | 0 | — |
▸case-20 Write a pytest test function `test_divide_by_zero()` that asserts `ZeroDivisionError` is raised when calling `divide(10, 0)`. | fail→fail | 3,033 | 2,332 | -23% | 1 | 1 | 0% | 565 | 376 | -33% | 0 | 0 | — |
▸case-21 Format a Sphinx reStructuredText docstring for a Python function taking parameter `timeout` (float) and returning boolean success indicator. | fail→fail | 3,983 | 4,383 | +10% | 1 | 1 | 0% | 607 | 486 | -20% | 0 | 0 | — |
▸case-22 Create a `pyproject.toml` configuration table block for mypy that enables strict mode and forces untyped def warnings across the repository. | fail→fail | 3,888 | 3,413 | -12% | 1 | 1 | 0% | 645 | 557 | -14% | 0 | 0 | — |