[output] | <?php header("Location: http://www.example.com"); die(); ?> [instruction] | Use PHP to create a web page redirect script. [input] |
[output] | def most_occurrences(sentence): freq = {} for word in sentence.split(): freq[word] = freq.get(word, 0) + 1 freq_words = [(freq[word], word) for word in freq] freq_words.sort(reverse=True) print(freq_words[:2]) most_occurrences("This is just a simple string") [instruction] | Build a script to print the words that have the most occurrences in a given string. [input] | "This is just a simple string"
[output] | #include <stdio.h> int getMax(int arr[], int n) { int i; int max = arr[0]; for (i = 1; i < n; i++) if (arr[i] > max) max = arr[i]; return max; } int main() { int arr[] = { 12, 3, 4, 5, 10, 7 }; int n = sizeof(arr) / sizeof(arr[0]); printf("Maximum ele [instruction] | Write a C program that takes an array and its size as an argument and returns its maximum value. [input] | int array[] = { 12, 3, 4, 5, 10, 7 };
[output] | false [instruction] | Given the following Python code, identify if it is syntactically correct or not. [input] | def add(a b): return a+b
[output] | str = "gfedcba" [instruction] | Given a string in Python, generate a new string with the same set of characters but in the reverse order. [input] | str = "abcdefg"
[output] | public class Add { public static void main(String[] args) { int x = 3; int y = 4; int sum = x + y; if (sum > 5) { System.out.println("Greater than 5"); } else { System.out.println("Less than or equal to 5"); } } } [instruction] | Write a Java program that adds two numbers and checks whether the sum is greater than 5 or not. [input] | int x = 3; int y = 4;
[output] | arr = [3, 4, 5, 6, 7, 8, 9] [instruction] | Given an array of integers, remove any duplicate numbers and sort the remaining elements in ascending order. [input] | arr = [3, 9, 8, 4, 6, 7, 5, 4]
[output] | str = "the quick brown fox jumps" [instruction] | Separate the words in a given string using a single space. [input] | str = "thequickbrownfoxjumps"
[output] | [1, 2, 3, 6, 9, 8, 7, 4, 5] [instruction] | Create a program that outputs a spiral array from the given input of a 2D array. [input] | [[ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9]]
[output] | def print_sum(n): sum = 0 for i in range(1, n+1): sum += i return sum [instruction] | Compute the sum of all integers from 1 to the given number n. [input] |
[output] | 15 [instruction] | Develop a program that offers the maximum value from a list of numbers. [input] | [2, 10, 7, 15, 8, 11]
[output] | 19 [instruction] | Create a program that takes in two lists of numbers and computes the maximum difference between the two lists. [input] | List 1: [20, 10, 4, 0] List 2: [17, 1, 10, 7, 8]
[output] | The article is about _____. It discusses the subject in depth, exploring various aspects of the topic. It provides a comprehensive overview of different perspectives on the topic and presents evidence to support its conclusions. In conclusion, the article provides a comprehensive evaluation of _____ [instruction] | Generate a summary of an article containing more than 500 words. [input] |
[output] | def minMoves(arr): n = len(arr) moves = 0 for i in range(n): for j in range(n - 1): if arr[j] > arr[j + 1]: temp = arr[j] arr[j] = arr[j + 1] arr[j + 1] = temp moves += 1 return moves [instruction] | Design an algorithm that computes the minimum number of moves taking an array of integers to a sorted array. [input] | [1, 3, 5, 4, 2]
[output] | def Fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: return Fibonacci(n-1) + Fibonacci(n-2) [instruction] | Design a function to find the Fibonacci sequence numbers given n. [input] | n = 5
[output] | def print_prime_numbers(n): for num in range(2, n + 1): is_prime = True for i in range(2, num): if (num % i) == 0: is_prime = False break if is_prime: print(num) [instruction] | Create a Python script to print out all prime numbers up to and including a given number n. [input] |
[output] | class Person(): def __init__(self, name, age): self.name = name self.age = age [instruction] | Update the code to create a class named Person that contains two instance attributes-name and age. [input] | class Person(): # TODO: add name and age instance attributes
[output] | def calculate_n_squared(n): return n**2 - 2*n [instruction] | Design a function to compute n^2-2n. [input] |
[output] | # Node class class Node: def __init__(self, data): self.data = data self.next = None # LinkedList class class LinkedList: # Function to initialize head def __init__(self): self.head = None def reverse(self): prev = None current [instruction] | Implement the algorithm to reverse a singly linked list. [input] |
[output] | def sum_of_even_odd(arr): even_sum = 0 odd_sum = 0 for i in arr: if i % 2 == 0: even_sum += i else: odd_sum += i return even_sum, odd_sum [instruction] | Compute the sum of all the even numbers and odd numbers in an array of numbers. [input] | [1, 2, 3, 4, 5, 6]
[output] | import re pattern = re.compile(r"\w+\s\w+") [instruction] | Create a regex pattern to match a string that contains two words separated by a single space. [input] |
[output] | def parse_url(url): parsed = {} parsed["domain"], parsed["path"] = url.split('/', 2)[2:4] params = parsed["path"].split('?')[1] if "?" in parsed["path"] else None parsed["query"] = params.split('&') if params else None return parsed [instruction] | Design a function to parse the given URL and return its components. [input] | url = "https://www.example.com/path/to/file.php?query=123¶m=value"
[output] | #!/bin/bash echo $1 echo $3 [instruction] | Create a script in Bash to print the 1st and 3rd program arguments. [input] |
[output] | def is_anagram(str1, str2): # removing all whitespace from strings str1 = ''.join(str1.split()) str2 = ''.join(str2.split()) # create list for each string list_str1 = list(str1.upper()) list_str2 = list(str2.upper()) # sort the list list_str1.sort() list_ [instruction] | Write a Python script to check if two string variables are anagrams or not. [input] |
[output] | let someNumber = 10; [instruction] | Replace the following PHP code with an equivalent JavaScript code [input] | $someNumber = 10;
[output] | { "name": "John" } [instruction] | Create a JSON object with the key 'name' and the value 'John'. [input] |
[output] | arr.forEach(item => console.log(item)); [instruction] | Suggest a more efficient way to write the following for loop. [input] | for (i = 0; i < arr.length; i++) { console.log(arr[i]); }
[output] | .square { width: 100px; height: 100px; border-radius: 10px; } [instruction] | Edit the following CSS class to display a square box with a border-radius of 10px [input] | .square { width: 100px; height: 100px; }
[output] | ["The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"] [instruction] | Convert the following string "The quick brown fox jumps over the lazy dog" to an array [input] |
[output] | The Express.js package can be used to implement a REST API in Node.js. [instruction] | Name a specific package that can be used to implement a REST API in Node.js [input] |