← 목록

Synth · CodeAlpaca일부

총 20,022개 · 페이지 356/668
🔀 랜덤
불러오는 중…

[output] | print(string[::-1]) [instruction] | Print a string in reverse. [input] | string = "Hello World!"

[output] | class Square: def __init__(self, side): self.side = side def area(self): return self.side * self.side [instruction] | Create a class named Square and create a method to calculate the area. [input] |

[output] | // Show the memory size of the list int memorySize = list.size() * Integer.SIZE / 8; System.out.println(memorySize); [instruction] | Show the memory size of a list using Java. [input] | List<Integer> list = new ArrayList<Integer>(); list.add(3); list.add(4); list.add(5);

[output] | // Change all the element in the array to negative for (var i = 0; i < arr.length; i++) { arr[i] = -arr[i]; } [instruction] | Change all the element in the array to negative using JavaScript. [input] | var arr = [1, 2, 3, 4, 5];

[output] | // Find the sum of all elements of the matrix int sum = 0; for (int i = 0; i < 2; i++) for (int j = 0; j < 2; j++) sum = sum + A[i][j]; [instruction] | Find the sum of all elements in a matrix using C. [input] | int A[2][2] = { {1, 2}, {3, 4} };

[output] | // Sort the strings alphabetically sort(arr, arr+3); [instruction] | Sort the strings alphabetically using C++. [input] | string arr[] = {"Geeks", "for", "Geeks"};

[output] | # Check whether all elements in the array are equal if all(x == arr[0] for x in arr): print("All elements are equal") else: print("Elements are not equal") [instruction] | Check whether all elements in the array are equal using Python. [input] | arr = [2,2,2]

[output] | // Perform linear search int flag = 0; for (int i = 0; i < 5; i++) { if (arr[i] == key) { flag = 1; break; } } if (flag == 1) printf("Present"); else printf("Not Present"); [instruction] | Perform a linear search to find if a key exists in an array using C. [input] | int arr[] = {4, 3, 2, 10, 40}; int key = 40;

[output] | // Create an object of your own class class MyClass { constructor(name) { this.name = name; } } let obj = new MyClass("MyObject"); console.log(obj); [instruction] | Create an object of your own class using JavaScript. [input] |

[output] | # Replace all negative numbers in an array to zero arr.each_with_index do |num, i| arr[i] = 0 if num < 0 end [instruction] | Replace all the negative numbers in an array to zero using Ruby. [input] | arr = [3, 4, -2, -1]

[output] | let countDown = 10; let interval = setInterval(() => { countDown--; if (countDown == 0) { clearInterval(interval); } }, 1000); [instruction] | Write a JavaScript code to create a timer that counts down from 10. [input] |

[output] | {'KEY1': 'VALUE1', 'KEY2': 'VALUE2', 'KEY3': 'VALUE3'} [instruction] | Use the provided text to generate a python ``dict``. [input] | KEY1:VALUE1,KEY2:VALUE2,KEY3:VALUE3

[output] | def searchTree(T, k): if not T: return False if k == T[0]: return True elif k < T[0]: return searchTree(T[1], k) else: return searchTree(T[2], k) [instruction] | Implement a search algorithm with the given data structure. [input] | def searchTree(T, k): """ Tree T is either empty or a node with two subtrees, left and right. The value at the root is a[0] """

[output] | ^(?=.*[A-Z])(?=.*[0-9])[A-Z0-9]+$ [instruction] | Generate a regular expression that matches strings containing at least one digit and one uppercase letter. [input] |

[output] | technology [instruction] | Classify the given input text into one of the 4 categories ("sports", "weather", "finance", "technology"). [input] | Apple Inc. reported earnings today

[output] | Recursion is a programming technique which involves a function calling itself in order to solve a problem. It allows the function to repeat itself until a certain condition is met, by breaking the problem down into simpler versions of itself. This is done by using a base case, which is a smaller ver [instruction] | Explain what is meant by recursion in programming. [input] |

