instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Write a search engine using an index in JavaScript. The search engine should be able to handle large amounts of data efficiently. Additionally, implement a feature that suggests related search terms based on the user's input.
codefeedback
Write a SQL query to find customers who have purchased the most items in the last month, considering only the unique items they have purchased.
codefeedback
Convert the given HTML code into its equivalent JSON structure. The HTML code may contain nested elements, such as div, span, ul, li, etc.
codefeedback
Given an array of integers, write a program to find the longest consecutive sequence of positive odd numbers.
codefeedback
Create a GUI calculator app in Java that allows users to perform basic arithmetic operations such as addition, subtraction, multiplication, and division on two numbers. The app should also include a button to clear the input fields and display the result of the operation in a separate output field. Additionally, implem...
codefeedback
Write a SQL query to find the employee names, job titles, and departments of employees who have been working in the company since January 2019 and have a salary greater than $50,000.
codefeedback
What is the Python function for swapping the values of three variables?
codefeedback
Write a program that connects to a database and executes the given SQL query, which should retrieve the names and ages of people whose age is less than
codefeedback
Create a class in Java to store student grades with functions for adding and calculating average grades. The class should also include a function to find the highest and lowest grades in the list of student grades. The average grade should be calculated excluding the highest and lowest grades. The student grades should...
codefeedback
Compare the given hashes and return true if they have the same set of keys and values. The function should have a time complexity of O(n), where n is the number of key-value pairs in the hashes. Additionally, the function should be able to handle larger input sizes efficiently. Hash1: {"a": 1, "b": 2, "c": 3, "d": 4, ...
codefeedback
Explain the benefits of using the OOP approach in programming, providing examples of at least three different design patterns commonly used in OOP.
codefeedback
Write an HTML web page from scratch that displays a list of 10 different CSS colors randomly. The colors should not repeat within the list, and each color should be displayed in a different font size.
codefeedback
Design an algorithm that can efficiently search for the closest element to a given value in a given sorted array.
codefeedback
Write a C++ program that orders the elements of an unordered array from greatest to smallest using a modified version of the bubble sort algorithm. The program should include the following features: - Implement a custom function for swapping two elements in the array. - Use a dynamically allocated array instead of a fi...
codefeedback
Create a React component that will render a list of student details for a particular class. The component should also include a search functionality that allows the user to filter the list based on specific criteria such as student name, grade, or attendance. Additionally, the component should display the average grade...
codefeedback
Write a JavaScript function that generates the Fibonacci sequence up to a given number, while also calculating the sum of all the numbers in the sequence.
codefeedback
Create an algorithm that performs bubble sort. In addition, implement a flag to indicate whether the array is already sorted before the completion of the sorting algorithm.
codefeedback
Create an SQL query that pulls data from three tables and sorts the results in descending order by date. Additionally, include a condition that only retrieves rows where the date is greater than a specific value provided as a parameter.
codefeedback
Write an algorithm to count the number of pairs in an array whose absolute difference is a prime number. The array will contain positive integers. The algorithm should return the count of such pairs. nums = [1, 5, 3, 4, 7, 8]
codefeedback
Create an algorithm to merge two sorted linked lists, but now the linked lists may contain duplicate values. Linked List 1: 1 - 3 - 4 - 7 - 7 Linked List 2: 2 - 4 - 5 - 8 - 8
codefeedback
Write a TensorFlow program for a multiple regression model with a custom loss function and regularization.
codefeedback
Create an object sorting function using bubble sort in JavaScript. const arr = [{id: 3, value: 10}, {id: 1, value: 4}, {id: 2, value: 7}, {id: 5, value: 8}, {id: 4, value: 1}, {id: 6, value: 6}] The function should sort the array of objects based on the "value" property in ascending order. If two objects have the same...
codefeedback
Create a function that takes in a timezone as a parameter and returns an instance of the Date class that represents the current date and time in that timezone. The function should also include error handling for invalid timezones.
codefeedback
Create a singly linked list of N integers, where N is an input parameter to the function. The function should allow for inserting, deleting, and searching for elements in the linked list. Additionally, implement a method to reverse the linked list in-place.
codefeedback
Implement the Bubble Sort algorithm to sort an array of integers in non-decreasing order. Your solution should have a time complexity of O(n^2), and should not use any built-in sorting functions or libraries. Additionally, you should handle cases where the input array is empty or contains duplicate elements.
codefeedback
Write an HTML code that creates a table with five columns and ten rows. Each cell in the table should contain a random number between 1 and 100. The table should have a header row with column names "ID", "Name", "Age", "Gender", and "Score". Additionally, the table should have alternating background colors for each row...
codefeedback
Implement a function in Rust which adds two numbers and returns the sum. However, you are not allowed to use the "+" operator or any built-in functions for addition. You can only use basic arithmetic operations like subtraction, multiplication, and division.
codefeedback
Sort the following items in O(n^2) time complexity. [2, 5, 4, 3, 9]
codefeedback
Scale up the following backend service using Kubernetes. Requirements: 1. The backend service should be scaled up to a minimum of 3 replicas. 2. Each replica should have a minimum of 2 CPU cores and 4GB memory allocated. 3. The service should be exposed through a LoadBalancer type service. 4. The service should only b...
codefeedback
Given a list of numbers, write a Python program to find the maximum and minimum number. However, you are not allowed to use any built-in functions or methods such as max(), min(), or sorting algorithms. Additionally, the program should have a time complexity of O(n), where n is the length of the list.
codefeedback
Design a function to filter words based on given characters. However, the characters may be given as a string or a list. The function should be able to handle both cases. characters = "aeiou" words = ['apple','elephant','mountain','river'] #Incorrectly Implemented Function# def filter_words(characters, words): fil...
codefeedback
Create an API endpoint for the following model, while also implementing the following additional features: 1. Authentication: Ensure that only authenticated users can create, update, or delete comments. 2. Pagination: Implement pagination for retrieving comments, allowing for a specified number of comments per page. 3...
codefeedback
Implement a B-Tree data structure with the following additional requirements: 1. The B-Tree should support both insertions and deletions of elements. 2. The B-Tree should be able to handle duplicates, allowing multiple occurrences of the same element. 3. Each node in the B-Tree should have a maximum of M children, whe...
codefeedback
Write a procedure in PL/SQL to find the sum of numbers from 1 to 10, but you are not allowed to use loops or any built-in functions that directly calculate the sum of numbers.
codefeedback
Create a function that takes two strings, s1 and s2, and checks to see if s2 is a substring of s1. The function should return True if s2 is a substring of s1, and False otherwise. Additionally, add the following requirements: 1. The function should be case-sensitive, meaning that "hello" is not considered a substrin...
codefeedback
Write a query in MySQL to delete all rows with a given ID from a table containing millions of records, while minimizing the impact on database performance.
codefeedback
Create a dictionary containing the count of each word in the sentence, while also excluding any common words such as "the", "a", "an", "and", "or", "but", "if", "is", "are", "was", "were", "has", "have", "had", "do", "does", "did", "for", "of", "with", "at", "by", "from", "in", "out", "on", "off", "to", "into", "onto",...
codefeedback
Create a package in R called "myPackage" and save it in a specific directory such as "/Users/yourname/Documents/RPackages". Additionally, include a function called "calculateMean" within the package that takes in a numeric vector as input and returns the mean of the vector.
codefeedback
Write a program that calculates the factorial of a given number using a for loop and prints the result. The factorial of a number is the product of all positive integers less than or equal to that number. a = 5 To solve this problem, you can initialize a variable, let's say "factorial", to 1. Then, use a for loop to i...
codefeedback
Print the output of the following nested loop, where the inner loop iterates from 1 to 5 and the outer loop iterates from 1 to 10. for i in range(1, 11): for j in range(1, 6): print(i * j)
codefeedback
Using a dictionary comprehension, select the keys that start with a specific letter and have a value greater than 1. Only consider keys that are strings and have a length greater than 3. d = {'cat' : 1, 'dog' : 2, 'mouse' : 3, 'elephant' : 4, 'lion' : 5}
codefeedback
Write a function that takes in a string of text and counts the number of times each lowercase vowel (a, e, i, o, u) appears in the string. The function should ignore uppercase vowels, consonants, and any other characters that are not lowercase vowels. text = "The quick brown fox jumps over the lazy dog"
codefeedback
Use a built-in Python method to print the contents of a list in reverse order, while ensuring that all even numbers in the list are printed first, followed by the odd numbers. Additionally, the solution should have a time complexity of O(n) and should not use any additional space other than the input list. arr = [1, 2,...
codefeedback
Launch an instance of an Amazon EC2 machine and write a program that automatically provisions the instance, installs a specific set of software, and configures the instance according to predefined specifications. The program should handle errors and retry failed provisioning steps, ensuring that the instance is success...
codefeedback
Calculate the distance of two points located in the 3-dimensional space. The distance should be rounded to two decimal places. Point 1: (3, 4, 5). Point 2: (2, 6, -1). The program should also display the vector components of the resulting distance in the form (x, y, z).
codefeedback
Write a query to return all the names of the tables in a database, but exclude any tables that have a specific prefix in their name.
codefeedback
Write a Python code to search for a given keyword in a dictionary and return the key-value pairs that contain the keyword. Additionally, the code should also allow for partial matches, meaning if the keyword is found within a value but not as a complete word, it should still be considered a match.
codefeedback
Generate a query to get the first 10 rows from the given table, excluding any rows where the "age" column is less than 18. Table name: "users"
codefeedback
Write a PHP function to print out multiplication table between two numbers, but with the following conditions: 1. The function should take three parameters: the two numbers between which the multiplication table should be printed, and a third parameter representing the number of columns in the table. 2. The function sh...
codefeedback
Create a C program to check if two strings are equal or not. The program should have a time complexity of O(n), where n is the length of the longer string. Additionally, the program should not use any library functions for string comparison. string1 = "Hello"; string2 = "Hello";
codefeedback
Generate a unique ID for a given string by performing the following steps: 1. Convert the string to lowercase. 2. Remove any leading or trailing spaces from the string. 3. Replace all consecutive spaces with a single space. 4. Remove all non-alphanumeric characters from the string. 5. Replace all spaces with underscore...
codefeedback
Create an API to return the average age of the users in the given database. However, the database connection is currently not established. You need to write the code to establish the connection first before retrieving the data. Database name: "users_database"
codefeedback
Write a regex pattern to match words that begin with "cat" and end with "s".
codefeedback
Using the given JSON string, extract the value of the "title" field, and assign it to a variable. Additionally, convert the value to uppercase and remove any leading or trailing whitespaces before assigning it to the variable. var jsonStr = '{"title":" My book ","author":"John Smith"}';
codefeedback
Write Angular code to bind a variable to the HTML view and implement two-way data binding using ngModel directive. Additionally, the variable should be an array of objects, and the HTML view should display the objects' properties in a table format.
codefeedback
Using the code provided, write a regular expression pieces of code that validates an email address and checks if the domain name of the email address is a valid top-level domain (TLD).
codefeedback
Create an SQL query that calculates the average of all the numbers greater than 10 from the 'number' column in the table 'test_data'.
codefeedback
Using the code provided, write a JavaScript function to compare two numbers and return the larger one. Additionally, ensure that the function is case-sensitive and returns an error message if the input is not a number.
codefeedback
Edit the given code to generate an Array of all the prime numbers between 1 and 100.
codefeedback
Generate a sorting algorithm written in Java that sorts an array of integers in ascending order. The sorting algorithm must be based on the quicksort algorithm, using a pivot element chosen randomly. Additionally, the algorithm should be implemented recursively.
codefeedback
Using the code provided, write a JavaScript function that checks if a given number is prime or not. However, you must implement the function without using any looping constructs (such as for, while, or do-while).
codefeedback
Using regular expression, write a code to extract words that start with a specific letter from a given string. However, the code should ignore any words that have the letter as a substring in the middle or at the end of the word. For example: string = "This is a test sentence" letter = "t" The expected output should...
codefeedback
Increase the difficulty of the given programming test by requiring the use of a specific synchronization mechanism, such as locks or semaphores. Rewrite the code such that it uses a lock to synchronize access to the shared variable `x` and prevents race conditions. ```java import java.util.concurrent.locks.Lock; impo...
codefeedback
Using numpy, write a code to multiply matrix A and B together. matrix A: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] matrix B: [[9, 8, 7], [6, 5, 4], [3, 2, 1]] Requirements: - The code should use numpy for matrix multiplication. - The code should handle matrices of any size. - The code should have a time complexity of O(n^3)...
codefeedback
Take in an array of integers and return the sum of all odd numbers. The array will contain at least one odd number and at most 1000 elements.
codefeedback
Create an HTML page with two columns and a tabular structure showing the employee salaries. Each row of the table should contain the following information for each employee: - Employee ID (a unique identifier for each employee) - Employee Name - Employee Department - Employee Position - Employee Salary In addition t...
codefeedback
Write a function that takes in a string and returns true if it is a valid IPv4 address and false otherwise. A valid IPv4 address consists of four decimal numbers, separated by periods, where each decimal number is between 0 and 255. Leading zeros are not allowed. For example, "127.0.0.1" is a valid IPv4 address, but ...
codefeedback
Take in a string and return an output where every third character of the input string is capitalized and every fourth character is replaced with a random symbol.
codefeedback
Write a set of if-else statements to convert numerical grade 1-100 to their letter grade equivalent. Additionally, handle the case where the numerical grade is negative or greater than 100 and display an error message for such cases.
codefeedback
Create a function to return all possible sums of two numbers in a given array. The function should also handle negative numbers and return the sums in ascending order. #Erroneous Code# Create a function to return all possible sums of two numbers. However, there is an error in the code that needs to be fixed. The funct...
codefeedback
Take in a list of integers and return true if any of the numbers in the list are prime numbers. The list can contain both positive and negative integers. The length of the list will be at most 10^6. The input numbers can be as large as 10^12. You should provide an efficient solution with a time complexity of O(n * sqrt...
codefeedback
Input a string with parameters and return an updated string that replaces each parameter with its corresponding value. However, the parameters can be nested within each other, and the values can be nested within other values. For example, the input string may contain a parameter like "{x}" and the value of "x" may be a...
codefeedback
Write a program that classifies a given string into the following categories using Regular Expressions: 1. Alphabetic strings 2. Numeric strings 3. Alphanumeric strings 4. Special character strings
codefeedback
Create an array in C++ and initialize it with 5 integer values. Then, implement a function that finds and returns the second smallest element in the array. The function should have a time complexity of O(n), where n is the size of the array.
codefeedback
Write a Java program to iterate through a HashMap and print the keys and values in reverse order.
codefeedback
Edit the following array in JavaScript so that all the strings are in uppercase. However, instead of using the built-in `toUpperCase()` method, you need to implement your own function to convert each string to uppercase. You are not allowed to use any built-in string manipulation functions.
codefeedback
Create a form element in HTML with the following requirements: - The form should have at least three input fields, including one text input, one checkbox, and one select dropdown. - All input fields should have proper labels. - The form should have a submit button with a custom background color and rounded corners. - U...
codefeedback
Write a JavaScript function that takes two parameters, which are both arrays of numbers, and compares them. The function should return true if the sum of the numbers in the first array is greater than the sum of the numbers in the second array, and false otherwise.
codefeedback
Using PHP, how can you print the JavaScript code that displays an alert message with the text “Hello World” only if the user's browser supports the latest version of ECMAScript (ES6) and has JavaScript enabled?
codefeedback
Write a SQL query to find the average rating of a movie having the title "The Godfather" and released in the year 1972.
codefeedback
Edit the following code to ensure that the conditions in the if-else statement are met. Additionally, use bitwise operators to check if x and y are both even numbers. if ((x & 1) === 0 && (y & 1) === 0 && x === 2 && y === 2) { console.log("x equals y and both are even numbers"); }
codefeedback
Reverse a string of characters and words in place. Example: Input: "Hello World" Output: "dlroW olleH"
codefeedback
Make an executable Bash shell script to print the factorial of a given number, but you are not allowed to use any loop structures or recursion.
codefeedback
Write a Bash script that takes a filename as input and prints its details such as ownership, permissions, group, filesize, etc. The script should also calculate and display the checksum of the file using SHA-256 algorithm. Additionally, the script should only allow execution by a user who has root privileges.
codefeedback
Create a table with three columns that stores a username, a password, and an email address. Implement a registration system where users can input their username, password, and email address. Validate the inputs to ensure that the username is unique, the password meets certain complexity requirements (e.g. minimum lengt...
codefeedback
Write a Ruby script that given an array of numbers, finds the greatest common factor (GCF) of all the numbers in the array. Additional Requirements: 1. The input array will always contain at least two numbers. 2. The script should handle both positive and negative numbers. 3. The script should handle decimal numbers a...
codefeedback
Write a SQL query to get the top 5 employees with the highest salary in the company, considering only those who have been employed for at least 3 years.
codefeedback
Develop a custom API endpoint for an online store using Node.js that allows users to add items to their shopping cart. Each item should have a name, price, and quantity. The endpoint should validate that the user is logged in before adding an item to the cart. If the user is not logged in, an error should be returned. ...
codefeedback
Generate a unique ID of exactly 8 characters in C#. The ID must consist of a combination of uppercase letters, lowercase letters, and numbers. Additionally, the first character of the ID must be a letter (either uppercase or lowercase), and the remaining 7 characters can be any combination of letters and numbers.
codefeedback
Design a REST endpoint for a web-scraping application that allows users to provide a target website URL and specify the data they want to scrape. The endpoint should return the scraped data in a specified format, such as JSON or XML. Additionally, the endpoint should implement rate limiting to prevent abuse and ensure...
codefeedback
Inject a variable in a Python script, named "greeting_message" with the value "hello world", but the value should be encrypted using a Caesar cipher with a shift of 13.
codefeedback
Construct an array of integers from 1 to 10000 in Javascript.
codefeedback
Write a recursive function in JavaScript that reverses a given string, but without using any built-in string manipulation methods. Example: Input: "Hello, world!" Output: "!dlrow ,olleH" You can assume that the input string will only contain alphanumeric characters and punctuation marks.
codefeedback
Write a HTML fragment that creates a list of hyperlinks of four book titles. The Cat in the Hat, Harry Potter and the Philosopher's Stone, To Kill a Mockingbird, The Great Gatsby. In addition to creating the list of hyperlinks, modify the HTML fragment to include a CSS stylesheet that changes the color of the hyperlin...
codefeedback
Create a Python script to generate a random password of 12 characters that contains at least 2 uppercase letters, 2 special symbols, and 2 numbers. The password should also have a mix of lowercase letters.
codefeedback
Create a program in JavaScript that calendarizes the upcoming week based on the current date. Additionally, the program should implement a feature that allows the user to input their preferred start day of the week (e.g., Sunday, Monday, etc.) and display the calendar accordingly.
codefeedback
Compile and run a C++ program that outputs the sum of all prime numbers between 1 and a given integer n, multiplied by the square of n. n = 10
codefeedback
Write a Rust program that prints the Fibonacci sequence up to a given number, where the starting number and the limit are provided by the user.
codefeedback
Create a processing sketch that can randomly generate 1000 circles within a given area. Requirements: 1. Each circle should have a random radius between 10 and 50 pixels. 2. The circles should be randomly positioned within a 600x600 pixel canvas. 3. The circles should not overlap with each other. 4. The circles should...
codefeedback
Create an array in C++ with 4 elements, where each element must be a prime number between 10 and
codefeedback