← 목록

Synth · CodeAlpaca일부

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

[output] | The string method is called indexOf() [instruction] | Name the string method that searches a string for a specified value and returns the position of the match. [input] |

[output] | public string Roman_Number(int number) { string roman = ""; int[] coefficients = new int[]{1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1}; string[] numerals = new string[]{"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"}; for (int i = 0; i < coefficients.Length; i++ [instruction] | Rewrite the following code using C# with the same output. [input] | def roman_number(number): roman = '' coefficients = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1] numerals = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"] for i in range(len(coefficients)): while number >= coefficients[i]: number -= coefficie

[output] | Block level elements: <div>, <h1> Inline level elements: <ul>,<span> Grouping elements: <ul> Text level elements: <span> [instruction] | Classify the following collection of HTML tags into four categories. [input] | <ul>, <div>, <span>, <h1>

[output] | <App title="My App" /> [instruction] | Suggest an appropriate input for the following ReactJS program to display the provided output. [input] | import React from 'react'; const App = (props) => { return ( <div> {props.title} </div> ) } ​ Output: My App

[output] | int [instruction] | Suggest an appropriate return data type of the following function that takes an integer array as input. [input] | def find_max(arr):

[output] | def all_upper(s): return s.isupper() [instruction] | Create a python function that takes a string as input and returns a boolean if the string contains only upper case letters. [input] |

[output] | SELECT MAX(amount) AS max_amount, MIN(amount) AS min_amount FROM transactions; [instruction] | Write an SQL query to display the maximum and minimum values of the "amount" column from the following table. [input] | transactions columns: id, user_id, amount

[output] | SELECT * FROM users LIMIT 5; [instruction] | Create an SQL Query to display the first 5 records from the following table. [input] | users columns: id, username, email

[output] | <style> table{ border-collapse: collapse; width: 100%; } th { text-align: left; background-color: darkgray; padding: 8px; } td { background-color: whitesmoke; padding: 8px; } </style> <table> <tr> <th>Name</th> <th>Age</th> </tr> <tr> [instruction] | Rewrite the following HTML table using CSS. [input] | <table> <tr> <th>Name</th> <th>Age</th> </tr> <tr> <td>John</td> <td>20</td> </tr> </table>

[output] | function validateEmail(email) { const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); } [instruction] | Create a JavaScript function to validate an email address with the following conditions. [input] |

[output] | def is_power_of_3(num): if num == 1: return True elif num % 3 != 0: return False else: return is_power_of_3(num / 3) [instruction] | Create code to check if the number is a power of three. [input] | num = 8

[output] | def reverseStr(str): revStr = "" i = len(str) - 1 while i >= 0: revStr += str[i] i = i - 1 return revStr [instruction] | Design a program to reverse a string without using the built-in 'reverse' method. [input] | string = "Hello World"

[output] | def sumCubes(arr): sum = 0 for i in arr: sum += i**3 return sum [instruction] | Create a method to calculate the sum of the cubes of the elements in an array. [input] | arr = [1,2,3,4]

[output] | def changeCase(string): return string.swapcase() [instruction] | Produce a code to change the case of a given string. [input] | string = "Hello World"

[output] | def deleteNode(head, node): # If head node itself holds the data to be deleted if (head == node): head = node.next # Find the previous node prev = None curr = head while (curr.data != node.data): prev = curr curr = curr.next # Unlin [instruction] | Develop an algorithm to delete a given node from a linked list. [input] | Node 3 in the list {1->2->3->4->5}

[output] | def insertAtPos(head, pos, data): if head is None: return else: temp = head newNode = Node(data) count = 0 while (count < pos-1) : temp = temp.next count += 1 newNode.next = temp.next temp.next = newNode [instruction] | Create a code to insert an item in a given position in a linked list. [input] | Insert "Hello" at position 2 in the list {1->2->3->4->5}

[output] | def substrings(string): substrings_list = [] for i in range(len(string)+1): for j in range(i+1, len(string)+1): substrings_list.append(string[i:j]) return substrings_list [instruction] | Write a function that takes a string as an input and returns a list of all the substring of the given string. [input] | string = "hello"

[output] | def remove_greater_than_10(numbers): return [x for x in numbers if x <= 10] [instruction] | Take a list of numbers and remove the numbers that are greater than 10. [input] | numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]

[output] | def count_a(string): count = 0 for char in string: if char == 'a': count += 1 return count [instruction] | Wirte a function that takes a string as input and returns the number of times the character 'a' appears in it. [input] | string = "abacadaba"

[output] | class Animal: def __init__(self, name, age): self.name = name self.age = age [instruction] | Modify the code to add a class called Animal that accepts a name and an age as arguments. [input] | class Animal:

[output] | def remove_duplicates(objects): new_list = [] for obj in objects: if obj not in new_list: new_list.append(obj) return new_list [instruction] | Take a list of objects as input and return a list with removed duplicates. [input] | objects = [1, 2, 3, 4, 5, 1, 2, 3]

[output] | def string_to_int(string): return int(string) [instruction] | Write a function that takes a numerical string as input and returns an integer. [input] | string = "12345"

[output] | boolean checkLogin(String username, String password) { boolean success = false; if(username.equals("admin") && password.equals("admin")) { success = true; } return success; } [instruction] | Create a basic log in security system in Java [input] |

[output] | for(var i = 2; i <= 50; i++) { var isPrime = true; for(var j = 2; j < i; j++) { if(i % j == 0) { isPrime = false; } } if(isPrime) { console.log(i); } } [instruction] | Generate a JavaScript solution to print all prime numbers between 1 and 50. [input] |

[output] | // Create a Hash Table let hashTable = {}; // Create a hash function function createHash(str) { for (let i = 0; i < str.length; i++) { // Assign a unique number to each character present in the string hashTable[str.charAt(i)] = i; } // Return the hash table r [instruction] | Create a hash function that assigns a unique number to each character of the input string. [input] | Hello World

[output] | function encryptCaesarCipher(str, key) { let encryptedStr = ""; for (i = 0; i < str.length; i++) { let charCode = str.charCodeAt(i); let encryptedCharCode = charCode + key; let encryptedChar = String.fromCharCode(encryptedCharCode); encryptedStr += encryptedChar; } return enc [instruction] | Design a function that encrypts a string using the Caesar Cipher [input] | Hello World

[output] | function maxFrequencyChar(str) { let maxChar = ''; let maxFrequency = 0; let hashTable = {}; for(let char of str) { if (hashTable[char]) { hashTable[char] += 1; } else { hashTable[char] = 1; } } for(let char in hashTable) { if(hashTable[char] > maxFrequenc [instruction] | Determine the most frequent character in the provided string [input] | Hello World

[output] | import requests url = "https://api.example.com/v1/search" response = requests.get(url) data = response.json() print(data) [instruction] | Fetch data from the internet using an API call in Python [input] | "https://api.example.com/v1/search"

[output] | def reverse_list(list): mid = len(list)//2 for i in range(mid): tmp = list[i] list[i] = list[len(list)-i-1] list[len(list)-i-1]=tmp return list [instruction] | Rewrite this function to reverse the order of the elements in the array. [input] | list = [1,2,3,4,5]

[output] | def list_length(head): count = 0 while head is not None: count += 1 head = head.next return count [instruction] | Create a function that calculates the length of a linked list. [input] | Linked List: 10 -> 20 -> 30 -> 40 -> 50

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