messages
listlengths
3
3
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Implement a method to check if a given string has all unique characters." }, { "role": "assistant", "content": "def has_unique_chars(string): \n chars = set() \n for char in string: \n...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Describe the action taken by the following code snippet and provide a sample output\ndef format_string(x): \n return \"The output is: {}\".format(x)" }, { "role": "assistant", "conten...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create an HTML element, a div with an ID of \"content\"." }, { "role": "assistant", "content": "<div id=\"content\"></div>" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a variable in Python and assign it the value 15." }, { "role": "assistant", "content": "num = 15" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Insert this HTML element at the appropriate place.\n<h1>Important Text</h1>" }, { "role": "assistant", "content": "<body>\n <p>Some other text here</p>\n <h1>Important Text</h1>\n<...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "What is the command line to create a tar archive in Linux?" }, { "role": "assistant", "content": "The command line to create a tar archive in Linux is \"tar -cvf <archive name>.tar <targ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a table in SQL to store the names and email addresses of users." }, { "role": "assistant", "content": "CREATE TABLE users ( \n name VARCHAR(255) NOT NULL,\n email VARCHAR(255) N...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write code to return a list of prime numbers in the given range.\nStart: 10. End: 15" }, { "role": "assistant", "content": "def get_prime_numbers(start, end):\n prime_numbers = []\n ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Compute the modulo of following two numbers\n56 % 7" }, { "role": "assistant", "content": "0" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a function in Python that takes two parameters, x and y, and prints out all numbers between x and y." }, { "role": "assistant", "content": "def display_numbers(x, y):\n for i in ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Generate a css code block to create a white text shadow for a given HTML element" }, { "role": "assistant", "content": ".element {\n text-shadow: 1px 0 white, 0 1px white, 1px 1px whi...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Count the number of occurrences of the letter “a” in a given string.\nstring = \"My favorite animal is a dog\"" }, { "role": "assistant", "content": "# 3" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Develop a program to determine if a given year is a leap year.\nyear = 2024" }, { "role": "assistant", "content": "# Determining if a year is a leap year\n\n# Assigning the current year\...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Modify the code below to create a new function called \"addSquares()\" that adds the squares of two numbers and returns the result.\ndef add(x, y):\n return x + y" }, { "role": "assistant"...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a HTML page with a textbox, button and a message “Hello World!”" }, { "role": "assistant", "content": "<html>\n <head></head>\n <body>\n <input type=\"text\" id=\"tex...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a code snippet to check if all characters in a given string are letters or numbers.\nstring = \"Welcome123\"" }, { "role": "assistant", "content": "function checkString(string) { \...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Given a numeric array and a length, find the longest increasing subsequence in the array.\nArray: [3, 4, 1, 5, 10, 9, 8, 11]\nLength: 8" }, { "role": "assistant", "content": "[3, 4, 5, 1...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Using conditional statements, print out whether a given number is odd or even.\nnumber = 7" }, { "role": "assistant", "content": "if(number % 2 == 0){\n console.log('`number` is even')\...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a program to calculate the standard deviation of an array of numbers.\narr = [10, 8, 12, 5, 9]" }, { "role": "assistant", "content": "def stdev(arr):\n n = len(arr)\n mean =...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Generate a list of 20 strings containing random characters of length 10." }, { "role": "assistant", "content": "['Kj9F7VAl1q', '28jVYbueph', 'f7VZRif5uP', '2jf5CHXyt7', '3qBtyKjDIY', 'hE...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a function that takes an array of integers and returns an array of the same length with each element multiplied by 2.\n[1, 2, 3]" }, { "role": "assistant", "content": "def multiply...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Scale a vector of 10 numbers from 0 to 10.\n[2.5, 3.5, 5.5, 7.5, 1.5, 8.5, 0.5, 4.5, 6.5, 9.5]" }, { "role": "assistant", "content": "def scale(vector): \n scaled_vector = []\n for...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a function to generate random numbers from 0-99." }, { "role": "assistant", "content": "import random\n\ndef random_number():\n return random.randint(0,99)" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a MySQL query to count the number of students enrolled in a course called \"Coding 101\"." }, { "role": "assistant", "content": "SELECT COUNT(*) FROM students WHERE course = 'Codin...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Define a function in JavaScript that returns true if a given number is even." }, { "role": "assistant", "content": "function isEven(num) {\n return num % 2 === 0;\n}" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "What is the definition of polymorphism in programming?" }, { "role": "assistant", "content": "Polymorphism in programming is a principle allowing the same code to be used for objects of ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a code to save the first ten prime numbers in an array." }, { "role": "assistant", "content": "# prime number sieve\ndef prime_numbers(n): \n \n prime = [True for i in range(n+...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Construct a JavaScript program to find all the prime numbers within a range of numbers\nrange = [2,10]" }, { "role": "assistant", "content": "function findPrimes(range) {\n let primes =...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a function to remove all whitespace characters from a given string.\nmyString = \"Hello World \"" }, { "role": "assistant", "content": "def remove_whitespaces(myString):\n ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Find the largest integer in this list?\n[1, 4, 9, 3, 5]" }, { "role": "assistant", "content": "largest_integer = max([1, 4, 9, 3, 5])\nprint(largest_integer) # Output: 9" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a program to apply upper case to a given string.\nString = \"welcome to The world Of gEEks\"" }, { "role": "assistant", "content": "def upperCaseString(str): \n res = \"\" \n ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a JavaScript function to check if a number is a whole number or has decimals." }, { "role": "assistant", "content": "const isWholeNumber = (num) => {\n if (num % 1 === 0) return t...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Implement a quick-sort algorithm in Python to sort a given array in ascending order." }, { "role": "assistant", "content": "def quick_sort(arr): \n if len(arr) <= 1:\n return a...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a new folder called 'data' within the current working directory." }, { "role": "assistant", "content": "import os\n\n# create 'data' folder in the current working directory\ncurre...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a Python program that compares two given lists to check if they have any common element.\nlist1 = [1,2,3]\nlist2 = [4,5,6]" }, { "role": "assistant", "content": "def compare_lists...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "What command should be added to the function to make sure the input list is sorted?\ndef remove_duplicates(list):\n # TODO: add command\n new_list = []\n for element in list:\n if el...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a function that checks if a give number is even or odd." }, { "role": "assistant", "content": "def is_even(n):\n if n%2 == 0:\n return True \n else:\n return F...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Using the list as an example, remove all elements from the list that have a value of 0.\nmy_list = [0, 5, 7, 0, 9]" }, { "role": "assistant", "content": "my_list = [5, 7, 9]\n \nmy_list ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write an SQL query to retrieve all rows in a table that match a certain criteria.\nTable: Users\n\n name | age \n------|------\n John | 20\n Pete | 22\n Alex | 18" }, { "role": "assistant", ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a Python program to check if a list contains a specific item.\ndata = [3, 4, 5, 6, 7]" }, { "role": "assistant", "content": "def contains_item(data, item):\n return item in data...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Explain the basic syntax for a for loop in JavaScript." }, { "role": "assistant", "content": "The basic syntax for a for loop in JavaScript is as follows: for (initialization; condition;...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Identify which language the following code snippet is written in.\n#include<bits/stdc++.h>\nusing namespace std;\n\nint main() \n{ \n cout << \"Hello, World\";\n return 0; \n}" }, { "r...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a SQL query to join two tables on a specified conditions.\nTable 1:\nid name age\n1 a 15\n2 b 18\n3 c 20\nTable 2:\nid class marks\n1 10 80\n2 10 75...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a function to check an array of strings and return a list of strings that have length of 5.\n[\"Ironman\", \"Spiderman\", \"Hulk\", \"Captain America\", \"Thor\"]" }, { "role": "assis...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "What is the best way to test for memory leaks in a C++ program?" }, { "role": "assistant", "content": "The best way to test for memory leaks in a C++ program is to use a memory profiler....
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a code to find out if a given number is prime in JavaScript.\nnumber = 29" }, { "role": "assistant", "content": "function isPrime(number) {\n\nfor (i=2; i <= Math.sqrt(number); i++...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Alter the following python code such that it prints \"Hello, world!\"\nfor x in range(1,10):\n print(x)" }, { "role": "assistant", "content": "for x in range(1,10):\n if x == 5:\n ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "What is the reason for the failure of a unit test?" }, { "role": "assistant", "content": "The reason for the failure of a unit test can be any number of things, including incorrect expec...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Given a sequence of numbers, write a program to find the length of the longest subsequence in which all numbers are in increasing order.\narr = [1, 7, 4, 3, 2, 8]" }, { "role": "assistant", ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a SQL query to find the average price for all products in the Products table.\nSELECT * FROM Products" }, { "role": "assistant", "content": "SELECT AVG(Price) FROM Products;" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write SQL code to select records from a table whose ID is greater than 200." }, { "role": "assistant", "content": "SELECT * \nFROM table \nWHERE ID > 200;" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "With given input string, create a program that returns a new string with the first character capitalized.\nhello world" }, { "role": "assistant", "content": "def capitalize(text):\n r...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a set containing the numbers from 1-10 that are divisible by 3." }, { "role": "assistant", "content": "my_set = {3, 6, 9}" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a Python program to group the values of a given list of elements based on the size of the elements." }, { "role": "assistant", "content": "\"\"\"\nWrite a Python program to group t...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a function to determine if a given number is prime and returns true or false." }, { "role": "assistant", "content": "def is_prime(num):\n if num <= 1: \n return False\n ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Construct a simple algorithm to check if a number is prime\n11" }, { "role": "assistant", "content": "def is_prime(n):\n # check if n is divisible by any number between 2 and n-1 \n ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Provide the output from executing the given program.\nmatrix = [\n [1, 2, 3], \n [4, 5, 6], \n [7, 8, 9]\n]\nfor row in matrix:\n print(row[1])" }, { "role": "assistant", "content"...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Find the index of the letter 'a' in the string 'abcde'.\nstring = \"abcde\"" }, { "role": "assistant", "content": "Index of 'a' in the given string is 0." } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write an algorithm that sorts the following list of integers in ascending order\n[15, 5, 8, 0, 42]" }, { "role": "assistant", "content": "def sort_list(lst):\n for i in range(len(lst)...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Compress the following string using a Huffman algorithm.\n\"aaaaaaaaabccddddee\"" }, { "role": "assistant", "content": "import heapq\n\ndef huffman_encode(string):\n freq = {}\n fo...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Generate a SQL command to update the salary by 5% for all the employees." }, { "role": "assistant", "content": "UPDATE employees SET salary = salary * 1.05;" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Identify the key differences between a set and a dictionary in Python." }, { "role": "assistant", "content": "The key difference between a set and a dictionary in Python is that a set st...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Using jQuery, write a snippet to add a click event handler to a given HTML element.\n#html element\n<div class=\"my-button\">Click Me!</div>" }, { "role": "assistant", "content": "$('.my...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Modify the code to make sure it is valid according to Java language specification.\npublic class HelloWorld {\n public static void main(String[] args) {\n System.out.println(\"Hello World!...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Given a string of text, write a python script to remove all non-alphanumeric characters." }, { "role": "assistant", "content": "def remove_non_alphanumeric_chars(input_string):\n return...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Recognize the type of error in the given code and provide which line of code is causing the error.\ndef divide(numerator, denominator):\n return numerator / denominator\n\nnumber = int(input(\"En...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Manually debug the following code to find any errors.\ndef foo(x):\n y = x**3\n z = y + 2\n return z" }, { "role": "assistant", "content": "No errors found in the given code." ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a fragment of HTML that displays a button which redirects the user to a given URL.\nURL = \"http://example.com\"" }, { "role": "assistant", "content": "<a href=\"http://example.co...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Implement a function to return the element that appears most frequently in a list.\n[5,5,5,5,6,6,7,7,7]" }, { "role": "assistant", "content": "def find_most_frequent_element(arr):\n d...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Derive the formula for calculating the circumference of a circle." }, { "role": "assistant", "content": "The formula for calculating the circumference of a circle is C = 2*π*r, where r i...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a SQL query which will select column names from a certain table." }, { "role": "assistant", "content": "SELECT column_name \nFROM table_name;" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Programmatically generate a random password of length 8 that contains at least one lowercase letter, one uppercase letter, one number, and one special character." }, { "role": "assistant", ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Generate a random string with the a capital letter followed by two lower case letters." }, { "role": "assistant", "content": "import string\nimport random\ndef random_string():\n\n capi...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a code in which the values in the dictionaries will be swapped.\ndic = {'x': 10, 'y': 20}" }, { "role": "assistant", "content": "def swap_dictionary_values(dic):\n \"\"\"Functio...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a function that adds two inputs of type integers and returns the sum.\na = 8\nb = 3" }, { "role": "assistant", "content": "def add(a, b):\n return a + b" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Change this code to print the reversed version of a string.\nstring s = \"Hello World!\";" }, { "role": "assistant", "content": "string s = \"Hello World!\"; \nreverse(s.begin(), s.end()...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a CSS code that demonstrates a nice hover effect for a button." }, { "role": "assistant", "content": ".button {\n background: #3498db;\n color: #fff;\n font-size: 1.2em;\n pad...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a Python function to convert a given string to lowercase.\nstring = \"FOO\"" }, { "role": "assistant", "content": "def to_lowercase(string):\n return string.lower()\n\nstring = ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "How can you sort a list of strings lexicographically in C++?" }, { "role": "assistant", "content": "We can use the sort() method from the algorithm library to sort a list of strings lexi...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Output the sum of digits in a number.\nn = 123" }, { "role": "assistant", "content": "6" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a Python program to compute the summation of a list of numbers.\nlist = [1, 2, 3, 4, 5]" }, { "role": "assistant", "content": "def compute_summation(list):\n result = 0\n for...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Summarize the given article using the Gensim summarizer.\n[Article about Gensim summarizer](https://gensim.readthedocs.io/en/latest/summarization.html)" }, { "role": "assistant", "conten...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Change the Python code to output the product of two numbers.\ndef multiply(a, b): \n return a + b" }, { "role": "assistant", "content": "def multiply(a, b): \n return a * b" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Given a list of numbers, write a program which partitions the list into two parts, such that the sum of the elements in the first part exceeds the sum of the elements in the second part." }, { ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Construct a while loop in the code to print the integers from 0 to 9." }, { "role": "assistant", "content": "i = 0\nwhile i < 10:\n print(i)\n i += 1" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "In JavaScript, write a function which can split a string into its constituent words." }, { "role": "assistant", "content": "function split_string_to_words(string) {\n return string.sp...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a Python dictionary which contains the student name and their grade for the course.\n{\n \"John\": 85, \n \"Alice\": 91,\n \"Bob\": 74\n}" }, { "role": "assistant", "content": "st...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a function that takes an array and returns true if it contains all the elements in an another array.\narray1 = [1, 2, 3, 4]\narray2 = [1, 2, 3]" }, { "role": "assistant", "content...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a query in MySQL to display the top 3 highest salaries." }, { "role": "assistant", "content": "SELECT salary\nFROM employees\nORDER BY salary DESC\nLIMIT 3" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Explain the purpose of the keyword ``this`` in Java." }, { "role": "assistant", "content": "In Java, the keyword \"this\" is used to refer to the current object. It can be used to access...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create a SQL query to find the average length of time for all purchases.\nTable structure: \nPurchase (Customer_ID, Purchase_Date, Purchase_Length)" }, { "role": "assistant", "content": ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Create an HTML page to display the output of a JavaScript greeting message.\nmessage: Welcome!" }, { "role": "assistant", "content": "<!DOCTYPE html>\n<html>\n<head>\n <title>JavaScript...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a PHP function for calculating the average of an array of numbers." }, { "role": "assistant", "content": "function calculateAverage($numbers) {\n $sum = array_sum($numbers);\n $n...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Given a list of numbers, sort them in increasing order.\nnums = [2, 3, 1, 4, 5]" }, { "role": "assistant", "content": "def sort_numbers(nums):\n return sorted(nums)" } ]
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write a predicate function to check whether the given string is palindrome." }, { "role": "assistant", "content": "function isPalindrome(str) {\n str = str.toLowerCase();\n for (let i ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Write an SQL query to display the first name and last name of all employees in the Employees table." }, { "role": "assistant", "content": "SELECT first_name, last_name\nFROM Employees;" ...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Calculate how many distinct values can be inserted in a binary tree containing 2 nodes." }, { "role": "assistant", "content": "2^2 - 1 = 3 distinct values can be inserted in a binary tre...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Find the Big O notation of the following code\ndef factorial(n):\n answer = 1\n for i in range(1, n+1):\n answer *= i\n return answer" }, { "role": "assistant", "content"...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Given an array of integers, write a function to determine whether the array is a palindrome.\narray = [1,2,3,2,1]" }, { "role": "assistant", "content": "def isPalindrome(array): \n re...
[ { "role": "system", "content": "You are a helpful AI assistant." }, { "role": "user", "content": "Program a function to add three integers and return the sum.\n2, 3 and 6" }, { "role": "assistant", "content": "def addThree(a, b, c):\n return a + b + c\n\nsum = addThree(2, 3, 6)" ...