-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitems.jsonl
More file actions
10 lines (10 loc) · 2.98 KB
/
Copy pathitems.jsonl
File metadata and controls
10 lines (10 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
{"input": {"signature": "def reverse_string(s: str) -> str:", "docstring": "Return the input string with its characters reversed."}, "expected_output": {"body": " return s[::-1]"}}
{"input": {"signature": "def is_palindrome(s: str) -> bool:", "docstring": "Return True if `s` reads the same forwards and backwards, ignoring case and spaces."}, "expected_output": {"body": " cleaned = ''.join(c.lower() for c in s if c.isalnum())\n return cleaned == cleaned[::-1]"}}
{"input": {"signature": "def fizzbuzz(n: int) -> list[str]:", "docstring": "Return the FizzBuzz sequence from 1 to n (inclusive). 'Fizz' for multiples of 3, 'Buzz' for multiples of 5, 'FizzBuzz' for both, str(i) otherwise."}, "expected_output": {"body": " out = []\n for i in range(1, n + 1):\n if i % 15 == 0: out.append('FizzBuzz')\n elif i % 3 == 0: out.append('Fizz')\n elif i % 5 == 0: out.append('Buzz')\n else: out.append(str(i))\n return out"}}
{"input": {"signature": "def safe_divide(a: float, b: float) -> float | None:", "docstring": "Return a / b. Return None when b is zero rather than raising."}, "expected_output": {"body": " if b == 0: return None\n return a / b"}}
{"input": {"signature": "def word_count(text: str) -> dict[str, int]:", "docstring": "Return a dict mapping each lowercase word in text to its count. Words are whitespace-separated, lowercased."}, "expected_output": {"body": " counts = {}\n for w in text.lower().split():\n counts[w] = counts.get(w, 0) + 1\n return counts"}}
{"input": {"signature": "def flatten(nested: list) -> list:", "docstring": "Flatten one level of nesting. flatten([[1,2],[3]]) == [1,2,3]."}, "expected_output": {"body": " return [item for sublist in nested for item in sublist]"}}
{"input": {"signature": "def chunked(items: list, size: int) -> list[list]:", "docstring": "Split items into chunks of at most `size` elements. chunked([1,2,3,4,5], 2) == [[1,2],[3,4],[5]]."}, "expected_output": {"body": " return [items[i:i+size] for i in range(0, len(items), size)]"}}
{"input": {"signature": "def fibonacci(n: int) -> int:", "docstring": "Return the n-th Fibonacci number (0-indexed). fibonacci(0) == 0, fibonacci(1) == 1."}, "expected_output": {"body": " a, b = 0, 1\n for _ in range(n):\n a, b = b, a + b\n return a"}}
{"input": {"signature": "def common_prefix(a: str, b: str) -> str:", "docstring": "Return the longest common prefix of a and b."}, "expected_output": {"body": " i = 0\n while i < len(a) and i < len(b) and a[i] == b[i]:\n i += 1\n return a[:i]"}}
{"input": {"signature": "def merge_sorted(a: list[int], b: list[int]) -> list[int]:", "docstring": "Merge two sorted ascending lists into a single sorted ascending list."}, "expected_output": {"body": " i = j = 0\n out = []\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n out.append(a[i]); i += 1\n else:\n out.append(b[j]); j += 1\n out.extend(a[i:])\n out.extend(b[j:])\n return out"}}