← 목록

Synth · CodeAlpaca일부

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

[output] | def get_permutations(array): results = [] if len(array) == 0: return results if len(array) == 1: results.append([array[0]]) return results for i in range(len(array)): permutations = get_permutations(array[:i] + array[i+1:]) for permutation in permutations: results.app [instruction] | Print all possible combination and permutations with length 3 for a given array. [input] | [1, 2, 3]

[output] | class Calculator def multiply(a, b) return a * b end def add(a, b) return a + b end end [instruction] | Create a Ruby class that has two methods - one for calculating the result of multiplications and one for calculating the addition of two numbers. [input] |

[output] | SELECT * FROM users ORDER BY age DESC; [instruction] | Write a MySQL query to display the contents of the table "users" sorted in descending order by "age". [input] | Table name: users Fields: name, age

[output] | def fibonacci(n): if n <= 1: return n else: return fibonacci(n-1) + fibonacci(n-2) for i in range(1, n+1): print(fibonacci(i)) [instruction] | Design a function in Python to calculate the Fibonacci sequence up to a particular number. [input] |

[output] | The highest common factor of 8 and 12 is 4. [instruction] | Find the highest common factor of two numbers 8 and 12. [input] |

[output] | <?php $elements = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); for($i = 0; $i < count($elements); $i ++){ echo $elements[$i]; } ?> [instruction] | Construct a for loop in PHP to print the value of each element in an array of 10 elements. [input] | Array: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

[output] | public static String reverseString(String input){ StringBuilder output = new StringBuilder(); for (int i = input.length()-1; i >= 0; i--){ output.append(input.charAt(i)); } return output.toString(); } System.out.println(reverseString("Hello World!")); // Outputs "!dlroW olle [instruction] | Design a function in Java to output the same string in reverse order. [input] | String: 'Hello World!'

[output] | The third element of the array is 5. [instruction] | Find the third element of an array [1, 3, 5, 7, 9]. [input] |

[output] | SELECT * FROM customers WHERE age > 30; [instruction] | Write a query in SQL to show all the details of the customers with age greater than 30. [input] | Table name: customers Fields: name, age

[output] | public static void checkNumber(int num){ if( num > 0 ) Console.WriteLine("Positive"); else if( num < 0 ) Console.WriteLine("Negative"); else Console.WriteLine("Zero"); } checkNumber(-17); // Outputs Negative. [instruction] | Design a code in C# to check if the input number is positive, negative or zero. [input] |

[output] | The UTF-8 representation of the string "Hello" stores it in 5 bytes. [instruction] | Calculate the amount of UTF-8 bytes need to code string "Hello". [input] |

[output] | def combinations(n, k): from itertools import combinations return len(list(combinations(range(n), k))) comb = combinations(10, 3) print(comb) [instruction] | Write a Python code to calculate the number of unique combinations of three digits from 0 to 9. [input] |

[output] | def pascal_triangle(n): trow = [1] y = [0] for x in range(max(n, 0)): print(trow) trow = [ l + r for l, r in zip(trow + y, y + trow)] if(x > 0): trow.append(1) return n >= 1 pascal_triangle(5) [instruction] | Write a Python code to print a Pascal's triangle with five rows. [input] |

[output] | False. Java and JavaScript are two different programming languages. Java is a statically typed, strong-typing, object-oriented language while JavaScript is an interpreted language and is used mainly in web development. [instruction] | Classify the following statement as either true or false. Java and JavaScript are the same language. [input] |

[output] | function linkedListToArray(list) { const array = []; let currentNode = list.head; while (currentNode) { array.push(currentNode.value); currentNode = currentNode.next; } return array; } console.log(linkedListToArray(list)); [instruction] | Convert a linked list to an array in JavaScript. [input] | function LinkedList() { this.head = null; this.tail = null; } function Node(value, next, prev) { this.value = value; this.next = next; this.prev = prev; } let list = new LinkedList(); list.head = new Node(1, new Node(2, new Node(3, new Node(4, null, null), null), null), nul

[output] | SELECT * FROM Animals ORDER BY Animals ASC [instruction] | Write an SQL query to return rows from a table and sorted in ascending order. [input] | Table Name: Animals

[output] | s = "Hello World!" res = "" for char in s: if char.islower(): res += char.upper() elif char.isupper(): res += char.lower() print(res) [instruction] | Write a code in Python to toggle all characters in a string. [input] | The string is: "Hello World!"

[output] | Pandas DataFrame is a two-dimensional data structure, i.e. data is aligned in a tabular fashion in rows and columns. It is a widely used tool for data manipulation and analysis in Python. It offers a variety of features such as filtering, sorting, adding/removing columns, updating the data, indexing [instruction] | Describe the Pandas feature "DataFrame" [input] |

[output] | def Fibonacci(n): a = 0 b = 1 if n == 0: return a elif n == 1: return b else: for i in range(2, n+1): c = a + b a = b b = c return b [instruction] | Generate a Python function to generate Fibonacci sequence given a number n. [input] | n = 5

[output] | multiplication_table = [] for i in range(1, 11): multiplication_table.append([x*i for x in range(1, 11)]) print(multiplication_table) [instruction] | Generate a code in Python to generate a list containing multiplication table up to 10. [input] |

[output] | Promises in JavaScript are objects that represent the eventual completion or failure of an asynchronous operation. They allow us to structure contingencies within our code, and to take actions based on the eventual result of asynchronous tasks. [instruction] | Describe the feature of "promise" in JavaScript. [input] |

[output] | public static int getRandomElement(int[] A) { int randomIndex = (int)(Math.random() * A.length); return A[randomIndex]; } [instruction] | Write a function in Java that returns a random element from an array. [input] | int[] A = {3, 5, 7, 9, 12};

[output] | user_id,name,age 1,John,15 2,Bob,22 [instruction] | Handle the given input and output a CSV string. [input] | [{ user_id: 1, name: 'John', age: 15 }, { user_id: 2, name: 'Bob', age: 22 }]

[output] | double AvgData(int[] input) { double sum = 0; for (int i = 0; i < input.Length; i++) { sum += input[i]; } return sum / input.Length; } [instruction] | Do some data analysis and find the average of the given data. [input] | [12, 15, 6, 8, 10, 20]

[output] | json_encode($input); [instruction] | Read the given input and output a JSON document. [input] | {"foo": "hello", "bar": "world"}

[output] | SELECT AVG(age) FROM people; [instruction] | Write a SQL statement that returns the average age of people in the table. [input] |

[output] | def toUpperCase(string): return string.upper() [instruction] | Develop a Python code that takes a string as input and converts it to all uppercase. [input] | string = "Hello World"

[output] | public static int findOccurrence (String string, char ch) { int count = 0; for (int i=0; i<string.length(); i++) { if (string.charAt(i) == ch) count++; } return count; } [instruction] | Develop a Java function that takes a string and searches for the occurrence of a given character. [input] | string="Hello World"; ch='l';

[output] | <html> <head> <title>Page Title</title> </head> <body> <h1>Welcome to my page</h1> <p>This is a simple page example built with HTML and CSS.</p> </body> </html> [instruction] | Build a HTML page with the provided structure. [input] | <html> <head> </head> <body> </body> </html>

[output] | var array = ["1", "Hello", "there", "10", "45", "Apple"]; [instruction] | Organize the given code snippet into an array data structure. [input] | ["1", "Hello", "there", "10", "45", "Apple"]

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