← 목록

Synth · CodeAlpaca일부

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

[output] | 2^2 - 1 = 3 distinct values can be inserted in a binary tree containing 2 nodes. [instruction] | Calculate how many distinct values can be inserted in a binary tree containing 2 nodes. [input] |

[output] | <li>List item</li> [instruction] | Write an HTML code for a common list item. [input] |

[output] | public class ArraySort { public static void main(String[] args) { int array[] = {1, 10, 4, 2, 5, 3, 9}; int n = array.length; for (int i = 0; i < n-1; i++) for (int j = 0; j < n-i-1; j++) if (array[j] < array[j+1]) { [instruction] | Write a Java program to sort the elements of an int array in the descending order. [input] | [1, 10, 4, 2, 5, 3, 9]

[output] | The built-in function to round off a given number to the nearest whole number is the round() function. [instruction] | Name a built-in function that rounds off a given number to the nearest whole number. [input] |

[output] | const arrayToObj = (arr) => { return arr.reduce((acc, item) => { acc[item.id] = item; return acc; }, {}); } const result = arrayToObj([ { id: '001', firstName: 'John' , lastName: 'Doe' }, { id: '002', firstName: 'Jim' , lastName: 'Smith' }, { id: '003', firstName: Joe , [instruction] | Write a JavaScript program to convert an array of objects into an object of objects. [input] | [ { id: '001', firstName: 'John' , lastName: 'Doe' }, { id: '002', firstName: 'Jim' , lastName: 'Smith' }, { id: '003', firstName: Joe , lastName: 'Mail' }, ]

[output] | print(addNumbers.signature) // prints: func addNumbers(a: Int, b: Int) -> Int [instruction] | Write a Swift code to print out the signature of a function. [input] | func addNumbers(a: Int, b: Int) -> Int { return a + b }

[output] | CREATE TABLE customers ( id int NOT NULL AUTO_INCREMENT, firstname varchar(45) NOT NULL, lastname varchar(45) NOT NULL, address varchar(100) NOT NULL, phone varchar(20) NOT NULL, email varchar(45) NOT NULL, PRIMARY KEY (id) ); [instruction] | Create a new table in a database named 'customers' with the specified columns. [input] |

[output] | if (number % 3 === 0) { console.log('Number is divisible by 3'); } [instruction] | Create a if statement in JavaScript that checks if number is divisible by 3. [input] | Number: 9

[output] | /Hello World/ [instruction] | Write a regular expression that returns “Hello World” if found in the provided text. [input] | Text: This example will show you how to print Hello World using Regular Expressions.

[output] | var i = 0; while (i < 5) { console.log('Hello!'); i++; } [instruction] | Use a while loop to print a message 5 times. [input] | Message: Hello!

[output] | def quick_calc(string): result = 0 calculation = string.split(" ") for item in calculation: try: result += int(item) except: if item.lower() == "*": result *= int(calculation[calculation.index(item) + 1]) return result print(q [instruction] | Create a quick calculator in Python based on the user input. [input] | 2 * 3 + 5

[output] | function Fibonacci(n) { var a = 0, b = 1, c, i; if (n == 0) return a; for (i = 2; i <= n; i++) { c = a + b; a = b; b = c; } return b; } console.log(Fibonacci(10)); 55 [instruction] | Output the nth Fibonacci number in JavaScript. [input] | 10

[output] | class UserAuthentication { constructor (startupOptions) { // initialize settings, read startup settings, etc. } authenticate(credentials) { // verify user credentials, read data, etc. } logout() { // delete session, reset variables, etc. } } [instruction] | Create a class in jQuery to handle user authentication. [input] |

[output] | function newtonsMethod(f, df, x, epsilon) { // Keep track of how many iterations we calculate let iteration = 0; while (Math.abs(f(x)) > epsilon && iteration < MAX_ITER) { x -= f(x) / df(x); iteration += 1; } return x; } [instruction] | Create a function in JavaScript to implement Newton's Method of Numerical Approximation. [input] |

[output] | let myVariable1: number, myVariable2: boolean, myVariable3: string [instruction] | You are presented with a string which contains a code snippet. Extract the variable types from this string. [input] | let myVariable1 = 5; let myVariable2 = true; let myVariable3 = "Hello";

[output] | // algorithm to find closest pair of points // uses divide and conquer approach const closestPair = (points) => { // base case: two or fewer points if (points.length <= 2) { return points; } // divide const middle = Math.floor(points.length / 2); const left = points.slice(0, midd [instruction] | Create an algorithm in JavaScript to find the closest pair of points from a given set of points. [input] | let points = [[2, 0], [4, 4], [-2, 2], [-3, -4], [4, -2]];

[output] | import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.ServerSocket; import java.net.Socket; public class WebServer { public static void main(String[] args) throws Exception { // listen for a connection from a client ServerSo [instruction] | Create a web server in Java to handle a POST request. [input] |

[output] | int result = (int) Math.pow(2, 8); System.out.println(result); //Output: 256 [instruction] | Output the result of 2 to the power of 8 in Java. [input] |

[output] | SELECT * FROM student_scores WHERE math_score > (SELECT AVG(math_score) from student_scores); [instruction] | Write an SQL query to select the students who scored higher than the average in Maths. [input] |

[output] | def reverse_string(s): reversed_string = "" for char in s: reversed_string = char + reversed_string return reversed_string [instruction] | Edit this code snippet to reverse a string in Python. [input] | def reverse_string(s): # Edit here return reversed_string

[output] | function searchString(str, val) { let pos = -1; const len = str.length; for (let i=0; i < len; i++) { if (str[i] === val) { pos = i; break; } } return pos; } const searchString = 'banana'; const searchValue = 'a'; const searchResult = searchString(searchString, searc [instruction] | Write a JavaScript function to search a string for a specified value and return the position of the match. [input] | searchString = "banana" searchValue = "a"

[output] | SELECT customers.* FROM customers JOIN orders ON customers.customer_id = orders.customer_id WHERE orders.order_date > DATE_SUB(CURDATE(), INTERVAL 1 MONTH); [instruction] | Write an SQL query to find all the customers who've purchased an item in the last month. [input] |

[output] | <?php $array = array('fruit' => array('apple', 'banana', 'orange'), 'vegetable' => array('carrot', 'potato')); foreach ($array as $category => $values) { echo "Category: " . $category . "\n"; foreach ($values as $value) { echo "Value: " . $value . "\n"; } [instruction] | Write a PHP script to loop through a multidimensional array and print out the values. [input] | $array = array('fruit' => array('apple', 'banana', 'orange'), 'vegetable' => array('carrot', 'potato'));

[output] | db.properties.find({ $and: [ { bedrooms: { $gt: 3 } }, { price: { $lt: 500 } } ] }) [instruction] | Translate the following SQL query into MongoDB syntax. [input] | SELECT * FROM properties WHERE bedrooms > 3 and price < 500

[output] | #!/bin/bash search_string="text string" directory="directory_name" #searching for text string recursive in the directory grep -rnw $directory -e "$search_string" [instruction] | Write a bash script that searches for a given text string in a directory tree recursively. [input] |

[output] | import React from 'react'; const RecordTable = (props) => ( <div> <table> <thead> <tr> <th>ID</th> <th>Name</th> <th>Age</th> </tr> </thead> <tbody> [instruction] | Create a React component that renders a table containing the records from an array of objects. [input] | const records = [ { id: 1, name: 'Adam', age: 25 }, { id: 2, name: 'James', age: 30 }, { id: 3, name: 'Nick', age: 28 }, { id: 4, name: 'John', age: 29 } ];

[output] | <html> <head> <title>{{ site.name }}</title> <style> body { display: flex; flex-direction: column; } header, footer { flex-basis: 10%; } main { flex-basi [instruction] | Create a Drupal 8 theme that implements a 3 column layout with a header, side bar, content and footer. [input] |

[output] | @RestController public class PaymentController { @PostMapping("/payment") public void processPayment(@RequestBody PaymentRequest request) { // Process the payment inside this method } } [instruction] | Implement a webhook endpoint in Java using Spring MVC to process a payment request. [input] |

[output] | ^[0-9]{4,}$ [instruction] | Generate a regular expression to match a string of consecutive numbers with a minimum of 4 digits. [input] |

[output] | def bubbleSort(arr): n = len(arr) # Traverse through all array elements for i in range(n): # Last i elements are already in place for j in range(0, n-i-1): # traverse the array from 0 to n-i-1 # Swap if the element found is greater [instruction] | Can you code a solution to Bubble Sort an array of integers? [input] | [5, 4, 3, 2, 1]

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