File size: 10,962 Bytes
de4ccc7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | {"id": "bug_easy_01", "category": "easy_bug", "language": "python", "prompt": "Find and fix the bug:\n\n```python\ndef average(nums):\n return sum(nums) / len(nums)\n\nprint(average([]))\n```"}
{"id": "bug_easy_02", "category": "easy_bug", "language": "python", "prompt": "Why does this function behave incorrectly?\n\n```python\ndef append_item(item, lst=[]):\n lst.append(item)\n return lst\n\nprint(append_item(1))\nprint(append_item(2))\n```"}
{"id": "bug_easy_03", "category": "easy_bug", "language": "javascript", "prompt": "Find the bug in this JavaScript code:\n\n```js\nfor (var i = 0; i < 3; i++) {\n setTimeout(() => console.log(i), 100);\n}\n```"}
{"id": "bug_easy_04", "category": "easy_bug", "language": "python", "prompt": "This function sometimes returns the wrong result. Why?\n\n```python\ndef is_even(n):\n return n % 2\n```"}
{"id": "bug_easy_05", "category": "easy_bug", "language": "python", "prompt": "Identify the problem in this code:\n\n```python\ndef sum_list(lst):\n total = 0\n for i in range(1, len(lst)):\n total += lst[i]\n return total\n```"}
{"id": "bug_tricky_01", "category": "tricky_bug", "language": "python", "prompt": "This code uses caching but can fail in concurrent environments. Why?\n\n```python\ncache = {}\n\ndef fib(n):\n if n in cache:\n return cache[n]\n if n <= 1:\n return n\n cache[n] = fib(n-1) + fib(n-2)\n return cache[n]\n```"}
{"id": "bug_tricky_02", "category": "tricky_bug", "language": "python", "prompt": "Why can this code produce inconsistent results?\n\n```python\nfrom threading import Thread\ncounter = 0\n\ndef inc():\n global counter\n for _ in range(100000):\n counter += 1\n\nthreads = [Thread(target=inc) for _ in range(2)]\nfor t in threads: t.start()\nfor t in threads: t.join()\nprint(counter)\n```"}
{"id": "bug_tricky_03", "category": "tricky_bug", "language": "python", "prompt": "There is a subtle logic bug here. What is it?\n\n```python\ndef normalize(values):\n total = sum(values)\n return [v / total for v in values if total]\n```"}
{"id": "bug_tricky_04", "category": "tricky_bug", "language": "c", "prompt": "Find the bug:\n\n```c\nint sum(int *arr, int n) {\n int total;\n for (int i = 0; i < n; i++) {\n total += arr[i];\n }\n return total;\n}\n```"}
{"id": "bug_tricky_05", "category": "tricky_bug", "language": "python", "prompt": "Why is this async code broken?\n\n```python\nimport asyncio\n\nasync def work():\n asyncio.sleep(1)\n print(\"done\")\n\nasyncio.run(work())\n```"}
{"id": "script_medium_01", "category": "medium_script", "language": "python", "prompt": "Write a Python script that reads a CSV file, groups rows by a column name, and computes the median of another column."}
{"id": "script_medium_02", "category": "medium_script", "language": "python", "prompt": "Write a Python script that scans a directory recursively and prints the 5 largest files with their sizes."}
{"id": "script_medium_03", "category": "medium_script", "language": "python", "prompt": "Write a Python script that parses a log file and counts how many ERROR, WARNING, and INFO lines it contains."}
{"id": "script_medium_04", "category": "medium_script", "language": "python", "prompt": "Write a Python CLI tool that accepts a JSON file path and prints all keys that appear more than once at any nesting level."}
{"id": "script_medium_05", "category": "medium_script", "language": "python", "prompt": "Write a Python script that fetches data from a public HTTP API and caches responses locally to avoid repeated requests."}
{"id": "script_medium_06", "category": "medium_script", "language": "javascript", "prompt": "Write a Node.js script that reads a JSON file, filters objects by a field value, and writes the result to a new file."}
{"id": "script_medium_07", "category": "medium_script", "language": "javascript", "prompt": "Write a JavaScript function that debounces another function with a configurable delay."}
{"id": "script_medium_08", "category": "medium_script", "language": "sql", "prompt": "Write an SQL query that returns the top 3 users by total purchase amount per month from a purchases table."}
{"id": "script_medium_09", "category": "medium_script", "language": "bash", "prompt": "Write a Bash script that finds all files modified in the last 24 hours and archives them into a tar.gz file."}
{"id": "script_medium_10", "category": "medium_script", "language": "python", "prompt": "Write a Python script that validates a configuration dictionary against a required schema and reports missing or invalid fields."}
{"id": "algo_hard_01", "category": "hard_algorithm", "language": "python", "prompt": "Implement a function that finds the maximum sum subarray with a maximum length k.\n\nInput: array of integers, integer k.\nOutput: maximum possible sum."}
{"id": "algo_hard_02", "category": "hard_algorithm", "language": "python", "prompt": "Implement a function that detects whether a directed graph contains a cycle.\n\nThe graph is given as an adjacency list."}
{"id": "algo_hard_03", "category": "hard_algorithm", "language": "python", "prompt": "Given a list of intervals, merge all overlapping intervals and return the result."}
{"id": "algo_hard_04", "category": "hard_algorithm", "language": "python", "prompt": "Implement an LRU cache with get and put operations in O(1) time."}
{"id": "algo_hard_05", "category": "hard_algorithm", "language": "python", "prompt": "Write a function that finds the lowest common ancestor (LCA) of two nodes in a binary tree."}
{"id": "algo_hard_06", "category": "hard_algorithm", "language": "python", "prompt": "Implement Dijkstra’s algorithm for shortest paths from a source node in a weighted graph."}
{"id": "algo_hard_07", "category": "hard_algorithm", "language": "python", "prompt": "Given a string, find the length of the longest substring without repeating characters."}
{"id": "algo_hard_08", "category": "hard_algorithm", "language": "cpp", "prompt": "Implement a function that reverses a singly linked list iteratively and recursively."}
{"id": "algo_hard_09", "category": "hard_algorithm", "language": "python", "prompt": "Given a matrix, rotate it 90 degrees clockwise in place."}
{"id": "algo_hard_10", "category": "hard_algorithm", "language": "python", "prompt": "Implement a function that computes edit distance (Levenshtein distance) between two strings."}
{"id": "arch_review_01", "category": "architecture_review", "language": "python", "prompt": "Review this function and suggest how to improve its readability and maintainability:\n\n```python\ndef process(data):\n res = []\n for i in data:\n if i[\"type\"] == \"A\":\n if i[\"value\"] > 10:\n res.append(i)\n else:\n if i[\"value\"] < 5:\n res.append(i)\n return res\n```"}
{"id": "arch_review_02", "category": "architecture_review", "language": "python", "prompt": "This function works but is hard to test. Why, and how would you refactor it?\n\n```python\ndef send_report():\n import requests\n data = load_data_from_db()\n requests.post(\"https://api.example.com/report\", json=data)\n```"}
{"id": "arch_review_03", "category": "architecture_review", "language": "javascript", "prompt": "What are the design problems in this code, and how would you improve it?\n\n```js\nfunction handle(req) {\n if (req.type === 'A') {\n if (req.flag) {\n doA1();\n } else {\n doA2();\n }\n } else if (req.type === 'B') {\n doB();\n } else {\n doDefault();\n }\n}\n```"}
{"id": "arch_review_04", "category": "architecture_review", "language": "python", "prompt": "Refactor this code to make error handling explicit and easier to follow:\n\n```python\ndef load_config(path):\n try:\n with open(path) as f:\n return json.load(f)\n except:\n return {}\n```"}
{"id": "arch_review_05", "category": "architecture_review", "language": "python", "prompt": "This function mixes concerns. Identify them and suggest a cleaner structure:\n\n```python\ndef process_order(order):\n if order['paid']:\n save_to_db(order)\n send_email(order['email'])\n print('done')\n```"}
{"id": "arch_reasoning_06", "category": "design_reasoning", "language": "any", "prompt": "You need to design a small service that processes background jobs. What components would you separate and why?"}
{"id": "arch_reasoning_07", "category": "design_reasoning", "language": "any", "prompt": "Given a growing codebase, how would you decide when to refactor versus when to leave code as-is?"}
{"id": "arch_reasoning_08", "category": "design_reasoning", "language": "any", "prompt": "What trade-offs do you consider when choosing between synchronous and asynchronous code?"}
{"id": "arch_reasoning_09", "category": "design_reasoning", "language": "any", "prompt": "How would you approach making a legacy system more testable without rewriting it?"}
{"id": "arch_reasoning_10", "category": "design_reasoning", "language": "any", "prompt": "Describe a situation where adding abstraction makes code worse instead of better."}
{"id": "eng_edge_01", "category": "engineering_judgment", "language": "any", "prompt": "You are asked to optimize a piece of code that runs once a day and takes 2 seconds. Would you do it? Why or why not?"}
{"id": "eng_edge_02", "category": "engineering_judgment", "language": "any", "prompt": "A bug appears once a month in production and cannot be reproduced locally. How would you approach debugging it?"}
{"id": "eng_edge_03", "category": "engineering_judgment", "language": "any", "prompt": "When is it acceptable to leave technical debt in a codebase?"}
{"id": "eng_edge_04", "category": "engineering_judgment", "language": "any", "prompt": "You can fix a bug quickly with a hack or properly with a refactor that takes longer. How do you decide?"}
{"id": "eng_edge_05", "category": "engineering_judgment", "language": "any", "prompt": "Describe a situation where adding tests could slow development instead of helping it."}
{"id": "edge_case_06", "category": "edge_cases", "language": "python", "prompt": "What edge cases should be considered when writing a function that parses user-provided dates?"}
{"id": "edge_case_07", "category": "edge_cases", "language": "sql", "prompt": "What edge cases can cause incorrect results in SQL queries that use GROUP BY and aggregation?"}
{"id": "edge_case_08", "category": "edge_cases", "language": "javascript", "prompt": "What edge cases should be handled when working with floating point numbers in JavaScript?"}
{"id": "edge_case_09", "category": "edge_cases", "language": "bash", "prompt": "What common edge cases break Bash scripts when handling file names?"}
{"id": "edge_case_10", "category": "edge_cases", "language": "any", "prompt": "Give an example of a bug caused by incorrect assumptions about input data."}
|