← 목록

Synth · CodeAlpaca일부

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

[output] | static int Fibonacci(int a) { if (a <= 1) return a; return Fibonacci(a - 1) + Fibonacci(a - 2); } [instruction] | Develop an algorithm in Java to compute the Fibonacci sequence [input] |

[output] | CREATE OR REPLACE PROCEDURE delete_employees_table() AS BEGIN DROP TABLE Employees; END; [instruction] | Create a procedure in PostgreSQL to delete a table [input] | Table name: Employees

[output] | int power(int k, int n) { int result = 1; while (n > 0) { result *= k; n--; } return result; } [instruction] | Compose a function in C to display the result of raising a number to a positive power [input] |

[output] | void bubbleSort(int arr[], int n) { for (int i = 0; i < n-1; i++) for (int j = 0; j < n-i-1; j++) if (arr[j] > arr[j+1]) swap(arr[j], arr[j+1]); } [instruction] | Generate code in C++ for performing Bubble Sort [input] |

[output] | def reverse_array(arr): """ Construct a new array with the elements reversed. """ new_arr = [] for i in range(len(arr)-1, -1, -1): new_arr.append(arr[i]) return new_arr [instruction] | Write a code to construct a new array with the elements reversed. [input] | arr = [1, 2, 3, 4, 5]

[output] | def sort_by_length(arr): """ Sort a list by the reverse order of its length. """ arr.sort(key=len, reverse=True) return arr [instruction] | Create a function that takes in a list and sorts by the reverse order of its length. [input] | [“hi”, “hello”, “hey”, “hola”]

[output] | def check_even_odd(num): """ Takes a number and checks if it is even or odd. """ if num % 2 == 0: return "even" else: return "odd" [instruction] | Create a function that takes a number and checks if it is even or odd. [input] |

[output] | \([0-9]{3}\) [0-9]{3}\-[0-9]{4} [instruction] | Write a regular expression that matches a phone number with the format (999) 999-9999 [input] |

[output] | import numpy as np np.random.seed(0) nums=np.random.rand(N,M) print(nums) [instruction] | Write a Python program to output an array with dimensions [N, M] filled with random numbers between 0 and 1 [input] | N = 5 M = 4

[output] | for i in range(1, 51): if i%2 == 1: print(i) [instruction] | Write a Python program to print the Odd numbers from 1 to 50. [input] |

[output] | def replace_value(mylist, old_value, new_value): if old_value in mylist: mylist[mylist.index(old_value)] = new_value return mylist [instruction] | Write a Python function to edit a given list by replacing an existing element with a new value. [input] | mylist = ["Apple", "Banana", "Cherry"] old_value = "Banana" new_value = "Strawberry"

[output] | import math def calculate_hypotenuse(side1, side2): hypotenuse = math.sqrt(side1**2 + side2**2) return hypotenuse [instruction] | Write a Python function to calculate the hypotenuse of a right angled triangle given the length of the two sides. [input] | side1 = 7 side2 = 5

[output] | def sum_of_integers(num): total = 0 for i in range(1, num + 1): total += i return total [instruction] | Write a Python program to calculate the sum of all integers up to the given number. [input] |

[output] | for i in range(1, 11): for j in range(1, 11): print(i*j, end=" ") print() [instruction] | Write a Python code to print the multiplication table upto 10. [input] |

[output] | Growing Rich Girl [instruction] | Input a scene (description) of a movie and output a title for the movie in 4 words or less. [input] | A young girl who comes from a rich family goes on a journey of self-discovery

[output] | /^([A-Z][a-z]*\s[A-Z][a-z]*)$/ [instruction] | Create a regex expression to capture a full name from a string. [input] | John Smith

[output] | """ Function to search an array of objects by any parameter """ const searchArray = (arr, key, value) => { return arr.find((obj) => obj[key] === value) } const searchedName = searchArray(people, 'name', 'John') console.log(searchedName) // {name: 'John', age: 19} [instruction] | Write a code that allows a user to search a array of objects by any parameter. [input] | const people = [ {name: 'John', age: 19}, {name: 'Mark', age: 20}, {name: 'Bob', age: 21} ]

