instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Write an HTML form for a survey about a school. Include validation for each input field to ensure that the user enters a valid response.
codefeedback
Create a SQL query to select the records of the table with column value greater than 5 and less than 10, while also excluding any records where the column value is a multiple of 3.
codefeedback
Generate C code that prints the result of multiplying two numbers. However, you are not allowed to use the multiplication operator (*) or any other built-in arithmetic operators or functions. int num1 = 10; int num2 = 5;
codefeedback
Write an assembly language program to check if two given numbers are equal or not, but you are not allowed to use any conditional branches or comparison instructions.
codefeedback
Write a Rust program to take an array of integers and print the sum of the elements in the array. However, you are not allowed to use any built-in functions or methods that directly calculate the sum of an array. You must implement the sum calculation using basic arithmetic operations and looping constructs.
codefeedback
Generate HTML code for displaying a list of items with the following requirements: - The list should be sorted in ascending order based on a specific attribute of each item. - Each item should have a unique identifier attribute. - The list should have a maximum of 10 items. - The HTML code should include a button to ad...
codefeedback
Write code to create a web server in Go that can handle concurrent requests and supports SSL/TLS encryption.
codefeedback
Write an algorithm to add a new user (name, email, password, address) to a table called 'users'. The email address must be unique and should follow the format 'username@domain.com', where the domain should be one of the following: 'gmail.com', 'yahoo.com', 'hotmail.com', 'outlook.com'. The password must be at least 8 c...
codefeedback
Write a function to query a database table 'trips' and return a list of all trips made over the past three months. Each trip in the list should include the following information: trip id, start date and time, end date and time, distance traveled, and average speed. Additionally, the trips should be sorted in descending...
codefeedback
Write a function that takes in an array of integers and a target integer, and returns the number of times the target integer appears in the array. The array can contain both positive and negative integers. #Example# Input: [5, 2, -4, 2, 5, 2, -5, 0], target: 2 Output: 3 #Constraints# - The length of the array will n...
codefeedback
Reverse a given string without using built-in library functions and without using additional data structures. The solution should have a time complexity of O(n) and a space complexity of O(1).
codefeedback
Using the input provided, write a code in Python to print the elements of a given dictionary along with the corresponding keys. Additionally, sort the dictionary in descending order based on the keys before printing the elements. my_dict = {'one':1, 'two':2, 'three':3, 'four':4, 'five':5} Expected output: five: 5 fo...
codefeedback
Design an algorithm to insert a new row into a table named 'products' with the following columns: title, description, price, and quantity. title: "New product" description: "This is an amazing product, it can do anything!" price: 10 quantity: 100 1. Connect to the database that contains the 'products' table. 2. Check ...
codefeedback
Write a code in Java to sort given list items in ascending order. my_list = [9, 4, 7, 2, 6] Additionally, you should handle the case where the list may contain duplicate elements.
codefeedback
Using TensorFlow, define a neural network for classifying a set of language data as either English or Spanish. Training data of 1000 samples with 500 English sentences and 500 Spanish sentences. The network should have at least 3 hidden layers and use the ReLU activation function. The model should also include dropout ...
codefeedback
Using the input provided, write a program in JavaScript that finds the largest prime number in an array. The array should contain at least 10,000 elements, and the prime number should be determined using the Sieve of Eratosthenes algorithm.
codefeedback
Write a JavaScript program to compute the difference between two dates in days, considering leap years and different months having different number of days. The two dates to compare are "2021/07/26" and "2022/06/01".
codefeedback
Using an AI platform, create a sentiment analysis model to predict a sentiment of a given sentence. Additionally, the model should be able to classify the sentiment into five categories: very negative, negative, neutral, positive, and very positive. The model should also be able to handle sentences with multiple clause...
codefeedback
Design a class in Java for creating a 2D point with the following requirements: 1. The point should be able to store both integer and floating-point coordinates. 2. The class should provide methods to set and retrieve the x and y coordinates separately. 3. The class should provide a method to calculate the distance be...
codefeedback
Write a code to optimize the parsing of a given sentence using CKY parsing, while also considering a larger vocabulary of words. Sentence: "The quick brown fox jumps over the lazy dog."
codefeedback
Suggest a method to optimize the following code to find the maximum value in an array, but without using any comparison operators such as ">". def find_max(arr): max = arr[0] for i in range(1, len(arr)): if arr[i] - max > 0: max = arr[i] return max
codefeedback
Create a program to detect spam emails by implementing a machine learning algorithm that can accurately classify emails as either spam or not spam based on their content and metadata. Additionally, the program should be able to continuously learn and improve its classification accuracy over time.
codefeedback
Design and implement a genetic algorithm for finding the optimal solution for the Traveling Salesman Problem, where the salesman must visit each city exactly once and return to the starting city, minimizing the total distance traveled.
codefeedback
Create an animation of multiple bouncing balls in the canvas using JavaScript. Requirements: - The balls should have random colors. - The balls should start from random positions on the canvas. - The balls should move in random directions and speeds. - The balls should bounce off the edges of the canvas. - The balls s...
codefeedback
Create a multi-threaded web scraper that can extract the title, description, and all the images present in the HTML of a given URL using BeautifulSoup. The program should also have the ability to handle dynamic web pages that are generated using JavaScript. The extracted data should be stored in a JSON file and all the...
codefeedback
Implement a function that takes a string as an argument, removes all duplicate characters from it, and returns the modified string. The function should only remove duplicate characters that are adjacent to each other. For example, if the input string is "aabbbccc", the function should return "abc".
codefeedback
Develop a program to join two strings with the following constraints: the length of String1 should be at least 5 characters long, and String2 should not contain any numbers. String1 = "HelloWorld" and String2 = "Goodbye".
codefeedback
How would you extend the following code to add the features "undo" and "redo" while maintaining a constant time complexity for adding items? def add_item(item, list): list.append(item) def undo(list): if len(list) > 0: list.pop() def redo(undone_list, list): if len(undone_list) > 0: item ...
codefeedback
Create a search engine to process natural language queries, with the following additional requirements: 1. Implement stemming: Stemming is the process of reducing words to their base or root form. For example, the word "running" should be reduced to "run" before processing the query. 2. Implement stop words removal: ...
codefeedback
Create an AI chatbot that can answer questions about the given topic "Covid-19". In addition to answering questions, the chatbot should also be able to provide real-time statistics of Covid-19 cases, including the number of confirmed cases, active cases, recovered cases, and deaths, for a specific country or worldwide...
codefeedback
Create a bash script to detect if a given IP address is valid or not, while also checking if the IP address belongs to a private network. The script should only consider IP addresses within the range of 10.0.0.0 to 10.255.255.255, 172.16.0.0 to 172.31.255.255, and 192.168.0.0 to 192.168.255.255 as valid private IP addr...
codefeedback
Generate a python program to solve the Tower of Hanoi problem with n discs, ensuring that each disc is a different size and the discs are initially stacked in increasing order of size on the first peg.
codefeedback
Given an array containing a string with duplicates, output an array with only unique strings, while maintaining the original order of the strings. ['apple', 'apple', 'orange', 'kiwi', 'apple', 'banana', 'banana'] # Higher Difficulty Test # Increase the size of the input array to a larger number (e.g., 100,000 element...
codefeedback
Explain the difference between JSON and XML, including their respective structures and use cases. Additionally, provide an example of a complex JSON structure and explain how it can be parsed and accessed using programming languages such as Python or JavaScript.
codefeedback
Create a dataframe in pandas that contains information about 7 employees. Each employee should have the following attributes: first name, last name, age, job title, salary, and years of experience. Additionally, create a function that can perform the following operations on the dataframe: 1. Sort the employees based o...
codefeedback
Sort this list of tuples in ascending order by the first value of the tuple. The tuples can have up to 10 elements and each element can have up to 10 characters. The number of tuples in the list can be up to 1 million. The sorting algorithm used should have a time complexity of O(n log n) or better.
codefeedback
Design a basic calculator that returns the output of two number inputs, but only using bitwise operators. The calculator should support addition, subtraction, multiplication, and division. Number inputs: 9, 12
codefeedback
Create a Java program to delete an element at a given position in an array. The position must be within the range of 1 to the length of the array. The program should handle the case where the position is outside of this range and provide an appropriate error message. The program should also handle the case where the ar...
codefeedback
Write a query statement to find all employees who joined in the last 10 years and have been with the company for at least 5 years.
codefeedback
Write an algorithm to determine if an input string is a palindrome, but with the additional requirement that the algorithm must be implemented using a recursive approach.
codefeedback
Generate a random string of a given length using different uppercase, lowercase characters, digits, and special characters. The string should have at least one uppercase letter, one lowercase letter, one digit, and one special character.
codefeedback
Describe the following heuristic optimization algorithm with additional complexity. [Algorithm Name] Enhanced Hill Climbing Algorithm [Problem Description] Implement an enhanced version of the Hill Climbing algorithm that is capable of finding the global optimum solution in a given search space. The original Hill Clim...
codefeedback
Implement a convolutional neural network (CNN) in Keras to solve the given classification problem. [Problem description] Given a dataset of images containing cats and dogs, create a CNN in Keras to classify the images into one of the two categories. Make sure to use data augmentation techniques such as rotation, scali...
codefeedback
Using Haskell, implement a function to calculate the sum of numbers from 1 to the given number, but excluding any number that is divisible by 3 or 5.
codefeedback
Train a logistic regression classifier on the given dataset. You are provided with a dataset containing information on Belgian bank customers. The dataset consists of 1000 rows and 5 columns, namely: - Age: the age of the customer (continuous variable) - Credit Score: the credit score of the customer (continuous varia...
codefeedback
Write an assembly language program to check if a given number is the smallest among a sequence of numbers. Additional instructions: 1. Instead of checking just one number, the program should prompt the user to enter a sequence of numbers. 2. The program should store the sequence of numbers in memory. 3. The program sh...
codefeedback
Generate a multi-threaded HTTP request using Python to send a GET request to https://www.wikihow.com/Main-Page. Each thread should include a different user agent header, and the program should be able to handle at least 100 concurrent requests.
codefeedback
Write a code to extract all the hyperlinks from a Wikipedia page and store them in a data structure. Your code should: - Accept a URL of a Wikipedia page as input. - Retrieve the HTML content of the page using web scraping techniques. - Parse the HTML content to extract all the hyperlinks. - Store the extracted hyperl...
codefeedback
Using HTML, CSS, and JavaScript, implement a drag and drop feature that only allows certain elements to be dropped into specific drop zones, and display a success message when the correct element is dropped into its designated zone. Additionally, ensure that the drag and drop feature is accessible for visually impaired...
codefeedback
Create a React component that accepts a string as a parameter and prints it in the console. The component should also display the length of the string on the screen. Additionally, the component should only accept strings that contain at least 5 characters and have at least one uppercase letter.
codefeedback
Write a code to check for a valid zip code in US and return the corresponding state.
codefeedback
Given a list of grocery items, write a code to generate 1 list containing only the fruits in the list. items = ["apple", "banana", "grapes", "rice", "onion"] Erroneous code example: ```python def get_fruits(items): fruits = [] for item in items: if item.lower() in ["apple", "banana", "grapes"]: ...
codefeedback
Parse a given HTML document and find all elements with the given class name using JavaScript. Additionally, check if the class name is nested within another class name, and if so, only return elements with the outer class name containing the nested class name.
codefeedback
Write a code to classify emails as spam or not-spam using Naive Bayes algorithms, while also considering the presence of attachments and the length of the email body. The code should take into account the frequency of words in both spam and not-spam emails, as well as the probability of an email being spam based on th...
codefeedback
Create a function to represent a decimal number in its binary form, but with the following additional requirements: 1. The function should be able to handle decimal numbers up to 1,000,000. 2. The function should have a time complexity of O(log(n)). 3. The function should not use any built-in conversion functions or li...
codefeedback
Implement the longest common subsequence algorithm in C, but you are not allowed to use any loops.
codefeedback
Determine the most efficient way to sort a complex data structure using Java. The data structure consists of objects with the following properties: - Name: a string of length at most 100 characters. - Age: an integer between 0 and 100. - Height: a float representing height in meters, accurate to two decimal places. - W...
codefeedback
Write a code snippet that reverses a string in JavaScript without using any built-in string manipulation methods or functions.
codefeedback
Write a Python function that prints the first n even numbers, where each number is a multiple of 4 and is greater than 100.
codefeedback
Explain what a cross-site scripting attack is and provide a code snippet demonstrating how it can be exploited.
codefeedback
Transform a given XML document into a nested JSON object using Python. The XML document may contain attributes, multiple levels of nested elements, and different types of data such as text, integers, and booleans. You should handle any edge cases, such as empty elements or attributes with no value. The time complexity...
codefeedback
Given two data sets, one containing the user id (user_id) and first name (firstname) and another data set containing user_id and last name (lastname), write a Python function to join the two sets and create a new data set with firstname, lastname and user_id. # Example Input user_id: [1,3,4,7] firstname: ["John", "Al...
codefeedback
Create a function to return all the indices in a string where a given substring occurs, but the substring can overlap with itself. For example, given the string "abababa" and the substring "aba", the function should return [0, 2, 4].
codefeedback
Using the given list of strings, create a function to count and return the number of capital letters in the list. The function should also handle strings containing non-alphabetic characters and ignore any capital letters within parentheses.
codefeedback
Create a JavaScript code snippet to check if an object contains a specified key. The object must have at least 5 nested levels, and the specified key must be located at the third level.
codefeedback
Write a Python program to compute and return a list that contains every possible combination of two given lists. The input lists may contain duplicate elements. The output list should only contain unique combinations, and the order of the combinations does not matter. list1 = [1,2,2] list2 = [3,4,4] Example: Input: l...
codefeedback
Generate a function that computes the sum of the prime numbers in a given list.
codefeedback
Create a class to store student names, ages, grades and attendance records. 1. The class should have a constructor that takes in the student's name, age, and grade as parameters and initializes the corresponding attributes. 2. Add a method called "add_attendance" that takes in a boolean value (True for present, False ...
codefeedback
Parse a JSON object and print out the elements. Additionally, the program should check if the 'name' key exists in the object and, if it does, print the value of the 'name' key. The program should also handle the case if the 'age' key is missing and print 'Unknown' as the value. The 'address' key should always be prese...
codefeedback
Write a virtual assistant in Python to gauge the sentiment of a given string. The string will be a paragraph of text, and the virtual assistant should be able to determine the sentiment of each sentence within the paragraph. The sentiment can be classified as either positive, negative, or neutral. Example input: strin...
codefeedback
Write a Python function to check if a number is perfect or not. A number is said to be a perfect number if the sum of its proper divisors is equal to itself. Proper divisors of a number are all the divisors excluding the number itself. Your function should take in a positive integer as input and return a boolean valu...
codefeedback
Complete the following code to fetch data from the "employees" table using an SQL query. The query should retrieve the following columns: employee_id, first_name, last_name, email, phone_number, hire_date, and job_id. The results should be ordered by the hire_date in descending order and only include employees who were...
codefeedback
Construct a loop to print prime numbers from 1 to 100 using a while loop in Python.
codefeedback
Change the following Python program so that it prints out all the distinct palindromic substrings of length greater than 1. The program should ignore case sensitivity and non-alphabetic characters. string = 'mom'
codefeedback
Create a Python script that finds the number of occurrences of a specific word in a given sentence, while also considering variations in capitalization and punctuation. Additionally, the script should be able to handle multiple words and return the count of each word in the sentence. For example, given the sentence "T...
codefeedback
Rewrite the following C program so that it prints the frequency of each character in a given string, excluding any digits present in the string. string = "abcabcabc123"
codefeedback
Design a solution in JavaScript to find the kth smallest element in an unsorted array. The array may contain negative numbers as well. Additionally, you are not allowed to use any sorting algorithms or built-in JavaScript functions to solve this problem. If the kth smallest element does not exist in the array, return -...
codefeedback
Make a class in Python which will represent a binary search tree. The tree should support the following operations: inserting a node, deleting a node, searching for a node, finding the minimum value in the tree, and finding the maximum value in the tree. Additionally, the tree should enforce the property that each left...
codefeedback
Design a simple HTML page using standard HTML tags which contains an input box, a button, and an output section. The input box should have the following requirements: 1. It should only allow alphanumeric characters. 2. It should have a maximum character limit of 100. 3. It should display an error message if the user e...
codefeedback
Multiply every element of a list and print the result. However, you are not allowed to use the '*' operator or any built-in multiplication functions. You can only use addition, subtraction, and bit shifting operations. The list will only contain positive integers. myList = [3, 4, 5]
codefeedback
How do you create a MySQL query to find a specific employee by their name and department in a table named 'employees'? Additionally, display the employee's salary and date of hire in the result set.
codefeedback
Design a database schema for a retail store that tracks customers, purchases, and items. The system should also track the sales representative responsible for each purchase and the commission earned by the representative for each sale. Additionally, the system should store information about the suppliers of the items, ...
codefeedback
What is the syntax for filtering a DataFrame using multiple OR conditions in Pandas, while optimizing for time complexity?
codefeedback
Create a function in Python that takes a date in the format "YYYY-MM-DD" as an argument and displays the corresponding day of the week from Monday to Sunday. The function should handle leap years correctly. You should not use any built-in date or time libraries in your solution. The time complexity of your solution ...
codefeedback
Write a function in Python that accepts an array of positive integers as an argument and returns the index of the first occurrence of the item with the maximum value. If there are multiple occurrences of the maximum value, return the index of the occurrence with the lowest index value. arr = [2, 5, 9, 4, 10, 10] For ...
codefeedback
Increase the difficulty by requiring the function to return the tuple in a specific order, where the first element is the index and the second element is the value. #Rewritten Test# Rewrite the following function so that it returns a tuple in the format (idx, arr[idx]) instead of two separate values. def random_arr(a...
codefeedback
In Java, what is a good way to make a deep copy of an object that contains nested collections and requires custom serialization and deserialization methods?
codefeedback
Write an algorithm that takes a set of positive numbers and returns the sum of all numbers in the set. The algorithm should also handle the case when the set is empty and return 0 in such cases. Additionally, the algorithm should have a time complexity of O(n), where n is the size of the set. my_set = {2, 3, 4, 5}
codefeedback
Design a class BankAccount that represents a bank account with the attributes name, balance, and interest_rate. The balance attribute should be restricted to only positive values, and the interest_rate attribute should be restricted to a range between 0 and 10. Additionally, implement a method that allows for withdrawi...
codefeedback
Create a method that takes a string as a parameter and returns the number of unique characters present in the string. However, the method should not consider characters that are surrounded by quotation marks as part of the string. For example, if the input string is 'ab"cd"ef', the method should only count 'a', 'b', 'e...
codefeedback
Update the given code to sort an array of strings based on their lengths in descending order. Additionally, you should implement the sorting algorithm from scratch instead of using built-in sort functions. arr = ["dogs", "cat", "lion", "elephant", "tiger", "giraffe", "zebra", "monkey", "snake", "crocodile", "bear", "w...
codefeedback
Create a function that takes in two parameters, a list of integers and a target sum. The function should return a list of all pairs of integers from the input list that add up to the target sum. If there are no such pairs, the function should return an empty list. The function should have a time complexity of O(n), wh...
codefeedback
Using the input provided, generate a random string consisting of 8 characters, where each character can be any lowercase letter or digit.
codefeedback
Write a Swift program to calculate the factorial of a given integer, but without using any loops or recursion.
codefeedback
Write a comprehensive test suite to thoroughly test an arithmetic function that takes two arguments and returns the sum. The function should handle positive and negative integers, floating point numbers, and zero as inputs. Additionally, the function should correctly handle edge cases such as very large or very small n...
codefeedback
Compile a given C program and link it with a shared library, ensuring that the program dynamically loads the shared library at runtime. The shared library must contain a function that takes a string as input and returns the string reversed. The C program should then call this function and print the reversed string.
codefeedback
Design a function to find the number of common keys between two arrays, where the keys are objects and each object has a name and age property. Additionally, the function should only consider objects with an age greater than 18 and should return an array of the common keys sorted in descending order based on the name p...
codefeedback
Rewritten Test: Write a program that takes a MySQL query as input and executes it against a database. The program should return the result of the query in a formatted manner. Requirements: 1. The program should be able to handle any valid MySQL query, including complex queries with multiple tables, joins, and subqueri...
codefeedback
Create a responsive website using HTML and CSS that displays "Hello, World!" in a stylish font, with a background color that changes every 5 seconds. Additionally, implement a button that allows users to toggle between displaying the text in uppercase and lowercase.
codefeedback
Create a console application in C++ that computes the sum of two numbers that are user input. However, you must restrict the use of basic arithmetic operators (such as +, -, *, /) in your code. Instead, you are required to implement the addition algorithm using bitwise operations only. Additionally, you should handle t...
codefeedback