[output] | def sum_of_list(lst, target): """ This function takes a list and a target number as inputs, and prints only the list items whose total add up to the target number. """ for i in range(len(lst)-1): for j in range(i+1, len(lst)): if lst[i] + lst[j] == target: [instruction] | Write a function that takes two inputs, a list and a target number, and prints only the list items whose total add up to the target number. [input] | list = [1, 5, 9, 10], target = 10

[output] | The above code initializes an Express web application by importing the express module and creating an Express application instance. The Express module is a web development framework for Node.js that provides a set of features that facilitate the creation of web applications and API's. The app instan [instruction] | Given the following Node.js code, explain its functionality. [input] | const express = require("express"); const app = express();

[output] | I have a dog and two dogs [instruction] | Find and replace all occurrences of "cat" with "dog" in the given string. [input] | I have a cat and two cats

[output] | function reverseString(str) { let newString = ""; for (let i = str.length - 1; i >= 0; i--) { newString += str[i]; } // Added return statement return newString; } // The change is a return statement that has been added to the end of the function. The purpose of this return stat [instruction] | Debug the following code, describe the changes and explain their purpose. [input] | function reverseString(str) { let newString = ""; for (let i = str.length - 1; i >= 0; i--) { newString += str[i]; } return newString; }

[output] | ^abc.*xyz$ [instruction] | Write a regex expression to match strings that start with "abc" and end with "xyz". [input] |

[output] | dict_from_lists = dict(zip(list1, list2)) [instruction] | How can you create a dictionairy from the following two lists in Python? [input] | list1 = ["a", "b", "c"] list2 = [1, 2, 3]

[output] | The ML algorithm should be a convolutional neural network architecture like LeNet and should take a 28x28 image of a handwritten digit as input. The output of the model should be a one hot vector of 10 elements representing the probability of the corresponding digit. [instruction] | Design a ML algorithm to classify a given handwritten digit. [input] |

[output] | <form> <label for="firstName">First Name</label> <input type="text" id="firstName" name="firstName"> <label for="lastName">Last Name</label> <input type="text" id="lastName" name="lastName"> <input type="submit" value="Submit"> </form> [instruction] | Create a HTML form with two text fields that accept a first and last name, respectively. [input] |

[output] | function sortByThirdLetter(arr) { return arr.sort((a, b) => { if (a[2] < b[2]) return -1; if (a[2] > b[2]) return 1; return 0; }); } sortByThirdLetter(["apple", "pear", "banana", "grape"]); // ["apple", "grape", "banana", "pear"] [instruction] | Create a JavaScript function for sorting a list of strings alphabetically by their third letter. [input] | ["apple","pear","banana","grape"]

[output] | CREATE TABLE Person ( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, first_name VARCHAR(42) NOT NULL, last_name VARCHAR(42) NOT NULL, birth_date DATE NOT NULL, age INT NOT NULL ); [instruction] | How would you create a MySQL table with the following columns? [input] | Person (id, first_name, last_name, birth_date, age)

[output] | <html> <head> <meta charset="utf-8"> <title>Navigation</title> </head> <body> <nav> <ul> <li><a href="home.html">Home</a></li> <li><a href="about.html">About</a></li> <li><a href="blog.html">Blog</a></li> <li><a href="contact.html">Contact</a>< [instruction] | Create an HTML webpage with a main navigation at the top. [input] |

[output] | def summation(n) sum = 0 for i in 1..n sum += i end return sum end [instruction] | Create a Ruby method to sum all numbers from 1 to the given number n. [input] |

[output] | .column-layout{ display: flex; flex-direction: row; width: 100%; } .column-layout > * { flex: 1 1 50%; } [instruction] | Create a CSS class for creating a two-column layout. [input] |

[output] | CREATE TABLE users ( user_id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, first_name VARCHAR(50) NOT NULL, last_name VARCHAR(50) NOT NULL, email VARCHAR(100) NOT NULL, password VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL ); CREATE TABLE blogposts ( post_id INT PRIMARY KEY NO [instruction] | How would you create a (scalable) database schema for a blog platform? [input] |

← → 방향키로 페이지 이동 · 숫자 입력 후 Enter로 점프