instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Create an HTML5 form to get a user's name, age, gender, and email address. Validate that the user's name is at least 3 characters long and the age is between 18 and 99. Display an error message if any of the fields are empty or if the validation fails. Additionally, the email address must be in a valid format and must ...
codefeedback
Using the given input, print a zero (or cross) pattern using asterisks (*) and underscores (_). Each row should have exactly three characters. Additionally, each row should have a prime number of asterisks and underscores, with a minimum of one asterisk and one underscore in each row.
codefeedback
Create an HTTP request to retrieve data from an API that requires the use of a specific authentication token. The API_URL is "https://example.com/api/get_data" and the authentication token is provided in the header as "Authorization: Bearer {token}". Additionally, the API returns a large amount of data in the response,...
codefeedback
Write a program that takes an input number from the user and prints the Fibonacci series up to that number.
codefeedback
Make a program to display the maximum, minimum, and median of numbers in a list, where the list may contain duplicates and negative numbers. Additionally, the program should exclude any outliers in the list when calculating the median. The program should also handle cases where the list is empty or contains only one el...
codefeedback
Create a JavaScript class that allows the user to choose the size, position, color, font, and text alignment of a textbox. The class should also provide a method to change the text content of the textbox. Additionally, the class should have a method to calculate and return the number of unique characters in the textbox...
codefeedback
Create a program to determine the intersecting elements of two lists, with the constraint that the program must have a time complexity of O(n) and must not use any built-in functions or libraries. Additionally, the program should handle lists of any data type, not just integers. list1 = ["apple", "banana", "cherry", "...
codefeedback
Rewritten Test: You are tasked with converting the given cURL command into a Fetch API call using JavaScript. The original cURL command is as follows: ``` curl -X POST https://example.com/api/users -H 'Content-type: application/json' -d '{ "name": "John" }' ``` Your goal is to write the equivalent Fetch API call. H...
codefeedback
Create a function that takes a single argument and returns a string describing the type of argument. The function should not use any built-in type checking functions or libraries, and should only consider the following data types: integer, string, list, tuple, dictionary, and boolean.
codefeedback
Write a SQL query to output the name, id, and address of each customer who has an address in a specified zip code (39911). Additionally, the query should also return the total number of orders placed by each customer, the average amount spent per order, and the date of the last order placed. Only customers who have pla...
codefeedback
What is the difference between function overloading and function overriding in Java? Please provide a code example for each to illustrate your answer. Please note that the code examples provided may contain errors or incorrect implementations.
codefeedback
Implement a function to convert a decimal number, including decimal places, to a binary representation using only bitwise operators and without using any built-in functions or libraries to convert the decimal number. Additionally, the function should handle negative decimal numbers and return a binary representation in...
codefeedback
Given the following code snippet, write the code to achieve the expected output: def convert_to_title_case(input): # Expected Output: # input = "this is a Title" # Output = This Is A Title # Step 1: Convert the input string to lowercase lowercase_input = input.lower() # Step 2: Split the lowercase input ...
codefeedback
Design a data structure that can efficiently store a series of strings in a specific order and allows for fast lookup by both index position and value. The data structure should ensure that each string is unique. The strings should be stored in a way that does not rely on any built-in data structures or libraries for ...
codefeedback
Create a class for a book object with properties for the title, author, pages, publication year, and genre. The title must be a string of at least 3 characters and cannot contain any special characters. The author must be a string of at least 5 characters and can only contain letters. The pages must be an integer betwe...
codefeedback
Generate a valid cURL command to request data from a given API endpoint that requires authentication and pagination. Endpoint: testserver.com/api/users Authentication method: Bearer token Pagination: The API returns 10 users per page and you need to retrieve data for all the pages.
codefeedback
Write a Ruby program to calculate the sum of the integers between 1 and 1000 (both inclusive) that are divisible by 7 and have a digit sum greater than or equal to 10.
codefeedback
Rewrite an algorithm in C++ to find the maximum and minimum elements in an unsorted array, without using any additional data structures. The array should contain at least 1,000,000 elements, and the algorithm should have a time complexity of O(n log n). arr = {1, 7, 4, 2, 9, 6, 5, 10, 3, 8, ...}
codefeedback
Write a python code snippet to calculate the sum of any number of integers greater than zero, with a maximum of 10 integers. The program should prompt the user to input the number of integers they want to add, and then prompt them to input each integer separately. The program should handle invalid inputs and display an...
codefeedback
Suggest an algorithm to find the longest common subsequence in two strings. The two strings can have arbitrary lengths. Additionally, modify the algorithm to handle cases where there can be multiple longest common subsequences. In such cases, the algorithm should return all the longest common subsequences. Note: A su...
codefeedback
Compose a CSS 3D transformation to rotate an element by 45 degrees around the y-axis and then scale it by 1.5 times in the z-axis. Additionally, ensure that the element is only visible within a specified rectangular region on the screen.
codefeedback
Modify the code to ensure that the variable 'str' not only is not None, but also that it is a string of alphabetic characters only (no numbers, special characters, or spaces). Additionally, the string must have a minimum length of 5 characters and a maximum length of 10 characters. You should also implement a loop that...
codefeedback
Suggest a data structure and implementation to store a list of vehicles, which includes cars, buses, and trucks. Each vehicle should have the following attributes: - Make (string): the manufacturer of the vehicle - Model (string): the model of the vehicle - Year (integer): the manufacturing year of the vehicle - Color...
codefeedback
Design an algorithm in Java to reverse a list of integers, but you are not allowed to use any additional data structures or recursion. The input list can only be modified in-place. The reversed list should still be in the same memory location as the original list. Additionally, the algorithm should have a time complex...
codefeedback
Suggest an appropriate data structure to store the test scores of a class, ensuring efficient retrieval and modification operations, while also enforcing a maximum score limit of 100 and a minimum score limit of 0. Additionally, the data structure should allow for the storage of the student's name along with their test...
codefeedback
Use a loop to print out each element of the list in reverse order. The list must contain at least 5 elements and should only include even numbers.
codefeedback
Count the number of nodes in a binary tree that have both left and right children. tree = { "data": 10, "left": { "data": 20, "left": { "data": 40, "left": { "data": 80 } }, "right": { "data": 50, ...
codefeedback
Implement a function that takes in two lists, lst1 and lst2, and returns a new list that contains only the elements that appear in both lists. The function should not use any built-in Python functions or libraries such as numpy or itertools. Additionally, the function should have a time complexity of O(n) where n is th...
codefeedback
Create a Node.js server which serves a static HTML page, but also implement a route that displays the current time in a specific timezone on the page when accessed. Additionally, the server should have a REST API endpoint that allows users to create and retrieve user-specific tasks. The tasks should be stored in a data...
codefeedback
Edit the code so that it can run in JavaScript async/await instead of Promise, and also add the requirement to handle errors and rejection. Additionally, modify the code to handle multiple asynchronous functions and ensure that they all run in parallel. const myAsyncFunction1 = async () => { return new Promise((reso...
codefeedback
Rewrite the following XML code to add a navigation bar to the top of a web page, which should include the following elements: 1. A logo on the left side of the navigation bar with a maximum width of 150 pixels and a maximum height of 50 pixels. 2. A menu with at least five different options on the right side of the na...
codefeedback
Create a database table using SQL containing information about employees. Add a constraint to ensure that the postal_code is always a 5-digit number and must not start with zero. Additionally, add a requirement that the id column must be auto-incrementing, unique, and not null. Create table with the following column na...
codefeedback
Design a code snippet to sort a hashtable by its values in descending order. The values are strings and the keys are integers. The hashtable may contain up to 1 million key-value pairs. Optimize your solution for time complexity.
codefeedback
Create a class to save data of a user's account with the following requirements: 1. The account data should include the user's name, email, and password. 2. The password must be encrypted using a one-way hashing algorithm and must be at least 8 characters long. 3. The class should have a method to validate the user's ...
codefeedback
Create a webpage with a two-column layout using HTML and CSS. 1. Create a container element for the two columns, such as a `<div>` element, and give it a class or id for easy targeting in CSS. 2. Set the width of the container to 100% to make it span the entire width of the screen. 3. Use CSS flexbox or CSS grid to cr...
codefeedback
Create an AI chatbot using JavaScript and Natural Language Processing that is capable of holding a conversation with the user, providing relevant responses based on the context and understanding of the input. The chatbot should be able to handle multiple users simultaneously and maintain separate contexts for each user...
codefeedback
Write an assembly language program to print the Fibonacci sequence up to the 10th term using only the basic operations of loading and storing data, arithmetic operations, and conditional branching.
codefeedback
Use NLTK to analyse the sentiment of a given text. The movie is extraordinarily awe-inspiring and mind-blowing, leaving the audience in awe of its impeccable storytelling and breathtaking visuals. You are required to implement a sentiment analysis function that takes a text as input and returns a sentiment score rangi...
codefeedback
Modify the following Python code to print the program output in descending order and without using any built-in sorting functions. The time complexity of the solution should be O(n^2). x = [1, 2, 3, 4, 4, 3, 1] n = len(x) for i in range(n): for j in range(0, n-i-1): if x[j] < x[j+1]: x[j], x[j+...
codefeedback
Create a SQL query to select the records with the name "John" and age less than 30 from the table "people", but only if their last name starts with the letter "S" and their email address contains the domain "gmail.com".
codefeedback
Create a PHP program that declares a function called "compareStrings" that takes two parameters. The function should check if the two parameters are equal and if so, return true. Additionally, the function should ignore any leading or trailing white spaces in the strings before comparing them. However, the function sho...
codefeedback
Write a JavaScript function to find the number of business days (excluding weekends and holidays) left from today to a given date. Consider implementing an algorithm that efficiently handles a large number of holidays and weekends. Note: You can use the `moment.js` library to simplify date and time calculations. Func...
codefeedback
Train a deep learning model using a recurrent neural network architecture to accurately classify emails as spam or legitimate messages, ensuring a minimum accuracy of 95% on a validation set of 10,000 emails and optimizing for a F1-score of at least 0.9. Additionally, implement a data preprocessing step to handle imbal...
codefeedback
Write a Python function that takes a positive integer n as a parameter and prints out all prime numbers from 2 to n in descending order. The function should also check if the number n is divisible by 5 and only print the prime numbers that are divisible by 5.
codefeedback
Write a code to find the first two prime numbers in a list that add up to a given number. my_list = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29] sum = 100 Note: The given list now contains more prime numbers, and the target sum has been increased.
codefeedback
Write a C# code snippet to create a binary search tree with the following string payload and print it out. However, you are not allowed to use the built-in BinarySearchTree<T> class or any other built-in tree data structure. You must implement your own custom data structure to store and retrieve the strings using the b...
codefeedback
Create a script to generate a random password using at least 1 uppercase letter, 1 lowercase letter, 1 numeric digit, and 1 special character. The password should be at least 12 characters long and should not contain any repeated characters. Additionally, the password should have at least 3 special characters, 2 numeri...
codefeedback
Design a class in Java that stores the number of uppercase letters, lowercase letters, numbers, special characters, and whitespace characters in a given string. The class should also provide methods to calculate the frequency of each type of character in the string and determine the percentage of each type of character...
codefeedback
Compute the average salary of the female employees who have worked in the company for at least 5 years and are in the top 10% highest paid employees.
codefeedback
Create a Swift program that reads in an array of integers from the user and prints out the maximum value. The array can contain up to 1000 integers. Additional Requirements: 1. The program should handle the case where the user enters less than or more than 1000 integers gracefully. 2. The program should handle negativ...
codefeedback
Given a string, remove any punctuation marks, convert it to lowercase, and count the frequency of each word in the string. Additionally, remove any stop words (commonly used words such as "the", "and", "is", etc.) from the string before counting the word frequencies.
codefeedback
Create a SQL query to list all customer names from the table "customers" in ascending alphabetical order, but exclude any customers whose names start with the letter "A" and whose age is above 30.
codefeedback
Create a web application in React that displays the temperature in Fahrenheit, Celsius, and Kelvin. The application should also allow the user to convert between these temperature units dynamically. The conversion should be implemented using custom algorithms, rather than relying on built-in conversion functions. Add...
codefeedback
Write a function to check if the parentheses, curly brackets, and square brackets in a given expression are balanced or not. Additionally, the function should also check if the angle brackets (<>) in the expression are balanced or not. expression = "{[(A+B)-C]*D+((E-F)*G}"
codefeedback
Create a function in Python to take a positive integer and return its factorial. However, the function should only work for integers between 1 and 10 (inclusive). If the input is outside this range, the function should raise a ValueError with an appropriate error message. Additionally, the function should check if the...
codefeedback
Generate a function in python that takes two lists of integers and returns the product of their longest common substrings. The longest common substring must be a strictly increasing subsequence. The function should only consider substrings of length greater than or equal to 5. If there are multiple longest common subst...
codefeedback
Create a program in C to find the biggest of five numbers. Additionally, include a sorting algorithm to arrange the numbers in ascending order.
codefeedback
Write a function that takes in a string as input and returns the number of words in the string. A word is defined as a sequence of characters separated by whitespace (spaces, tabs, or newlines). The function should also ignore any punctuation marks such as commas, periods, question marks, and exclamation marks within t...
codefeedback
Suggest a code in Python that will calculate the area and perimeter of any given shape, with the following additional requirements: 1. The code should be able to handle shapes with any number of sides, not just a maximum of 5. 2. The code should support different types of shapes such as triangles, rectangles, squares, ...
codefeedback
Explain the functional programming paradigm and provide an example of a higher-order function in a programming language of your choice. Additionally, identify and correct any syntax errors in the following code snippet: ```python def filter_even(numbers): even_numbers = [] for num in numbers: if num % ...
codefeedback
Create a Python code to print out all the common elements in two lists, but without using the built-in set() function. The code should also handle duplicate elements in the lists and return the common elements in sorted order. Additionally, the code should have a time complexity of O(n), where n is the total number of ...
codefeedback
Implement a jQuery code for the following purpose: Make an element hide when the mouse moves over it, but only if the element has a specific CSS class named "hideable". Additionally, when the element is hidden, change its background color to red, and when the mouse moves away from the hidden element, make it reappear ...
codefeedback
Design a MySQL query to delete all records in a specified table that have a specific value in a specified column, but only if they meet additional conditions.
codefeedback
Using SQL, write a query to find the most recently hired employee who has been with the company for at least 6 months. Additionally, include the number of years the employee has been with the company as a separate column in the result.
codefeedback
Implement a Java code to print the first 15 multiples of a given number, but only if the number is divisible by both 3 and 5.
codefeedback
Create a HTML link with the following description: "Go to HackerRank". When the link is clicked, it should open the website in a new tab. Additionally, the link should have a hover effect that changes the color of the text to red. The link should only work if the user is using the Chrome browser and has JavaScript enab...
codefeedback
Design a database table to store user information such as an email address, name, age, etc. The table should be optimized for efficient search and retrieval operations, even with a large number of users (millions or more). Additionally, ensure that the table design takes into account data privacy and security concerns,...
codefeedback
Write a regular expression to extract phone numbers from a list of text. text_list = ["contact me at +1 (123) 456-7890 for more information", "reach out to 555-123-4567 for a discussion"] The regular expression should handle cases where phone numbers are followed by punctuation marks or other special characters.
codefeedback
Design a responsive HTML page that shows a page counter that increments by 1 every time the page is refreshed. Additionally, display a button that allows the user to reset the page counter to 0 when clicked. The page counter should be implemented using JavaScript and the button should have a hover effect when the curso...
codefeedback
Generate an algorithm in any language that can find the sum of the numbers in a given array, while only using a constant amount of space. The algorithm should have a time complexity of O(n), where n is the number of elements in the array. Additionally, the algorithm should handle negative numbers in the array and provi...
codefeedback
Please write a SQL query that returns the top 5 most frequent names in a given table, along with the count of how many times each name appears. The query should exclude any names that are duplicates within the table. table: Employees Example Input: Employees table: +----+----------+-------+ | ID | Name | Title | ...
codefeedback
Create a class in Python that takes a list of numbers and finds the median. Additionally, handle cases where the list is empty or contains non-numeric elements. The median is the middle value of a sorted list of numbers. If the list has an odd number of elements, the median is the value at the center position. If the...
codefeedback
Create a C++ class to store data for a student including their name, age, address, and a unique student ID. The student ID should be a randomly generated alphanumeric string of length 12. Additionally, the class should include a method to display all the data for the student in a formatted manner. The class should al...
codefeedback
Write a program that generates an HTML code to display a given list of items. Each item should be displayed in a separate paragraph element and styled with a different font color for each item. Additionally, each paragraph element should have a background color that is a shade lighter than the font color. The font size...
codefeedback
Create a Rails controller that can render a JSON response for a given URL. The URL must include a query parameter called "id" and the controller should return a JSON response containing the user information corresponding to the specified id. Additionally, implement error handling in the controller to handle cases where...
codefeedback
Write a code in Go that will reverse all the words in a sentence, preserving the order of punctuation marks and special characters. The sentence may contain hyphenated words and multiple spaces between words.
codefeedback
Design a function that takes a sentence and returns an array with each word in the sentence as an element, while ensuring that the returned array does not contain any duplicate words. Additionally, the function should ignore any punctuation marks and consider words in a case-insensitive manner.
codefeedback
Create a JavaScript program which takes two arguments as strings and returns true if they both have the same length and are anagrams of each other. The program should have a time complexity of O(n), where n is the length of the strings, and a space complexity of O(1).
codefeedback
Use jquery to dynamically select an element of a given HTML form and change its value. The value should only be changed if it meets a certain condition, such as being a string with a minimum length of 10 characters, containing at least one uppercase letter, one lowercase letter, one number, and one special character. T...
codefeedback
Generate a code that takes an array of integers and splits them into two equal halves. The sum of integers in each half should be equal. Additionally, the code should return the two halves as separate arrays, and the order of elements in each half should be in descending order. The code should also remove any duplicate...
codefeedback
Output a list of all prime numbers between two given positive integers m and n. Additionally, for each prime number found, output the sum of its digits. m=10, n=50
codefeedback
Write a code to print the common elements of two given arrays, but with the constraint that the code must have a time complexity of O(nlogn), where n is the size of the larger array. Additionally, the code must not use any built-in functions or data structures for sorting. arr1 = [2, 3, 4, 5, 9, 10, 12] arr2 = [3, 6, ...
codefeedback
Design a function in PHP that takes two strings as input and returns true if the strings are an anagram of each other. An anagram is a word or phrase formed by rearranging the letters of another word or phrase. The function should also be case-insensitive, meaning that it should consider 'Listen' and 'silent' as anagra...
codefeedback
Create a function in Java to remove all the values equal to the given number from an array, and then sort the remaining elements in descending order.
codefeedback
Write a JavaScript code that randomly generates a 2D array of size m X n, wherein each element has a random value between -10 and 10. The sum of all the positive elements in the array should be greater than or equal to 50.
codefeedback
Create a Python class named 'Student' that contains the name, age, and grade of a student. The class should also include a method named 'calculate_average' that calculates and returns the average grade of the student. Additionally, implement a method named 'increase_grade' that increases the grade of the student by a s...
codefeedback
Design a function that takes a string of HTML tags as input and removes the tags from the string while preserving the content within the tags. #Additional Steps# 1. Validate the input to ensure it is a valid HTML string with proper opening and closing tags. The function should handle cases where tags are improperly ne...
codefeedback
Write a shell script to print the unique values from an array, but without using any built-in array functions or external commands. Additionally, the solution should have a time complexity of O(n^2) and a space complexity of O(n). Example input: [1, 2, 2, 3, 4, 4, 5] Expected output: 1 3 5 Note: The array can contain...
codefeedback
Modify and update the given HTML code to include a background color. The background color should be randomly generated from a predefined set of colors. Additionally, ensure that the generated color is unique each time the page is refreshed.
codefeedback
Create a program in Ruby to print out the first n prime numbers, where n is a positive integer provided as input by the user. However, you should optimize the program to use the Sieve of Eratosthenes algorithm for finding prime numbers.
codefeedback
Write a web application that displays a table of employees' information. The table should have five columns: ID, name, email address, phone number, and department. Implement the following functionalities: 1. Sorting: Allow users to sort the table by any column in ascending and descending order. Initially, the table sh...
codefeedback
Use CSS to create a responsive text area with a width of 300px and a height of 200px. Additionally, the text area should have a maximum width of 500px and should be aligned to the center of the page. The text area should also have a border radius of 10px and a background color of #F2F2F2. Furthermore, the text area sho...
codefeedback
Create a program that analyzes the given text and labels each token, ensuring that the program can handle multiple paragraphs and punctuation marks. Additionally, implement a feature that calculates the frequency of each token in the text and displays the top 10 most frequently occurring tokens.
codefeedback
In Python, write code to sort a list of integers in ascending order using the Bubble Sort algorithm. The code should include a check to ensure that the list contains only unique integers and that it has at least 5 elements. Additionally, the algorithm should be optimized to minimize the number of comparisons made durin...
codefeedback
Create a program in C to calculate the average of nodes in the given linked list. The program should handle linked lists of any size and should also consider the possibility of an empty linked list. Additionally, the program should ignore any negative numbers present in the linked list while calculating the average.
codefeedback
Write a JavaScript code to find all the elements with class 'myclass' in a given HTML page, alert their inner HTML, change their font color to red, and append a new paragraph after each element with the class 'myclass' displaying the number of siblings it has. #Explanation# To increase the difficulty of the given prog...
codefeedback
Write an SQL query to find all the rows in a table containing the number 5, but exclude any rows where the number 5 is followed immediately by the number 6. Additionally, the query should return the total count of such rows and display the rows in descending order based on another column named "timestamp".
codefeedback
Write a regular expression to detect phone numbers with country code and area code in a string. The phone number should start with a plus sign (+) followed by a two-digit country code (between 1 and 99), followed by a hyphen (-), then a three-digit area code (between 100 and 999), followed by another hyphen (-), and th...
codefeedback
Write a function that converts a given three-digit number to its hexadecimal equivalent, without using any built-in conversion functions or libraries.
codefeedback
Calculate the sum of squares of all positive even numbers till 10, considering only numbers that are divisible by both 3 and 5, and are less than 50.
codefeedback