← 목록

Synth · CodeAlpaca일부

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

[output] | sample_dict = {"a":1, "b":2, "c": 3} def get_key_highest_value(dict): highest_value = max(dict.values()) for key, value in dict.items(): if value == highest_value: return key [instruction] | Update the following code to return the key of the highest value in the dictionary. [input] | sample_dict = {"a":1, "b":2, "c": 3}

[output] | SELECT name FROM employees ORDER BY salary DESC LIMIT 1; [instruction] | Write a query in SQL to find the name of the employee with the largest salary. [input] | TABLE employees ( name TEXT, salary INTEGER )

[output] | #include <iostream> #include <string> int main() { std::string comment; // Read data from the "Comments" column in the "Users" table std::cin >> comment; std::cout << comment << std::endl; return 0; } [instruction] | Modify the program to read data from the column 'Comments' in the table 'Users' [input] | #include <iostream> int main() { std::cout << "Hello, World!" << std::endl; return 0; }

[output] | [30, 12, 5, 17, 11] [instruction] | Rearrange the array so each element is divisible by 3 [input] | [5,12,17,30,11]

[output] | <html> <head> <title>Hello World!</title> <style> body { background-color: yellow; padding: 10px; } </style> </head> <body> <p>Hello World!</p> </body> </html> [instruction] | Generate a valid HTML page with the following styles and content [input] | background color: yellow; padding: 10px; Content: "Hello World!"

[output] | <p>Hello <strong>World</strong>!</p> [instruction] | Add some markup to the following text [input] | Hello World!

[output] | switch (input) { case "5": System.out.println("Input is 5"); break; default: System.out.println("No match"); break; } [instruction] | Create a switch statement to provide different output depending on the given input [input] | Input: "5"

[output] | def check_divisible(arr): arr.sort() for i in range(len(arr)): for j in range(i+1, len(arr)): if (arr[i] + arr[j]) % 10 == 0: return True return False [instruction] | Implement a computationally efficient algorithm to solve the following problem [input] | Given an array of integers, check if the sum of any two integers in the array is divisible by 10

[output] | def double_array(arr): doubled_arr = [] for i in arr: doubled_arr.append(i*2) return doubled_arr [instruction] | Given an array of integers, return an array of twice the values [input] | arr = [1, 2, 3, 4]

[output] | Odd, Even, Even [instruction] | Classify these numbers as even or odd [input] | 21, 2, 8

[output] | """ Define a function which can generate a list of 15 random numbers between 1 to 30 """ import random def generate_random_list(): return [random.randint(1,30) for _ in range(15)] if __name__ == '__main__': print(generate_random_list()) [instruction] | Define a function which can generate a list of 15 random numbers between 1 to 30. [input] |

[output] | def twoSum(nums, target): numDict = dict() for index, num in enumerate(nums): if num in numDict.keys(): return [numDict[num], index] else: numDict[target-num] = index [instruction] | Find a Python solution for this leetcode problem. [input] | Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice.

[output] | pattern = r'\d{3}-\d{3}-\d{4}|\(\d{3}\)\s\d{3}-\d{4}|\d{10}|\d{3}\s\d{3}\s\d{4}' [instruction] | Create a regex pattern to extract all phone numbers from a given string. [input] |

[output] | def coinChange(coins, amount): dp = [float("inf")] * (amount + 1) dp[0] = 0 for coin in coins: for x in range(coin, amount + 1): dp[x] = min(dp[x], dp[x - coin] + 1) if dp[amount] == float("inf"): return -1 return dp[amount] [instruction] | Write code to solve this DP(Dynamic Programming) problem from LeetCode. [input] | You are given coins of different denominations and a total amount of money. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.

[output] | def binary_search(array, target): low = 0 high = len(array)-1 while low <= high: mid = (low+high)//2 if array[mid] == target: return mid elif array[mid] < target: low = mid+1 else: high = mid-1 return -1 # target not found [instruction] | Improve the following implementation of a binary search algorithm. [input] | def binary_search(array, target): low = 0 high = len(array)-1 while low <= high: mid = (low+high)//2 if array[mid] == target: return mid elif array[mid] < target: low = mid+1 else: high = mid-1

[output] | def doubleInt(num): return num * 2 [instruction] | Write a function that takes an integer and doubles it. [input] |

[output] | myCar = Car("red", 50) [instruction] | Create an object of class 'Car' with attributes 'color' and 'speed'. [input] |

[output] | for i in range(1, 11): if i%2 != 0: print(i) # Output: 1, 3, 5, 7, 9 [instruction] | Using the "for" loop, print out all odd numbers from 1 to 10. [input] |

[output] | import random arr = [] for _ in range(10): elem = random.randint(1,10) arr.append(elem) print(arr) [instruction] | Create an array of size 10, initialize the array elements with random values between 1 to 10. [input] |

[output] | @GET @Path("/helloWorld") @Produces(MediaType.TEXT_PLAIN) public String getHelloWorldString() { return "Hello world"; } [instruction] | Return the string "Hello world" as a response from a web service written in Java. [input] |

[output] | def longest_strings(str_list): longest_str = [] for s in str_list: if len(s) == max(map(len, str_list)): longest_str.append(s) return longest_str print(longest_strings(["Hello", "world", "This", "is", "a", "sentence"])) # Output: ["Hello", "world", "sentence"] [instruction] | Given a list of strings, return a new list with the longest strings. [input] | str_list = ["Hello", "world", "This", "is", "a", "sentence"]

[output] | import pandas as pd [instruction] | Import the pandas library in Python. [input] |

[output] | A set is the ideal data structure to store a set of strings. It is a collection of unique values and can store any primitive data types. No duplicates are allowed in a set and it is also unordered, meaning it does not keep track of the order in which items were added. [instruction] | What data structure should be used to store a set of strings? [input] |

[output] | The break statement is often used to terminate a loop prematurely if a certain condition is met. This can provide an efficient way to end a loop when a condition is found and can help improve the readability and performance of the code. Additionally, it can be used to handle any exceptions that may [instruction] | What are the benefits of using the break statement in a loop? [input] |

[output] | { "firstName": "jane", "lastName": "doe", "email": "jane.doe@gmail.com" } [instruction] | Generate a JSON response from the following Java object. [input] | User user = new User("jane", "doe", "jane.doe@gmail.com");

[output] | git clone https://github.com/username/my-project.git [instruction] | Create Git commands to clone a remote repository called “my-project”. [input] |

[output] | SELECT * FROM users WHERE age > 25; [instruction] | Create a MySQL query to display all users in the “users” table who are over the age of 25. [input] |

[output] | Sum of squares of all numbers from 1 to 5 is 55 (1^2 + 2^2 + 3^2 + 4^2 +5^2). [instruction] | Generate a sum of square numbers from 1 to 5. [input] |

[output] | <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet"> <title>My First Web Page</title> <style> body { font-family: 'Roboto', sans-serif; } </style> </head> <body> </body> </html> [instruction] | Edit this HTML code to add the Google Font “Roboto”. [input] | <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>My First Web Page</title> </head> <body> </body> </html>

[output] | SELECT * FROM users WHERE lastName = 'Smith'; [instruction] | Create a SQL query to find all users from the “users” table who have a last name of “Smith”. [input] |

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