instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Create a web page that contains a button with the text "Click Here!". When the button is clicked, the background color of the button should change to red. Additionally, a popup should appear displaying the number of times the button has been clicked. To achieve this, you need to implement the following steps: 1. Crea...
codefeedback
Construct a code to replace all instances of 'A' with 'Z' and 'B' with 'Y' in a given string, while also preserving the original case sensitivity. For example, if the original string is "This is a string AB with multiple AB's", the code should replace 'A' with 'Z', 'B' with 'Y', 'a' with 'z', and 'b' with 'y', resultin...
codefeedback
Write a C++ code to implement quick sort algorithm with the following additional requirements: 1. The pivot element should be selected randomly from the array. 2. The partitioning step should be implemented using the Hoare's partition scheme. 3. The quick sort algorithm should be implemented as a recursive function. 4....
codefeedback
Write a web scraper using Python that retrieves data from a website and saves it to a database. The website uses JavaScript to load data dynamically, and you must find a way to handle this dynamically loaded content. Implement rate limiting to avoid overwhelming the website's server and handling of anti-scraping measur...
codefeedback
Print the first prime number that occurs in the list and is divisible by 5, but it must also be larger than 10 and smaller than 100.
codefeedback
Given a list of phone numbers, write a code to find the one with the highest number of repeated digits. The phone numbers may contain special characters such as parentheses, hyphens, or spaces. Your code should consider the repeated digits only when comparing the phone numbers. phone_numbers = ["+44 (0) 123-456-789", ...
codefeedback
Return the index of the first occurrence of an element in the given array, but only if the element occurs consecutively at least three times in a row. If there are no consecutive occurrences, return -1. arr = [2, 3, 3, 3, 1, 5, 2]
codefeedback
Write a function in Python that takes in a list of positive integers and returns the second largest element. The list must have at least 10 elements and cannot contain duplicates. Additionally, the function should be able to handle a list with a size up to 10,000 elements efficiently. list_of_numbers = [i for i in ran...
codefeedback
Please implement a thread-safe LRU cache in Java with the following requirements: 1. The cache should have a fixed capacity. 2. When the cache is full and a new element is added, the least recently used element should be removed. 3. The cache should support thread-safe operations, allowing multiple threads to read and...
codefeedback
Write a CSS class to create a link which shows on hover. Additionally, make the link underline when it is hovered over. Implement a transition effect to smoothly animate the appearance and disappearance of the link.
codefeedback
Write a code to detect if a string is a palindrome or not. Output true if it is a palindrome, output false if it is not. Palindrome is a word, phrase, number, or other sequence of characters which reads the same forward and backward, ignoring spaces, punctuation, and capitalization. For example, "racecar" is a palind...
codefeedback
Create a SQL query to select all columns in a table but exclude the contents of a specific column. Additionally, ensure that the query only includes rows where a certain condition is met. The condition should be that the sum of a specific column in each row is greater than a given value.
codefeedback
You need to write a program that takes a list of words as an input and returns the longest word in the list that starts with a vowel and ends with a consonant. Additionally, the program should ignore any words that contain numbers or special characters. If there is no such word, the program should return None. word_lis...
codefeedback
You need to write a program that takes a given string and checks if it is a valid IP address. The program should also handle both IPv4 and IPv6 addresses. Additionally, the program should validate that the IPv6 address is in the recommended compressed format, where leading zeroes in each block can be omitted. string1=...
codefeedback
You need to write a program to delete a given node from a singly linked list. However, you can only access the node to be deleted, and not the head of the linked list. Example: head = [1, 2, 3, 4, 5] node_data = 3 In this case, you can only access the node with data = 3. You cannot access the head node or any other n...
codefeedback
You need to write a program to print out the prime numbers between a given range of numbers, where the starting number is greater than 1 and the ending number is less than or equal to 10^9. Additional Requirements: 1. The program should run in O(n log(log n)) time complexity, where n is the difference between the star...
codefeedback
How can I get the second-to-last element of this list, without using any built-in list methods? The list may contain up to 10^6 elements and all elements will be integers between 1 and 10^6 (inclusive).
codefeedback
Using Python, write code to check if a list contains duplicates or not, with a time complexity of O(n) and a space complexity of O(1). Additionally, handle the case where the list contains negative integers as well. list = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50]
codefeedback
Create a highly scalable and performant AWS service to host a website with the following specifications: 1. The website should be able to handle extremely high traffic and should be capable of auto-scaling based on demand. 2. The website should have a highly available and durable database backend to store user informa...
codefeedback
Construct a URL to search for a given query on Google, while also including the options to filter search results by date and location. The function should take the following parameters: - query: A string representing the search query. - date: A string representing the desired date range for the search results. This ca...
codefeedback
Construct a JSON object to represent the following shoes array, ensuring that the "name" field is a string with a maximum length of 50 characters, the "color" field is a string with a maximum length of 20 characters, the "size" field is a number between 5 and 15 (inclusive), and the "brand" field is a string with a max...
codefeedback
Translate the statement "All animals are mammals" into a valid predicate in first-order logic, including a specific condition for aquatic animals. Additionally, consider introducing a specific condition for mammals that can fly.
codefeedback
Describe the difference between lists and tuples in terms of mutability, indexing, and iteration. Additionally, you should implement a function that takes in a list of tuples, removes any tuples that have a duplicate element, sorts the modified list in descending order based on the length of the tuples, and returns the...
codefeedback
Write an HTML tag to create a table with four columns and three rows, where each cell in the second column contains a link to an external website and the first row has a background color of #FF0000.
codefeedback
Using the given data, find the average monthly temperature in Fahrenheit for the months of June, July, and August, excluding any temperature readings below 80 degrees. Additionally, round the average temperature to the nearest whole number. To solve this problem, we need to perform the following steps: 1. Create an a...
codefeedback
Write a program to generate the Fibonacci sequence up to a given number 'n', where n is greater than or equal to 2. The program should also calculate the sum of all the Fibonacci numbers generated. Additionally, the program should check if the sum of all the Fibonacci numbers generated is a prime number and display a m...
codefeedback
Create a Ruby function to generate a number between -1000 and 1000 with a precision of exactly 10 decimal places and ensure that the number is always divisible by 5.
codefeedback
Design a MySQL query to find out the youngest employee who has a salary greater than $50,000 and works in the department with the highest average salary.
codefeedback
Write a SQL query to get the top 10 customers with highest overall spending, considering only customers who have made at least 5 purchases and have spent a total of at least $1000. #Explanation# To solve this problem, we need to consider customers who have made at least 5 purchases. Additionally, we need to calculate ...
codefeedback
Write an SQL query to display all employees who work in the R&D department, have a salary higher than the average salary of all employees in the company, and have been with the company for at least 2 years.
codefeedback
Implement a recursive algorithm in Java to count the number of ones in a binary number, without using any bitwise operations or loops. The input binary number will be a string of 0s and 1s with a maximum length of 10 characters. The algorithm should have a time complexity of O(n), where n is the length of the binary nu...
codefeedback
Write a query in MySQL to display the top 5 highest salaries, but exclude any employees whose salary is above $150,000 and have been employed for at least 3 years.
codefeedback
Using JavaScript, convert the following JSON object into a string. However, before converting, add an additional key-value pair to the JSON object. The new key should be "address" and the value should be an object with two key-value pairs: "street" with a value of "123 Main Street" and "city" with a value of "New York ...
codefeedback
Write a SQL statement that selects the name, age, gender, and address of every student in the database who is enrolled in at least three courses, has an age greater than 20, and whose address starts with the word "Main".
codefeedback
Create a PHP function to print the first 1000 prime numbers that are also palindromic, and each prime number must be greater than or equal to 10.
codefeedback
Create a function in C++ to calculate the sum of a range of numbers, with the additional requirement that the range should exclude any multiples of a given divisor. The function should have a time complexity of O(n), where n is the size of the range.
codefeedback
Create a Java program to find all Armstrong numbers in a given range and display them in descending order. An Armstrong number is a number that is equal to the sum of its digits raised to the power of the number of digits. For example, 153 is an Armstrong number because 1^3 + 5^3 + 3^3 = 153. Your program should take...
codefeedback
Create a function in Python that takes in an integer and breaks down the number into its digits. The function should then check if any permutation of the digits is a prime number and return a boolean value indicating the result. Note: A permutation is a rearrangement of the original digits. For example, the permutatio...
codefeedback
Write a Python program to find all numbers from 1 to the given number n which are divisible by 6, have the sum of their digits divisible by 3, and are not divisible by 4.
codefeedback
Construct a JSON object from the given key-value pair, where the value can be either a string or a number. Key-Value Pair: name:John Doe Erroneous Code: // Incorrect way of creating a JSON object var obj = {name = "John Doe"}; New Constraint: The value of the "name" key should always start with a capital letter. Ne...
codefeedback
Create an animation using CSS that moves an element diagonally from the top-left corner to the bottom-right corner on an infinite loop. Additionally, the element should gradually change its color from blue to red during each loop. The animation should also include a fade-in effect when the element starts moving and a f...
codefeedback
Parse the following XML data and print the value of the 'id' key as an integer. However, you are not allowed to use any XML parsing libraries or functions. You must implement your own XML parser to extract the value of the 'id' key.
codefeedback
Use the regular expression to extract the words ending with 'sion' from a paragraph of text, ensuring that the words are preceded by a space or a punctuation mark and followed by a space or a punctuation mark. The paragraph may contain up to 1000 words and should be case-insensitive. The extracted words should be sorte...
codefeedback
Convert a date in the format "MM/dd/yyyy HH:mm:ss" to a Unix timestamp, considering time zone offsets, daylight saving time adjustments, and leap years. Additional instructions: - Handle dates before January 1, 1970. - Validate the input format to ensure it follows the specified format. - Implement the conversion algo...
codefeedback
Design a recursive function in Python that prints a given string in reverse, while also counting the number of vowels in the string and excluding any duplicate vowels from the count. Additionally, the function should return the number of consonants in the string. You can assume that the input string will only contain ...
codefeedback
Design a key-value database with Python for storing course information, taking into consideration the following additional requirements: - The Course ID should be a unique alphanumeric identifier with a maximum length of 10 characters. - The Course Name should be a string with a maximum length of 50 characters. - The C...
codefeedback
Find the longest string between two substrings, ensuring that the starting substring is followed immediately by the ending substring. The string may contain special characters, numbers, and whitespace. The starting and ending substrings must be case-insensitive. Return the length of the found string. String: "ThiS is...
codefeedback
Edit the given code to add a new element to the list, but the new element must be a prime number. The list should initially contain the prime numbers [2, 3, 5]. Additionally, the code should check if the new prime number is a palindrome and only add it to the list if it satisfies this condition.
codefeedback
Rewritten Test: Consolidate the following array into a dictionary, but only include fruits with a count greater than 1. Additionally, sort the fruits in the dictionary in descending order based on their count. arr = [("apple", 1), ("banana", 2), ("orange", 3), ("kiwi", 0), ("grape", 4)] Note: You are not allowed to u...
codefeedback
Define an iterator class in Python that iterates over a range of numbers from 1 to 10 and only returns prime numbers.
codefeedback
Define a function in Python that calculates the sum of the product of the elements of a nested list, where each element is a positive integer and the nested list can have up to three levels of nesting.
codefeedback
Write a program that takes a sentence as input and determines the syntactic structure of each word in the sentence. The program should identify the part of speech (noun, verb, adjective, etc.) for each word, including specific subcategories such as transitive or intransitive verbs, countable or uncountable nouns, and c...
codefeedback
Create a list in Python that contains the first 1000 prime numbers. Additionally, sort the list in descending order.
codefeedback
Create a class in Python that can be used as a context manager. The context manager should also have the ability to handle and propagate exceptions within the context block. Additionally, it should implement the `__enter__` and `__exit__` methods to ensure that specific resources are properly acquired and released resp...
codefeedback
Write a SQL statement to fetch the maximum age and minimum salary from the table "employee" for each department, along with the department name, only for employees who have been with the company for more than 5 years and have a job title of "Manager".
codefeedback
Write a Python program to implement the Find-Max algorithm, which finds the maximum value in an array, while also keeping track of the number of comparisons made during the search. The program should take an array of integers as input and output the maximum value along with the total number of comparisons made. The inp...
codefeedback
Write VBA for a search interface to pull information from one tab of an excel sheet to a different tab, with the additional requirement that the search should be case-sensitive. In addition to searching for an exact match, the program should also provide options to search for partial matches and perform wildcard search...
codefeedback
Generate a list of random alphanumeric strings of length 25. The strings must contain at least one uppercase letter, one lowercase letter, one digit, and one special character. Additionally, each string must have a unique set of characters, meaning no two strings can have the same characters in the same order.
codefeedback
Write a Python program to compare two dictionaries by both key and value, ensuring that the keys are strings and the values are positive integers.
codefeedback
Write a React component that accepts an array of objects, where each object has a "name" property (string), an "age" property (number), and a "country" property (string), and renders a sorted list of the objects based on their age in descending order. The list should also be grouped by country, with each group being so...
codefeedback
Write a SQL query for finding the customers who have placed orders with a total price of more than $100, have made a purchase in the last 30 days, and have not made any returns or cancellations for those orders.
codefeedback
Given a Node.js object, write a function that takes in the object, a property name, and an optional depth as arguments and returns true if the property exists in the object at the specified depth, and false otherwise. The depth indicates the number of levels nested within the object that should be considered when check...
codefeedback
Create a function to generate a sorted list of unique random numbers from 0-999. The length of the list should be a randomly generated number between 100 and 1000.
codefeedback
Write a function to check whether a doubly linked list contains a given value. The doubly linked list can contain integers and is represented by a class `DoublyLinkedList`. The class should have the following methods: 1. `addFront(value)`: Adds a new node with the given value to the front of the doubly linked list. 2....
codefeedback
Create a PHP class with three protected fields "User Name", "Password", and "Email". Add a public method called "validateEmail" that takes an email address as a parameter and returns a boolean value indicating whether the email address is valid or not. Use regular expressions to validate the email address. Additionally...
codefeedback
Given two sorted arrays in Java, how would you merge them into one sorted array without using any additional data structures? int[] array1 = {1, 3, 5, 7, 9}; int[] array2 = {2, 4, 6, 8, 10}; You need to merge the two arrays into a single sorted array without using any additional arrays or data structures. The merged ...
codefeedback
Write a SQL query that returns the number of orders shipped on each day, excluding any orders with a status of "cancelled" and "pending". Include the order date, number of orders, and the total order amount for each day. Additionally, the query should only consider orders placed within the last 30 days.
codefeedback
Create a Java program to multiply two given matrices, ensuring that the dimensions of the matrices are not equal and that the number of columns in the first matrix is equal to the number of rows in the second matrix. The program should also handle the case where the matrices have dimensions greater than 1000. Additiona...
codefeedback
Increase the difficulty of the test by requiring the program to reverse both the first name and the last name before combining them into the full name. The full name should be saved as a variable called "reversed_full_name". #Given Test# Combine the two strings into one and save it as a variable called full_name. Howe...
codefeedback
In JavaScript, create a function that returns the length of a string. However, you are not allowed to use the built-in `length` property or any other built-in methods such as `split()`, `slice()`, or `substr()` to calculate the length. You must implement your own logic to count the characters in the string. Additionall...
codefeedback
Write a function in any programming language that takes a string email address as input and returns an HTML code snippet to create an email link for that email address. The function should also include error handling to ensure the input is a valid email address. In addition, the function should also check if the domai...
codefeedback
Given a JavaScript object that may be nested within multiple levels of other objects and arrays, how can you remove a specific key from the object while preserving the structure of the remaining data? The key can be located at any level within the nested structure. The time complexity of the solution should be O(n), w...
codefeedback
Write a script that inputs a list of strings and converts the list into a dictionary, where the keys are the strings and the values are the lengths of the strings. The script should also remove any duplicate strings from the list before converting it into a dictionary. Example: Input: ["ABC", "XYZ", "PQR", "ABC", "PQR...
codefeedback
Write code to output the sum of all prime numbers between 1 and 100, excluding the numbers that are divisible by 5.
codefeedback
Create a function that takes in a list of strings and returns a list of all possible anagrams for each string. The anagrams should be sorted in alphabetical order. The input list may contain duplicates, and the function should remove duplicate anagrams from the output list. Time Complexity Requirement: The function s...
codefeedback
Extract all instances of a specific word in the given text, but only if the word is enclosed within parentheses and each occurrence must be unique (ignoring case sensitivity). Additionally, the word can be a combination of letters, numbers, and special characters, but it must be at least 3 characters long. Text: The q...
codefeedback
Write an SQL query that updates the 'price' field for all documents in the collection to 200, but only for documents where the 'quantity' field is greater than 10. Additionally, for these documents, set the 'discount' field to the value of the 'quantity' field multiplied by 0.1. Provide a piece of erroneous code as a ...
codefeedback
Suggest a way to create a singly linked list in Python, where each node has a data value and a pointer to the next node. Implement a method to reverse the linked list recursively, ensuring that it has a time complexity of O(n) and does not exceed O(n) space complexity. Note: In addition to reversing the linked list, y...
codefeedback
Create a function that prints the binary representation of a decimal number in reverse order, with a time complexity of O(log N) and a space complexity of O(1). number = 123
codefeedback
Create a MongoDB query that retrieves all the documents whose 'name' field contains the given string, ignoring case sensitivity and also including documents whose 'name' field is an exact match of the given string. Additionally, the query should only return documents that have a 'status' field equal to "active" and a '...
codefeedback
Generate a link of the page given below by following these steps: 1. Create a variable called "baseUrl" and assign it the value "www.example.com". 2. Create a variable called "product" and assign it the value "apple". 3. Combine the variables "baseUrl" and "product" to create a new variable called "url" by concatenati...
codefeedback
You are given a text and the task is to output each individual word in the text along with its character count. Additionally, you need to remove any punctuation marks and whitespace from the text before processing it. The time complexity of your solution should be less than O(n^2), where n is the length of the text. ...
codefeedback
Create a binary heap sort algorithm in Java that has a time complexity of O(n log n) and a space complexity of O(1). Additionally, the algorithm should handle duplicate elements in the input array and sort them in descending order while maintaining the overall time and space complexity.
codefeedback
Create an HTML structure that mimics the mockup given below, where the header has a background color of #333333, the width is fixed to 800 pixels, and the height is fixed to 100 pixels. Additionally, the header should have a navigation bar consisting of 5 menu items evenly spaced horizontally, each with a font color of...
codefeedback
How would you create an API endpoint that returns a list of users and their associated posts? The API should also allow filtering the posts based on certain criteria, such as post type or date created. Additionally, the API should implement pagination to limit the number of results returned per request.
codefeedback
Compute the sum of all positive even numbers in a given array using a Python function. The array should only contain integers. If the array does not contain any positive even numbers, return 0. The array should have at least 5 elements. The function should be implemented using recursion. arr = [1, 2, 3, 4, -5, 6]
codefeedback
Create a React component for a Postcard element to display on a webpage. The postcard should contain a paragraph element containing the text "Hello from Paris!", an image of the Eiffel Tower, and a "Return to Homepage" button below the image. In addition, the postcard should have a "Share on Facebook" button that, whe...
codefeedback
Write a function to merge two sorted lists into one sorted list, using only recursion and without using any built-in sorting functions or data structures. The input lists are guaranteed to be non-empty and contain only positive integers. The merged list should not contain any duplicates and should be sorted in ascendin...
codefeedback
Write a regular expression to extract the city names and their respective postal codes from the following string. The city names can consist of multiple words and may contain special characters. The postal codes must be exactly 5 digits long. Example: Input: address: #38 number street, new york city, san jose, CA, 1...
codefeedback
Given an input of numbers, sort the numbers in descending order using a custom sorting algorithm that is not built-in or commonly used in programming languages. Additionally, you are not allowed to use any external libraries or functions for sorting.
codefeedback
Write a function called `remove_duplicates` that takes in a list of integers and removes any duplicate elements, while maintaining the order of the elements. Your function should return the modified list. Example: Input: [3, 1, 7, 5, 3, 8, 7] Output: [3, 1, 7, 5, 8] Additional Constraints: - Your function should h...
codefeedback
Create a C program that prints all distinct combinations of characters from two given strings, where the first string must contain at least one uppercase letter and the second string must contain at least one special character (!@#$%^&*). Additionally, the program should output the combinations in reverse order. Stri...
codefeedback
Suggest a better algorithm than Bubble sort for sorting a large array, while also considering memory efficiency and time complexity. The algorithm should have a time complexity of O(n log n) and should use a constant amount of additional memory. Additionally, provide a piece of code that showcases the erroneous impleme...
codefeedback
Write a code to shuffle a list randomly in Python without using any built-in functions or libraries. The code should have a time complexity of O(n) and should not use any additional space beyond the input list. Additionally, ensure that the shuffled list is always guaranteed to be in a different order than the original...
codefeedback
Explain how to calculate the mean value of a function defined on a closed interval [a, b], considering that the function must be continuously differentiable and satisfy certain conditions at the endpoints of the interval.
codefeedback
Create a shell script to list all available printer models. The script should only display models that have a print speed of at least 30 pages per minute and a color print capability. The script should also display the printer models in descending order based on their print speed.
codefeedback
Suggest a data structure for storing a collection of countries and their corresponding population, ensuring efficient retrieval of the top 10 most populous countries based on population. Additionally, provide a method to efficiently retrieve the countries with a population above a certain threshold.
codefeedback
Ask the assistant to write a program that calculates the factorial of a given number. The factorial of a number is the product of all positive integers less than or equal to that number. The assistant should handle input validation for negative numbers and display an appropriate error message.
codefeedback
Classify whether the following statement is an input or an output. Calculate and print the product of all the even numbers in the given array.
codefeedback
Develop an Angular application that displays the current date and time in multiple time zones. The application should also allow the user to select a specific time zone and convert a given time to that time zone. Additionally, the application should have a feature that allows the user to set reminders for specific time...
codefeedback