← 목록

Synth · CodeAlpaca일부

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

[output] | <a href="https://www.hackerrank.com" target="_blank">Go to HackerRank</a> [instruction] | Create a HTML link with the following description [input] | Go to HackerRank

[output] | public class Multiples { public static void main(String[] args) { int number = 5; for (int i = 1; i <= 10; i++) { System.out.println(number*i); } } } [instruction] | Implement a Java code to print the first 10 multiples of a given number [input] |

[output] | SELECT DISTINCT * FROM Employees; [instruction] | Write a SQL query that returns all the distinct values in a given table. [input] | table: Employees

[output] | <ul> <li>apple</li> <li>orange</li> <li>banana</li> <li>strawberry</li> </ul> [instruction] | Write an HTML code to show all the items in a given list. [input] | list: ["apple", "orange", "banana", "strawberry"]

[output] | p { margin-bottom: 2em; } [instruction] | Write a CSS code to add a space between two paragraphs. [input] | <p>This is the first paragraph.</p> <p>This is the second paragraph.</p>

[output] | #include <iostream> using namespace std; int main() { int n = 100; int a = 0, b = 1, c; cout << a << " " << b << " "; for (int i = 2; i < n; i++) { c = a + b; cout << c << " "; a = b; b = c; } return 0; } [instruction] | Write a C++ code to generate the Fibonacci sequence from 0 to 100. [input] |

[output] | int compareToFindSmallest(int[] numbers, int targetIndex) { int smallestIndex = 0; for (int i = 1; i < numbers.length; i++) { if (numbers[i] < numbers[smallestIndex]) { smallestIndex = i; } } int tempIndex = smallestIndex; int resultIndex = -1; [instruction] | Find the fifth smallest number in a list of numbers using Java. [input] | list of numbers: [23, 12, 15, 7, 34, 19]

[output] | function MyObject(x, y, z) { this.x = x; this.y = y; this.z = z; } [instruction] | Create a constructor in JavaScript that will assign a value to an object's properties. [input] | properties: x, y, z

[output] | class AverageCalculator: def __init__(self, numbers): self.numbers = numbers def calculate_average(self): total = 0 for item in self.numbers: total += item return total / len(self.numbers) [instruction] | Create a class in Python that takes a list of numbers and finds the average. [input] | list: [4, 5, 6]

[output] | package main func reverseWords(sentence string) string { words := strings.Split(sentence, " ") var reversedSentence string for i:=len(words)-1; i>=0; i-- { reversedSentence += words[i] + " " } return strings.TrimSpace(reversedSentence) } [instruction] | Write a code in Go that will reverse all the words in a sentence. [input] | sentence: "GPT is a powerful tool"

[output] | class UserController < ApplicationController def index @users = User.all render json: @users end end [instruction] | Create a Rails controller that can render a JSON response for a given URL. [input] | URL: /user

[output] | $("#name").val("John Doe"); [instruction] | Use jquery to dynamically select an element of a given HTML form and change its value. [input] | Form element: input with id="name"

[output] | @Component({ selector: 'app-hello-world', template: ` <p>{{ message }}</p> <button>Show Message</button> ` }) export class HelloWorldComponent { message = "Hello World"; } [instruction] | Create an Angular component to display a message and a button. [input] | message: "Hello World"

[output] | def split_array(arr): n = len(arr) mid = n//2 left_half = arr[:mid] right_half = arr[mid:] return left_half, right_half [instruction] | Generate a code that takes an array of integers and splits them into two equal halves [input] | arr = [1, 2, 3, 4, 5, 6]

[output] | def strip_tags(s): tag = False out = "" for c in s: if c == "<": tag = True elif c == ">": tag = False elif not tag: out += c return out [instruction] | Design a function that takes a string of HTML tags in an input and removes the tags from the string [input] |

[output] | function sameLength(str1, str2) { if (str1.length == str2.length) { return true; } else { return false; } } [instruction] | Create a JavaScript program which takes two arguments as strings and returns true if they both have the same length [input] |

[output] | def common_elements(arr1, arr2): common = [] for i in arr1: if i in arr2: common.append(i) return common [instruction] | Write a code to print the common elements of two given arrays [input] | arr1 = [2, 3, 4, 5] arr2 = [3, 6, 7, 8]

[output] | def sentence_to_array(sentence):     return sentence.split(' ') [instruction] | Design a function that takes a sentence and returns an array with each word in the sentence as an element. [input] |

[output] | class Student: def __init__(self, name, age, grade): self.name = name self.age = age self.grade = grade [instruction] | Create a Python class named 'Student' that contains the name, age and grade of a student. [input] |

[output] | <table> <tr> <th>ID</th> <th>Name</th> <th>Email Address</th> <th>Phone Number</th> </tr> </table> [instruction] | Write an HTML table with four columns consisting of ID, name, email address and phone number. [input] |

[output] | function checkAnagram(string1, string2) { if(string1.length !== string2.length) { return false; } var charCounter1 = {}, charCounter2 = {}; for(var i = 0; i < string1.length; i++) { var char1 = string1[i]; var char2 = string2[i]; if(charCounter1[char1]) { charCounter [instruction] | Design a function in PHP that takes two strings as input and return true if the strings are an anagram of each other. [input] | string1 = “listen” string2 = “silent”

[output] | p:first-of-type { /* styles go here */ } [instruction] | Write a CSS selector for selecting the first paragraph in any web page. [input] |

[output] | .redBackground { background-color: red; } [instruction] | Create a CSS class for styling the background of any page red. [input] |

[output] | def traverseTree(root): if root != None: traverseTree(root.left) print(root.item) traverseTree(root.right) [instruction] | Write an algorithm to traverse a binary tree. [input] |

[output] | thisisastring [instruction] | Output a single string composed of all the characters of the given string, one after the other. [input] | This is a string

[output] | function genRandom2DArray(m, n){ let result = new Array(m); for (let i = 0; i < m; i++) { result[i] = new Array(n); for (let j = 0; j < n; j++) { result[i][j] = Math.floor(Math.random() * 6); } } return result; } [instruction] | Write a JavaScript code that randomly generates a 2D array of size m X n, wherein each element has a random value between 0 and 5. [input] |

[output] | public static int[] removeFromArray(int[] arr, int num){ int[] newArr = new int[arr.length]; int newIndex = 0; for(int i = 0; i < arr.length; i++){ if(arr[i] != num){ newArr[newIndex] = arr[i]; newIndex++; } } return Arrays.copyOfRange [instruction] | Create a function in Java to remove all the values equal to the given number from an array. [input] |

[output] | int calculateAverage(struct node* head) { if (head == NULL) return 0; int count = 0; int sum = 0; struct node* temp = head; while (temp != NULL){ sum += temp->data; temp = temp->next; count++; } return sum/count; } [instruction] | Create a program in C to calculate the average of nodes in the given linked list. [input] |

[output] | #!/bin/bash InputArray=(1 2 2 3 4 4 5) echo "Unique values in the array: " echo $(echo "${InputArray[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' ') [instruction] | Write a shell script to print the unique values from an array. [input] | [1, 2, 2, 3, 4, 4, 5]

[output] | def evenNumbers(m,n): evenNum=[] for i in range(m,n+1): if i%2 == 0: evenNum.append(i) return evenNum [instruction] | Output a list of all even numbers between two given positive integers m and n. [input] | m=2, n=10

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