instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Write a JavaScript function to filter out all falsy values from an array and return a new array without modifying the original one. The function should also exclude any null values from the array and only include values that are of type string, number, or boolean. Falsy values to be filtered out include NaN, 0, false, ... | codefeedback |
Explain how LSTMs can be utilized to predict time-series data, illustrating the necessary steps involved in preprocessing the data, designing and training the LSTM model, and evaluating the model's performance. Additionally, discuss any potential challenges or limitations that may arise during the process and suggest p... | codefeedback |
Create a list comprehension for a given list that only contains prime numbers. The resulting list should also be sorted in descending order and must not contain any duplicate values. You are not allowed to use any built-in sorting or duplicate removal functions. The original list can contain up to 1 million elements. A... | codefeedback |
Create a class called "UniqueList" that implements a list with the following characteristics:
- The list has a maximum length of 10.
- The list only allows unique elements, meaning that no duplicate elements can be added.
- The list supports the following methods:
- `add(item)`: Adds the specified item to the list ... | codefeedback |
Explain how to use advanced selectors and complex filters, such as combinators and pseudo-classes, in CSS to target specific elements based on various conditions and states. Provide examples and demonstrate how these advanced techniques can be utilized in different scenarios, such as targeting specific child elements w... | codefeedback |
Create a function that takes in a list of strings and returns a new list that contains words with an odd number of characters and do not contain any vowels. Additionally, sort the resulting words in reverse alphabetical order before returning the list.
mylist = ["programming", "python", "test", "difficulty"] | codefeedback |
Construct an SQL query to get the sum of all integers in a given table over a condition while also excluding any books that have been published before a specific year and have a price greater than 100. | codefeedback |
Write a JavaScript program to convert an array of objects into a comma-separated values (CSV) string with column headers. The program should handle the case where the array is empty and also convert all the values into uppercase. Additionally, the program should only include objects that have a 'name' property and igno... | codefeedback |
How can you find the sum of all prime numbers in a list, without using any built-in sum function or loops? | codefeedback |
Use the zip function to combine two lists by index, but exclude any values from list1 that are divisible by 3. Additionally, sort the resulting list in descending order based on the sum of each pair of values from list1 and list2.
list1 = [1, 2, 3, 4, 5, 6]
list2 = [7, 8, 9, 10, 11, 12] | codefeedback |
Suggest a way to efficiently extract all the unique words from an HTML page using Python, excluding any HTML tags and considering only words with at least 3 characters. Additionally, the solution should be able to handle HTML pages with a size of up to 100 MB and should be optimized to run on multiple cores for faster ... | codefeedback |
Name four different types of sorting algorithms and briefly explain how each algorithm works. Additionally, discuss the time complexity of each algorithm and provide a piece of erroneous code that implements one of the sorting algorithms. Explain the error in the code and propose a fix to correct it. | codefeedback |
Create a function in JavaScript that takes in an array of strings as a parameter. The function should iterate over the array and return a new array that contains only the strings that are longer than 5 characters. The function should have a time complexity of O(n^2), where n is the length of the input array. Additional... | codefeedback |
Increase the difficulty of the test by requiring the solution to handle a list of strings that contains special characters and to capitalize the first letter of each word within each string, while ignoring special characters.
mylist = ["this is a test!", "of the...", "difficulty increase!!"]
# Expected Output:
# ["Th... | codefeedback |
Generate a correct Python code to turn a list of strings into a list of their lengths, ensuring that the code is implemented using recursion. The input list should have a minimum length of 10 strings and a maximum length of 20 strings.
Additionally, modify the code to handle cases where the input list contains nested ... | codefeedback |
Implement a switch-case statement in Java that takes in a string as input and performs different operations based on the value of the string.
Requirements:
- The input string can only contain lowercase alphabets (a-z).
- The switch-case statement should handle at least 15 different cases.
- Each case should perform a ... | codefeedback |
Given an array of size n, find the maximum subarray sum. A subarray is defined as a contiguous portion of the array. Implement a function that returns the maximum subarray sum.
Example:
Input: [-2, 1, -3, 4, -1, 2, 1, -5, 4]
Output: 6
In the above example, the maximum subarray sum is obtained from the subarray [4, -1... | codefeedback |
Write a schema for a table to store student grades in a school. Additionally, include a column to store the date when each grade was assigned, another column to store the name of the teacher who assigned the grade, and a constraint that ensures the maximum length of the teacher's name is 50 characters. | codefeedback |
Find the most common element in a list of strings. The input list may contain up to 1 million strings, each with a maximum length of 100 characters. The strings are case-sensitive and can contain any printable ASCII characters. The solution should have a time complexity of O(n log n), where n is the total number of cha... | codefeedback |
Create a method in Python to generate all the prime numbers between 1 and 1000, where each prime number is also a palindrome and contains at least one even digit. | codefeedback |
Using the input, create a function to calculate the median of the set. The set may contain duplicates and negative numbers as well.
nums = [-5, 1, 2, 3, 4, 4, 5] | codefeedback |
Create a class in C++ named 'Animal' that has a method named 'getDescription()' and two public member variables named 'name' and 'age'. The 'name' variable should store the name of the animal as a string, and the 'age' variable should store the age of the animal as an integer.
The 'getDescription()' method should ret... | codefeedback |
Suggest an improvement to the following C++ for-loop to make it more efficient. Additionally, ensure that the loop terminates after a maximum of 50 iterations, that the target value is not allowed to be negative, and that the array elements are distinct (no duplicate values in the array). Return the index of the target... | codefeedback |
Create a class in Java named 'Person' that has the following fields: name (String), age (int), and gender (String). Add a method named 'calculateBirthYear' that calculates and returns the birth year of the person based on the current year and their age.
In addition, add the following methods to the 'Person' class:
1.... | codefeedback |
Given a sentence, clean up any duplicate words. If a word appears more than once, remove all instances of that word except for the first occurrence. Return the modified sentence.
Example:
Input: "My favorite favorite food is pizza."
Output: "My favorite food is pizza."
#New Test#
Given a sentence, clean up any dupli... | codefeedback |
Find all the occurrences of the word "the" in the following text while ignoring case sensitivity. Additionally, ensure that the word "the" is not part of any other word or substring within the text. Remove all occurrences of the word "the" from the text and output the modified text. Finally, calculate the total number ... | codefeedback |
Use a RegEx function to identify all the words that contain at least 7 characters and start with a capital letter in a given sentence.
Sentence: This is A sample Sentence to Test.
Difficulty Increase:
In addition to identifying the words that meet the given criteria, now also replace the identified words with their... | codefeedback |
Describe the concept of static variables in Java and provide an example of how they can be used in a practical scenario. Additionally, explain the potential drawbacks or limitations of using static variables in a multi-threaded environment and suggest possible solutions to overcome them. | codefeedback |
Explain the difference between a variable and a constant in C++ and provide an example of each. Also, discuss the implications of using variables and constants in terms of memory allocation, program execution, and error handling.
In addition, write a C++ function called "swapValues" that takes in two integer variables... | codefeedback |
Develop a Chatbot that can respond to the user's queries about programming languages with real-time results from online sources. The Chatbot should also be able to analyze the sentiment of the user's query and respond accordingly, providing a positive or negative sentiment analysis along with the relevant information. ... | codefeedback |
Create a data visualization comparing the population of California and New York over the span of 10 years, using data from the U.S. Census Bureau. Implement a dynamic and interactive visualization that allows users to filter and explore the data based on different demographic factors such as age groups, ethnicity, and ... | codefeedback |
Write a SQL query to display the name, most recent transaction date, and total transaction amount of the top 5 customers who have made the highest total transaction amount. Additionally, include the average transaction amount for each customer. | codefeedback |
Use this data to predict the weather for the next week.
Current temperature: 34 degrees Celsius
Humidity: 66%
Precipitation chance: 30%
Wind speed: 10 km/h
Cloud cover: 50%
Write a program that takes the above weather data as input and outputs a weather forecast for the next week. The program should consider various ... | codefeedback |
Given a string and a number, print the string the number of times specified by the number. However, the string must be printed in reverse order each time it is repeated. Instead of using a loop or built-in functions, you need to come up with a recursive solution to solve this problem. The string will only contain upper... | codefeedback |
Implement an autocomplete feature for an input field, but the suggested autocomplete options should be fetched in real-time from a remote server using an asynchronous API call. Additionally, the autocomplete feature should support handling multiple simultaneous API requests and display the suggestions in a dropdown men... | codefeedback |
Given two strings, find the longest common substring between them. The substring should contain only alphabetic characters and should be case-sensitive. Additionally, the solution should have a time complexity of O(n^3), where n is the length of the longest string.
s1 = "Hello, world!"
s2 = "world, goodbye!" | codefeedback |
Edit the given MySQL query to return all employee details from the "employees" table having both salary and designation value "Manager" and who have joined the company before the year 2010. Additionally, the query should exclude any employees whose last name starts with the letter "S".
SELECT * FROM employees WHERE des... | codefeedback |
Edit the following Java program to read 10 integers from the user and display the top three largest ones in descending order. Additionally, ensure that the program handles cases where the user inputs duplicate integers and provides an error message in such cases. | codefeedback |
Write a Python script to display the number of weekdays (excluding weekends) between two given dates. The script should also consider any public holidays within the date range and exclude those days as well.
Date 1: 21 May 2020
Date 2: 13 June 2020
Consider the following assumptions:
- The script should handle any va... | codefeedback |
Write a JavaScript program to compare two given strings, and count the number of common characters between them. The comparison should be case-insensitive. The strings can contain any characters from ASCII range 0-127.
#Additional Instructions#
1. You are not allowed to use any built-in JavaScript functions or methods... | codefeedback |
Write a Java program to print a right triangle star pattern with a given base, where each row contains a number sequence. The number sequence should start from 1 and increment by 2 for each row. The triangle should be centered and have alternating colors for the number sequence. Additionally, the program should display... | codefeedback |
Create a two-dimensional array in Java with values corresponding to the given output. Each element in the array should be the sum of the previous three elements in the Fibonacci sequence. The output should be: [0, 1, 1, 2, 4, 7, 13, 24, 44, 81]. | codefeedback |
Use HTML and CSS to create a web page that displays a welcome message, a button, and a form. When the button is clicked, the user should be redirected to another page. Additionally, the form should include input fields for the user to enter their name, email address, and phone number. The form data should be validated ... | codefeedback |
Create a C program to read two numbers between 1 and 100 and display the minimum of them. Ensure that the inputted numbers are within the specified range and are both prime numbers, otherwise display an error message. Additionally, implement a function to calculate the sum of all prime numbers within the given range an... | codefeedback |
Generate a Python program to extract the digits of a given number and print the extracted digits in descending order. However, you are not allowed to use any built-in functions or methods that directly manipulate or convert the number into a string or list. The program should have a time complexity of O(n) and a space ... | codefeedback |
Use PHP to create a login page which contains an input field to accept the username and password, and a submit button. Implement server-side validation to check if the username and password match the stored credentials in a MySQL database. Additionally, implement client-side validation to ensure that the username and p... | codefeedback |
Create a Python class for a student that holds their name, age, grade, and a list of subjects they are enrolled in. The class should have methods to add and remove subjects from the list, as well as a method to calculate the average grade of all enrolled subjects.
Additionally, modify the average grade calculation met... | codefeedback |
Sort an array of integers in ascending order without using the built-in sort() function. Additionally, you are not allowed to use any loops or recursion. The time complexity of the algorithm should be O(n log n).
my_array = [1, 6, 9, 5, 8, 10, 4, 2, 7, 3]
Please provide the implementation of the sorting algorithm. | codefeedback |
Create a function that takes in a positive integer and returns all the prime factors of the number in ascending order. The function should handle numbers up to 1,000,000. The returned list should not contain any repeated factors. The function should be able to handle inputs within a reasonable time limit for numbers up... | codefeedback |
Write a function that takes in an integer n and returns the maximum value that a 64-bit signed integer can represent. The function should handle both positive and negative numbers. | codefeedback |
Increase the difficulty of the given programming test question by requiring the following additional steps:
1. Group the dataset by category and sort the categories in ascending order.
2. Assign a unique identifier to each category and store it in a new column called 'Category ID' in the dataset.
3. Sort the dataset b... | codefeedback |
Calculate the value of the following expression: 3 to the power of 7, but without using any mathematical operators or built-in functions for exponentiation. Additionally, your solution should have a time complexity of O(log n) or better. | codefeedback |
Create a function that takes in a positive integer up to 10^9 and returns its prime factorization as a list of tuples, where each tuple consists of a prime number and its corresponding exponent. The prime factorization should be sorted in ascending order based on the prime numbers. Additionally, the function should opt... | codefeedback |
Describe the concept of text mining and write a program that implements a text mining algorithm. The program should take a text file as input and extract key information such as the most frequently occurring words, word frequencies, and any patterns or trends in the text. Additionally, the program should provide an opt... | codefeedback |
Analyze a provided string of characters and return the number of occurrences of each character, excluding whitespace and punctuation. The function should also sort the characters in descending order based on their frequency. The input string will only contain lowercase and uppercase letters. The function should also ha... | codefeedback |
Create a class named Person with the following properties:
- name: a string representing the person's full name
- age: an integer representing the person's age (must be between 0 and 150)
- email: a string representing the person's email address (must be a valid email address)
- address: a string representing the perso... | codefeedback |
Create a function that takes in a string and returns a string in reverse order. However, the function should only use a constant amount of extra space and should have a time complexity of O(n), where n is the length of the string.
Additionally, the function should handle strings containing unicode characters properly. | codefeedback |
Normalize the following URL and remove any query parameters and fragments, and also remove any trailing slashes. Additionally, convert any non-ASCII characters to their ASCII equivalents. Finally, check if the resulting URL is valid by ensuring that it starts with "http://" or "https://":
http://www.çafé.com/çäfe?pàge... | codefeedback |
Write a function which will take an array of integers as an argument and return an object with the keys being the elements of the array and the values being their counts. The function should also remove any duplicate elements from the array before counting their occurrences. Additionally, the function should be impleme... | codefeedback |
Write a function which will take an array of integers and returns an array with no repeated elements. The function should also sort the array in ascending order. If there are any negative numbers in the array, they should be excluded from the final sorted array.
my_array = [1, 2, 3, 2, 4, 6, 1, 2, -3, -5, -2, 0]
# E... | codefeedback |
Create a function to calculate the sum of all the prime numbers between 1000 and 2000, excluding any numbers that are divisible by both 3 and 7. | codefeedback |
Write a C++ program that takes an integer input N and prints the first N terms of the Fibonacci sequence, where N is guaranteed to be a prime number. The Fibonacci sequence is defined as follows:
- The first term is 0.
- The second term is 1.
- Each subsequent term is the sum of the two previous terms.
The program sho... | codefeedback |
Design and implement an algorithm to predict the customer churn rate based on a dataset containing customer data such as demographics, spending patterns, customer lifetime value, and customer satisfaction.
The algorithm should have a time complexity of O(nlogn) or better, where n is the number of customers in the data... | codefeedback |
Write a function that takes in an array of integers and returns a new array with all elements greater than 5 incremented by 1 and all elements equal to 0 removed. The function should also remove any duplicate elements from the resulting array. Additionally, the function should be implemented using a recursive approach.... | codefeedback |
Convert the given string of HTML into a DOM tree, using recursion, while ensuring that each HTML tag is properly closed and nested within its parent tag. Additionally, implement a validation function to check for any syntax errors or missing closing tags in the HTML string.
html_string = "<html><body><h1>Title</h1><p>H... | codefeedback |
Search for the first and last index of a given element in a given array, but the array may contain duplicates and the array must be sorted in ascending order.
array = [1,2,3,3,3,4,5,6]
element = 3 | codefeedback |
Write a JS function to make an authenticated API request and retrieve data from a specific endpoint of the API. The function should require an API key to be passed as a parameter. The returned data should be filtered based on a specific condition specified by the user. The function should handle any errors that occur d... | codefeedback |
Decompile the following HTML code while also parsing and displaying the contents of any nested tags and their attributes. Implement the program to handle HTML code containing up to three levels of nesting. Consider including error handling for any potential malformed or invalid HTML code, such as mismatched opening and... | codefeedback |
Create a Python class to represent a 3 x 3 matrix with variable values. The matrix should only accept integer values in the range of -100 to 100. Additionally, the matrix should have methods to perform matrix multiplication and matrix addition with another 3 x 3 matrix. The matrix multiplication method should also be a... | codefeedback |
Create a JavaScript function that logs a friendly message when the page is loaded. Additionally, the function should:
- Accept a parameter representing the user's name and include it in the friendly message.
- Check if the user's name is provided as an argument. If not, the function should log a generic friendly messag... | codefeedback |
Create a server in Node.js that can handle multiple endpoints and respond with different status codes and messages based on the endpoint requested.
Requirements:
- The server should be able to handle at least 10 different endpoints.
- The server should respond with a status code 200 and a custom message for each endpo... | codefeedback |
Design a Python class to represent a user with the following fields: name, age, address, email, and phone number. Include a method to calculate the user's birth year based on their current age. Additionally, add a method to check if the user is an adult (age >= 18). Implement input validation for each field to ensure t... | codefeedback |
Create a Python class to represent an employee record with fields name, salary, and department. The name field should be a string with a maximum length of 50 characters. The salary field should be a positive integer. The department field should be a string with a maximum length of 100 characters. Implement the class me... | codefeedback |
Calculate the area of a triangle given the coordinates of its three vertices, and round the result to the nearest integer.
x1 = 1
y1 = 5
x2 = 4
y2 = 3
x3 = 7
y3 = 2
Write a function named "calculate_area" that takes in six parameters: x1, y1, x2, y2, x3, y3.
Your function should return the area of the triangle, round... | codefeedback |
Make a 3D scatter chart with a dataset containing 1000 rows and 5 columns, where the values in column 'A' and 'B' are between 0 and 1. The scatter chart should have a title and a legend, with the title stating "3D Scatter Chart" and the legend displaying the values from column 'B'. The chart should also have a grid, an... | codefeedback |
Create a function that takes two lists and returns a dictionary with the elements of each list as keys. The value for each key should be a list of tuples, where each tuple contains the index of the element in the first list and the index of the element in the second list. Additionally, the function should also include ... | codefeedback |
Merge two dictionaries into another dictionary, but ensure that the merged dictionary only contains key-value pairs where the key is a string and the value is a positive integer. If a key-value pair in either dict1 or dict2 does not meet this requirement, it should be skipped.
dict1 = {'a':1, 'b':2, 'e':'hello'}
dict2... | codefeedback |
Develop a function in C to find the power of a given base to an exponent.
Base: -3
Exponent: 4
In addition to handling error cases where the base or exponent is negative, the function should also handle the case where the exponent is a floating-point number. If the exponent is a floating-point number, the function s... | codefeedback |
Create a script in Java to find the most repeated character in an array of strings, where each string consists of lowercase letters only. The array is passed as a command-line argument to the script. However, you are not allowed to use any built-in Java libraries or functions such as `Collections` or `HashMap` to solve... | codefeedback |
Create a JavaScript function called "calculateSquareRoots" that takes in an array of positive integers and returns an array of rounded square roots for each number. The function should have a time complexity of O(n), where n is the length of the input array.
Example:
Input: [1, 4, 9, 16]
Output: [1, 2, 3, 4] | codefeedback |
Create a web application that allows users to search for movies and save their favorites. The application should require users to create an account and log in before accessing any features. Additionally, implement a rating system where users can rate movies from 1 to 5 stars. Users should only be able to rate movies th... | codefeedback |
Develop a script in Java to generate the nth prime Fibonacci number.
The script should take an input, n, which represents the position of the prime Fibonacci number to be generated. The script should then generate and output the nth prime Fibonacci number.
Example:
Input: 5
Output: 13
Note: In this example, the 5th ... | codefeedback |
Build a neural network using Python to solve the XOR problem.
import numpy as np
# Sample data
X = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
y = np.array([[0, 1, 1, 0]]).T
# Neural network architecture
# Hidden layer with 4 neurons
# Output layer with 1 neuron
# Initialize random weights for the hidden layer
hidde... | codefeedback |
Create a function in Python that will print out a random word from a given list. However, the function should not print the same word twice in a row. If the same word is randomly chosen twice in a row, the function should choose a different word and print that instead. Additionally, the function should keep track of th... | codefeedback |
Write a JavaScript code for setting a different background color for every odd table row. Additionally, the code should alternate the background color for every cell within each row. The background color for each odd cell should be a shade of blue, while the background color for each even cell should be a shade of gree... | codefeedback |
Develop a function in JavaScript to get the maximum and minimum values from an array, along with their corresponding index positions. The function should also handle arrays that contain duplicate values.
Array elements: 10, 5, 8, 12, 9, 15, 3, 20, 7, 20, 15, 5, 10
Example Output:
Maximum value: 20
Minimum value: 3
In... | codefeedback |
Define a function in Java that will take a string as an argument and return it in uppercase. The function should have a time complexity of O(n), where n is the length of the input string, and a space complexity of O(1). Additionally, the function should not use any built-in string manipulation functions or libraries, s... | codefeedback |
Create a function in Python to generate all possible strings of length k from given lowercase characters, where k is the maximum length of the strings and is less than or equal to 15.
character_set = {'a', 'b', 'c', 'd', 'e'}
k = 10 | codefeedback |
You need to write a CSS rule to change the background color of every third div element in a web page, but you are not allowed to use the class or ID selectors to target the divs. Instead, you must use the `:nth-child` pseudo-class selector.
In addition, you need to ensure that the CSS rule only applies to divs that ha... | codefeedback |
Generate all possible combinations of the characters in a given string, considering both upper and lower case letters and numbers. Additionally, ensure that the combinations are sorted in lexicographical order. | codefeedback |
Create a C program to check if the given number is prime or not. However, you are not allowed to use any loops, recursive functions, or the modulus operator in your solution. | codefeedback |
Write a Java code snippet to calculate the area of a triangle, given three points. The points should not be collinear and should lie on a 2D plane.
x1, y1 = -2.5, 3.7
x2, y2 = 1.8, -4.2
x3, y3 = 6.3, 1.9
The code should handle the case when the points are collinear and output an appropriate message. Additionally, the... | codefeedback |
Read the given JSON data and return a list of all the keys. Additionally, modify the function to return the keys in reverse order. The JSON data will always contain at least 3 key-value pairs. You must implement the function using recursion. | codefeedback |
You need to edit the given code for sorting. Make the array sort in descending order. The sorting algorithm should have a time complexity of O(n^2). Additionally, the array should be sorted in-place without using any additional data structures.
arr = [3, 5, 8, 9, 10]
Rewrite the code to implement the Bubble Sort algo... | codefeedback |
You need to find the area of a given circle with the formula: Area = pi * r * r, where r is the radius of the circle. The radius can be any positive integer between 1 and 10^9 (inclusive).
Please write a function that takes the radius as input and returns the area of the circle. Your solution should have a time comple... | codefeedback |
You need to write an API request in Python to return JSON data from an API endpoint. Your code should handle pagination and retrieve data from multiple pages until all data is fetched. Additionally, you should implement error handling to handle potential API errors and retries in case of failed requests. Furthermore, y... | codefeedback |
Write an SQL query to select all rows from the table 'users' where the 'last_name' is 'Smith' and the 'age' is greater than or equal to 30, but exclude any rows where the 'first_name' is 'John'. | codefeedback |
Write a C++ program to read a string of characters from stdin and validate that it is a valid IPv4 address. | codefeedback |
You need to write a Java program to check whether a given string is a palindrome or not. However, you are not allowed to use any built-in string manipulation functions such as reverse() or compareTo(). You must implement your own logic to determine if the string is a palindrome. Additionally, you need to handle cases w... | codefeedback |
Edit the statements given below so that they can be compiled and run without any errors. Additionally, modify the code to perform the following tasks:
1. Generate a random number between 1 and 1000 and assign it to the variable "x".
2. Calculate the factorial of "x" and assign it to the variable "factorial".
3. Print ... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.