[output] | try { URL page = new URL(url); URLConnection conn = page.openConnection(); BufferedReader in = new BufferedReader( new InputStreamReader(conn.getInputStream()) ); String line; while ((line = in.readLine()) != null) { System.out.println(line); [instruction] | Gather the source code of a web page using a Java program. [input] | String url = "https://www.example.com";
[output] | uppercase str = map toUpper str [instruction] | Write a helper function in Haskell that prints out a given string in uppercase. [input] | str = "hello"
[output] | A hashmap (also known as a dictionary or associative array) is a data structure that stores key-value pairs. It is used to store and retrieve information using a keyword or search term as the key. The key can then be used to quickly fetch the associated value from the hashmap. This makes hashmaps a [instruction] | What is a hashmap, and what is it used for? [input] |
[output] | new_list = [] for i in range(len(list1)): new_list.append(list1[i] + list2[i]) print(new_list) # Output: [7, 10, 7] [instruction] | Write a code snippet to add two numbers provided in two lists. [input] | list1 = [2, 4, 3] list2 = [5, 6, 4]
[output] | def countDigits(num): count = 0 while(num > 0): num = num//10 count += 1 return count print(countDigits(num)) # Output: 4 [instruction] | Write a function in Python that takes an integer as an input and prints the number of digits in the integer. [input] | num = 1234
[output] | A set is a data structure that stores a collection of unique values. A set is efficient for checking if a particular value exists in the collection, as the existence of the value can be checked in constant time. [instruction] | What data structure can you use to store a set of unique values? [input] |
[output] | db.customers.find({ customer_id: 1 }); [instruction] | Convert this MySQL query to MongoDB. [input] | SELECT * FROM customers WHERE customer_id=1;
[output] | def delete(A, B): for i in B: if i in A: A = A.replace(i, '') return A delete(A, B) # Output: 'bdef' [instruction] | You are given two strings, A and B. Write a function to delete the characters in A that also appear in B. [input] | A = 'abcbbdef' B = 'abcdc'
[output] | Dynamic programming is a technique for solving complex problems by breaking them down into smaller subproblems. The subproblems are solved and stored in a table, which is reused to solve future subproblems. This technique allows for efficient solutions regardless of the complexity of the problem, as [instruction] | Explain the principle of dynamic programming. [input] |
[output] | The main problem with this code is that it is not very efficient. It uses a recursive approach which requires solving the same subproblem multiple times, thus leading to a large time complexity. To improve the efficiency of the code, it could be rewritten to use iteration instead of recursion. [instruction] | You need to read a code and predict possible problems. [input] | def fib(n): if n == 0: return 0 elif n == 1: return 1 else: return (fib(n-1) + fib(n-2))
[output] | The official language for developing applications for the Android platform is Java. Java is an object-oriented programming language, which allows developers to create robust and reliable applications for Android devices. [instruction] | Which language is used to develop applications for the Android platform? [input] |
[output] | def sort_nums_asc(arr): for i in range(len(arr)): lowest_value_index = i for j in range(i + 1, len(arr)): if arr[j] < arr[lowest_value_index]: lowest_value_index = j arr[i], arr[lowest_value_index] = arr[lowest_value_index], arr[i] return a [instruction] | Create a sorting algorithm in Python that will sort an array of numbers in ascending order [input] | [3, 1, 5, 2, 4, 6]
[output] | #include <stdio.h> #include <string.h> void characterCount(char str[]) { int count[256] = {0}; int len = strlen(str); // Count the frequency of each character in the string int i; for (i = 0; i < len; i++) count[str[i]]++; // print lowercase char [instruction] | Generate a C program to count the frequency of each character in a given string [input] | String = “abcabcabc”
[output] | const dateformat = require('dateformat'); const getDayName = (date) => { const dayName = dateformat(date,'dddd'); return dayName; }; [instruction] | Write a node.js program to get the name of the day for a given date [input] |
[output] | Negative [instruction] | Classify a given paragraph as having a positive or negative sentiment [input] | The customer service was horrible and the wait was too long.
[output] | SELECT * FROM database_name; [instruction] | Retrieve the data stored in a SQL database [input] |
[output] | function factorial(n) { let result = 1; for (let i = 2; i <= n; i++) result *= i; return result; } console.log( factorial(n) ); [instruction] | Edit a JavaScript program to input a number and output its factorial [input] | let n = 5;
[output] | #!/bin/bash arr=($list) sort=`echo ${arr[*]} | tr " " "\n" | sort -n` echo $sort [instruction] | Create a bash script that sorts a list of numbers [input] | list = [3,12,1,4,5]
[output] | public static int findSum(int[][] array) { int sum=0; for(int i=0;i<array.length;i++){ for(int j=0;j<array[i].length;j++){ sum = sum+array[i][j]; } } return sum; } [instruction] | Write a function in Java to sum up all the elements in a two-dimensional array [input] | int arr[][]={{1,2,3},{4,5,6}};
[output] | class StringProcessor: def __init__(self, String): self.string = String def processString(self): myString = "" for char in self.string: if char.isalnum(): myString += char.lower() return myString [instruction] | Create a Python class that processes a string of text [input] | String = "Hello World"
[output] | git pull origin master [instruction] | Generate a command to update a folder [input] |
[output] | cubes_list = [x**3 for x in range(1, 11)] [instruction] | Generate a list comprehension in Python to get the cube of all the numbers between 1 to 10 [input] |
[output] | [DataContract] public class SampleObject { [DataMember(Name = "name")] public string Name { get; set; } [DataMember(Name = "age")] public int Age { get; set; } } public static string SerializeObject(SampleObject obj) { DataContractJsonSerializer serializer = new DataContractJ [instruction] | Create a C# class to serialize a JSON object [input] |
[output] | def create_array(n): arr = [] for i in range(0, n, 2): arr.append(i) return arr [instruction] | Create an array of length n, containing all even numbers starting from 0. [input] |
[output] | <?xml version="1.0" encoding="utf-8"?> <root> <Company>Company Name</Company> <Product>Product Name</Product> <Price>Price in Dollars</Price> </root> [instruction] | Create an XML document with three elements "Company", "Product", and "Price". [input] |
[output] | const randomString = function() { const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; let str = ""; for (let i = 0; i < 3; i++) str += alphabet[Math.floor(Math.random() * alphabet.length)]; return str; } console.log(randomString()); [instruction] | Write a Node.js program to generate a random 3-character string. [input] |
[output] | SELECT * FROM products ORDER BY date_created DESC LIMIT 10; [instruction] | Write an SQL query to display the 10 most recently added products. [input] |
[output] | model = svm.SVC(kernel="linear") model.fit(X, y) [instruction] | Train a SVM model on the given input data to classify the output as either "yes" or "no". [input] | x1, x2, y 2, 3, Yes 3, 4, Yes 3, 5, No
[output] | let arr = [1, 7, 5, 4, 2]; arr.sort(function(a, b){return a-b}); console.log(arr); // [1, 2, 4, 5, 7] [instruction] | Sort the given array [1, 7, 5, 4, 2] in ascending order. [input] |
[output] | Affective [instruction] | Classify the following sentence into either Affective or Predicate. [input] | "She was beautiful."