← 목록

Synth · CodeAlpaca일부

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

[output] | We can use a two pointer approach to traverse the string and compare the leftmost and rightmost characters. If the characters are not equal, then the string cannot be a palindrome. We can move the left pointer one character to the right, and move the right pointer one character to the left, and comp [instruction] | Design an algorithm to check if a given string can be converted to a palindrome. [input] |

[output] | One popular supervised machine learning algorithm is the Support Vector Machine (SVM). It uses labelled data points to infer the best decision boundary between different classes. It uses an optimization function to maximize the margin between the support vectors (data points) and the decision bounda [instruction] | Describe a machine learning algorithm that uses supervised learning. [input] |

[output] | The maximum sum of any subarray of a given array of integers can be found with the Kadane's algorithm. This algorithm works by keeping track of the maximum sum seen so far and the current sum running. Whenever the current sum running is negative, the current sum running is reset to 0 and the maximum [instruction] | You are given an array of integers and you need to find the maximum sum of any subarray of the given array. [input] |

[output] | The binary search tree can be traversed in a depth-first manner to search for the target element in a time complexity of O(log n), where n is the number of nodes in the binary search tree. In a depth-first search, the target node is compared with each node in the tree and if it does not match, the l [instruction] | Suggest a way to search for a target element in a binary search tree in less than O(n) time. [input] |

[output] | We can use a recursive approach to compare two binary trees. We can start by a root node comparison and if the values of the two root nodes are not equal, the trees are not equivalent. Otherwise, we can move on to compare the left subtree and the right subtree of each tree for equality. To do so, we [instruction] | Design an algorithm to check if two given binary trees are identical. [input] |

[output] | def sort_list_of_tuples(my_list): my_list.sort(key=lambda x: x[0]) return my_list [instruction] | Design a function in Python to sort a list of tuples based on the first element. [input] |

[output] | ["Hello World", "Wonderful Day"] [instruction] | Format the strings given in the list so that only the first letter of each word is in upper case. [input] | ["Hello world", "Wonderful DAY"]

[output] | def sum_dict_values(mydict): ans = 0 for key,val in mydict.items(): ans += val return ans [instruction] | Write a function to sum values stored in a dictonary using for loop. [input] | mydict = {‘a’:1, ‘b’:2, ‘c’:3}

[output] | <table> <tr> <th>Name</th> <th>Age</th> </tr> <tr> <td>Alice</td> <td>20</td> </tr> <tr> <td>Bob</td> <td>30</td> </tr> <tr> <td>Eve</td> <td>40</td> </tr> </table> [instruction] | Create an HTML table with two columns called "Name" and "Age", and three rows, with the name and age of Alice, Bob and Eve. [input] |

[output] | body { font-color: blue; } [instruction] | Create a CSS class to make all the text in the body of the page blue. [input] |

[output] | INSERT INTO users (name, email, age) VALUES ('John', 'john@example.com', 28); [instruction] | Write a MySQL query to insert values into a table called 'users' with three columns: 'name', 'email', and 'age'. [input] | name: John, email: john@example.com, age: 28

[output] | import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; @Injectable() export class DataService { constructor(private http: HttpClient) { } async getData() { const data = await this.http.get(address).toPromise(); console.log(data); } } [instruction] | Create an Angular 10 service to fetch data from a remote API and print the results to the console. [input] | address: 'www.example.com/api/v1/data'.

[output] | import React from 'react'; export default function Form() { return ( <form> <input type="text" /> <input type="submit" value="Submit" /> </form> ); } [instruction] | Create a React component which renders an input box and a submit button. [input] |

[output] | <div class="progress"> <div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div> </div> [instruction] | Generate code to display a progress bar in HTML. [input] |

[output] | class Validation { func validate(value: Int) -> Bool { return value > 10 } } [instruction] | Create a Swift class with a method named 'validate' which returns true if the given value is greater than 10 and false otherwise. [input] |

[output] | int[] sorted = nums.OrderBy(n => n).ToArray(); [instruction] | Create a C# program to sort a given array of integers. [input] | int[] nums = {8, 5, 1, 3, 9};

[output] | fetch(url) .then(response => { return response.json() }).then(data => { console.log(data); }); [instruction] | Generate code to call an API and print the results using JavaScript. [input] | url: 'www.example.com/api/v1/data'

[output] | <input type="number"> [instruction] | Using HTML, create an input field that stores an integer. [input] |

[output] | String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; StringBuilder randomString = new StringBuilder(); Random rand = new Random(); for (int i = 0; i < 1000; i++){ int randIndex = rand.nextInt(chars.length()); randomString.append(chars.charAt(randIndex)); } String result = randomString.toString() [instruction] | Use Java to generate a string containing 1000 random characters of length 10. [input] |

[output] | div { background-color: blue; } [instruction] | Using CSS, modify the background color of a div. [input] |

[output] | <form> <label for="password">Password: </label> <input type="password" id="password" name="password" maxlength="8"> </form> [instruction] | Create an HTML form element to store a password with a validation of maximum 8 characters. [input] |

[output] | import random def random_num_gen(start, end): random_nums = [] for _ in range(start, end + 1): random_nums.append(random.randint(1, 10)) return random_nums [instruction] | Create a Python script to generate random numbers from 1 to 10 in a given range. [input] |

[output] | <select> <option>Option 1</option> <option>Option 2</option> <option>Option 3</option> <option>Option 4</option> <option>Option 5</option> </select> [instruction] | Using HTML, create a select option field with five given options. [input] | Options: Option 1, Option 2, Option 3, Option 4, Option 5

[output] | <input type="text" pattern="^#([A-Fa-f0–9]{6}|[A-Fa-f0–9]{3})$"> [instruction] | Using JavaScript, create an input field to store a hexadecimal value. [input] |

[output] | public class TryAgain { public static void main (String[] args) { int x = 4; System.out.println("Can you try again?"); } } [instruction] | Debug the following Java program to get the output "Can you try again? [input] | public class TryAgain { public static void main (String[] args) { x = 4; System.out.println(x = 4); } }

[output] | SELECT SUM(amount) FROM table_name; [instruction] | Create an SQL query to sum all values in the "amount" column. [input] |

[output] | function checkVowels(str) { const sortedVowels = 'aeiou'.split('').sort().join(''); const sortedStr = str .toLowerCase() .split('') .filter(letter => ['a','e','i','o','u'].includes(letter)) .sort() .join(''); return sortedVowels === sortedStr; } [instruction] | Write a JavaScript function to check whether a string contains all the vowels in alphabetical order. [input] |

[output] | import re def extract_urls(strings): urls = [] for s in strings: urls += re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', s) return urls [instruction] | Create a Python program to extract the URLs from a given list of strings. [input] | ['https://stackoverflow.com/questions/42063887/how-to-extract-urls-from-a-list-of-strings-in-python', 'This is an example of a string without a URL']

[output] | public static boolean isPowerOfTwo(int n) { return (n > 0) && ((n & (n - 1)) == 0); } [instruction] | Check if an integer is a power of two. [input] |

[output] | for x in range(5): print(x) [instruction] | Change the following code to use for-loops instead of while-loops. [input] | x = 0 while x < 5: print(x) x += 1

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