instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Create a function in JavaScript that takes a string and a number as arguments, and returns a string with the first number of characters (specified by the number argument) replaced with the character '@'. The function should only consider alphabetic characters for replacement and ignore any non-alphabetic characters. Ad... | codefeedback |
Create a deep learning model using convolutional neural networks to predict a multi-class classification problem with 10 classes. | codefeedback |
Inspect the given code and find any possible bugs. The list of numbers should not contain any negative numbers. Additionally, the sum should be calculated using a recursive function instead of a loop. | codefeedback |
Write a Ruby program to remove duplicate elements from the given array, while maintaining the original order of elements. The program should have a time complexity of O(n) and should not use any additional data structures or methods like `uniq` or `uniq!`.
arr = [1, 2, 2, 3, 4, 4]
Example:
Input: [1, 2, 2, 3, 4, 4]
O... | codefeedback |
Write a query to find the author with the highest number of books published in each year, excluding any authors who have published less than 5 books in that year. | codefeedback |
Construct a program to compute the sum of two numbers and display the result. However, the program should not use the addition operator (+) or any built-in functions that directly perform addition. Instead, you should implement your own algorithm to add the numbers.
number1 = 5
number2 = 10 | codefeedback |
Suppose you are given an array of 0s, 1s, and 2s. Write a program to sort the given input array. Your program should have a time complexity of O(n) and space complexity of O(1). | codefeedback |
Offer a solution for converting a bank of binary strings, represented as an array, to Roman numerals. | codefeedback |
Design a program to solve a 3x3 Sudoku puzzle using only recursive backtracking algorithm and without using any additional data structures. | codefeedback |
Compile the given piece of code and identify any errors. Additionally, optimize the code to print "Hello World!" 100 times without using any loops or recursion. | codefeedback |
Write a recursive function in Python that calculates the factorial of a given positive integer. | codefeedback |
Design a program to generate all prime numbers between 1 and 1,000,000. | codefeedback |
Boil down a JavaScript object into an array of key-value pairs. The object may contain nested objects and arrays.
object = {a: 1, b: {c: 2, d: [3, 4]}, e: {f: {g: 5, h: [6, 7]}}}
#Expected Output#
[
['a', 1],
['b.c', 2],
['b.d[0]', 3],
['b.d[1]', 4],
['e.f.g', 5],
['e.f.h[0]', 6],
['e.f.h[1]', 7]
] | codefeedback |
Create a procedure in C# to print a string, but you are not allowed to use the built-in Console.WriteLine() method. The string must be printed using a custom implementation of the printing mechanism. The procedure should also handle the case where the string contains special characters and should print them as they are... | codefeedback |
Construct a for loop in C# for picking out numbers that are divisible by 3 and storing them in a separate array. The original array is named "numbers" and it contains the elements [1, 2, 3, 4, 5, 6, 7]. The resulting array should be named "divisibleNumbers". | codefeedback |
Write a SQL query for listing students who are 18 years old and have scored above 90 marks in their exams. Student table with the columns "name", "age", and "score". | codefeedback |
Write a SQL code to generate a new table called "Customers" by selecting all columns from the "Orders" table, but exclude any duplicate rows. | codefeedback |
Write a function to remove all occurrences of a given element from an array of integers.
arr = [2, 3, 4, 5, 4, 6, 4]
remove_element = 4 | codefeedback |
Write a function in C that uses gradient descent to find the minimum value of a given parameter.
The parameter is w(t+1) = w(t) - alpha * Le(w)
Here, alpha= 0.3 and Le(w) = 14w^2 + 8 * w - 7
In addition, the function should handle the following:
1. Implement a stopping condition to terminate the gradient descent algor... | codefeedback |
Write a Node.js code to call an API and print the output. Additionally, the code should handle potential errors and implement pagination to retrieve and print all available data from the API. | codefeedback |
Write Python code to group list elements into sublists of particular length. Each sublist should have a length that is a multiple of 3. The original list should have a length that is a multiple of 8. [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32] | codefeedback |
Write a JavaScript code to print the pyramid pattern for a given number of rows, where each row should consist of odd numbers only and the first and last number in each row should be a prime number.
7 | codefeedback |
Create a program in JavaScript to edit the existing string by replacing some of its characters. The replacement can only be performed if the character to be replaced is a lowercase letter and its index in the string is a prime number. If the character meets both conditions, it should be replaced with the corresponding ... | codefeedback |
Create a function that returns the evaluation metric of a model, where the metric must be computed within a time limit of 1 second. | codefeedback |
Write a SQL query to extract all the orders placed on a given date, sorted by the total price of each order in descending order. The query should also include the customer's name, email, and address for each order.
order_date = "2020-01-01" | codefeedback |
Determine the angle of the triangle given its three sides and the coordinates of its vertices. The sides are defined by the following coordinates: (0, 0), (5, 0), and (0, 6). | codefeedback |
Retrieve data from an SQL database.
Table name: users
1. Connect to the SQL database using appropriate credentials.
2. Check if the connection to the database was successful.
3. Write a SQL query to retrieve all columns from the "users" table.
4. Execute the query and fetch the results.
5. Check if any data was return... | codefeedback |
Replace all occurrences of one character with another in a given string, while also maintaining the original order of the characters in the string.
string: Hello there
characters: 'o' and 'a'
constraint: The characters to be replaced must be adjacent to each other. | codefeedback |
Create a list comprehension that finds all elements in a given list that are divisible by both 3 and 5, and are greater than 10. The output should be sorted in descending order.
numbers =[1, 5, 8, 10, 15, 20, 25, 30] | codefeedback |
Create a function that creates a tuple of the given arguments and returns the tuple. However, the function should also perform the following operations:
- Convert the arguments to uppercase before creating the tuple.
- Remove any duplicate characters from the arguments before creating the tuple.
- Sort the characters i... | codefeedback |
Create a loop that prints out the numbers from 1000 to 0, going in increments of -10. | codefeedback |
Write a function that takes a list of strings and counts the number of each string that contains the letter "a". The function should also ignore any strings that start with a capital letter. The function should return a dictionary where the keys are the strings that contain the letter "a" and the values are the counts ... | codefeedback |
Construct a SQL query to find all first names from the table "Employees" beginning with "J" and the last name containing the letter "a".
Table: Employees
Columns: First_Name, Last_Name | codefeedback |
Write a function that takes two strings as parameters and returns whether they are an anagram of each other or not. An anagram is a word or phrase formed by rearranging the letters of another word or phrase.
For example, if string1 = "abcde" and string2 = "edcba", the function should return True because "abcde" can b... | codefeedback |
Construct a function to check for an anagram in Python, but the function should have a time complexity of O(1). | codefeedback |
Update the given Python program to reverse a string, but do not use any built-in string reversal functions or methods. You can only use basic string manipulation operations and loops. Additionally, the program should ignore any punctuation and whitespace characters while reversing the string. | codefeedback |
Create a MySQL query to delete all the entries with the name "John" in the table "users" without using the DELETE statement. | codefeedback |
Create a code to validate an email address using Regular Expressions. Additionally, ensure that the email address contains at least one uppercase letter and one lowercase letter. | codefeedback |
Implement a custom sorting algorithm, using a modified version of the quicksort algorithm, that sorts a list of integers in descending order. The algorithm should have a time complexity of O(n log n) and should not use any built-in sorting functions or libraries. | codefeedback |
Create a pseudocode to solve the FizzBuzz problem, but instead of printing "Fizz" for numbers divisible by 3 and "Buzz" for numbers divisible by 5, print "Fizz" for numbers divisible by 3 and containing the digit 3, and "Buzz" for numbers divisible by 5 and containing the digit 5. | codefeedback |
Create a program that reads a CSV file containing temperature data for different cities and plots a line graph using Python's matplotlib library. Each city's temperature should be plotted on the y-axis, while the x-axis represents the dates. The program should also include a legend displaying the names of the cities. A... | codefeedback |
Build a CNN model in Keras to detect cancer from a provided dataset. In addition, implement data augmentation techniques such as rotation, zooming, and flipping to improve the model's performance. Use a transfer learning approach by fine-tuning a pre-trained model like VGG16 or ResNet50 to further enhance the accuracy.... | codefeedback |
Create a deep learning neural network in Keras that can accurately classify images from the CIFAR-10 dataset.
The network should consist of the following layers:
1. Convolutional layer with 32 filters, a kernel size of 3x3, and a ReLU activation function.
2. Convolutional layer with 32 filters, a kernel size of 3x3, a... | codefeedback |
Solve this regular expression problem.
A string should start with a letter, contain only letters and numbers, and should be at least 8 characters in length. Additionally, the string should not contain any repeated characters. | codefeedback |
Write an algorithm in C that prints a string in reverse, but you are not allowed to use any built-in string functions or arrays. | codefeedback |
In Java, construct a data structure for storing employee information, including name, age, phone number, address, and salary. | codefeedback |
Write an algorithm in Java to reverse the words in a string while preserving the position of any punctuation marks.
For example, the input "The quick, brown fox." should return "ehT ,kciuq nworB .xof". | codefeedback |
Create a Java web application that displays a welcome message and allows users to input their name. The application should validate the input and display a personalized welcome message with the user's name. | codefeedback |
Create a React component to sort an array of strings in ascending order. The component should take in an array of strings as a prop and display the sorted array. Additionally, the component should include a button that, when clicked, reverses the order of the sorted array and updates the display accordingly. Finally, t... | codefeedback |
Create an Angular project that includes the necessary dependencies for routing and authentication.
1. Set up a new Angular project using the Angular CLI.
2. Install the necessary dependencies for routing and authentication, such as `@angular/router` and `firebase`.
3. Create a basic login component with a form for use... | codefeedback |
Write a code snippet to find the most frequent number greater than 100 from a list of numbers. The list may contain duplicates and can have a maximum of 10^6 numbers. The numbers in the list are guaranteed to be integers between 1 and 10^6. Your solution should have a time complexity of O(n) and a space complexity of O... | codefeedback |
Create an HTML form with two dropdowns to select from different countries and cities. Additionally, implement the following features:
1. Populate the country dropdown dynamically from a JSON file or API endpoint.
2. Enable cascading behavior between the two dropdowns, where selecting a country should update the city d... | codefeedback |
Calculate the hypotenuse of a right triangle when the other two sides are 4 and 5, while ensuring that the program must include error handling for cases where the input sides are not positive integers greater than zero. | codefeedback |
Write a program to parse and extract dates from a given text that may contain multiple date formats.
The conference will be held on Wednesday, June 16th, 2021, at 10:00 AM. However, please note that there are other events scheduled as well. For example, there will be a workshop on Friday, July 2nd, 2021, from 2:00 PM ... | codefeedback |
Classify the given text as "positive", "negative", or "neutral" using Natural Language Processing.
This movie is absolutely terrible and the worst thing I've ever seen. | codefeedback |
Using the given datasets and Scikit-Learn, develop a K Nearest Neighbors (KNN) classifier. Implement the classifier to handle imbalanced classes, ensuring that the minority class has at least 10% representation in the training set. Additionally, apply feature scaling to the dataset before training the classifier. Impor... | codefeedback |
Using the given JSON string, parse the string and convert it into an object or array in JavaScript. Additionally, ensure that the object or array is sorted alphabetically based on the keys and the values are formatted as strings with the first letter capitalized and the rest of the letters in lowercase. Finally, implem... | codefeedback |
Write a function in C++ to convert a list of integers to a tuple, where each element in the tuple must be a positive integer. | codefeedback |
Write a MySQL query to insert new records in an 'Employees' table and return the number of records added.
Table Name: Employees
Records to add:
Name: John, Age: 28, Job Title: Programmer
Name: Alice, Age: 24, Job Title: Designer
The query should also ensure that the name of the employee is unique, and if a record wit... | codefeedback |
Perform a radix sort on the given list.
List: [9876, 5432, 1098, 7654, 3210] | codefeedback |
Write a program that parses a JSON string and prints each key-value pair to the console. The program should be able to handle nested JSON objects and arrays as well.
Input: '{"name": "John", "age": 30, "address": {"street": "123 Main St", "city": "New York"}, "hobbies": ["sports", {"type": "chess", "level": "advanced"... | codefeedback |
Create an HTML form to allow a user to enter their contact information.
Fields requested: Full Name, Email Address, Phone Number, Birthdate, Gender
Additional Requirements:
1. The Full Name field should only accept alphabets and spaces.
2. The Email Address field should validate the input to ensure it follows the corr... | codefeedback |
Create a C++ object to represent a 2D point. The object should have the following features:
- The point should have x and y coordinates.
- The object should be able to calculate the distance between two points.
- The object should be able to calculate the angle between two points.
- The object should be able to rotate ... | codefeedback |
Create an Android app with a button to switch between light and night mode. Additionally, implement a feature that allows the user to customize the color scheme of the app by selecting from a list of predefined color options. | codefeedback |
Write a JavaScript function that takes an object as input and returns an array of all the key names in the object. The function should handle nested objects as well.
Example input:
let obj = {name: "John", age: 30, job: "teacher"};
Example output:
["name", "age", "job"]
Write the JavaScript function that solves this... | codefeedback |
Create a SQL database containing three tables. Each table must have at least five columns and one of the tables should have a foreign key constraint referencing a primary key from another table. Additionally, one of the tables should have a column with a unique constraint. | codefeedback |
Find and display all the employees who earn more than the median salary across all departments, excluding any employees who are part-time or have less than one year of experience. | codefeedback |
Write code that removes spaces and punctuation marks from a given string and returns the modified string. The input string may contain uppercase and lowercase letters, spaces, punctuation marks (such as periods, commas, exclamation marks, etc.), and digits. The modified string should only contain the alphanumeric chara... | codefeedback |
Create a nested loop to print every combination of numbers between 0-9, excluding any combination that contains the number 5. Additionally, exclude any combination that contains a repeating digit. | codefeedback |
Formulate an equation to calculate the height of a triangle given the angle, side lengths, opposite side length, and the ratio of the side lengths. The equation should take into account the Law of Sines and the Law of Cosines. Additionally, the equation should also consider the effect of air resistance on the trajector... | codefeedback |
Write a method for a string class which replaces all occurrences of a given substring with a given set of characters, but only if the substring appears an odd number of times in the string. If the substring appears an even number of times or does not appear at all, the method should return the original string unchanged... | codefeedback |
Write a function to find the number of distinct states in a given matrix. Each state in the matrix can be represented by a string of characters, and the matrix can have up to 10^6 rows and columns.
Provide a piece of erroneous code as a reference to increase misdirection.
# Misdirection code #
def count_distinct_stat... | codefeedback |
Write code to find the sum of all prime numbers between 1 and 1 million. | codefeedback |
Write a function to find the maximum difference between two prime numbers in a given array. The array can contain positive and negative integers, and can be unsorted. Additionally, the function should handle arrays of any length. The function should return the maximum difference as an absolute value. For example, for t... | codefeedback |
Create an array of length N (where N is a positive integer) containing numbers divisible by M (where M is a positive integer) up to X (where X is a positive integer). Each number in the array must be unique and in ascending order. Additionally, the sum of all the numbers in the array should be a prime number.
Addition... | codefeedback |
Write a function that checks if a given number is prime or not. The function should return "Prime" if the number is prime, and "Not Prime" if the number is not prime.
Note: A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. | codefeedback |
Increase the difficulty by asking to print the square of each number in reverse order using a while loop instead of a for loop.
i = n
while i >= 1:
# TODO
i -= 1 | codefeedback |
Write a function to generate the nth Fibonacci number. The function should have a time complexity of O(log n) and use dynamic programming. | codefeedback |
Create a function to calculate the area of a given circle, but this time, the input parameter for the radius should be a string instead of a number. Additionally, the function should handle invalid inputs and return an error message if the input is not a valid number. | codefeedback |
Create a recursive function in Java for computing the factorial of a positive integer number, where the input number must be less than or equal to 15. Additionally, the function should handle negative numbers gracefully by throwing a custom exception with an appropriate error message. | codefeedback |
Use the function to debug the given program and prevent the segmentation fault. Your solution should also handle the case where the array contains duplicate elements. You are not allowed to use any additional data structures. Additionally, the time complexity of your solution should be O(n) and the space complexity sho... | codefeedback |
Write a program to find all prime numbers between 2 and 100. The program should prompt the user to enter a number and check whether it is prime or not. If the number is prime, it should add it to a list. The program should continue prompting the user for input until an invalid number is entered. Finally, the program sh... | codefeedback |
Follow the comments in the code to complete the program which prints a conversion table from Fahrenheit to Celsius.
# This program prints a conversion table from Fahrenheit to Celsius
# Print a heading for the table in the following format:
# Temperature Conversion Table (Fahrenheit to Celsius)
# Print the column he... | codefeedback |
Write a SQL query to calculate the total number of orders in the "orders" table, where the orders have been placed in the last 30 days and have a total order value greater than $1000. | codefeedback |
Create a C++ program for randomly shuffling an array of integers without using any built-in shuffling functions or algorithms. Additionally, ensure that the program is able to handle arrays of any size, including very large arrays. | codefeedback |
Create a CSS script that not only centers the login form on the webpage, but also adds a transition effect when the form is hovered over. The transition effect should smoothly change the background color of the form from white to a light shade of blue. Additionally, the form should have a border radius of 10px and a dr... | codefeedback |
Write a SQL query to find the total number of orders placed between two given dates, group the results by the month in which the orders were placed, and include only orders with a total cost greater than $100. start_date = '2020-01-01' end_date = '2020-02-01' | codefeedback |
Modify the code to perform the mathematical expression "x to the power of y" while also ensuring that the value of x is between 1 and 10, and the value of y is between 0 and 5. Additionally, the code should handle any potential errors or edge cases that may arise during the calculation. The code should also check for i... | codefeedback |
Write an SQL query to calculate the average order price for each product category in the "orders" table. Additionally, calculate the total number of orders, the total revenue generated, and the total quantity sold for each category.
To do this, you will need to join the "orders" table with the "products" table using t... | codefeedback |
Increase the difficulty of the given programming test question:
Remove the boilerplate code from the program for printing 10 random numbers. Instead, write a function that generates a sequence of n random numbers, where n is the input to the function. The function should return the sequence of random numbers.
The fun... | codefeedback |
Edit the code to create a try-except block to handle the exception and include a custom error message. The custom error message should indicate the specific variables that were involved in the division.
a = 5
b = 0
try:
ans = a/b
except ZeroDivisionError:
print(f"Cannot divide {a} by {b}.") | codefeedback |
Please write a function in JavaScript to count the number of vowels in a given string. However, you are not allowed to use any built-in string methods or regular expressions. The input string may contain lowercase and/or uppercase alphabets, as well as special characters and numbers. The function should be case-insensi... | codefeedback |
Create a C program that prints out the Fibonacci sequence up to the nth term, where n is a positive integer inputted by the user. Additionally, the program should calculate and print the sum of all the even terms in the Fibonacci sequence.
To solve this problem, follow these steps:
1. Start by declaring three variable... | codefeedback |
Write a script using Bash that replaces all vowels in a given text file with a random number between 1 and 100. The script should also keep track of the total count of each replaced vowel and print the count at the end of the script execution. | codefeedback |
Create a Java program that prints out the contents of a given two-dimensional array in a spiral pattern. The array will have dimensions M x N, where M represents the number of rows and N represents the number of columns. The program should print the elements of the array in a clockwise spiral pattern, starting from the... | codefeedback |
Sort the array in descending order without using any built-in sorting functions or libraries.
arr = [3, 2, 1, 5, 4] | codefeedback |
Write a list comprehension to calculate the factorial of each number in the list, but without using the factorial function or any built-in libraries.
arr = [1, 2, 3, 4, 5]
#Revised Test# | codefeedback |
Create a PHP code to check if an array contains a given item. The input array can contain up to 1 million integers and the item to check can be any integer value between -10^9 and 10^9. The code should have a time complexity of O(log n) where n is the number of elements in the input array. Additionally, the code should... | codefeedback |
Write a SQL query to return the sum of salaries for each department, excluding any departments where the average salary is less than or equal to $75,000. | codefeedback |
Write a function that takes a string and reverses the words in it, while also maintaining the original order of punctuation marks and special characters. The function should only reverse the words and not alter the position or order of any non-alphabetic characters. Additionally, the function should not use any built-i... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.