instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Create an assembly language program to find the median of a list of 1000 integers.
codefeedback
Design an algorithm to find the maximum subarray of an array of both positive and negative numbers, where the subarray must contain at least k elements, and k is a given integer. The algorithm should have a time complexity of O(n) and a space complexity of O(1).
codefeedback
Create a sorting algorithm that can handle negative numbers and has a time complexity of O(n log n).
codefeedback
Construct an algorithm to fulfill the following purpose: Given an array of integers and a target number N, find all pairs of numbers in the array that add up to N. #Difficulty Increased Test#
codefeedback
How would you print a big "Hello World" on the console output, but the letters 'H', 'W', 'o', 'l', and 'd' should be replaced with their corresponding ASCII values?
codefeedback
Solve the following problem: Given two strings s and t, find the minimum window in s which will contain all the characters in t. Now, in addition to finding the minimum window, you also need to return the minimum length of the window. For example, if s = "ADOBECODEBANC" and t = "ABC", the minimum window would be "BAN...
codefeedback
Develop a PHP script that creates and populates a database table called “customers” with the following fields: - id (auto-incrementing integer) - first_name (string) - last_name (string) - email (string) - phone (string) - address (string) - city (string) - state (string) - zip_code (string) The script should also val...
codefeedback
Design a SQL query to retrieve the names of movies released in the last 10 years that have a rating higher than 8 and belong to the genres of action or thriller.
codefeedback
Use recursion to return the sum of all odd numbers up to a given number.
codefeedback
Write a function in assembly language that takes two integers as input and returns their sum.
codefeedback
Design a class in Java to represent a bank account that has a balance, a name, and an account number. Implement the following additional functionalities: 1. Add a method to deposit money into the account. This method should validate the deposit amount to ensure it is a positive value. 2. Add a method to withdraw money...
codefeedback
Write a function to generate a random permutation of a given array, while also ensuring that no two consecutive elements in the permutation are equal. [1, 2, 3, 4, 5]
codefeedback
Create a UI component in ReactJs to render a list of items from an array of objects. Each item should have the following properties: - name: a string representing the name of the item (required) - price: a number representing the price of the item (required) - quantity: a number representing the quantity of the item (o...
codefeedback
Create a MySQL query to fetch data from three tables using a LEFT JOIN and a UNION ALL clause. TableOne: ID, Name, Age TableTwo: ID, School TableThree: ID, Hobby
codefeedback
Design a Node.js class to create a RESTful API that implements a custom authentication and authorization system using JWT (JSON Web Tokens). The API should also include rate limiting functionality to prevent abuse and protect against DoS attacks. Additionally, the API should support secure file uploads and implement pa...
codefeedback
Multiply two matrices and return the resulting matrix. Matrix A = [[1, 2, 3], [4, 5, 6]] Matrix B = [[7, 8], [9, 10], [11, 12]] #Erroneous Code# ```python def matrix_multiply(A, B): if len(A[0]) != len(B): return "Matrices cannot be multiplied." else: result = [[0]*len(B[0])]*len(A) for...
codefeedback
Write a Python program using Scrapy to collect data from multiple websites simultaneously. The program should store the collected data in a MongoDB database. Additionally, handle any potential errors that may occur during the scraping process, such as connection timeouts or HTTP errors.
codefeedback
Design a database schema for a table which stores customer information, including their personal details such as name, address, phone number, and email. Additionally, include fields to track their purchase history, such as order dates, products purchased, and order quantities. Ensure proper normalization and data types...
codefeedback
Convert the following for loop to a recursive solution. Instead of printing the value of 'i', sum up all the values of 'i' from 0 to 10 and return the final sum.
codefeedback
Write an algorithm to check if a given positive integer is a prime number or not, without using any built-in libraries or functions for prime number calculation or checking. The algorithm should have a time complexity of O(sqrt(n)), where n is the given positive integer.
codefeedback
Given two arrays of integers, find a pair of values (one from each array) that you can swap to give the two arrays the same sum. The length of the arrays will not exceed 10^5 and the maximum absolute value of any element in the arrays will not exceed 10^9. #Difficulty Increased Test#
codefeedback
Create a RUST program that prints out the highest prime number from an array of integers. The array may contain duplicates and negative numbers.
codefeedback
Implement a breadth-first search algorithm to find the shortest path between two nodes in a weighted graph in Java.
codefeedback
Create a shell script to list out the folders and its size in the current directory, excluding any folders that are hidden or have a size larger than 1 GB.
codefeedback
Create a program in C# to find the nth Fibonacci number in the sequence. However, you are not allowed to use recursion or the built-in Fibonacci function in any way. You must implement your own algorithm to calculate the Fibonacci sequence.
codefeedback
Validate the email address using a regular expression. The email must also have at least one uppercase letter, one lowercase letter, one number, and one special character. email = "example@gmail.com"
codefeedback
Write a program that takes a string as input and prints the same string with all the vowels replaced by a given character. The program should have a time complexity of O(n) and a space complexity of O(1), where n is the length of the input string.
codefeedback
Design a program that automatically refactors a python code to improve readability and reduce complexity. The program should be able to handle nested functions and classes, as well as complex data structures such as dictionaries and sets. Additionally, the program should be able to analyze and refactor code that includ...
codefeedback
Write a JavaScript program for finding the sum of all pairs of numbers in an array that add up to a given target value. Example: ```javascript Input: [1, 2, 3, 4, 5], target = 7 Output: [[2, 5], [3, 4]] Explanation: The pairs that add up to the target value of 7 are [2, 5] and [3, 4]. ``` Note: - The array may contai...
codefeedback
Replace every occurrence of 'a' with 'b' in the given string, while also ensuring that the resulting string is palindrome and contains exactly 3 vowels.
codefeedback
Modify the previous code so that it is now optimized for both time and space complexity.
codefeedback
Create a JavaScript program to loop through the following array in ascending order and calculate the sum of all even numbers divisible by 3. Then, display the sum and the number of elements that meet this criteria. The program should also print the average of the odd numbers in the array. Finally, the program should so...
codefeedback
Create a function that takes two integers as input: a starting number and an ending number. The function should return a list of square numbers between the two input integers (inclusive). Make sure to handle cases where the input integers are negative or where the starting number is greater than the ending number.
codefeedback
Write a Tensorflow model to classify a given set of X and Y coordinates into four categories: 1. Positive X and Positive Y 2. Positive X and Negative Y 3. Negative X and Positive Y 4. Negative X and Negative Y X = [1, 1, 2, 4, -3, -2, -4] Y = [3, 1, 0, 4, -1, 2, -3] Additionally, implement a mechanism to handle and ...
codefeedback
Design an efficient algorithm to search for an item in a two-dimensional array.
codefeedback
Create a function in Python which takes an integer n and an unsorted list of numbers as input and returns the nth smallest number in the list. Requirements: - The function should have a time complexity of O(n log n). - The function should have a space complexity of O(1). Example: Input: [10, 2, 8, 6, 4, 1, 5], 5 Outp...
codefeedback
Implement a recursive function in Python to calculate the nth Fibonacci number, where n is a non-negative integer. The Fibonacci sequence is defined as follows: the first two numbers in the sequence are 0 and 1, and each subsequent number is the sum of the two preceding ones. The function should have a time complexity ...
codefeedback
Identify the most efficient algorithm to find the maximum element in a 2D array of size n x m, where n is the number of rows and m is the number of columns. The array contains positive integers. The algorithm should have a time complexity of O(n*m) and a space complexity of O(1).
codefeedback
Sort the following list of strings in reverse alphabetical order, using a custom sorting function that first sorts by the length of each string in descending order, and then alphabetically within strings of the same length. list = ["apple", "mango", "banana", "pear"]
codefeedback
Create a C++ program that computes the weighted average of the given array elements, where each element is multiplied by its corresponding weight. The weights are provided in a separate array. The program should also output the index of the maximum element in the array. arr = {1, 2, 3, 4, 5} weights = {0.1, 0.2, 0.3, 0...
codefeedback
Generate a correct for loop that prints every prime number between 0 and 100.
codefeedback
Create a function that takes a dictionary, a list, and an integer as parameters, and returns the value of the dictionary corresponding to the given integer, only if the integer is present in the list. If the integer is not present in the list, the function should return None. The dictionary and list may contain duplica...
codefeedback
Create a function in JavaScript that reverses the order of characters in a given string while also preserving the original order of any non-alphabetic characters within the string. For example, if the input string is "Test@String123", the output should be "gnirtS@tseT321".
codefeedback
Write a program that can validate a given string as a valid email address according to the following requirements: - The email address must have a maximum length of 50 characters. - The local part (before the '@' symbol) must contain only alphanumeric characters, dots (.), underscores (_) and hyphens (-), and it cannot...
codefeedback
Create a program that accepts two strings as input, and then check to see if the two strings are an anagram of each other. An anagram is a word or phrase formed by rearranging the letters of another word or phrase. For example, "earth" and "heart" are anagrams of each other. In your program, you need to implement the ...
codefeedback
Use CSS to center a div inside a parent div, but the parent div must have a fixed height and width, and the child div must be positioned absolutely.
codefeedback
You are tasked with debugging an unresponsive Flask web application. Identify and fix the issue causing the unresponsiveness, ensuring that the application is functioning properly. Additionally, provide detailed documentation on the steps you took to debug and resolve the issue.
codefeedback
Using regex, convert a string of dates from the format 'dd/mm/yyyy' to 'mm/dd/yyyy'. The string can contain up to 10,000 dates.
codefeedback
Write a program that calculates the area and perimeter of a triangle with given sides. The program should: 1. Prompt the user to enter the lengths of the three sides of the triangle. 2. Check if the entered values are valid for forming a triangle. If not, display an error message and prompt the user to re-enter valid ...
codefeedback
Given a table called "customers" with columns for name, address, and city, write an SQL statement to add a new row to the table. Assign the following values to the columns: - name = 'John' - address = '123 Main Street' - city = 'Winter Park' In addition to adding the row, ensure that the name column does not already e...
codefeedback
Implement a function which takes an array and returns the maximum number. If the array is empty, return None. #Example# Input: [2, 4, 8, 6] Output: 8
codefeedback
Convert the given SQL query to its equivalent Python expression using list comprehension, ensuring that the result is sorted in ascending order of the student's name.
codefeedback
Write a Python function that finds the median of a list of numbers in a single pass, without using any built-in libraries or functions. The function should return the median as a floating-point number. Input: - A list of integers, `nums`, where 1 <= len(nums) <= 10^5 - The list may contain both positive and negative i...
codefeedback
Train a linear regression model on a dataset containing m columns and n rows, ensuring that missing values are handled appropriately. Additionally, apply feature scaling to the dataset before training the model.
codefeedback
Using HTML and CSS, create a two-columns landing page with a fixed navigation bar at the top and a footer at the bottom. The left column should contain a list of links, and the right column should display content based on the selected link. Add a responsive design feature, where the layout adjusts dynamically based on ...
codefeedback
Develop a Python function to append a number with zeros to a given string up to a maximum number of characters. However, the maximum number of characters should be a prime number.
codefeedback
Write an SQL query to count the number of records with age greater than 25 and salary greater than 50000 from a given table.
codefeedback
Create a code snippet to print the star pattern below in Python. The number of rows should be given as an input by the user. Example: Input: 5 Output: * *** ***** ******* *********
codefeedback
Write a code snippet to get the remainder when 34 is divided by 5, and then multiply it by 2, in JavaScript.
codefeedback
Name the commonly used data structure for implementing stacks. Provide a brief explanation of its implementation and discuss its time and space complexity.
codefeedback
Create a class to represent a complex number with two private fields (real, imaginary) and three public member functions (getMagnitude, incrementReal, incrementImaginary) in Java. The getMagnitude function should calculate and return the magnitude of the complex number, which is defined as the square root of the sum o...
codefeedback
Remove all duplicate words from the given sentence, while preserving the order of the remaining words. You must implement the solution using only a single loop and without using any built-in functions or data structures to store the unique words. The solution should have a time complexity of O(n), where n is the length...
codefeedback
Construct an SQL query that selects the employee name, job title, and salary for employees with a salary greater than $50,000. Additionally, sort the result in descending order based on the job title. Table Name: employee Columns: Name, JobTitle, Salary
codefeedback
Create a SQL query that searches the database for users with names beginning with the letter 'A' and whose age is less than 30. Table Name: Users
codefeedback
Construct an SQL query that averages the grades of students belonging to the Physics department, considering only students who have at least 3 completed courses. Table Name: Grades
codefeedback
Write a JavaScript code snippet that creates a pop-up window with the text "Welcome!" when a button with the id "popupBtn" is clicked. Additionally, the pop-up window should automatically close after 5 seconds and prevent the user from closing it manually.
codefeedback
Construct an SQL query to search the database for the user with the highest score, where the score is calculated based on the average of the last 10 games played by each user. Each game has a score between 0 and 100. Table Name: users Columns: user_id (integer), game_id (integer), score (integer), timestamp (datetime)
codefeedback
Write an AJAX query to get the data from the given URL and store it in a database. Then, retrieve the data from the database and display it on a webpage using HTML and CSS.
codefeedback
Write a JavaScript function that takes in a string as a parameter and returns the reversed version of the string. The function should have a time complexity of O(n), where n is the length of the input string.
codefeedback
Classify the following statement as true or false. The square root of 4 is 2. Additional instructions: 1. You cannot use the built-in square root function in your programming language. 2. You must implement your own square root function using any mathematical method of your choice. 3. Your solution must have a time...
codefeedback
Create a recursive function in Java that prints out each index in the array A from 0 to the length of A minus 1. The function should use only constant space complexity and have a time complexity of O(n), where n is the length of the array A. int[] A = {1, 2, 3, 4, 5}
codefeedback
Create a HTML page with a textbox and a button. When the button is clicked, display the message “Hello World!” in an alert box. Additionally, ensure that the textbox only accepts numeric input and display an error message if non-numeric characters are entered.
codefeedback
Rewritten Test: You are tasked with designing a data structure to store an employee roster containing their name, age, gender, and department. Additionally, the roster should support the following operations efficiently: 1. Add an employee to the roster. 2. Remove an employee from the roster. 3. Update an employee's ...
codefeedback
Reverse the following linked list in Java. // single linked list Node { int data; Node next; } head | V 1 -> 2 -> 3 -> 4 -> NULL Expected Output: 4 -> 3 -> 2 -> 1 -> NULL Note: You cannot create a new linked list. You must modify the given linked list in-place to reverse it. Additional Constraints:...
codefeedback
Write a PowerShell script to list all the installed applications on a Windows machine, excluding any applications that start with the letter "A".
codefeedback
Write a line of code to input 10 prime numbers from the user.
codefeedback
Create a function that searches for a given element in a list and outputs the index of the first occurrence of the element. If the element is not found, the function should return -1. Additionally, the function should only use recursion to implement the search algorithm. The list_numbers will always contain unique elem...
codefeedback
Create a Node.js program to find the first 5 prime numbers that are palindromic when represented in binary.
codefeedback
Write a function in JavaScript that takes the two given arrays, A and B, and merges them into a single array in a specific way. The merged array should have elements from A and B arranged alternatively, starting with the first element of A. For example, if A = [1, 2, 3] and B = [4, 5, 6], the merged array should be [...
codefeedback
Write a function in C# to round a given number to the next closest odd integer. Number: 27.7
codefeedback
Construct a regular expression pattern in Python that matches all emails, but also exclude any emails that contain the domain "gmail.com".
codefeedback
Create a function to compare two strings and output their similarity score, considering the following specific requirements: 1. The similarity score should be calculated based on the number of common characters between the strings, considering both the character and its position in the strings. 2. Ignore case sensitiv...
codefeedback
Create a class in TypeScript that contains a method that takes an array of numbers, finds the two largest numbers in the array, adds them together, and returns the result. Requirements: - The time complexity of the method should not exceed O(n log n), where n is the length of the input array. - The space complexity of...
codefeedback
Write a SQL query to retrieve the last five entries of a table called "students" in reverse order.
codefeedback
Create a thread-safe Java method that increments a given counter and then checks if the counter value is a prime number.
codefeedback
Write a command to install a package in Node.js from the Node Package Manager. Package name: ejs Additional Requirements: 1. The command should be written using asynchronous programming concepts. 2. The installation process should display a progress bar to indicate the installation progress. 3. The progress bar shoul...
codefeedback
Write a function in Go language that will return the number of unique elements in a slice, without using any built-in functions or data structures to track uniqueness.
codefeedback
Write a command to retrieve the first n items from a list in reverse order. For example, given the list [10, 20, 30, 40, 50] and n = 3, the command should return [40, 30, 20].
codefeedback
Design an algorithm in JavaScript that finds the k most frequent elements in an array, where k is a given integer.
codefeedback
Construct an HTML form that includes two input fields, one for a name and one for an email address. The form should have client-side validation to ensure that the name field is not empty and that the email address field is in a valid email format. Additionally, the form should have a submit button that, when clicked, s...
codefeedback
Write an SQL query to select all the customers who are from the US and have made at least 5 purchases in the last 30 days.
codefeedback
Write a code snippet in Python to print the contents of a nested dictionary that may contain dictionaries as values. {"key1": {"nested_key1": "value1", "nested_key2": "value2"}, "key2": {"nested_key3": "value3", "nested_key4": "value4"}}
codefeedback
Write a SQL command to create a table named "Employees" with the following columns: - "employee_id" (integer) as the primary key - "first_name" (text) - "last_name" (text) - "email" (text) with a unique constraint - "hire_date" (date) - "salary" (numeric) with a default value of 0.0 - "department_id" (integer) with a ...
codefeedback
Find the indices of the two numbers in an array that have the sum of a given number using JavaScript. The array will contain only positive integers. You cannot use any built-in methods or libraries to solve the problem. The time complexity of your solution should be O(n). Let arr = [2, 5, 11, 15], targetSum = 16.
codefeedback
Write a code to generate the first n terms of the Fibonacci sequence, where n is a prime number.
codefeedback
Merge two sorted linked lists and return it as a new list. The time complexity of your solution should be O(n+m), where n and m are the lengths of the two linked lists respectively.
codefeedback
Construct an array of objects in JavaScript to represent a list of users. Each user object should have properties for their name, age, and email. Additionally, each user object must have a unique ID, generated using a random alphanumeric string of length 10. The name property should only accept strings of at least 2 ch...
codefeedback
Print the nth prime number in ascending order using only O(1) space.
codefeedback
Implement a doubly linked list structure with the following methods using Java: 1. insertFront(int value): Inserts a node with the given value at the front of the list. 2. insertEnd(int value): Inserts a node with the given value at the end of the list. 3. insertAfter(int insertValue, int afterValue): Inserts a node wi...
codefeedback
Convert the following Python code to an equivalent JavaScript code. Handle any errors that may occur. for item in items console.log(item);
codefeedback