← 목록

Synth · CodeAlpaca일부

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

[output] | function isSubstring(str1, str2){ if(str2.indexOf(str1) !== -1){ return true; } else{ return false; } } [instruction] | Given two strings str1 and str2, write a function in JavaScript to check if str1 is a substring of str2. [input] |

[output] | function mod_exp(base, exponent, modulus){ var result = 1; for (var i = 0; i < exponent; i++){ result = (result * base) % modulus; } return result; } [instruction] | Edit the following PHP code to return the modular exponentiation of two numbers. [input] | function mod_exp(base, exponent, modulus){ return base^exponent % modulus; }

[output] | <html> <head> <title>Registration Form</title> </head> <body> <h1>Registration Form</h1> <form action="register.php" method="POST"> <div class="form-row"> <label>Username:</label> <input type="text" name="username" required> [instruction] | Construct a HTML page for a registration form. [input] |

[output] | def search(arr, target): left, right = 0, len(arr) - 1 while left <= right: mid = (left + right) // 2 if arr[mid] == target: return mid elif arr[mid] > target: right = mid - 1 else: left = mid + 1 return -1 [instruction] | Implement a search() function that uses binary search to find a given element in an array. [input] |

[output] | function getRandom() { return Math.random(); } [instruction] | Suggest a way to the generate a random number between 0 and 1 in JavaScript. [input] |

[output] | __m256 x_vec = _mm256_loadu_ps(x + 0); __m256 y_vec = _mm256_loadu_ps(y + 0); __m256 z_vec =_mm256_loadu_ps(z + 0); x_vec = _mm256_add_ps(y_vec, z_vec); _mm256_storeu_ps(x + 0, x_vec); [instruction] | Using C++, unroll the following loop and vectorize the code. [input] | for (int i = 0; i < 10; ++i) x[i] = y[i] + z[i];

[output] | import pandas as pd def sample_df(df,n): return df.sample(n) [instruction] | Generate a random sample with size n from a given pandas DataFrame. [input] |

[output] | public static Object getRandomElement(List<?> list) { Random rand = new Random(); int randIndex = rand.nextInt(list.size()); return list.get(randIndex); } [instruction] | Create a function to retrieve a random element from a given list in Java. [input] |

[output] | SELECT MAX(salary) FROM Employees; [instruction] | Build a SQL query to calculate the biggest salary in the table “Employees”. [input] |

[output] | #!/bin/bash echo "I love programming in Bash!" [instruction] | Create a bash shell script that will print “I love programming in Bash!”. [input] |

[output] | <html> <head> <script> function alert_button(){ alert("You pressed the button!"); } </script> </head> <body> <button onclick="alert_button()">Click Here</button> </body> </html> [instruction] | Generate a HTML code that will create an alert message with the text “You pressed the button!” [input] |

[output] | .flex-container { display: flex; flex-flow: row wrap; justify-content: space-between; } .flex-item { flex: 1 0 auto; padding: 5px; } [instruction] | Generate a CSS code for creating a flex container with columns of equal width. [input] |

[output] | function isOddNumber(num) { return num % 2 !== 0; } [instruction] | Suggest a completion for the following JavaScript code to determine if a number is an odd number. [input] | function isOddNumber(

[output] | import scala.io.Source val products = Source.fromFile("products.txt").getLines.toList val avgPrice = products.map(p => p.split(",")(4).toDouble).sum/products.length println(s"The average price is: $avgPrice") [instruction] | Create a program in Scala to calculate the average price of all products in the table “Products”. [input] |

[output] | <html> <head> <script> function submitForm(){ var formData = document.getElementById("textEntry").value; alert("You said: "+ formData); } </script> </head> <body> <form> <input type="text" id="textEntry"> <input type="button" value="Submit" o [instruction] | Create a HTML form to submit a text entry and view it after submission. [input] |

[output] | const containsSubstring = (string, substr) => { return string.indexOf(substr) !== -1; } module.exports = containsSubstring; [instruction] | Write a Node.js module that accepts two strings and checks if the first string contains the second string. [input] | "Hello World", "ello"

[output] | from flask import Flask, redirect, request app = Flask(__name__) @app.route('/', methods=['GET', 'POST']) def index(): if request.method == 'POST': if request.form['userInput']: url = 'https://www.example.com' return redirect(url) return ''' <form method [instruction] | Create a Flask application to redirect the user to a given URL when the user input is valid. [input] |

[output] | for(let i=1; i<=30; i++){ console.log(i); } [instruction] | Generate a JavaScript code that prints all the numbers from 1 to 30. [input] |

[output] | { "menu": { "id": "file", "value": "File", "popup": { "menuitem": [ { "value": "New", "onclick": "CreateNewDoc()" }, { "value": "Open", "onclick": "OpenDoc()" }, { "value": "Close", [instruction] | Reformat a given JSON string between quotes to a properly indented and formatted output. [input] | "{\"menu\":{\"id\":\"file\",\"value\":\"File\",\"popup\":{\"menuitem\":[{\"value\":\"New\", \"onclick\":\"CreateNewDoc()\"},{\"value\":\"Open\", \"onclick\":\"OpenDoc()\"},{\"value\":\"Close\", \"onclick\":\"CloseDoc()\"}]}}}"

[output] | <span class="important"></span> [instruction] | Create an HTML <span> element with a given CSS class name. [input] | class="important"

[output] | newList = [x + y for x, y in zip([1, 2, 3], [4, 5, 6])] [instruction] | Write a Python program to add the items of two given lists and create a new list. [input] | [1, 2, 3], [4, 5, 6]

[output] | export MY_PASSWORD='MyPassword' [instruction] | Set an environment variable in Bash that holds the value of the given string. [input] | MyPassword

[output] | ^(a|b|c){2}d$ [instruction] | Write a regex expression to match the given input. [input] | abbccd

[output] | function calculateMedian(arr) { arr.sort(function(a, b){return a-b}); if (arr.length % 2 !== 0) { return arr[Math.floor(arr.length / 2)]; } else { return (arr[arr.length / 2 - 1] + arr[arr.length / 2]) / 2; } } [instruction] | Create a Javascript function that calculates the median value of an array of numbers. [input] | [2, 7, 12, 15]

[output] | public class Circle { public static void main(String[] args) { double radius = 7.0; double circArea = Math.PI * (radius * radius); System.out.println("The area of the circle with radius" + radius + " is: " + circArea); } } [instruction] | Write a Java program to display the area of a given circle. [input] | radius = 7

[output] | $('.hidden').hide(); [instruction] | Use jQuery to hide all the elements with the given CSS class. [input] | hidden

[output] | string names[] = {"John", "Sam", "Anna"}; [instruction] | Create an array with 3 strings, "John", "Sam" and "Anna". [input] |

[output] | function add(a, b) { return a + b; } [instruction] | Design a JavaScript function that will accept two numbers and return their sum. [input] |

[output] | SELECT name, age FROM users ORDER BY age ASC; [instruction] | Adjust the following SQL query so that it will return the results sorted in an ascending order. [input] | SELECT name, age FROM users;

[output] | class Car { public $make; public $model; public $color; public $year; public function __construct($make, $model, $color, $year) { $this->make = $make; $this->model = $model; $this->color = $color; $this->year = $year; } } [instruction] | Create a PHP class called "Car" with public member variables. [input] |

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