instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Write a function to generate the Lucas series in Python. | codefeedback |
Write code for reversing a list in Python without using the built-in reverse() method. | codefeedback |
Write a program that generates all possible permutations of a given string. Your program should have a time complexity of O(n!), where n is the length of the string. | codefeedback |
Write a JavaScript program to convert temperatures to and from Celsius, Fahrenheit. The program should also provide the option to convert the temperature to Kelvin.
Additional requirements:
1. The program should prompt the user to enter the temperature and the unit of measurement (Celsius, Fahrenheit, or Kelvin).
2. T... | codefeedback |
Create a program in Java that sorts a given array using bubble sort algorithm.
The bubble sort algorithm works by repeatedly swapping adjacent elements if they are in the wrong order. It continues this process until the array is fully sorted.
Modify the given program to include the following additional steps:
1. Pro... | codefeedback |
Create a function to calculate the number of different ways to climb n stairs, but with the additional constraint that you can only climb 1, 2, or 3 stairs at a time. | codefeedback |
Create an algorithm to determine the most common element in an array, with a time complexity requirement of O(nlogn), where n is the size of the array. | codefeedback |
Write a MySQL query to select all employees who are 30 years old or above, and have been with the company for at least 5 years. | codefeedback |
Create a JavaScript class for a circle that calculates its area and returns the result. Additionally, the class should have a method to calculate and return the circumference of the circle. The radius of the circle should be provided as a parameter when creating an instance of the class. The class should also include a... | codefeedback |
Insert a line of code to change the value of the string "text" to "Hello World" only if the length of the string is greater than 5 characters.
String text = ""; | codefeedback |
Create a loop in Python to print the fibonacci sequence of the given number.
n = 10
However, the loop must use a recursive function to generate the fibonacci sequence. | codefeedback |
Classify the following code as either a single statement, multiple statement, or a control flow statement.
if(x > 5)
print("x is greater than five") | codefeedback |
Create a function in Java that takes in a String parameter and returns the length of the longest substring without repeating characters. The function should have a time complexity of O(n) and a space complexity of O(min(n, m)), where n is the length of the input string and m is the size of the character set. | codefeedback |
Design an HTML form that requires the user to enter three pieces of information: a name, email address, and password. Additionally, the form should have the following requirements:
1. The name field should only accept alphabetical characters and have a minimum length of 2 characters.
2. The email address field should ... | codefeedback |
Write a Java program to print the following output: "This is a test statement" in reverse order, without using any built-in string manipulation functions or data structures. | codefeedback |
Write an HLSL code snippet that creates a 3D vector with the components (x, y, z) = (1, 0, 1) and then normalize the vector. | codefeedback |
Create a SQL query to select all customers from the "Customers" table that have the "State" column equal to "New York" and have made more than 5 orders in the past month. | codefeedback |
How would you create a class in Java and add a field, constructor, method, and an inner class? | codefeedback |
Calculate the sum of all prime numbers in the following list: 10, 12, 14, 16, 18. | codefeedback |
Modify the following JavaScript code to return the result "Hello World!" using only a single statement:
let x = 'Hello';
let y = 'World';
console.log(x + ' ' + y); | codefeedback |
Create a program that takes in an array of integers as input and returns a sorted array in ascending order. The program should have a time complexity of O(n^2) or worse. Additionally, the program should use a bubble sort algorithm to sort the array.
Example:
Input: [7, 3, 5, 9, 11, 10]
Output: [3, 5, 7, 9, 10, 11] | codefeedback |
Mix the given list of numbers in a random order, but without using the built-in shuffle function or any other random number generator functions. | codefeedback |
Create a function to take in a given array, rotate it by a given number of positions to the right, so that the last element of the array becomes the first element. The given number of positions can be any positive integer.
#Example Input/Output#
Input:
array = [1, 2, 3, 4, 5]
positions = 2
Output:
[4, 5, 1, 2, 3] | codefeedback |
Create a sorting algorithm that sorts an array from lowest to highest numbers using the bubble sort approach. The algorithm should have a time complexity of O(n^2) and must not use any built-in sorting functions or libraries. The array will contain at most 1000 integers ranging from -10^9 to 10^9. The algorithm should ... | codefeedback |
Use the OpenGL API to create a vertex buffer object (VBO) that stores a custom data structure containing the position, color, and texture coordinates of each vertex. | codefeedback |
Create a program which takes a given list and returns a list with only the unique elements, but with a time complexity of O(n) and a space complexity of O(1).
[3, 5, 7, 9, 5, 3, 7] | codefeedback |
Design an algorithm in Python for reversing a singly linked list iteratively without using any extra space. | codefeedback |
Write a function in JavaScript to create and return a deep copy of an object. | codefeedback |
Create a function that finds the highest peak in an array of elevation data. The highest peak must be surrounded by at least two valleys, which are defined as adjacent elements that are both lower than the peak. Return the index of the highest peak.
Example:
Input: [9, 10, 12, 15, 7, 8, 11]
Output: 3 | codefeedback |
Create a database query in MySQL to delete "Inactive" status records from a table named 'users' based on the following conditions:
1. Only delete records where the 'status' column is set to "Inactive".
2. Additionally, delete records where the 'last_login' column is older than 30 days.
3. Ensure that the deletion query... | codefeedback |
Write a code to calculate the mean of the list of integers provided, but you are not allowed to use any built-in functions or libraries for calculating the sum or length of the list.
nums = [10, 20, 30, 40, 50] | codefeedback |
Calculate the total sum of digits in the given integer, but with the following additional constraints:
1. The input integer can be negative.
2. If the input integer is negative, the sum should include the negative sign as part of the total sum.
3. The input integer can be a decimal number, and the sum should include t... | codefeedback |
Given a list of integers, write a function that takes the list and returns only the odd numbers in the list. Additionally, the function should also remove any duplicates from the list before returning the final result. | codefeedback |
Create a code to generate a list of all prime numbers between a given start and end number, where the start and end numbers can be as large as 10^6. The code should have a time complexity of O(n√m), where n is the number of prime numbers between the start and end, and m is the average value of those prime numbers. | codefeedback |
Rewrite the following function so that it takes in an int argument and returns the factorial of that number. The function should now handle negative input as well, returning None for negative numbers. Additionally, the function should include a time limit of 1 second for calculating the factorial. If the factorial calc... | codefeedback |
Design a Java class to store user information. The class should include the following functionalities:
1. Ability to store and retrieve the user's first name, last name, email address, and date of birth.
2. Ability to validate the email address format.
3. Ability to calculate the user's age based on the provided date o... | codefeedback |
Create a Java class to find all distinct substrings of a given string. The substring should not contain any repeating characters.
String str = "Hello World"
#Erroneous Code Reference#
Provide a piece of code that mistakenly includes substrings with repeating characters, such as "ll" or "o Wo". | codefeedback |
Generate a C++ program that sorts the elements in an array using the quick sort algorithm. The program should only use recursion to implement the quick sort algorithm and should not use any loop constructs. | codefeedback |
Implement a function in Java that finds the average of two given integers. The integers can be positive or negative, and the function should handle both cases correctly. Additionally, the function should return the average as a double value with two decimal places. | codefeedback |
Using jQuery, update the HTML code to provide the user a toggle switch that changes the text from "off" to "on" when clicked. The toggle switch should only be visible to users who are logged in, and the text should change color to green when the switch is toggled on. Additionally, the toggle switch should only be click... | codefeedback |
Create a HTML page that displays the current time in both digital and analog formats.
Additionally, the page should include a button that allows the user to switch between a 12-hour and 24-hour time format.
Furthermore, the page should display the current date and include a feature that allows the user to switch be... | codefeedback |
Write a function in JavaScript to verify that a given email address is valid or not. The function should validate the email address according to the following requirements:
1. The email address should have a valid format, which includes an "@" symbol and a domain name.
2. The domain name should have at least one dot a... | codefeedback |
Create a Ruby program to generate a random 9-digit alphanumeric string that must contain at least one uppercase letter, one lowercase letter, one digit, and one special character from the set of !@#$%^&*()-_=+{}[]|\:;"'<>,.?/`~. | codefeedback |
Using HTML and CSS, create a responsive page layout with three columns and a header row. Add a navigation bar to the header row and make it fixed to the top of the page. Implement a dropdown menu in the navigation bar with multiple options. Apply a hover effect to the options in the dropdown menu. Ensure that the layou... | codefeedback |
Setup a multi-node PostgreSQL cluster using Docker Compose, where each node has a different replication role (master, replica, standby). | codefeedback |
You need to build an API endpoint to support role-based authentication.
User roles: 'admin', 'manager', 'employee'
Additionally, each user can have multiple roles assigned to them. The roles are stored in a separate table called "user_roles", which has the following columns:
- user_id: integer (foreign key referencing... | codefeedback |
You need to collect user input to get the total sum of numbers, ensuring that the input only consists of positive integers and the sum should be calculated using a recursive function. | codefeedback |
Write a function to parse a string and return a set of unique words. The string may contain punctuation marks and special characters.
#Incorrect Code#
Here is a reference to incorrect code that may misdirect the test-taker:
def parse_string(string):
words = string.split(' ')
unique_words = set(words)
retu... | codefeedback |
You need to sort the given array in descending order. However, you cannot use any built-in sorting functions or methods provided by the programming language. You have to implement the sorting algorithm yourself. | codefeedback |
You need to implement a depth-first search algorithm to search for a value in a given tree. However, the tree is not necessarily a binary tree, but can have any number of child nodes for each parent node. | codefeedback |
Debug the given Java program to make it print out the value of x, but without directly using the variable x inside the print method. | codefeedback |
You need to make a function that takes in a number and its reverse and checks whether the two numbers are equal or not. The number can be of any length, ranging from 1 to 10^6 digits. The function should return True if the two numbers are equal, and False otherwise.
You need to design an efficient algorithm that mini... | codefeedback |
Create a unit test for a given function to reverse a list of strings, but the function should also handle reversing strings that contain special characters and numbers. | codefeedback |
Write a JavaScript function that will take a string and returns the reverse of that string without using any built-in string manipulation methods or arrays. The function should have a time complexity of O(n), where n is the length of the input string. | codefeedback |
Use a deep convolutional neural network to accurately classify handwritten digits from the MNIST dataset with at least 95% accuracy, while using only 50% of the available training data and within a time limit of 10 minutes for model training. | codefeedback |
Output the first 100 prime numbers in ascending order. | codefeedback |
Create a Java class called 'Rectangle' that has the following properties and methods:
Properties:
- length (integer)
- width (integer)
Methods:
1. `calculateArea()`: This method should return the area of the rectangle.
2. `calculatePerimeter()`: This method should return the perimeter of the rectangle.
3. `isSquare()... | codefeedback |
Given a string, write a Python function that will remove all the vowels from it and return the resulting string in reverse order. | codefeedback |
Write a SQL query to select users who have a username that starts with "S" and whose email address contains the domain "@gmail.com". | codefeedback |
Create a Python function to find the pair of numbers that have the highest product in an array of numbers. The array will contain both positive and negative numbers. The function should return the pair of numbers with the highest product, considering all possible combinations. If there are multiple pairs with the same ... | codefeedback |
Implement a JavaScript function that takes an array of integers as input and returns a new array containing only the prime numbers. The function should have a time complexity of O(n^2). | codefeedback |
Write a JavaScript function that takes a number as an argument and finds the sum of all the numbers in a given range (based on the given number). The range should be a random sequence of numbers that are generated based on a certain condition. The condition is that each number in the range should be a multiple of the p... | codefeedback |
How would you create a function that takes a list of strings as an argument and returns the total number of characters in all the strings together, while excluding any special characters and white spaces? | codefeedback |
Convert the following deep learning model definition code to use the Keras API, ensuring that the model is compiled with a loss function, an optimizer, and an additional metric for evaluation. | codefeedback |
Create a function in C++ that takes in two arrays of integers, multiplies each element of the first array by the corresponding element in the second array, and then returns the resulting array.
Requirements:
- The function should have a time complexity of O(n), where n is the length of the input arrays.
- The function... | codefeedback |
Design a data structure that can be used to store student records with the fields 'name', 'age', 'major', 'graduation_year', and 'GPA'. The GPA field should be represented as a floating-point number between 0 and 4, inclusive. | codefeedback |
Write a C++ program to print the following pattern.
1
1 2
1 2 3
1 2 3 4
The program should take an integer input from the user and print the pattern based on that input. For example, if the user enters 5, the pattern should be:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
The program should handle input validation to ens... | codefeedback |
Given a string consisting of alphanumeric characters, separate it into left and right parts so that the left part contains only digits and the right part contains only lowercase letters. If there are no lowercase letters in the string, return an empty string for the right part.
String: A1b2C3d | codefeedback |
Parse the following XML document and print out the 'name' fields of all the nodes, but exclude any nodes where the 'age' field is greater than 25. | codefeedback |
Design a relational database schema for a library that stores book information such as title, subject, and author. Additionally, the schema should include tables for tracking book availability, borrower information, and due dates. The borrower information should include fields for name, contact information, and a uniqu... | codefeedback |
Develop a function in Python which prints the name of the day (eg. "Monday") given any date as an argument. The function should also check if the given date is a public holiday in a specific country and print a corresponding message. The function should handle dates from January 1st, 1900 to December 31st, 2099. | codefeedback |
Write a JavaScript method for validating a form that has at least 5 input fields and requires the user to input a valid email address and a password with a minimum of 8 characters. The form should also have a checkbox that the user must check before submitting the form. | codefeedback |
Create a function that takes a string and an integer as input and returns a string where each character is repeated n times. | codefeedback |
Write a code to add two matrices of any size, but the matrices must have the same number of rows and columns. | codefeedback |
Write a code to print out all numbers between 1 and n that are divisible by both 3 and 5 without using a loop. Additionally, the code should have a time complexity of O(1) and a space complexity of O(1). | codefeedback |
Construct an object in JavaScript where the key is a positive integer from 1 to 1000 and the value is an array of prime numbers less than or equal to the key. | codefeedback |
Create a function to split a string into substrings based on a given separator. The separator can be any combination of characters and can occur multiple times within the string. The resulting substrings should be returned in a list.
Example:
string = "apple,banana,cherry"
separator = ","
Expected output:
["apple", "... | codefeedback |
Write a code to train a sentiment classification model on the IMDB sentiment analysis dataset. In addition to training the model, you should also implement a method to evaluate the model's performance using appropriate metrics such as accuracy, precision, recall, and F1 score. Additionally, you should preprocess the da... | codefeedback |
Suggest a way to comment out a block of code in C++, ensuring that the commented block is still visible to an automated code analysis tool, while also optimizing the commenting technique for code readability and maintainability. | codefeedback |
Convert the following character stream into a number. However, there may be some erroneous characters in the stream that need to be handled correctly.
char_stream = “8kk573" | codefeedback |
Write CSS code to style a list of items with the following requirements:
- Each item should have a unique background color, with a gradient effect from top to bottom.
- The font size should increase by 2 pixels for each subsequent item in the list.
- The font weight should start at bold for the first item, and decrease... | codefeedback |
Create a SQL query that performs a SELECT operation on a table "employee" with columns Id, Name, Age and Address. The query should return the Name, Age and Address of employees who are older than 30 years and whose addresses contain the word "Street". The query should also order the results in ascending order of age. | codefeedback |
Write a SQL query to print all the data in a table "scoreboard" with columns "name", "score", "category", and "rank". The rank should be calculated based on the score, with the highest score receiving rank 1 and the lowest score receiving the highest rank. In case of ties, the rank should be assigned based on the alpha... | codefeedback |
Write an SQL query to calculate the maximum salary earned by each employee in the table "salary" which has columns "employee_name" and "salary". Additionally, include the department name for each employee in the result. | codefeedback |
Split a string into an array of characters in JavaScript, while also reversing the order of the characters in the resulting array. | codefeedback |
Write a function that expects a string as a parameter and returns all the unique words in the string with the length greater than three. The function should ignore punctuation and be case insensitive.
Example:
Input: "This is a test string."
Output: ["test", "string"]
Constraints:
- The input string can contain any p... | codefeedback |
Write a code to get the current weather information for a given city using only HTTP requests and without using any third-party libraries or APIs.
city = "New York" | codefeedback |
Write a Python program to find the group of three numbers in a list that has the greatest product. The list will contain both positive and negative integers, and may also contain zeroes. You may assume that the list will always have at least three elements.
#Example:
Input: [2, 3, -2, -3, 4, -5]
Output: The group of t... | codefeedback |
Create a php website that allows users to perform CRUD operations (Create, Read, Update, Delete) on a collection of data records. The data records should have the following fields:
- firstname (string)
- lastname (string)
- address (string)
- email (string)
- phone (string)
- age (integer)
The website should have the... | codefeedback |
Create a loop to iterate through all the values in the following list and find the sum of all the even numbers in the list. Additionally, you should only use a while loop to solve the problem.
List: [2,7,16,2,9] | codefeedback |
Suggest a code to extract the first and last occurring unique characters from a string and return them in a sorted order.
String: "Hello World!" | codefeedback |
Suggest a code to print the first three positions in an array, where the array can contain duplicates and negative numbers as well.
Array = [1, 2, -3, 4, 2, -1, 5] | codefeedback |
Check if the given string contains any uppercase characters and special characters, and output the count of uppercase characters and the positions of special characters in the string.
String: "Hello, World! How are you doing today?" | codefeedback |
Write a code to generate a random password containing at least one symbol, one number, one lowercase letter and one uppercase letter. Additionally, the password must not contain any repeated characters. | codefeedback |
Implement a function to concatenate two arrays, but you are not allowed to use any built-in array concatenation methods or functions. You must write your own logic to concatenate the arrays.
Array 1: [1,2,3]
Array 2: [5,6] | codefeedback |
Generate a code to identify duplicate elements in a list and count the number of occurrences for each duplicate element. | codefeedback |
Generate an algorithm that creates a Fibonacci sequence with a specified length.
#Explanation#
The original problem was to generate a Fibonacci sequence, which is a relatively simple task. To increase the difficulty, we can add a requirement to generate the sequence with a specified length. This would require addition... | codefeedback |
Create a Java class named "Card" to represent a standard playing card. The class should contain a constructor which takes the card's suit and number as parameters. It should also contain two getter methods to get the suit and number of the card.
Additionally, add a method named "getValue" which returns the numerical v... | codefeedback |
Edit the following HTML form to validate an email address and display an error message if the email is not valid.
<form>
<input type="text" name="email" required>
<span id="error-msg" style="display: none; color: red;">Invalid email address</span>
<input type="submit" value="Submit" onclick="validateEmail(... | codefeedback |
Write a css code to put a shadow on all the paragraphs, but only if the paragraph contains more than 10 words. | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.