← 목록

Synth · CodeAlpaca일부

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

[output] | def find_primes(n): primes = [] for num in range(2, n + 1): for i in range(2, num): if (num % i) == 0: break else: primes.append(num) return primes [instruction] | Create a program to return all the prime numbers under the nth number. [input] | n = 10

[output] | #include <vector> std::vector< std::vector<int> > find_inverse(std::vector< std::vector<int> > arr) { std::vector< std::vector<int> > inv; inv.resize(arr[0].size(), std::vector<int>(arr.size(), 0)); for (int i = 0; i < arr.size(); i++) for (int j = 0; j < arr[0].size(); j++) [instruction] | Implement a function in C++ to return the inverse of a given 2-D array. [input] | [[1, 2], [3, 4]]

[output] | public static boolean checkSum(int num1, int num2) { if((num1 + num2) > (2 * num2)) return true; else return false; } [instruction] | Create a function in Java to check if the sum of two given numbers is greater than two times the second number. [input] | num1 = 6, num2 = 7

[output] | #!/bin/sh ls -al /path/to/folder [instruction] | Write a shell script to list the contents of a given folder. [input] | /path/to/folder

[output] | def factorial(n): if n == 0: return 1 return n * factorial(n-1) [instruction] | How would you create a function to calculate factorial of a given number in Python? [input] |

[output] | The following program writes "Hello World!" to the screen. [instruction] | Delete all comments that start with the string '#' from the given text. [input] | The following program writes "Hello World!" to the screen. # This is a comment

[output] | The best way to format a large number is to add separator characters such as comma, underscore, period or space. This makes it easier to read and understand the large number. [instruction] | What is the best way to format a large number such that it is easy to read? [input] |

[output] | def power(n, x): if x == 0: return 1 return n * power(n, x-1) [instruction] | Create a function to raise a given number to the Nth power. [input] |

[output] | 31 days. [instruction] | Print the number of days in the month of January 2021. [input] |

[output] | for i in range(1, 101): print(i**2) [instruction] | Create a program to output the squares of all numbers between 1 and 100. [input] |

[output] | You can set up a yaml list with a specific size by declaring the list and adding the required number of elements to it, like so: my_list: - Element 1 - Element 2 - Element 3 - Element 4 [instruction] | How do you set up a yaml list with a specific size? [input] |

[output] | The prime numbers between 8 and 20 are 11, 13, 17, 19 [instruction] | Generate prime numbers between two given numbers [input] | start = 8 end = 20

[output] | The two parts of the list will be [1, 2, 3, 4] and [5, 6]. [instruction] | Split a list into two parts [input] | mylist = [1, 2, 3, 4, 5, 6]

[output] | h1 { color: CornflowerBlue; font-size: 22px; } [instruction] | Edit the following CSS code to make all text in an <H1> tag have a font size of 22 pixels. [input] | h1 { color: CornflowerBlue; font-size: 20px; }

[output] | <!DOCTYPE html> <html> <head> <title>Login</title> </head> <body> <div> <h1>Login</h1> <form id="loginForm" action="" method="post"> <label>Username:</label> <input type="text" name="username" required/> <label>Password:</label> <input type=" [instruction] | Generate HTML code to create a login page with a username and password field. [input] |

[output] | SELECT * FROM books WHERE title LIKE '%Ember%'; [instruction] | Create a SQL query to return every column from a table named 'books' where the title includes the word 'Ember'. [input] |

[output] | <p style="text-align: center;">This is some text.</p> <p style="text-align: center;">Some more text.</p> [instruction] | Edit the following HTML code so the inner text of all the <p> tags is centered. [input] | <p>This is some text.</p> <p>Some more text.</p>

[output] | <button type="submit">Submit</button> [instruction] | Generate HTML code to create a button with the text "Submit". [input] |

[output] | let arr = [5, 12, 7, 23, 10]; let evenNumbers = arr.filter(num => num % 2 == 0); [instruction] | Edit the following JavaScript code to create an array of only the even numbers from the given array. [input] | [5, 12, 7, 23, 10]

[output] | SELECT * FROM users WHERE firstname = 'John'; [instruction] | Write a SQL query to select everyone from the table named 'users' with the first name equal to 'John'. [input] |

[output] | a { font-size: 16px; color: #efefef; background-color: #237ac2; } [instruction] | Edit the following CSS code to make the background color of all <a> tags equal to '#237ac2'. [input] | a { font-size: 16px; color: #efefef; }

[output] | def insertionSort(arr): for i in range(1, len(arr)): temp = arr[i] j = i - 1 while j >= 0 and temp < arr[j]: arr[j + 1] = arr[j] j -= 1 arr[j + 1] = temp [instruction] | Extend the following code to ensure that the array of numbers is sorted using insertion sort. [input] | arr = [9, 5, 7, 3]

[output] | A hash table is a data structure that is used to store key-value pairs. It allows efficient insertion, retrieval, and deletion of items by using a hash function to map keys to values. Hash tables are typically used for faster lookups, and they can be used to implement associative arrays, symbolic di [instruction] | Describe the purpose of a hash table. [input] |

[output] | function findMax(nums) { return nums.reduce((currentMax, num) => num > currentMax ? num : currentMax, 0); } [instruction] | Rewrite the following JavaScript function to be more concise. [input] | function findMax(nums) { let currentMax = 0; for (let i = 0; i < nums.length; i++) { if (nums[i] > currentMax) currentMax = nums[i]; } return currentMax; }

[output] | def find_maximum(lst): max_value = float('-inf') for i in lst: if i > max_value: max_value = i return max_value print(find_maximum(lst)) [instruction] | Debug the following code snippet in Python to find the maximum number accross a list of integers. [input] | lst = [-1, 5, 10, 0, -9]

[output] | function findCommonElements(arr1, arr2) { const commonElements = []; arr1.forEach(num => { if(arr2.includes(num)) { commonElements.push(num); } }); return commonElements; } console.log(findCommonElements([1,7,9], [2,7,8])) [instruction] | Write an algorithm in JavaScript for finding all common elements between two given integer arrays. [input] | [1,7,9] and [2,7,8]

[output] | import re regex = re.compile('[1-9]|[1-9][0-9]|100') [instruction] | Create a regex expression in Python that finds all numbers from 1 to 100 inclusive. [input] |

[output] | public class Rectangle { int length; int width; public Rectangle(int length, int width) { this.length = length; this.width = width; } public int calculateArea() { return this.length * this.width; } } [instruction] | Create a class in Java for representing a Rectangle that stores length and width attributes and a method to calculate its area. [input] |

[output] | SELECT COUNT(*) FROM employees WHERE name = 'John'; [instruction] | Create a SQL query to find the number of employees with the same name as the given name 'John'. [input] |

[output] | int[] randNums = new int[10]; Random rand = new Random(); for(int i = 0; i < randNums.length; i++) { randNums[i] = rand.nextInt(50) + 1; } [instruction] | Write a Java code snippet for creating an array with 10 random numbers between 1 and 50. [input] |

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