[output] | const position = haystack.indexOf(needle) console.log(position) // 15 [instruction] | Find the position of a string within another string. [input] | haystack = "This is a sample string with the word 'sample' in it" needle = "sample"

[output] | """ Basic class in JavaScript with a constructor, a method for changing the greeting and a method for saying the greeting """ class GreetingGenerator { constructor(greeting) { this.greeting = greeting } setGreeting(greeting) { this.greeting = greeting } sayGreeting() { conso [instruction] | Create a basic class in JavaScript that includes a constructor, a method for changing the greeting, and a method for saying the greeting. [input] |

[output] | """ Function rotate array to the right by k steps """ const rotateArray = (arr, k) => { let rotatedArray = [...arr] // Create a shallow copy of the array for (let i = 0; i < k; i++) { let lastElement = rotatedArray.pop() rotatedArray.unshift(lastElement) } return rotatedArray } co [instruction] | Create a code to rotate an array to the right by k steps. [input] | arr = [1,2,3,4,5], k = 3

[output] | """ Function to count the total number of digit only divisors of n """ const countDivisors = (n) => { let count = 0 for (let i = 1; i <= n; i++) { let divisor = true let num = i while (num) { let digit = num % 10 if (!(n % digit === 0)) { divisor = false [instruction] | Given a number n, count the total number of digit only divisors of n. [input] | n = 100

[output] | """ Function to find the shortest possible palindrome """ const findShortestPalindrome = (string) => { let reversedString = string.split('').reverse().join('') let newString = string + '#' + reversedString let lps = [] let i = 1 let j = 0 while (i < newString.length) { if (newString [instruction] | Write a code to find the shortest possible palindrome. [input] | string = 'race'

[output] | """ Function to identify whether a given number is a power of two """ const isPowerOfTwo = (num) => { let i = 0 while (2 ** i <= num) { if (2 ** i === num) { return true } i++ } return false } console.log(isPowerOfTwo(num)) // true [instruction] | Create a function to identify whether a given number is a power of two. [input] | num = 8

[output] | def filter_words_with_letter_a(words): filtered_words = [] for word in words: if 'a' in word: filtered_words.append(word) return filtered_words words = ['apple', 'book', 'zebra', 'banana', 'ball'] result = filter_words_with_letter_a(words) print(result) [instruction] | Write a code to filter out all the words from a input list of strings, containing the letter 'a'. [input] | words = ['apple', 'book', 'zebra', 'banana', 'ball']

[output] | def categorize_number_divisibility(number, divisible_number): if number % divisible_number == 0: return 'divisible' else: return 'not divisible' number = 9 divisible_number = 3 result = categorize_number_divisibility(number, divisible_number) print(result) [instruction] | Write a code to categorize the given number according to their divisibility by a certain number. [input] | number = 9 divisible_number = 3

[output] | name = “Alice” print(name) name = "Alice" [instruction] | Edit the code below so that the variable 'name' cannot be modified after the first print statement. [input] | name = “Alice” print(name) name = “Bob”

[output] | .info li { border: 2px solid red; } [instruction] | Write a CSS code snippet to add a red border to all list items on a web page with class “info”. [input] |

[output] | SELECT COUNT(Order_ID) AS Total_Orders FROM Orders WHERE Cust_Country="USA" [instruction] | Using the data provided, create a SQL command to get the total number of orders from customers in the USA. [input] | Table name: "Orders" Columns: "Cust_ID", "Cust_Country", "Order_ID"

[output] | $('p.warning').select(); [instruction] | Write a jQuery code snippet to select all paragraphs which have a class “warning”. [input] |

[output] | <form action='/post_input1_value' method='POST'> New Value: <input type="text" name="input1"> <input type="submit" value="Enter New Value"> </form> [instruction] | Create a HTML form to enter a “new value” into the field named “input1”. [input] |

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