dataset
stringclasses
12 values
id
stringlengths
5
50
messages
listlengths
1
138
code_alpaca
code_alpaca_100
[ { "role": "user", "content": "Design an algorithm that takes a list of strings and returns the longest string.\n\nlist = [\"cat\", \"dog\", \"lion\", \"bird\"]\n\n" }, { "role": "assistant", "content": "def find_longest(list):\n \"\"\"Return the longest string from a list of strings.\"\"\" \n...
code_alpaca
code_alpaca_101
[ { "role": "user", "content": "Task: Write a function that takes in a matrix of numbers and reverses the order of the rows and columns.\n\nmatrix = [[1, 2, 3], \n [4, 5, 6], \n [7, 8, 9]\n ]\n\nAnswer:" }, { "role": "assistant", "content": "def reverse_matrix(matrix):\n ...
code_alpaca
code_alpaca_102
[ { "role": "user", "content": "Instruction: Design an algorithm that creates a random password of 8 characters.\nOutput:" }, { "role": "assistant", "content": "def generate_password():\n \"\"\"Generate a random password of 8 characters.\"\"\"\n import random\n chars = 'ABCDEFGHIJKLMNOPQR...
code_alpaca
code_alpaca_103
[ { "role": "user", "content": "FOr a given list, create a program that prints out the standard deviation of the elements in the list.\nlist = [1, 4, 9, 16]\n\nResponse:" }, { "role": "assistant", "content": "def std_dev(list):\n \"\"\"Print the standard deviation of elements in a given list.\"...
code_alpaca
code_alpaca_104
[ { "role": "user", "content": "Create a program that can filter out words of a string that contain a specific character.\nstring = \"This is a sentence\"\ncharacter = 's'\n\n" }, { "role": "assistant", "content": "def filter_string(string, character):\n \"\"\"Filter out words of a string that ...
code_alpaca
code_alpaca_105
[ { "role": "user", "content": "Task: Create a program that can calculate the distance between two points in three-dimensional space.\nInput: point1 = (1, 5, 9)\npoint2 = (4, 2, 8)\nOutput:" }, { "role": "assistant", "content": "def dist_points_3d(point1, point2):\n \"\"\"Calculate the distance...
code_alpaca
code_alpaca_106
[ { "role": "user", "content": "Create a program that ciphers a given text using the caesar cipher.\n\ntext = \"This is a secret message\"\nkey = 3\n\n" }, { "role": "assistant", "content": "def caesar_cipher(text, key):\n \"\"\"Cipher a given text using the Caesar Cipher.\"\"\"\n ciphertext...
code_alpaca
code_alpaca_107
[ { "role": "user", "content": "Find the second smallest element in an integer array of size n.\n\nInput: array = [4, 5, 8, 2, 9, 13]\n\nOutput:" }, { "role": "assistant", "content": "def second_smallest(array):\n\nsmallest = min(array)\nsecond_smallest = float('inf')\n\nfor num in array:\n if ...
code_alpaca
code_alpaca_108
[ { "role": "user", "content": "Write a SQL query to find all the users in a database with age greater than 25.\nResponse:" }, { "role": "assistant", "content": "SELECT * FROM users WHERE age > 25" } ]
code_alpaca
code_alpaca_109
[ { "role": "user", "content": "Write a response that appropriately completes the request.\n\n### Instruction:\nCreate a function to calculate the maximum of two numbers.\n\n### Response:" }, { "role": "assistant", "content": "def max_of_two(x, y):\n if x > y:\n return x\n else:\n ...
code_alpaca
code_alpaca_110
[ { "role": "user", "content": "Instruction:Write a Python program to split a string on a given character separator.\n\nInput: mystring = \"Hello, World!\"\nseparator = \",\"\n\n" }, { "role": "assistant", "content": "def split(mystring, separator):\n return mystring.split(separator)" } ]
code_alpaca
code_alpaca_111
[ { "role": "user", "content": "Write a Python program to get the day of week from a given date and time.\nfrom datetime import datetime\ndate = datetime(2020, 4, 20, 19, 15, 0)\n\n" }, { "role": "assistant", "content": "from datetime import datetime\n\ndef get_day_of_week(date):\n return date....
code_alpaca
code_alpaca_112
[ { "role": "user", "content": "Write a Javascript function to determine if the given number is an even number or not.\n\nAnswer:" }, { "role": "assistant", "content": "function isEven(num) {\nreturn num % 2 === 0;\n}" } ]
code_alpaca
code_alpaca_113
[ { "role": "user", "content": "Write a Python program to print out an ASCII art of a given word.\n\nword = \"happy\"\n\n" }, { "role": "assistant", "content": "def draw_word(word):\n art = \"\"\"\n __\n _ / \\\\\n \\\\_/\\_/\\_/\n / |\n ...
code_alpaca
code_alpaca_114
[ { "role": "user", "content": "Write a response that appropriately completes the request.\n\n### Instruction:\nWrite a JavaScript function to validate a given URL.\n\n### Response:" }, { "role": "assistant", "content": "function isValidURL(url) {\n const regex = /^(?:http(s)?:\\/\\/)?[\\w.-]+(...
code_alpaca
code_alpaca_115
[ { "role": "user", "content": "Tell me how would you respond to the following request.\nWrite a C# program to find the maximum and minimum of three numbers.\n" }, { "role": "assistant", "content": "public void Maximum_Minimum(int num1, int num2, int num3)\n{\n int max = Math.Max(Math.Max(num1,...
code_alpaca
code_alpaca_116
[ { "role": "user", "content": "Write a Java program to reverse a given string.\n" }, { "role": "assistant", "content": "public class ReverseString\n{ \n\n public static void main(String[] args) \n { \n String input = \"Hello\"; \n StringBuilder input1 = new StringBuilder(); \n...
code_alpaca
code_alpaca_117
[ { "role": "user", "content": "Task: Write an HTML template to display a greeting message. The message should include the name of the user who visits the website.\nInput: username = \"John\"\nOutput:" }, { "role": "assistant", "content": "<html>\n\t<head>\n\t\t<title>Greeting Message</title>\n\t<...
code_alpaca
code_alpaca_118
[ { "role": "user", "content": "Task: Write a Python program to concatenate all elements in a list into a string separated by a given separator.\nInput: input_list = [\"Python\", \"is\", \"a\", \"programming\", \"language\"]\nseparator = \"-\"\nOutput:" }, { "role": "assistant", "content": "def li...
code_alpaca
code_alpaca_119
[ { "role": "user", "content": "Write a C program to find the sum of all digits of a given number\n\n" }, { "role": "assistant", "content": "#include <stdio.h>\n\nint getSumOfDigits(int num) {\n // Initialize sum\n int sum = 0;\n\n // Find the sum of digits\n while(num > 0) {\n ...
code_alpaca
code_alpaca_120
[ { "role": "user", "content": "Can you help with this?\n\nWrite a Java program to generate random numbers\n" }, { "role": "assistant", "content": "import java.util.Random; \n \npublic class GenerateRandom { \n \n public static void main(String[] args) \n { \n \n Random rand = new ...
code_alpaca
code_alpaca_121
[ { "role": "user", "content": "Rewrite the following Python code using a for-loop.\ni = 0\nwhile i <= 10:\n print(i)\n i += 1\n\nResponse:" }, { "role": "assistant", "content": "for i in range(11):\n print(i)" } ]
code_alpaca
code_alpaca_122
[ { "role": "user", "content": "Can you help with this?\n\nWrite a code to print the current date and time in ISO format.\n" }, { "role": "assistant", "content": "from datetime import datetime\n\ndate_time_obj = datetime.now()\n\nprint(date_time_obj.isoformat()) # prints \"2020-07-29T15:10:01.5841...
code_alpaca
code_alpaca_123
[ { "role": "user", "content": "Create a new folder called 'data' within the current working directory.\n\nAnswer:" }, { "role": "assistant", "content": "import os\n\n# create 'data' folder in the current working directory\ncurrent_directory = os.getcwd()\nnew_directory = os.path.join(current_dire...
code_alpaca
code_alpaca_124
[ { "role": "user", "content": "Write a code to sort the following array in increasing order.\n\n[10, 2, 7, 8, 32, 4]\n\n" }, { "role": "assistant", "content": "# sorting array using insertion sort\narr = [10, 2, 7, 8, 32, 4] \n\n# traverse through all array elements \nfor i in range(1, len(arr)):...
code_alpaca
code_alpaca_125
[ { "role": "user", "content": "Create a function in JavaScript that takes an array of integers and returns the largest number." }, { "role": "assistant", "content": "\nfunction findMax(arr) {\n let max = arr[0];\n for (let i = 1; i < arr.length; i++) {\n if (arr[i] > max) {\n ...
code_alpaca
code_alpaca_126
[ { "role": "user", "content": "Create a regular expression to validate a URL string.\n\n" }, { "role": "assistant", "content": "# Regular expression to validate a URL string\n^(http:\\/\\/|https:\\/\\/|ftp:\\/\\/)?(www\\.)?([a-zA-Z0-9]+(-?[a-zA-Z0-9])*\\.)+[\\w]{2,5}(\\/\\S*)?$" } ]
code_alpaca
code_alpaca_127
[ { "role": "user", "content": "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\nWrite a Python code to calculate the mean of a given array.\n\n### Input:\n[1,2,3,4]\n\n### Respons...
code_alpaca
code_alpaca_128
[ { "role": "user", "content": "Tell me how would you respond to the following request.\nCreate a function in Java that takes a string and prints the reversed version.\n" }, { "role": "assistant", "content": "public static void reverseString(String str) { \n StringBuilder sb = new StringBuilder...
code_alpaca
code_alpaca_129
[ { "role": "user", "content": "Write a code to get the time difference between two date-time objects.\n\nNow complete the following instance -\nInput: date1: 2019-05-11 21:00:00\ndate2: 2019-05-13 10:00:00\nOutput:" }, { "role": "assistant", "content": "from datetime import datetime\n\ndef time_d...
code_alpaca
code_alpaca_130
[ { "role": "user", "content": "Write a code to connect to a remote database.\nusername: john\npassword: john123\nIP: 100.10.0.10\n" }, { "role": "assistant", "content": "import psycopg2\n\nconn = psycopg2.connect(host=\"100.10.0.10\", database=\"mydb\", user=\"john\", password=\"john123\")" } ]
code_alpaca
code_alpaca_131
[ { "role": "user", "content": "Create an HTML form with a textbox, a submit button, and two radio buttons.\n\n" }, { "role": "assistant", "content": "<form>\n <input type=\"text\" id=\"textbox\">\n <input type=\"submit\" value=\"Submit\">\n <input type=\"radio\" name=\"choice\" value=\"yes\">Y...
code_alpaca
code_alpaca_132
[ { "role": "user", "content": "Tell me how would you respond to the following request.\nWrite a code to access the nth element of a linked list.\n" }, { "role": "assistant", "content": "# defining the Node class\nclass Node: \n\tdef __init__(self, data): \n\t\tself.data = data \n\t\tself.next = N...
code_alpaca
code_alpaca_133
[ { "role": "user", "content": "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\nCreate a function in JavaScript to find the number of occurrences of a letter in a word.\n\n### Inp...
code_alpaca
code_alpaca_134
[ { "role": "user", "content": "Write a code to add two linked lists of different sizes.\n\nlist1 = [2->4->3]\nlist2 = [5->6->4->1]\n\n" }, { "role": "assistant", "content": "# adding two linked lists\nclass Node: \n\tdef __init__(self, data): \n\t\tself.data = data \n\t\tself.next = None\n\ndef a...
code_alpaca
code_alpaca_135
[ { "role": "user", "content": "Create a function in Java to convert a list of strings to a 2D array.\nInput: list: [\"aa\", \"bb\", \"cc\"]\nOutput:" }, { "role": "assistant", "content": "public static String[][] convertTo2DArray(List<String> strings) {\n int n = strings.size();\n String[][...
code_alpaca
code_alpaca_136
[ { "role": "user", "content": "Modify the code below to make it calculate the sum of all the numbers from 1 to n.\n\nnum = 5\nsum = 0\nfor i in range(num):\n sum += i\n\n" }, { "role": "assistant", "content": "num = 5\nsum = 0\nfor i in range(1, num+1):\n sum += i" } ]
code_alpaca
code_alpaca_137
[ { "role": "user", "content": "You need to complete the following task:\n\nCreate a program to generate a histogram using data from a set of numbers.\n\nvalues = [3, 4, 2, 5, 8, 1, 2, 6]\n\nAnswer:" }, { "role": "assistant", "content": "import matplotlib.pyplot as plt\n\nvalues = [3, 4, 2, 5, 8, ...
code_alpaca
code_alpaca_138
[ { "role": "user", "content": "Can you help with this?\n\nCreate a function to convert Celsius to Fahrenheit.\n" }, { "role": "assistant", "content": "def celsius_to_fahrenheit(c):\n f = c * (9/5) + 32\n return f" } ]
code_alpaca
code_alpaca_139
[ { "role": "user", "content": "Write a function to find the number of occurrences of an element in a list.\n\narr = [10, 20, 10, 40, 40, 40, 50]\n\n" }, { "role": "assistant", "content": "def count_occurrences(arr, element):\n count = 0\n for e in arr:\n if e == element:\n ...
code_alpaca
code_alpaca_140
[ { "role": "user", "content": "Write a JavaScript code snippet to print the numbers from 1 to 10.\nResponse:" }, { "role": "assistant", "content": "for (let i = 1; i <= 10; i++) {\n console.log(i);\n}" } ]
code_alpaca
code_alpaca_141
[ { "role": "user", "content": "Generate a dictionary of 10 key-value pairs, where the key is a string and the values are random numbers from 1 to 100.\n\nAnswer:" }, { "role": "assistant", "content": "import random\n\nd = dict()\n\nkeys = [\"one\", \"two\", \"three\", \"four\", \"five\", \"six\",...
code_alpaca
code_alpaca_142
[ { "role": "user", "content": "Create a JavaScript function which takes a string as a parameter and returns the most frequent character in the string.\n'Hello World!'\n\n" }, { "role": "assistant", "content": "function mostFrequentChar(string) {\n let charMap = {};\n let maxCount = 0;\n ...
code_alpaca
code_alpaca_143
[ { "role": "user", "content": "Instruction:Write a C# function which takes 2 strings as parameters and returns a new string which is a concatenation of the two parameters.\n\nInput: 'Hello', 'World!'\n\n" }, { "role": "assistant", "content": "string ConcatenateStrings(string str1, string str2)\n{...
code_alpaca
code_alpaca_144
[ { "role": "user", "content": "Create an HTML page where the main content area has a random background color when the page is loaded. Output:" }, { "role": "assistant", "content": "<!DOCTYPE html>\n<html>\n <head>\n <title>RandomBackground</title>\n <script>\n window.addEventL...
code_alpaca
code_alpaca_145
[ { "role": "user", "content": "Create a Java program which takes an integer array as a parameter, sorts the array in ascending order, and returns the sorted array.\n[3, 5, 9, 1, 6]\n\n" }, { "role": "assistant", "content": "public int[] SortIntegerArray(int[] nums)\n{\n Arrays.sort(nums);\n ...
code_alpaca
code_alpaca_146
[ { "role": "user", "content": "Write an SQL query to select the number of employees in each department, sorted by the department name in ascending order.\n\nAnswer:" }, { "role": "assistant", "content": "SELECT department, COUNT(employee_ID)\nFROM employees\nGROUP BY department\nORDER BY departme...
code_alpaca
code_alpaca_147
[ { "role": "user", "content": "Task: Write a Python program to remove all instances of a given value from a given list.\n\n[1, 2, 3, 2, 3, 4], 2\n\nAnswer:" }, { "role": "assistant", "content": "def remove_value(nums, val):\n res = []\n for num in nums:\n if num != val:\n ...
code_alpaca
code_alpaca_148
[ { "role": "user", "content": "Create a Java program to take a given string and replace all occurrences of a given letter with another given letter\n'bbac', 'b', 'a'\n\n" }, { "role": "assistant", "content": "public String ReplaceLetters(String str, char oldChar, char newChar) {\n return str.r...
code_alpaca
code_alpaca_149
[ { "role": "user", "content": "Write an SQL query to calculate the average salary of all employees in a table, rounded to the nearest integer." }, { "role": "assistant", "content": "\nSELECT ROUND(AVG(salary))\nFROM employees;" } ]
code_alpaca
code_alpaca_150
[ { "role": "user", "content": "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\nCreate a JavaScript function that takes a given sentence as a parameter and capitalizes the first l...
code_alpaca
code_alpaca_151
[ { "role": "user", "content": "Instruction: Write a Python program to generate the first n Fibonacci numbers.\n" }, { "role": "assistant", "content": "def generate_fibonacci_numbers(n):\n if n==1:\n return [0]\n elif n==2:\n return [0,1]\n else:\n fib_list = [0,1]\n ...
code_alpaca
code_alpaca_152
[ { "role": "user", "content": "Create a C# program which takes two strings as parameters, and returns true if the two strings are anagrams of each other.\n\nInput: 'listen', 'silent'\n\nOutput:" }, { "role": "assistant", "content": "bool AreAnagrams(string s1, string s2)\n{\n if (s1.Length != ...
code_alpaca
code_alpaca_153
[ { "role": "user", "content": "Write an SQL query to calculate the difference between the total salaries of male and female employees in a table.\n\nAnswer:" }, { "role": "assistant", "content": "SELECT SUM(CASE WHEN gender = 'female' THEN salary ELSE 0 END) - SUM(CASE WHEN gender = 'male' THEN s...
code_alpaca
code_alpaca_154
[ { "role": "user", "content": "Create a JavaScript program which takes an array of integers as a parameter and reverses the array in-place.\n\n[3, 5, 9, 1, 6]\n\n" }, { "role": "assistant", "content": "function reverseArrayInPlace(nums) {\n let left = 0;\n let right = nums.length - 1;\n \n...
code_alpaca
code_alpaca_155
[ { "role": "user", "content": "Explain what the following line of code does.\na %= b\n\n" }, { "role": "assistant", "content": "This line of code assigns the remainder of a divided by b to a, so that the resulting value of a is the remainder of a divided by b. For example, if a is 10 and b is 3, ...
code_alpaca
code_alpaca_156
[ { "role": "user", "content": "Construct an if-else statement that returns ‘even’ if the given number is even and ‘odd’ if the given number is odd." }, { "role": "assistant", "content": "\nif n % 2 == 0:\n return 'even'\nelse:\n return 'odd'" } ]
code_alpaca
code_alpaca_157
[ { "role": "user", "content": "Multiply two vectors of size 5 and return the output.\n\nAdditional Context:\na = [1, 2, 3, 4, 5] \nb = [5, 4, 3, 2, 1]\n\nAnswer:" }, { "role": "assistant", "content": "[5, 8, 9, 8, 5]" } ]
code_alpaca
code_alpaca_158
[ { "role": "user", "content": "Create a list comprehension that takes all the elements of list_one and creates a new list where all the elements are doubled.\nlist_one = [1, 2, 3, 4, 5]\n\n" }, { "role": "assistant", "content": "[x*2 for x in list_one]" } ]
code_alpaca
code_alpaca_159
[ { "role": "user", "content": "You are given a matrix of m rows and n columns. Write a function that calculates the transpose of the given matrix.\nmatrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\n\n" }, { "role": "assistant", "content": "def transpose(matrix):\n m = len(matrix)\n n = len(matrix...
code_alpaca
code_alpaca_160
[ { "role": "user", "content": "Given a list of numbers, print the difference between the largest and the smallest number.\n\nlist_of_numbers = [10, 7, 5, 12, 4]\n\n" }, { "role": "assistant", "content": "difference = max(list_of_numbers) - min(list_of_numbers)\nprint(difference)" } ]
code_alpaca
code_alpaca_161
[ { "role": "user", "content": "Task: Create a for loop that goes through every element of list_of_words and prints ‘success’ if an element is equal to “example” and prints ‘failure’ in any other case.\nInput: list_of_words = [\"hello\", \"example\", \"world\"]\nOutput:" }, { "role": "assistant", ...
code_alpaca
code_alpaca_162
[ { "role": "user", "content": "Create a function that takes in a list of temperatures and returns the average temperature\nlist_of_temperatures = [20, 24, 26, 18]\n\n" }, { "role": "assistant", "content": "def average_temperature(temperatures):\n num_items = len(temperatures)\n sum_items = ...
code_alpaca
code_alpaca_163
[ { "role": "user", "content": "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\nYou are given a list of numbers. Create a function that returns a new list with duplicates removed\...
code_alpaca
code_alpaca_164
[ { "role": "user", "content": "Instruction:In a given string, create a function that returns the longest consecutive sequence of characters.\n\nInput: my_string = “abccdeefghj\"\n\n" }, { "role": "assistant", "content": "def longest_consecutive(string):\n character_list = []\n max_length = ...
code_alpaca
code_alpaca_165
[ { "role": "user", "content": "Create a function that takes in a string and counts the number of vowels in it\n\n" }, { "role": "assistant", "content": "def count_vowels(string):\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n count = 0\n for char in string:\n if char in vowels:\...
code_alpaca
code_alpaca_166
[ { "role": "user", "content": "Write a function that takes in a string and returns a list of all the words that have more than 5 characters\n" }, { "role": "assistant", "content": "def long_words(string):\n words = string.split()\n long_words_list = []\n for word in words:\n if le...
code_alpaca
code_alpaca_167
[ { "role": "user", "content": "Instruction: Create a function that takes in a string and replaces all punctuation with a space\nOutput:" }, { "role": "assistant", "content": "import string\n\ndef replace_punctuation(string):\n for char in string:\n if char in string.punctuation:\n ...
code_alpaca
code_alpaca_168
[ { "role": "user", "content": "Create a function that takes in a list of numbers and returns true if the list contains at least one positive number\nlist_of_numbers = [-2, -5, 0, 3]\n\n" }, { "role": "assistant", "content": "def is_positive_number(numbers):\n for num in numbers:\n if nu...
code_alpaca
code_alpaca_169
[ { "role": "user", "content": "Write code in Java to generate the Fibonacci sequence up to N numbers.\n\nN = 10\n\n" }, { "role": "assistant", "content": "public class Fibonacci { \n \n public static void FibonacciN(int n) { \n int i, f=0, s=1; \n \n if (n == 1) \n S...
code_alpaca
code_alpaca_170
[ { "role": "user", "content": "Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.\n\n### Instruction:\nWrite an algorithm to find the largest element in an array.\n\n### Input:\n[8, 11, 12, 5, 3]\n\n###...
code_alpaca
code_alpaca_171
[ { "role": "user", "content": "Write code in Java to sort an array of integers in ascending order.\n\nAdditional Context:\n[5, 2, 8, 10, 4, 9]\n\nAnswer:" }, { "role": "assistant", "content": "public static void sortAscending(int[] arr) {\n for(int i = 0; i < arr.length - 1; i++) {\n in...
code_alpaca
code_alpaca_172
[ { "role": "user", "content": "Create a new button using HTML.\nResponse:" }, { "role": "assistant", "content": "<button>My Button</button>" } ]
code_alpaca
code_alpaca_173
[ { "role": "user", "content": "Can you help with this?\n\nWrite a SQL query to add a new column \"age\" in the employees table.\n" }, { "role": "assistant", "content": "ALTER TABLE Employees\nADD COLUMN age INT;" } ]
code_alpaca
code_alpaca_174
[ { "role": "user", "content": "Design a function in Python to delete duplicates from a list.\n\nNow complete the following instance -\nInput: The list is: [2, 3, 2, 4, 5, 5, 6]\nOutput:" }, { "role": "assistant", "content": "def remove_duplicates(list): \n \n unique_list = [] \n \n ...
code_alpaca
code_alpaca_175
[ { "role": "user", "content": "Implement an algorithm to find the sum of all the elements in an array.\n\nThe array is: [3, 5, 8, 10, 4]\n\n" }, { "role": "assistant", "content": "// Algorithm to calculate the sum of all the elements in an array\n\n// Step 1: Initialize a variable 'sum' and set i...
code_alpaca
code_alpaca_176
[ { "role": "user", "content": "Write a MySQL query to display the name, job and salary of all employees.\n\n" }, { "role": "assistant", "content": "SELECT name, job, salary \nFROM employees;" } ]
code_alpaca
code_alpaca_177
[ { "role": "user", "content": "Find the sum of two numbers using C#.\n\nInput: The two numbers are: 123 and 456\n\nOutput:" }, { "role": "assistant", "content": "int result = 123 + 456;\nConsole.WriteLine(result); //Output: 579" } ]
code_alpaca
code_alpaca_178
[ { "role": "user", "content": "Create a web page using HTML and CSS that displays a div with some text. Output:" }, { "role": "assistant", "content": "<html>\n <head>\n <title>Div Example</title>\n </head>\n <body>\n <div>Hello, welcome to my website!</div>\n </body>\n</html>" ...
code_alpaca
code_alpaca_179
[ { "role": "user", "content": "Write a JavaScript function to capitalize the first letter of each word in a string.\nInput: String: \"This is an example\".\nOutput:" }, { "role": "assistant", "content": "function capitalizeFirstLetter(str) {\n return str.replace(/\\w\\S*/g, function(txt) {\n ...
code_alpaca
code_alpaca_180
[ { "role": "user", "content": "Task: Write a Python program to loop through all the items in a given list.\n\nList: [1, 2, 3, 4, 5, 6]\n\nAnswer:" }, { "role": "assistant", "content": "my_list = [1, 2, 3, 4, 5, 6]\nfor item in my_list:\n print(item)" } ]
code_alpaca
code_alpaca_181
[ { "role": "user", "content": "Task: Write a SQL query to select the name and address from a given table.\n\nTable: Employee\n\n" }, { "role": "assistant", "content": "SELECT name, address FROM Employee" } ]
code_alpaca
code_alpaca_182
[ { "role": "user", "content": "Write a response that appropriately completes the request.\n\n### Instruction:\nCreate a new CSS animation rule to rotate an object a full circle.\n\n### Response:" }, { "role": "assistant", "content": "@keyframes rotate {\n 0% {\n transform: rotate(0deg);...
code_alpaca
code_alpaca_183
[ { "role": "user", "content": "Write a PL/SQL program to print out all numbers from 1 to 10.\n\n" }, { "role": "assistant", "content": "BEGIN\n FOR i IN 1..10 LOOP\n DBMS_OUTPUT.PUT_LINE(i);\n END LOOP;\nEND;" } ]
code_alpaca
code_alpaca_184
[ { "role": "user", "content": "Write a JavaScript code snippet to remove the last element from an array.\n\nInput: Array: [1, 2, 3, 4, 5]\n\nOutput:" }, { "role": "assistant", "content": "let array = [1, 2, 3, 4, 5];\narray.pop(); // remove the last element\nconsole.log(array); // [1, 2, 3, 4]" ...
code_alpaca
code_alpaca_185
[ { "role": "user", "content": "Convert the following binary number to a decimal number.\nBinary Number: 10011\n" }, { "role": "assistant", "content": "19 (10011 = 2^4 + 2^3 + 2^1 = 16 + 8 + 1 = 25)" } ]
code_alpaca
code_alpaca_186
[ { "role": "user", "content": "Instruction:Write a Java program to calculate the sum of the two given integers.\n\nInput: Integers: 4 and 9\n\n" }, { "role": "assistant", "content": "public static int addIntegers(int a, int b) {\n int sum = a + b;\n return sum;\n}\n\npublic static void main...
code_alpaca
code_alpaca_187
[ { "role": "user", "content": "What is the largest prime factor of the number 885?\n" }, { "role": "assistant", "content": "The largest prime factor of 885 is 5." } ]
code_alpaca
code_alpaca_188
[ { "role": "user", "content": "Create a function in Python which takes two parameters and returns their product.\n\n" }, { "role": "assistant", "content": "def product(a, b):\n return a*b" } ]
code_alpaca
code_alpaca_189
[ { "role": "user", "content": "Construct a for loop that prints out the numbers from 1 to 10 Output:" }, { "role": "assistant", "content": "for i in range(1, 11):\n print(i)" } ]
code_alpaca
code_alpaca_190
[ { "role": "user", "content": "Create an HTML form with three input fields: firstName, lastName and age. Output:" }, { "role": "assistant", "content": "<form> \n First Name:<br> \n <input type=\"text\" name=\"firstName\"><br> \n Last Name:<br> \n <input type=\"text\" name=\"lastName\"...
code_alpaca
code_alpaca_191
[ { "role": "user", "content": "Write a function in Java that takes two strings as parameters and returns true if the first string is a substring of the second.\n" }, { "role": "assistant", "content": "public boolean isSubstring(String s1, String s2) \n{ \n int M = s1.length(); \n int N = s2...
code_alpaca
code_alpaca_192
[ { "role": "user", "content": "Construct a while loop that increments a counter every time a number is divisible by 3.\n" }, { "role": "assistant", "content": "int count = 0; \nint i = 0; \nwhile(i < 100)\n{\n if(i % 3 == 0)\n count++; \n i++;\n}" } ]
code_alpaca
code_alpaca_193
[ { "role": "user", "content": "Write a response that appropriately completes the request.\n\n### Instruction:\nCreate a Regular Expression pattern to find words that contain the letters \"a\", \"b\", and \"c\".\n\n### Response:" }, { "role": "assistant", "content": "\\b[abc]+\\w*\\b" } ]
code_alpaca
code_alpaca_194
[ { "role": "user", "content": "Create a class in Python to represent a Person. Output:" }, { "role": "assistant", "content": "class Person:\n # Constructor \n def __init__(self, name, age): \n \n # instance attributes \n self.name = name \n self.age = age \n \n...
code_alpaca
code_alpaca_195
[ { "role": "user", "content": "Instruction:Write a code to check whether the input string is a palindrome or not.\n\nInput: a man a plan a canal panama\n\n" }, { "role": "assistant", "content": "\"\"\"\nWrite a code to check whether the input string is a palindrome or not\n\"\"\"\n\ndef check_pal...
code_alpaca
code_alpaca_196
[ { "role": "user", "content": "Write a code to remove the duplicates from a given list.\n\nAdditional Context:\nmylist = [1,2,3,1,2]\n\nAnswer:" }, { "role": "assistant", "content": "\"\"\"\nWrite a code to remove the duplicates from a given list\n\"\"\"\n\n# List containing the elements\nmylist ...
code_alpaca
code_alpaca_197
[ { "role": "user", "content": "Create a dictionary containing the key-value pair of a given string.\n\nstring = \"test string\"\n\n" }, { "role": "assistant", "content": "\"\"\"\nCreate a dictionary containing the key-value pair of a given string\n\"\"\"\n\n# Given string\nstring = \"test string\...
code_alpaca
code_alpaca_198
[ { "role": "user", "content": "Write a response that appropriately completes the request.\n\n### Instruction:\nWrite a code to generate a random number between 1 to 10.\n\n### Response:" }, { "role": "assistant", "content": "\"\"\"\nWrite a code to generate a random number between 1 to 10\n\"\"\"...
code_alpaca
code_alpaca_199
[ { "role": "user", "content": "Plase answer the following request: Write a code to create a 3 x 3 matrix containing all 0s.\nAnswer:" }, { "role": "assistant", "content": "\"\"\"\nWrite a code to create a 3 x 3 matrix containing all 0s\n\"\"\"\n\n# Creating an empty 3 x 3 matrix\nmatrix = [[0 for...