CoolFace
Modelpublic

Fox-AI-by-teolm30/Ult1-coding

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
1likes76downloads
training_data.json42 linesDownload Raw Back to root
1[
2  {
3    "instruction": "Write a Python function to check if a string is a palindrome ignoring case and non-alphanumeric characters.",
4    "response": "def is_palindrome(s: str) -> bool:\n    cleaned = ''.join(c.lower() for c in s if c.isalnum())\n    return cleaned == cleaned[::-1]"
5  },
6  {
7    "instruction": "Write a JavaScript function to debounce a function call.",
8    "response": "function debounce(fn, delay = 300) {\n  let timer;\n  return (...args) => {\n    clearTimeout(timer);\n    timer = setTimeout(() => fn(...args), delay);\n  };\n}"
9  },
10  {
11    "instruction": "Write a Rust function that reads a file and returns lines as Vec<String>.",
12    "response": "use std::fs::File;\nuse std::io::{BufRead, BufReader};\n\nfn read_lines(path: &str) -> Result<Vec<String>, std::io::Error> {\n    let file = File::open(path)?;\n    let reader = BufReader::new(file);\n    reader.lines().collect()\n}"
13  },
14  {
15    "instruction": "Write a SQL query to find employees who earn more than their department's average.",
16    "response": "SELECT e.name, e.salary, d.name AS department\nFROM employees e\nJOIN departments d ON e.department_id = d.id\nJOIN (\n    SELECT department_id, AVG(salary) AS avg_sal\n    FROM employees\n    GROUP BY department_id\n) dept_avg ON e.department_id = dept_avg.department_id\nWHERE e.salary > dept_avg.avg_sal;"
17  },
18  {
19    "instruction": "Explain the CAP theorem and give examples of CP vs AP databases.",
20    "response": "CAP Theorem: A distributed system can guarantee 2 of 3: Consistency, Availability, Partition Tolerance. Partitions are inevitable, so you choose CP or AP. CP databases: HBase, MongoDB, Redis cluster. AP databases: Cassandra, DynamoDB, CouchDB."
21  },
22  {
23    "instruction": "Write a Python async function that fetches multiple URLs concurrently.",
24    "response": "import asyncio\nimport aiohttp\n\nasync def fetch_urls(urls, timeout=10.0):\n    async with aiohttp.ClientSession() as session:\n        async def fetch_one(url):\n            async with session.get(url, timeout=aiohttp.ClientTimeout(total=timeout)) as resp:\n                return await resp.text()\n        tasks = [fetch_one(url) for url in urls]\n        return await asyncio.gather(*tasks, return_exceptions=True)"
25  },
26  {
27    "instruction": "Implement an LRU cache in Python with O(1) get and put.",
28    "response": "from collections import OrderedDict\n\nclass LRUCache:\n    def __init__(self, capacity: int):\n        self.cache = OrderedDict()\n        self.capacity = capacity\n\n    def get(self, key: int) -> int:\n        if key not in self.cache:\n            return -1\n        self.cache.move_to_end(key)\n        return self.cache[key]\n\n    def put(self, key: int, value: int) -> None:\n        if key in self.cache:\n            self.cache.move_to_end(key)\n        self.cache[key] = value\n        if len(self.cache) > self.capacity:\n            self.cache.popitem(last=False)"
29  },
30  {
31    "instruction": "Write a TypeScript type for a Redux reducer with discriminated union actions.",
32    "response": "type Action =\n  | { type: 'INCREMENT'; payload: number }\n  | { type: 'DECREMENT'; payload: number }\n  | { type: 'RESET' };\n\ninterface State { count: number; }\n\nfunction reducer(state: State, action: Action): State {\n  switch (action.type) {\n    case 'INCREMENT': return { count: state.count + action.payload };\n    case 'DECREMENT': return { count: state.count - action.payload };\n    case 'RESET': return { count: 0 };\n    default: return state;\n  }\n}"
33  },
34  {
35    "instruction": "Write a Go function to reverse a linked list.",
36    "response": "type ListNode struct {\n    Val  int\n    Next *ListNode\n}\n\nfunc reverseList(head *ListNode) *ListNode {\n    var prev *ListNode\n    curr := head\n    for curr != nil {\n        next := curr.Next\n        curr.Next = prev\n        prev = curr\n        curr = next\n    }\n    return prev\n}"
37  },
38  {
39    "instruction": "What is the difference between inner join, left join, and full outer join?",
40    "response": "INNER JOIN: Only matching rows from both tables. LEFT JOIN: All rows from left table, NULLs for non-matches on right. FULL OUTER JOIN: All rows from both tables, NULLs where no match exists on either side."
41  }
42]