{"n": 1, "prompt": "Reverse a string in Python.", "answer": "```python\ndef reverse_string(s):\n    return s[::-1]\n\nprint(reverse_string(\"Hello World\"))\n```\n\nThis function takes a string as input and returns the reversed version of it.", "words": 22, "prose_words": 14, "code_first": true, "tok_s": 3.2}
{"n": 2, "prompt": "Flatten a nested list in Python.", "answer": "```python\ndef flatten(nested_list):\n    flat_list = []\n    for item in nested_list:\n        if isinstance(item, list):\n            flat_list.extend(flatten(item))\n        else:\n            flat_list.append(item)\n    return flat_list\n\nnested_list = [1, 2, [3, 4], [5, [6, 7]]]\nprint(flatten(nested_list))  # Output: [1, 2, 3, 4, 5, 6, 7]\n```\n\nIn this code, we define a function `flatten` that takes a nested list as input.", "words": 53, "prose_words": 15, "code_first": true, "tok_s": 110.2}
{"n": 3, "prompt": "Read a CSV file into a list of dictionaries in Python.", "answer": "```python\nimport csv\n\ndef read_csv_to_dict(file_path):\n    data = []\n    with open(file_path, mode='r') as file:\n        reader = csv.DictReader(file)\n        for row in reader:\n            data.append(row)\n    return data\n```\n\nYou can use this function like so:", "words": 31, "prose_words": 7, "code_first": true, "tok_s": 109.4}
{"n": 4, "prompt": "Check if a number is prime in Python.", "answer": "```python\ndef is_prime(n):\n    if n <= 1:\n        return False\n    elif n == 2:\n        return True\n    elif n % 2 == 0:\n        return False\n    else:\n        for i in range(3, int(n**0.5) + 1, 2):\n            if n % i == 0:\n                return False\n        return True\n\nprint(is_prime(7))  # Output: True\n```\n\nIn this function, we first check if the number is less than or equal to 1.", "words": 63, "prose_words": 16, "code_first": true, "tok_s": 108.2}
{"n": 5, "prompt": "Merge two sorted lists in Python.", "answer": "```python\ndef merge_sorted_lists(list1, list2):\n    merged_list = []\n    i = j = 0\n\n    while i < len(list1) and j < len(list2):\n        if list1[i] < list2[j]:\n            merged_list.append(list1[i])\n            i += 1\n        else:\n            merged_list.append(list2[j])\n            j += 1\n\n    # If there are remaining elements in either list, add them to the merged list\n    while i < len(list1):\n        merged_list.append(list1[i])\n        i += 1\n\n    while j < len(list2):\n        merged_list.append(list2[j])\n        j += 1\n\n    return merged_list\n\n# Test the function\nlist1 = [1, 3, 5, 7]\nlist2 = [2, 4, 6, 8]\nprint(merge_sorted_lists(list1, list2))  # Output: [1, 2, 3, 4, 5, 6, 7, 8]\n```\n\nIn this function, we initialize two pointers `i` and `j` to keep track of the current position in each list.", "words": 115, "prose_words": 20, "code_first": true, "tok_s": 109.5}
{"n": 6, "prompt": "Count word frequency in a string in Python.", "answer": "```python\ndef count_word_frequency(text):\n    words = text.split()\n    frequency = {}\n    \n    for word in words:\n        if word in frequency:\n            frequency[word] += 1\n        else:\n            frequency[word] = 1\n            \n    return frequency\n\ntext = \"Hello world! Hello everyone. This is a test.\"\nprint(count_word_frequency(text))\n```\n\nThis program will output:", "words": 42, "prose_words": 4, "code_first": true, "tok_s": 109.3}
{"n": 7, "prompt": "Remove duplicates from a list while keeping the order in Python.", "answer": "```python\ndef remove_duplicates(lst):\n    seen = set()\n    return [x for x in lst if not (x in seen or seen.add(x))]\n\n# Example usage:\nlst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3]\nprint(remove_duplicates(lst))\n```\n\nThis function works by iterating over the list and adding each element to a set.", "words": 54, "prose_words": 15, "code_first": true, "tok_s": 108.6}
{"n": 8, "prompt": "Write a Python decorator that times a function.", "answer": "```python\nimport time\n\ndef timer(func):\n    def wrapper(*args, **kwargs):\n        start_time = time.time()\n        result = func(*args, **kwargs)\n        end_time = time.time()\n        print(f\"{func.__name__} took {end_time - start_time:.4f} seconds to execute\")\n        return result\n    return wrapper\n\n@timer\ndef example_function():\n    # some code here\n    pass\n```\n\nIn this decorator, `wrapper` is the function that will be called instead of the original function.", "words": 55, "prose_words": 16, "code_first": true, "tok_s": 107.8}
{"n": 9, "prompt": "Read JSON from a file in Python.", "answer": "```python\nimport json\n\nwith open('filename.json', 'r') as f:\n    data = json.load(f)\n```\n\nIn this example, `filename.json` is the name of your JSON file.", "words": 23, "prose_words": 11, "code_first": true, "tok_s": 109.1}
{"n": 10, "prompt": "Sort a list of dictionaries by a key in Python.", "answer": "```python\n# Define the list of dictionaries\ndata = [\n    {'name': 'Alice', 'age': 25},\n    {'name': 'Bob', 'age': 30},\n    {'name': 'Charlie', 'age': 20}\n]\n\n# Sort by age in ascending order\nsorted_data = sorted(data, key=lambda x: x['age'])\n\nprint(sorted_data)\n```\n\nOutput:", "words": 39, "prose_words": 1, "code_first": true, "tok_s": 109.5}
{"n": 11, "prompt": "Write a Fibonacci generator in Python.", "answer": "```python\ndef fibonacci():\n    a, b = 0, 1\n    while True:\n        yield a\n        a, b = b, a + b\n\nfib_gen = fibonacci()\n\nfor i in range(10):\n    print(next(fib_gen))\n```\n\nIn this code, `fibonacci()` is a generator function that yields the Fibonacci sequence.", "words": 41, "prose_words": 13, "code_first": true, "tok_s": 108.9}
{"n": 12, "prompt": "Check if a string is a palindrome in Python.", "answer": "```python\ndef is_palindrome(s):\n    # Remove spaces and convert to lowercase\n    s = s.replace(\" \", \"\").lower()\n    \n    # Check if the string reads the same forwards and backwards\n    return s == s[::-1]\n\n# Test the function\nprint(is_palindrome(\"A man a plan a canal Panama\"))  # Output: True\n```\n\nIn this code, we first remove all spaces from the input string and convert it to lowercase.", "words": 62, "prose_words": 17, "code_first": true, "tok_s": 107.2}
{"n": 13, "prompt": "Write a debounce function in TypeScript.", "answer": "```typescript\nfunction debounce(func: () => void, wait: number) {\n  let timeout: NodeJS.Timeout | null = null;\n\n  return function(...args: any[]) {\n    const context = this;\n    clearTimeout(timeout);\n\n    timeout = setTimeout(() => func.apply(context, args), wait);\n  };\n}\n```\n\nYou can use it like this:", "words": 41, "prose_words": 6, "code_first": true, "tok_s": 106.6}
{"n": 14, "prompt": "Write a throttle function in JavaScript.", "answer": "```javascript\nfunction throttle(func, wait) {\n  let timeout;\n  return function(...args) {\n    const context = this;\n    clearTimeout(timeout);\n    timeout = setTimeout(() => func.apply(context, args), wait);\n  };\n}\n```\n\nYou can use it like this:", "words": 31, "prose_words": 6, "code_first": true, "tok_s": 108.3}
{"n": 15, "prompt": "Deep clone an object in JavaScript.", "answer": "```javascript\nfunction deepClone(obj) {\n  if (obj === null || typeof obj !== 'object') return obj;\n\n  let copy = Array.isArray(obj) ? [] : {};\n\n  for (let key in obj) {\n    if (obj.hasOwnProperty(key)) {\n      copy[key] = deepClone(obj[key]);\n    }\n  }\n\n  return copy;\n}\n```\n\nThis function will create a new object that is a deep clone of the original.", "words": 56, "prose_words": 15, "code_first": true, "tok_s": 107.1}
{"n": 16, "prompt": "Fetch JSON from a URL with error handling in JavaScript.", "answer": "```javascript\nfetch('https://api.example.com/data')\n  .then(response => {\n    if (!response.ok) {\n      throw new Error(`HTTP error! status: ${response.status}`);\n    }\n    return response.json();\n  })\n  .then(data => {\n    console.log(data);\n  })\n  .catch(error => {\n    console.error('There has been a problem with your fetch operation:', error);\n  });\n```\n\nIn this code, we first make the HTTP request to the specified URL.", "words": 51, "prose_words": 13, "code_first": true, "tok_s": 106.2}
{"n": 17, "prompt": "Group an array of objects by a key in TypeScript.", "answer": "```typescript\ninterface Person {\n  name: string;\n  age: number;\n}\n\nconst people: Person[] = [\n  { name: 'Alice', age: 25 },\n  { name: 'Bob', age: 30 },\n  { name: 'Charlie', age: 25 }\n];\n\nfunction groupBy<T, K extends keyof T>(arr: T[], key: K): {[key in K]: T[]} {\n  return arr.reduce((acc, item) => {\n    const keyValue = item[key];\n    if (!acc[keyValue]) {\n      acc[keyValue] = [];\n    }\n    acc[keyValue].push(item);\n    return acc;\n  }, {} as {[key in K]: T[]});\n}\n\nconst groupedPeople = groupBy(people, 'age');\nconsole.log(groupedPeople); // {25: [{name: 'Alice', age: 25}, {name: 'Charlie', age: 25}], 30: [{name: 'Bob', age: 30}]}\n```\n\nIn this example, we have an array of `Person` objects.", "words": 106, "prose_words": 10, "code_first": true, "tok_s": 106.6}
{"n": 18, "prompt": "Write a sleep function using promises in JavaScript.", "answer": "```javascript\nfunction sleep(ms) {\n  return new Promise(resolve => setTimeout(resolve, ms));\n}\n```\n\nYou can use this function like so: ```javascript\nsleep(1000).then(() => console.log('I waited for 1 second'));\n```\n\nThis will wait for 1 second before executing the `console.log` statement.", "words": 39, "prose_words": 18, "code_first": true, "tok_s": 106.6}
{"n": 19, "prompt": "Remove duplicates from an array in JavaScript.", "answer": "```javascript\nfunction removeDuplicates(arr) {\n  return arr.filter((value, index, self) => self.indexOf(value) === index);\n}\n\nconsole.log(removeDuplicates([1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2])); // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n```\n\nIn this function, we use the `filter` method to create a new array with only unique values.", "words": 54, "prose_words": 17, "code_first": true, "tok_s": 109.1}
{"n": 20, "prompt": "Format a date as YYYY-MM-DD in JavaScript.", "answer": "```javascript\nlet date = new Date();\nlet year = date.getFullYear();\nlet month = String(date.getMonth() + 1).padStart(2, '0');\nlet day = String(date.getDate()).padStart(2, '0');\n\nconsole.log(`${year}-${month}-${day}`);\n```\n\nThis code will output the current date in the format YYYY-MM-DD.", "words": 35, "prose_words": 11, "code_first": true, "tok_s": 107.6}
{"n": 21, "prompt": "Check if an object is empty in JavaScript.", "answer": "```javascript\nfunction isEmpty(obj) {\n  return Object.keys(obj).length === 0;\n}\n\nconsole.log(isEmpty({})); // true\nconsole.log(isEmpty({a:1})); // false\n```\n\nIn this function, `Object.keys(obj)` returns an array of all the keys in the object.", "words": 30, "prose_words": 14, "code_first": true, "tok_s": 107.0}
{"n": 22, "prompt": "Capitalize the first letter of each word in JavaScript.", "answer": "```javascript\nfunction capitalizeFirstLetter(str) {\n  return str.replace(/\\b\\w/g, function(letter) {\n    return letter.toUpperCase();\n  });\n}\n\nconsole.log(capitalizeFirstLetter(\"hello world\")); // Output: \"Hello World\"\n```\n\nIn this code, `replace` method is used to replace each word in the string with its first character capitalized.", "words": 38, "prose_words": 19, "code_first": true, "tok_s": 105.9}
{"n": 23, "prompt": "SQL query for the ten customers with the highest total spend.", "answer": "```sql\nSELECT c.customer_id, c.first_name, c.last_name, SUM(o.total_amount) as total_spend\nFROM customers c\nJOIN orders o ON c.customer_id = o.customer_id\nGROUP BY c.customer_id, c.first_name, c.last_name\nORDER BY total_spend DESC\nLIMIT 10;\n```\n\nThis query will return the ten customers with the highest total spend.", "words": 42, "prose_words": 12, "code_first": true, "tok_s": 107.7}
{"n": 24, "prompt": "SQL to delete duplicate rows and keep the lowest id.", "answer": "```sql\nDELETE FROM your_table_name\nWHERE id NOT IN (\n    SELECT MIN(id)\n    FROM your_table_name\n    GROUP BY column1, column2, ...\n);\n```\n\nReplace `your_table_name` with the name of your table and `column1, column2, ...` with the columns you want to group by.", "words": 40, "prose_words": 20, "code_first": true, "tok_s": 106.6}
{"n": 25, "prompt": "SQL query to count orders per month.", "answer": "```sql\nSELECT \n    DATE_TRUNC('month', order_date) AS month,\n    COUNT(*) AS order_count\nFROM \n    orders\nGROUP BY \n    month;\n```\n\nThis query will return the number of orders for each month in your database.", "words": 29, "prose_words": 14, "code_first": true, "tok_s": 108.5}
{"n": 26, "prompt": "SQL query to find the second highest salary.", "answer": "```sql\nSELECT DISTINCT salary \nFROM employees \nORDER BY salary DESC \nLIMIT 1 OFFSET 1;\n```\n\nThis query will return the second highest salary from the `employees` table.", "words": 27, "prose_words": 12, "code_first": true, "tok_s": 109.3}
{"n": 27, "prompt": "Bash one liner to rename all .txt files to .md.", "answer": "```bash\nfor f in *.txt; do mv \"$f\" \"${f%.txt}.md\"; done\n```\n\nThis script will iterate over all `.txt` files in the current directory and rename them by removing the `.txt` extension and replacing it with `.md`.", "words": 36, "prose_words": 25, "code_first": true, "tok_s": 107.7}
{"n": 28, "prompt": "Find files larger than 100 MB with a shell command.", "answer": "```bash\nfind . -type f -size +100M\n```\n\nThis command will search the current directory and all subdirectories for files larger than 100MB.", "words": 23, "prose_words": 15, "code_first": true, "tok_s": 107.2}
{"n": 29, "prompt": "Git command to undo the last commit but keep the changes.", "answer": "```bash\ngit reset HEAD~1 --soft\n```\n\nThis will move the HEAD pointer back by one commit, but it will not change the working directory or the index.", "words": 27, "prose_words": 21, "code_first": true, "tok_s": 107.1}
{"n": 30, "prompt": "Git command to delete all merged local branches.", "answer": "```bash\ngit branch -r --merged | xargs git branch -d\n```\n\nThis command will list all the remote branches that have been merged into your current branch and then delete them.", "words": 31, "prose_words": 20, "code_first": true, "tok_s": 106.7}
{"n": 31, "prompt": "Count the lines in all .js files with a shell command.", "answer": "```sh\nfind . -name \"*.js\" | xargs wc -l\n```\n\nThis command will find all `.js` files in the current directory and its subdirectories, and then count the number of lines in each file.", "words": 34, "prose_words": 24, "code_first": true, "tok_s": 105.8}
{"n": 32, "prompt": "Tail a log file and show only lines containing ERROR.", "answer": "```bash\ntail -f /path/to/logfile | grep \"ERROR\"\n```\n\nThis command will follow the log file (`/path/to/logfile`) and print new lines as they are added to it.", "words": 26, "prose_words": 18, "code_first": true, "tok_s": 105.6}
{"n": 33, "prompt": "Read a file line by line in Go.", "answer": "```go\npackage main\n\nimport (\n\t\"bufio\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tfile, err := os.Open(\"filename.txt\")\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\treturn\n\t}\n\tdefer file.Close()\n\n\tscanner := bufio.NewScanner(file)\n\n\tfor scanner.Scan() {\n\t\tline := scanner.Text()\n\t\tfmt.Println(line)\n\t}\n}\n```\n\nIn this code:", "words": 42, "prose_words": 3, "code_first": true, "tok_s": 106.6}
{"n": 34, "prompt": "Write a minimal HTTP server in Go that returns hello.", "answer": "```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n\tfmt.Fprintf(w, \"Hello\")\n}\n\nfunc main() {\n\thttp.HandleFunc(\"/\", handler)\n\tfmt.Println(\"Server is running on port 8080\")\n\tif err := http.ListenAndServe(\":8080\", nil); err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\nThis program listens for HTTP requests on port 8080.", "words": 50, "prose_words": 9, "code_first": true, "tok_s": 104.9}
{"n": 35, "prompt": "Rust struct with serde Serialize and Deserialize.", "answer": "```rust\nuse serde::{Serialize, Deserialize};\n\n#[derive(Serialize, Deserialize)]\nstruct MyStruct {\n    field1: String,\n    field2: i32,\n}\n```\n\nIn this example, `MyStruct` is a Rust struct that can be serialized to JSON using the `serde_json` crate.", "words": 33, "prose_words": 18, "code_first": true, "tok_s": 105.8}
{"n": 36, "prompt": "Read a file into a String in Rust.", "answer": "```rust\nuse std::fs::File;\nuse std::io::{self, BufReader};\n\nfn main() {\n    let filename = \"example.txt\";\n\n    // Open the file in read-only mode\n    let file = match File::open(filename) {\n        Err(e) => panic!(\"There was a problem opening the file: {}\", e),\n        Ok(file) => file,\n    };\n\n    // Create a buffered reader to read from the file\n    let reader = BufReader::new(file);\n\n    // Read the entire contents of the file into a String\n    let mut s = String::new();\n    match reader.read_to_string(&mut s) {\n        Err(e) => panic!(\"There was a problem reading the file: {}\", e),\n        Ok(_) => println!(\"File successfully read to string\"),\n    }\n\n    // Print the contents of the String\n    println!(\"{}\", s);\n}\n```\n\nIn this example, we first open the file in read-only mode.", "words": 116, "prose_words": 11, "code_first": true, "tok_s": 105.5}
{"n": 37, "prompt": "Binary search in Java.", "answer": "```java\npublic class BinarySearch {\n    public static void main(String[] args) {\n        int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};\n        int target = 7;\n        int result = binarySearch(array, target);\n\n        if (result == -1) {\n            System.out.println(\"Element not found\");\n        } else {\n            System.out.println(\"Element found at index \" + result);\n        }\n    }\n\n    public static int binarySearch(int[] array, int target) {\n        return binarySearchHelper(array, target, 0, array.length - 1);\n    }\n\n    private static int binarySearchHelper(int[] array, int target, int left, int right) {\n        if (left > right) {\n            return -1;\n        }\n        int mid = left + (right - left) / 2;\n\n        if (array[mid] == target) {\n            return mid;\n        } else if (array[mid] < target) {\n            return binarySearchHelper(array, target, mid + 1, right);\n        } else {\n            return binarySearchHelper(array, target, left, mid - 1);\n        }\n    }\n}\n```\n\nIn this program, we have a method `binarySearch` that takes an array and a target value as input.", "words": 152, "prose_words": 18, "code_first": true, "tok_s": 106.2}
{"n": 38, "prompt": "Singleton class in Java.", "answer": "```java\npublic class Singleton {\n    private static Singleton instance;\n\n    // Private constructor prevents instantiation from other classes\n    private Singleton() {}\n\n    public static Singleton getInstance() {\n        if (instance == null) {\n            instance = new Singleton();\n        }\n        return instance;\n    }\n\n    // Other methods and properties can be added here\n}\n```\n\nIn this example, the `Singleton` class has a private constructor to prevent instantiation from other classes.", "words": 65, "prose_words": 16, "code_first": true, "tok_s": 105.2}
{"n": 39, "prompt": "Convert a list of strings to uppercase with LINQ in C#.", "answer": "```csharp\nusing System;\nusing System.Collections.Generic;\nusing System.Linq;\n\nclass Program\n{\n    static void Main()\n    {\n        List<string> stringList = new List<string> { \"hello\", \"world\", \"LINQ\" };\n\n        var upperCaseList = stringList.Select(s => s.ToUpper());\n\n        foreach (var item in upperCaseList)\n        {\n            Console.WriteLine(item);\n        }\n    }\n}\n```\n\nIn this code, we first create a list of strings.", "words": 51, "prose_words": 10, "code_first": true, "tok_s": 105.7}
{"n": 40, "prompt": "Reverse a linked list in C.", "answer": "```c\n#include <stdio.h>\n#include <stdlib.h>\n\n// Define the structure for a node of the linked list\ntypedef struct Node {\n    int data;\n    struct Node* next;\n} Node;\n\n// Function to create a new node\nNode* newNode(int data) {\n    Node* temp = (Node*)malloc(sizeof(Node));\n    temp->data = data;\n    temp->next = NULL;\n    return temp;\n}\n\n// Function to reverse the linked list\nvoid reverseList(Node** head_ref) {\n    Node* prev = NULL;\n    Node* current = *head_ref;\n    Node* next;\n\n    while (current != NULL) {\n        next = current->next;  // Store next node\n        current->next = prev;   // Reverse current node's pointer\n        prev = current;         // Move pointers one position ahead\n        current = next;\n    }\n    *head_ref = prev;          // Change head to point to the new beginning of list\n}\n\n// Function to print the linked list\nvoid printList(Node* head) {\n    Node* temp = head;\n    while (temp != NULL) {\n        printf(\"%d \", temp->data);\n        temp = temp->next;\n    }\n    printf(\"\\n\");\n}\n\nint main() {\n    Node* head = newNode(1);\n    head->next = newNode(2);\n    head->next->next = newNode(3);\n    head->next->next->next = newNode(4);\n\n    printf(\"Original list: \");\n    printList(head);\n\n    reverseList(&head);\n\n    printf(\"Reversed list: \");\n    printList(head);\n\n    return 0;\n}\n```\n\nIn this program, we first define a structure for the nodes of the linked list.", "words": 193, "prose_words": 15, "code_first": true, "tok_s": 106.3}
{"n": 41, "prompt": "Regex that matches an email address.", "answer": "```python\nimport re\n\ndef is_valid_email(email):\n    pattern = r'^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+$'\n    if re.match(pattern, email):\n        return True\n    else:\n        return False\n```\n\nThis function uses a regular expression to check if the input string is a valid email address.", "words": 34, "prose_words": 17, "code_first": true, "tok_s": 105.8}
{"n": 42, "prompt": "Explain what this does: for i in range(0, len(a), 2): print(a[i])", "answer": "```python\nfor i in range(0, len(a), 2):\n    print(a[i])\n```\n\nThis code snippet iterates over the elements of list `a` starting from index 0 and incrementing by 2 each time.", "words": 29, "prose_words": 20, "code_first": true, "tok_s": 107.4}
{"n": 43, "prompt": "Fix: for i in range(10) print(i)", "answer": "```python\nfor i in range(10):\n    print(i)\n```\n\nThis will print numbers 0 through 9 on separate lines.", "words": 17, "prose_words": 10, "code_first": true, "tok_s": 108.3}
{"n": 44, "prompt": "Dockerfile for a Node.js app.", "answer": "```dockerfile\n# Use an official Node.js runtime as a parent image\nFROM node:14\n\n# Set the working directory in the container to /app\nWORKDIR /app\n\n# Copy the current directory contents into the container at /app\nCOPY . /app\n\n# Install any needed packages specified in package.json\nRUN npm install\n\n# Make port 3000 available to the world outside this container\nEXPOSE 3000\n\n# Run app.js when the container launches\nCMD [\"node\", \"app.js\"]\n```", "words": 74, "prose_words": 0, "code_first": true, "tok_s": 106.5}
{"n": 45, "prompt": "Write a pytest unit test for a function add(a, b).", "answer": "```python\nimport pytest\n\ndef add(a, b):\n    return a + b\n\n@pytest.mark.parametrize(\"a,b,expected\", [\n    (1, 2, 3),\n    (-1, -2, -3),\n    (0, 0, 0),\n    (5, 7, 12)\n])\ndef test_add(a, b, expected):\n    assert add(a, b) == expected\n```\n\nIn this test we are using the `pytest.mark.parametrize` decorator to provide multiple sets of arguments for our function.", "words": 53, "prose_words": 18, "code_first": true, "tok_s": 106.9}
{"n": 46, "prompt": "Make an async HTTP GET request in Python with aiohttp.", "answer": "```python\nimport aiohttp\n\nasync def fetch(session, url):\n    async with session.get(url) as response:\n        return await response.text()\n\nasync def main():\n    async with aiohttp.ClientSession() as session:\n        html = await fetch(session, 'https://example.com')\n        print(html)\n\n# Run the asyncio event loop\nimport asyncio\nloop = asyncio.get_event_loop()\nloop.run_until_complete(main())\n```\n\nIn this code:", "words": 45, "prose_words": 3, "code_first": true, "tok_s": 105.3}
{"n": 47, "prompt": "Convert a callback based function to a promise in JavaScript.", "answer": "```javascript\nfunction fetchData(callback) {\n  setTimeout(() => {\n    const data = { name: 'John', age: 30 };\n    callback(data);\n  }, 1000);\n}\n\nfetchData((data) => {\n  console.log(data); // Output: { name: 'John', age: 30 }\n});\n```\n\nIn this example, `fetchData` is a callback based function that takes a callback as an argument.", "words": 50, "prose_words": 16, "code_first": true, "tok_s": 105.7}
{"n": 48, "prompt": "TypeScript interface for a user with id, name and optional email.", "answer": "```typescript\ninterface User {\n  id: number;\n  name: string;\n  email?: string; // Optional property\n}\n```\n\nIn this interface, `id` is required and of type `number`, `name` is also required and of type `string`.", "words": 33, "prose_words": 18, "code_first": true, "tok_s": 107.1}
{"n": 49, "prompt": "CSS to center a div horizontally and vertically.", "answer": "```css\ndiv {\n  position: absolute;\n  top: 50%;\n  left: 50%;\n  transform: translate(-50%, -50%);\n}\n```\n\nThis will center the div both horizontally and vertically within its parent container.", "words": 27, "prose_words": 13, "code_first": true, "tok_s": 106.9}
{"n": 50, "prompt": "HTML form with an email field and a submit button.", "answer": "```html\n<form action=\"/submit_form\" method=\"post\">\n  <label for=\"email\">Email:</label><br>\n  <input type=\"email\" id=\"email\" name=\"email\"><br>\n  <input type=\"submit\" value=\"Submit\">\n</form>\n```\n\nIn this example, the form's `action` attribute specifies where to send the data when the user submits the form.", "words": 34, "prose_words": 19, "code_first": true, "tok_s": 105.7}
