instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Write a function that takes in two strings, a main string and a target string, and returns a boolean indicating whether the target string is a substring of the main string. You may not use any built-in string manipulation functions or methods (e.g., substring, contains) or any external libraries.
The time complexity o... | codefeedback |
Explain the uses of AJAX in web development and provide a detailed code example showcasing its implementation. Additionally, discuss the potential drawbacks or limitations of using AJAX in various scenarios, including handling errors and security vulnerabilities. | codefeedback |
Use TensorFlow to build a convolutional neural network (CNN) to classify the MNIST digits. Additionally, implement a dropout layer to improve the model's generalization ability. | codefeedback |
Calculate the frequency of occurrence of each letter in a sentence, taking into account punctuation marks and case sensitivity. Ensure that the solution is case sensitive, meaning 'A' and 'a' should be considered as different letters. The sentence will not contain any special characters or digits. The sentence may also... | codefeedback |
Design a Python class structure for playing cards with three classes: Deck, Card, and Player.
The Deck class should have methods to initialize a deck of cards, shuffle the deck, and deal cards to players. It should also keep track of the number of remaining cards in the deck. The deck should be able to handle multipl... | codefeedback |
Make an array with 10 prime numbers between 0 and 100, but the prime numbers should be in descending order and each prime number should be a palindrome. | codefeedback |
Using Perl, write a program that reads a text file and extracts all email addresses from it. The program should then count the occurrences of each domain and display the top 3 domains with the highest number of occurrences. Additionally, the program should exclude any email addresses that have a subdomain and only cons... | codefeedback |
## Find the Locality from an Indian Pin Code ##
Write a function `find_locality(pin_code: str) -> str` that takes a string `pin_code` as input and returns the corresponding locality for that pin code.
The function should adhere to the following constraints and requirements:
1. The pin code must be a valid Indian pi... | codefeedback |
Construct a query using MongoDB to find all the documents with a "city" field that equals "New York" and a "population" field greater than 1 million. Additionally, the query should return only the documents where the "country" field is "USA" and the "year" field is within the range of 2010 to 20 | codefeedback |
Reverse the order of the elements in the list using recursion. However, you are not allowed to use any built-in or library functions for list manipulation. You can only use recursion and basic operations such as indexing and swapping. The original list should be modified in-place. [1, 2, 3, 4, 5] | codefeedback |
Write a Python function that finds the maximum and minimum numbers from a sequence of numbers. The sequence must contain at least 10 numbers and cannot contain any duplicates. Additionally, the function should also return the average of all the numbers in the sequence. | codefeedback |
Create a SQL query that returns the sum of all the numbers in the "num" column, but excluding any negative numbers and any numbers greater than 100. | codefeedback |
Using Node.js, create a function to take a JSON string and return a JavaScript object. Additionally, include error handling in your code to handle cases where the JSON string is not valid or when the JSON object contains circular references.
For the error handling, instead of using the built-in JSON.parse() function,... | codefeedback |
Use HTML, CSS, and JavaScript to format a responsive page with three columns, two of which contain two paragraphs each. The first paragraph in each column should have a maximum word count of 100 words, while the second paragraph should have a maximum word count of 50 words. The last column should contain a dynamically ... | codefeedback |
Construct a query using MongoDB to find documents where the "user_id" field contains any number greater than 5, the "age" field contains any number greater than or equal to 18, and the "name" field contains a string that starts with the letter "A". | codefeedback |
Write a SQL query to sort the records by the given field in descending order, but only for records that have a price greater than 100 and a quantity greater than 5. | codefeedback |
Amend the following Python code to add error handling to the function print_score. Additionally, introduce a new variable called `name` and print it along with the score. Furthermore, modify the code to handle a specific custom exception called `ScoreOutOfRangeError`.
```python
class ScoreOutOfRangeError(Exception):
... | codefeedback |
Create a MySQL query to summarize total sales for each month, considering only sales made by customers with a loyalty level of "Gold" or above. Additionally, exclude any sales that were made on a weekend.
Table name = Sales
Note: You can assume that the sales table has the following columns: sales_id (unique identifi... | codefeedback |
Design and implement a convolutional neural network (CNN) for image classification. The CNN should have at least three convolutional layers with different kernel sizes and pooling layers. Additionally, the CNN should include at least two fully connected layers and utilize a dropout layer for regularization. Train the C... | codefeedback |
Implement a dynamic programming solution to find the maximum sum of a subarray in a given array of integers, with the following additional requirements:
1. The time complexity of the solution should be O(n).
2. The space complexity of the solution should be O(1).
3. The solution should be able to handle arrays contain... | codefeedback |
Create a SQL query to retrieve the first name, last name, email address, and the total amount spent of each customer whose total number of orders is greater than 10. Sort the results in descending order of the total amount spent.
Note: Assume that there are two tables - "Customers" and "Orders". The "Customers" table ... | codefeedback |
Move the parentheses to make the expression give the correct answer, while also ensuring that each operation is performed in the correct order according to the order of operations. Expression: 8 / 2 * (2 + 2) - 1
Answer: 15 | codefeedback |
Write a Bash script to print a message when the system time is between 8pm and 8am, only on weekdays and excluding public holidays. The script should also check if the user has a specific environment variable set and if a specific file exists before executing the message printing. | codefeedback |
Generate an HTML code to display a speech bubble with a maximum width of 300 pixels and a minimum width of 200 pixels. The speech bubble should have a rounded border with a radius of 10 pixels. The text inside the bubble should be aligned to the right and have a font size of 18 pixels. Additionally, the speech bubble s... | codefeedback |
Analyze the given statement for any syntax errors and logical errors.
Statement: The user entered his name James and password1234, and the program should verify if the password meets the following criteria:
1. The password must be at least 8 characters long.
2. The password must contain at least one uppercase letter, o... | codefeedback |
Write an Apache Spark program to count the occurrence of each word in the given dataset. Additionally, for each word, compute the percentage of its occurrence out of the total number of words in the dataset. Finally, output the word, its count, and its percentage of occurrence, sorted in descending order of count.
Inc... | codefeedback |
Write an SQL query to retrieve the names, salaries, and departments of employees who joined in the year 2018 and have a salary higher than the average salary of all employees in their department, ordered by their salary in descending order. | codefeedback |
Create a C program to remove all occurrences of a specified character from a given string, while also keeping track of the number of occurrences that were removed.
Input: A string and a character to be removed
Output: The modified string and the count of removed occurrences
Additional Requirements:
1. The program shou... | codefeedback |
Convert the Python Dictionary given below into a valid JSON format while ensuring that the "firstName" value is a string of length between 2 and 20 characters, the "lastName" value is a string of length between 2 and 20 characters, and the "age" value is an integer between 18 and 100 (inclusive). Additionally, the JSON... | codefeedback |
Write a script to display the Fibonacci sequence up to the 100th number in the console. However, ensure that the script can handle large numbers efficiently without causing any memory overflow errors or excessive runtime. | codefeedback |
Write a program that generates all possible permutations of a given string. Your program should have a time complexity of O(n!) and should also handle cases where the string contains duplicate characters. Additionally, your program should output the permutations in lexicographically sorted order. | codefeedback |
Write a MySQL query to select all employees who are 30 years old or above, have a salary higher than the average salary of their department, and have been with the company for at least 5 years. | codefeedback |
Create a function to calculate the number of different ways to climb n stairs, but with the additional constraint that you can only climb 1, 2, or 3 stairs at a time. The function should have a time complexity of O(n) and a space complexity of O(1). | codefeedback |
Create an algorithm to determine the k most common elements in an array, with a time complexity requirement of O(nlogk), where n is the size of the array and k is a given integer.
#Explanation#
In the original test, we were only interested in finding the single most common element in the array. In the rewritten test, ... | codefeedback |
Create a program in Java that sorts a given array using bubble sort algorithm.
The bubble sort algorithm works by repeatedly swapping adjacent elements if they are in the wrong order. It continues this process until the array is fully sorted.
Modify the given program to include the following additional steps:
1. Pro... | codefeedback |
What is the maximum number of arguments that can be passed to a JavaScript function? Explain how the number of arguments affects the performance and memory usage of a function. Also, discuss the time complexity of a function that receives and logs all of the arguments, considering different scenarios and optimization t... | codefeedback |
Compare the features and performance of Mercurial and Git, focusing specifically on their support for rebasing and merging strategies. Provide in-depth analysis and examples of when and why you would choose one tool over the other based on their capabilities in these areas. Additionally, discuss the impact of large-sca... | codefeedback |
Compose the html for the following table
| Column 1 | Column 2 | Column 3 |
|-----------|-------------|----------|
| Item 1 | Value 1 | Description 1 |
| Item 2 | Value 2 | Description 2 |
Please ensure that the table is responsive and adjusts its layout accordingly on different devices.
Requi... | codefeedback |
Write a SQL query to find all the users that have been created within the last 24 hours and whose usernames start with the letter 'A'. Additionally, sort the results in descending order based on the length of the username and return only the top 5 users. | codefeedback |
Describe the basic structure of an XML document, ensuring that all opening and closing tags are properly nested and balanced, that the document adheres to a specified schema definition, and that all attributes and values within the tags are valid according to the schema. Additionally, implement a function that checks f... | codefeedback |
Create a loop in Python to print the fibonacci sequence of the given number, n. However, the loop must use a recursive function to generate the fibonacci sequence. Additionally, the program should check if the input number is a positive integer and handle invalid inputs appropriately. | codefeedback |
Create a JavaScript class for a circle that calculates its area and returns the result. Additionally, the class should have a method to calculate and return the circumference of the circle. The radius of the circle should be provided as a parameter when creating an instance of the class. The class should also include a... | codefeedback |
Write an HLSL code snippet that creates a 3D vector with the components (x, y, z) = (1, 0, 1), normalize the vector, and then perform a dot product with another 3D vector (a, b, c) where a, b, and c are user inputs. | codefeedback |
Classify the given code snippet as either a single statement, multiple statement, or a control flow statement. Additionally, require that the solution must implement the classification logic as a function and use the function to classify at least two more code snippets of the same format. | codefeedback |
Write a Java program to print the following output: "This is a test statement" in reverse order, without using any built-in string manipulation functions or data structures, and without using any iteration (loops or recursion). | codefeedback |
Create a function in Java that takes in a String parameter and returns the length of the longest substring without repeating characters. The function should have a time complexity of O(n) and a space complexity of O(min(n, m)), where n is the length of the input string and m is the size of the character set.
Additiona... | codefeedback |
Create a SQL query to select all customers from the "Customers" table that have the "State" column equal to "New York" and have made more than 5 orders in the past month. Additionally, include the total sum of the orders made by each customer in the result set. | codefeedback |
How would you create a class in Java with the following requirements:
- The class should have a private integer field called "age".
- The class should have a public constructor that takes an integer parameter and assigns the parameter value to the "age" field.
- The class should have a public method called "getAge" tha... | codefeedback |
Design an HTML form that requires the user to enter three pieces of information: a name, email address, and password. Additionally, the form should have the following requirements:
1. The name field should only accept alphabetical characters, have a minimum length of 2 characters, and a maximum length of 30 characters... | codefeedback |
Create a program that takes in an array of integers as input and returns a sorted array in ascending order. The program should have a time complexity of O(n^2) or worse. Additionally, the program should use a bubble sort algorithm to sort the array. The program should also handle duplicate integers in the input array a... | codefeedback |
Mix the given list of numbers in a random order, but without using the built-in shuffle function or any other random number generator functions. The algorithm should have a time complexity of O(n) and a space complexity of O(1). | codefeedback |
Calculate the sum of all prime numbers between 1 and 1000 in the following list: 10, 12, 14, 16, 18. | codefeedback |
Create a program which takes a given list and returns a list with only the unique elements, but with a time complexity of O(n) and a space complexity of O(1). Additionally, you are not allowed to use any built-in functions or libraries for counting or checking for uniqueness.
[3, 5, 7, 9, 5, 3, 7] | codefeedback |
Create a database query in MySQL to delete "Inactive" status records from a table named 'users' based on the following conditions:
1. Only delete records where the 'status' column is set to "Inactive".
2. Additionally, delete records where the 'last_login' column is older than 30 days.
3. Ensure that the deletion query... | codefeedback |
Create a function that finds the highest peak in an array of elevation data. The highest peak must be surrounded by at least two valleys, which are defined as adjacent elements that are both lower than the peak. Return the index of the highest peak.
Example:
Input: [9, 10, 12, 15, 7, 8, 11]
Output: 3
The time complex... | codefeedback |
Write a function in JavaScript to create and return a deep copy of an object. Additionally, ensure that the function can handle objects that contain circular references without causing an infinite loop. | codefeedback |
Design an algorithm in Python for reversing a singly linked list iteratively without using any extra space.
You are given a singly linked list. Each node of the linked list contains an integer value and a pointer to the next node. Implement a function reverse_list_iteratively() that reverses the given linked list in-p... | codefeedback |
Write a code to calculate the median of the list of integers provided, but you are not allowed to use any built-in functions or libraries for sorting the list or calculating the length of the list.
nums = [10, 20, 30, 40, 50] | codefeedback |
Use the OpenGL API to create a vertex buffer object (VBO) that stores a custom data structure containing the position, color, and texture coordinates of each vertex. Additionally, implement a shader program that applies a custom transformation matrix to each vertex in the VBO before rendering it on the screen. | codefeedback |
Using the dictionary provided, write a code to print out the values in the dictionary. However, you are now required to print the values in reverse order, starting from the last value and ending with the first value.
dict1 = {"A":"Apple","B":"Banana","C":"Cherry"}
Expected Output:
Cherry
Banana
Apple
# Updated Test... | codefeedback |
Generate a python code program that removes punctuation from a given string. Additionally, the program should convert all letters to lowercase, remove any leading or trailing whitespaces, and remove any numbers from the string. The program should also handle strings that contain multiple sentences, where a sentence is ... | codefeedback |
For the given string, write a code to print out the longest word in the string. However, the code must also handle cases where there are multiple words with the same longest length. In such cases, the code should print out all the longest words in reverse order of appearance in the original string.
test_string = "Thi... | codefeedback |
Create a code to find all common elements in two lists and store it in a new list. The common elements should be in descending order and should not contain any duplicates. The code should also have a time complexity of O(n log n), where n is the total number of elements in both lists.
list1 = [1, 2, 3, 4, 5, 5]
list2 ... | codefeedback |
Calculate the total sum of the absolute values of the digits in the given integer, but with the following additional constraints:
1. The input integer can be negative.
2. If the input integer is negative, the sum should include the negative sign as part of the total sum.
3. The input integer can be a decimal number, a... | codefeedback |
Create a code to generate a list of all prime numbers between a given start and end number, where the start and end numbers can be as large as 10^6. The code should have a time complexity of O(n√m), where n is the number of prime numbers between the start and end, and m is the average value of those prime numbers. Addi... | codefeedback |
Rewrite the following function so that it takes in a positive integer argument and returns the factorial of that number. The function should now handle decimal input as well, returning None for decimal numbers. Additionally, the function should include a memory limit of 1 MB for storing intermediate results during the ... | codefeedback |
Write a function to generate a list of prime numbers between 1000 and 2000, where the sum of the digits of each prime number is a multiple of 5. | codefeedback |
Generate a program that accepts an integer array and returns its median value. Handle the case when the array contains an even number of elements. Additionally, handle the case when the array is empty and when it contains duplicate values. | codefeedback |
Generate a C++ program that sorts the elements in an array using the quick sort algorithm. The program should only use recursion to implement the quick sort algorithm and should not use any loop constructs. Additionally, the program should be able to handle arrays with a size of up to 10^7 elements efficiently, with a ... | codefeedback |
Implement a function in Java that finds the average of three given integers. The integers can be positive or negative, and the function should handle both cases correctly. Additionally, the function should return the average as a double value with two decimal places. The function should also ignore any integer that is ... | codefeedback |
## Revised Test ##
You are given a Java program that prompts the user to enter their name and then displays a personalized greeting along with the "Hello World" message.
Your task is to make the following modifications to the given program:
1. The program should ask the user to enter their name three times, and for ... | codefeedback |
Using plain JavaScript, update the HTML code to provide the user a toggle switch that changes the text from "off" to "on" when clicked. The toggle switch should only be visible to users who are logged in, and the text should change color to green when the switch is toggled on. Additionally, the toggle switch should onl... | codefeedback |
Write a function that takes a string of HTML code as input and adds CSS styling to the <body> element so that the background color of the webpage is white. The function should also add a CSS class to all <h1> elements, with the class name being "header". The function should return the modified HTML code.
Constraints:
... | codefeedback |
Create a Ruby program to generate a random 12-digit alphanumeric string that must contain at least two uppercase letters, two lowercase letters, two digits, and two special characters from the set of !@#$%^&*()-_=+{}[]|\:;"'<>,.?/`~. Additionally, the string must not contain any repeating characters. | codefeedback |
Design a Java class to store user information. The class should include the following functionalities:
1. Ability to store and retrieve the user's first name, last name, email address, and date of birth.
2. Ability to validate the email address format using regular expressions.
3. Ability to calculate the user's age ba... | codefeedback |
Create a function "distance" that takes two sets of coordinates in the form of [x1, y1] and [x2, y2] and computes the Euclidean distance between them.
However, this time, you need to implement the function without using any mathematical functions or operators such as square root or power. You can only use basic arith... | codefeedback |
Write a function in JavaScript to verify that a given email address is valid or not. The function should validate the email address according to the following requirements:
1. The email address should have a valid format, which includes an "@" symbol and a domain name.
2. The domain name should have at least one dot a... | codefeedback |
Using HTML, CSS, and JavaScript, create a responsive page layout with three columns and a header row. Add a navigation bar to the header row and make it fixed to the top of the page. Implement a dropdown menu in the navigation bar with multiple options. Apply a hover effect to the options in the dropdown menu. Addition... | codefeedback |
Create a HTML page that displays the current time in both digital and analog formats.
Additionally, the page should include a button that allows the user to switch between a 12-hour and 24-hour time format.
Furthermore, the page should display the current date and include a feature that allows the user to switch be... | codefeedback |
Setup a multi-node PostgreSQL cluster using Docker Compose, where each node has a different replication role (master, replica, standby). Additionally, ensure that the replica node automatically syncs with the master node every 5 seconds and that the standby node can be manually promoted to the master role in case of fa... | codefeedback |
Using HTML and CSS, create a form with 5 input fields and 3 buttons.
- The first input field should only accept alphabetic characters and should have a minimum length of 3 characters.
- The second input field should only accept numeric characters and should have a minimum length of 4 characters.
- The third input fiel... | codefeedback |
You need to build an API endpoint to support role-based authentication.
User roles: 'admin', 'manager', 'employee'
Additionally, each user can have multiple roles assigned to them. The roles are stored in a separate table called "user_roles", which has the following columns:
- user_id: integer (foreign key referencing... | codefeedback |
You need to collect user input to get the total sum of numbers, ensuring that the input only consists of positive integers and the sum should be calculated using a recursive function. Additionally, you need to implement memoization to improve the efficiency of the recursive function. | codefeedback |
Write a function to parse a string and return a set of unique words. The string may contain punctuation marks and special characters. Additionally, the function should handle cases where the string contains words separated by hyphens, apostrophes, or other non-alphanumeric characters.
# Incorrect Code #
Here is a refe... | codefeedback |
Write a program to sort a given array of integers in ascending order using the insertion sort algorithm. The insertion sort algorithm works by repeatedly taking an element from the unsorted part of the array and inserting it into its correct position in the sorted part of the array.
Input: [9, 3, 6, 1, 8]
Output: [1, 3... | codefeedback |
You need to sort the given array in descending order. However, you cannot use any built-in sorting functions or methods provided by the programming language. You have to implement the sorting algorithm yourself. Additionally, your sorting algorithm must have a time complexity of O(n log n), where n is the length of the... | codefeedback |
Debug the given Java program to make it print out the value of x, but without directly using the variable x inside the print method.
Note: You are not allowed to use any additional variables or modify the existing code. You can only modify the print method to achieve the desired output. | codefeedback |
Write a CSS style to apply a different color to each link on the page, with a total of 10 different colors. Each link should have a unique color and the colors should be applied in the order they appear in the HTML code. Additionally, the color for each link should be randomly generated and should not be repeated for a... | codefeedback |
You need to implement a depth-first search algorithm to search for a value in a given tree. The tree can have any number of child nodes for each parent node, and each node can have any number of attributes associated with it.
1. Start with the root node of the tree.
2. Check if the current node contains the value you ... | codefeedback |
Create a unit test for a given function to reverse a list of strings, but the function should also handle reversing strings that contain special characters, numbers, and whitespace characters. Additionally, the function should handle reversing strings that contain Unicode characters. | codefeedback |
You need to make a function that takes in two numbers, num1 and num2, and checks whether num1 is a cyclic rotation of num2 or not. A cyclic rotation is obtained by moving the last digit of a number to the first position and shifting all other digits one position to the right.
The function should return True if num1 is... | codefeedback |
Write a JavaScript function that will take a string and returns the reverse of that string without using any built-in string manipulation methods or arrays. The function should have a time complexity of O(n), where n is the length of the input string.
Additionally, you should handle cases where the input string contai... | codefeedback |
Given a string, write a Python function that will remove all the vowels from it and return the resulting string in reverse order. Additionally, the function should replace all occurrences of the letter 's' with the letter 'z' before reversing the string. | codefeedback |
Write a SQL query to select users who have a username that starts with "S" and whose email address contains the domain "@gmail.com". Additionally, the selected users should have at least 100 followers on the social media platform and their account should have been created within the last month. | codefeedback |
Use a deep convolutional neural network to accurately classify handwritten digits from the MNIST dataset with at least 98% accuracy, while using only 30% of the available training data and within a time limit of 8 minutes for model training. Additionally, the model should have a maximum complexity of O(N^2), where N is... | codefeedback |
Create a Python function to find the pair of numbers that have the highest product in an array of numbers. The array will contain both positive and negative numbers. The function should return the pair of numbers with the highest product, considering all possible combinations. If there are multiple pairs with the same ... | codefeedback |
Write a program that takes input from the user and stores it in an integer array of size 10. The program should then sort the elements in the array in ascending order and print the median of the array. Additionally, the program should validate that the input values are unique and within the range of -1000 to 1000 befor... | codefeedback |
What type of search algorithm is commonly used to find the shortest path between two points in a weighted graph, while also considering the maximum capacity constraint on each edge in the graph? | codefeedback |
How would you create a function that takes a list of strings as an argument and returns the total number of characters in all the strings together, while excluding any special characters, white spaces, and digits? | codefeedback |
Create a C# program that takes a string input from the user and outputs the length of the longest increasing subsequence present in the string.
#Erroneous Code#
```csharp
public class Program {
public static int FindLongestIncreasingSubsequence(string input) {
int[] dp = new int[input.Length];
dp[0... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.