instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Write a regular expression that matches URLs that start with "www." and end with ".net" and have at least one digit between the "www." and ".net". | codefeedback |
Create a class called RandomGenerator that contains two methods:
1. The first method, called generateRandomNumber, should take in two parameters: a minimum value (min) and a maximum value (max). This method should generate and return a random number between the given range (inclusive).
2. The second method, called gen... | codefeedback |
Suggest a data structure that can be used to store contacts information, where each contact should have a unique identifier, and the phone number must be in a specific format (e.g., +1 (123) 456-7890). Additionally, implement a function to search for contacts based on their email domain. | codefeedback |
Use regular expression to create a pattern to identify email addresses in a string.
‘This is an example of an email: xyz@example.com’
#Revised Test#
Write a program that reads a text file and identifies email addresses in the given text. The program should then extract the domain names from the email addresses and c... | codefeedback |
Create a stored procedure in SQL to insert a new entry into a 'products' table. Additionally, ensure that the stored procedure checks for duplicate entries before inserting the new entry. If a duplicate entry is found, instead of inserting a new entry, update the existing entry with the new information. | codefeedback |
Provide a function to implement a Binary Tree traversal. However, the function should not use recursion and should instead use an iterative approach. | codefeedback |
Implement the bottom up cut rod algorithm in Python, ensuring that the time complexity of your solution is O(n^2) and the space complexity is O(n). | codefeedback |
Write code to convert a given string to all uppercase letters in Python, but without using the built-in `upper()` function. | codefeedback |
What is the typical workflow of a deep learning project, including the steps for data preprocessing, model training, and model evaluation, while adhering to best practices and ensuring efficient memory management? | codefeedback |
Implement a class to implement a Huffman coding algorithm, but without using any built-in data structures or libraries for sorting or priority queue. You must create your own data structure and implement the sorting and priority queue functionalities from scratch. | codefeedback |
Explain the concept of a Long Short-Term Memory (LSTM) neural network and its role in sequence prediction tasks. Discuss the advantages and disadvantages of using LSTM compared to a standard Recurrent Neural Network (RNN) model. | codefeedback |
For a given programming language, list the data types supported by that language and provide a brief explanation of each data type and its use cases. Additionally, categorize the data types into primitive and non-primitive data types, and explain the differences between them. | codefeedback |
Write a SQL query to select all the vehicles from a table that are owned by John and were manufactured in the year 20 | codefeedback |
Write a code to print out a multiplication table of a number in Python. The multiplication table should include all numbers from 1 to 10. The code should also allow the user to input the range of numbers to be included in the multiplication table. | codefeedback |
Create a url parser in JavaScript that can return the path and query parameters from a given url. The input url will be in the following format: "protocol://domain:port/path?param1=value1¶m2=value2". The parser should be able to handle urls with or without query parameters.
Note:
- The protocol will always be eith... | codefeedback |
Write a program that converts a given integer into its corresponding ASCII character. The program should take user input for the integer and output the corresponding ASCII character.
Note: The program should not use any built-in functions or libraries that directly convert integers to ASCII characters. | codefeedback |
Write a recurrence relation for the following algorithm.
Algorithm A:
n = n - 3
if n ≥ 0 then A(n)
New constraints:
1. The algorithm must be implemented using a recursive approach.
2. The value of n must be a positive integer.
3. The algorithm must terminate when n becomes negative. | codefeedback |
Write a code snippet that prints out each name and its length, but exclude any names that contain the letter "a".
names = ["John", "Alice", "Paul", "Adam"] | codefeedback |
Write CSS code to position a div in the middle and bottom of the page, but the div must also be fixed in place and have a minimum width of 500 pixels. | codefeedback |
Write a JavaScript function called `modifyStringArray` that takes in an array of strings and returns a new array where each string has been modified in the following way:
1. Remove all whitespace characters from the beginning and end of the string.
2. Capitalize the first letter of the string.
3. Convert all remaining... | codefeedback |
Generate a list containing all multiples of 3 and 5 from 0 to 100, but exclude any numbers that are also multiples of 7. | codefeedback |
Implement a machine learning model using recurrent neural networks (RNNs) for predicting the daily closing prices of a specific stock based on historical data. Additionally, your model should be able to handle non-linear dependencies and capture long-term dependencies in the data. | codefeedback |
Create a C# class with an interface that can be used to store and manipulate data. The class should have the following functionalities:
1. Add data to the storage.
2. Retrieve data from the storage.
3. Update existing data in the storage.
4. Delete data from the storage.
5. Calculate the total number of data items in t... | codefeedback |
Sort the string list in descending order based on the sum of the ASCII values of each character in the key and the value. | codefeedback |
Given a string s, create a function to find the character that appears the most and return its index. The function should only consider alphanumeric characters and ignore any special characters or whitespaces. Additionally, the function should be case-insensitive. If multiple characters have the same maximum occurrence... | codefeedback |
Write a program that takes an XML file as input and extracts specific data from it. The program should import the XML file as an object and then iterate through its elements to find and print the values of specific tags.
Additional Requirements:
1. The program should use a stack to store the nested elements of the XML... | codefeedback |
Parse a HTML page and find all text content within the page, while maintaining the order of appearance for each text element. Additionally, the algorithm should handle nested HTML tags properly, meaning that any text content within nested tags should be concatenated and treated as a single text element. The algorithm s... | codefeedback |
Create a correlation heatmap in Python using a given dataset, but without using any built-in functions or libraries such as pandas or numpy. You must implement your own functions for calculating the correlation and generating the heatmap.
Additionally, the dataset provided will now have missing values (NaNs). You need... | codefeedback |
In SQL, write an expression to output all valid email addresses from a table of users, where the email addresses must meet the following criteria:
1. The email address must be in the format "username@domain.com".
2. The username can only contain alphanumeric characters, underscore (_), dot (.), and hyphen (-).
3. The ... | codefeedback |
Increase the difficulty by rewriting the program to use recursion instead of a loop.
public class OddNumber {
public static void main(String[] args) {
printOddNumbers(10, 20);
}
public static void printOddNumbers(int start, int end) {
if(start > end) {
return;
}
if(start % 2 == 1) {... | codefeedback |
Create a C++ program that prompts the user to enter two integers and outputs their sum. The program should check that the entered values are within the range of -1000 to 1000 (inclusive). If the entered values are not within this range, the program should display an error message and ask the user to re-enter valid valu... | codefeedback |
Convert a given decimal number to binary, then convert the resulting binary number to hexadecimal using C programming language.
Example input:
12
Example output:
The binary representation of 12 is 1100.
The hexadecimal representation of 1100 is C. | codefeedback |
Suggest a SQL query to retrieve the employee records with an age greater than 30 and whose salary is in the top 10% among all employees in the company. | codefeedback |
Using JavaScript, write a function that takes a string as an argument and returns whether the string is a Palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, ignoring spaces, punctuation, and capitalization.
The function should have a time compl... | codefeedback |
Create a function that takes an integer n as an argument and returns the sum of all prime numbers from 1 to n. The function should have a time complexity of O(n√n).
n = 10 | codefeedback |
Describe how to debug a complex web application built using React.js, Node.js, and MongoDB. Include a piece of erroneous code in the question prompt to increase misdirection. | codefeedback |
Describe the process of writing a recursive program to calculate the factorial of a given number. Include additional reasoning steps to demonstrate your understanding of recursion and its implementation. | codefeedback |
Given a list of numbers, write a function that returns the sum of all the even numbers without using the built-in 'sum()' function. The function should have a time complexity of O(n), where n is the length of the list. The function should also have a space complexity of O(1), meaning it should not use any additional da... | codefeedback |
Given an HTML code snippet, write a program to analyze the structure and content of the code.
The HTML code snippet may contain multiple nested elements, including div, h3, p, and button. The goal is to parse the code and extract specific information about the elements.
Your program should:
1. Parse the HTML code and... | codefeedback |
Find the max 2 numbers in a list of n numbers without using any comparison operator. The list can contain both positive and negative integers, and the numbers can be repeated.
#Additional Requirements#
1. The solution should have a time complexity of O(n).
2. The solution should have a space complexity of O(1).
#Exam... | codefeedback |
Write an SQL query to get all employee salaries whose salaries are more than 50000 and have been with the company for at least 2 years. | codefeedback |
Write a Python program to create a random string of size 10 consisting of alphabets, digits, and special characters. | codefeedback |
Write an SQL query to display the name, department, and salary of the employees and their managers. Additionally, include the total number of employees each manager is responsible for and the average salary of the employees they manage.
#Difficulty increased by#
Adding more information to be displayed in the query and... | codefeedback |
Construct an SQL query to display the titles, directors, and release years of movies with more than 10 awards. The result should be ordered by the release year in descending order.
#Explanation#
In the rewritten test, we have added more complexity by requiring the query to also retrieve the directors and release years... | codefeedback |
Write a Java program to find the maximum element in a two dimensional array.
int[][] matrix = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} | codefeedback |
Write a Java code snippet to check whether or not a number is a prime, but this time you are not allowed to use any built-in functions or libraries. You must implement the logic from scratch.
In addition, the code should also print all the prime numbers within a given range, instead of just checking whether a single n... | codefeedback |
Write the shortest code to print "Hello World" without using the letter 'o' and with a maximum line length of 10 characters. | codefeedback |
Create a function in Python to replace all occurrences of a specified element in a given list with another specified element. The function should have a time complexity of O(n), where n is the length of the list. | codefeedback |
Write an Android program to detect if the device is connected to the Internet using only the TCP/IP protocol and without using any external libraries or APIs. | codefeedback |
Develop a C++ program to implement a scientific calculator that performs addition, subtraction, multiplication, division, square root, exponentiation, logarithm, and trigonometric functions (sin, cos, tan). | codefeedback |
Create a function that takes an integer n as input and returns an array containing the last n prime numbers. | codefeedback |
Create a regular expression pattern to find all words ending with "able" that are preceded by a digit and followed by a punctuation mark. | codefeedback |
Write a function to identify leap year, but without using any built-in date or time functions.
#Erroneous Code#
Write a function to identify leap year, but make sure it does not use the modulo operator (%) or any built-in mathematical functions. | codefeedback |
Write a Python class to find the maximum subarray sum of an array. The maximum subarray sum is the sum of the largest possible contiguous subarray within the array.
Constraints:
- The array can contain both positive and negative integers.
- The array may be empty.
- The time complexity of the solution should be O(n), ... | codefeedback |
Write an AppleScript program that opens a given link in Safari and performs the following additional actions:
1. Checks if Safari is currently open. If it is not open, the script should open Safari before proceeding.
2. Prompts the user to input a link and stores it in a variable.
3. Verifies if the entered link is a v... | codefeedback |
Design a regular expression to match strings that begin with the letter "a" and end with the letter "z", and have at least one digit in between. | codefeedback |
Write a query in SQL to retrieve the records that have the highest salary and belong to employees who have been with the company for at least 5 years. | codefeedback |
Rewrite the following code to delete the elements from the list which are not even and greater than 5. Additionally, sort the list in descending order after deleting the elements.
x = [1, 2, 3, 4, 5, 6, 7, 8, 9] | codefeedback |
Convert a given JSON string to its Python dictionary equivalent. The JSON string may contain nested objects and arrays.
json_string = '{"name":"John","age":30,"address":{"street":"123 Main St","city":"New York"},"languages":["Python","JavaScript","Java"]}' | codefeedback |
Define a C++ function to calculate the volume of a sphere given its radius. The function should only accept positive values for the radius and should return an error message if the radius is negative or zero. Additionally, the function should have a time complexity of O(1). | codefeedback |
Given two lists of integers, combine the contents of both lists into a new list. The resulting list should only contain the integers that are divisible by 3 and are greater than 10. If there are no such integers, return an empty list.
list1 = [12, 5, 9, 14, 21]
list2 = [16, 3, 20, 27, 18, 4] | codefeedback |
Construct a JSON object which contains the elements "name", "age", "occupation", and "address". The "address" element should have the sub-elements "street", "city", and "country". Additionally, the "name" element should only accept strings with a maximum length of 20 characters, the "age" element should only accept int... | codefeedback |
Construct an HTML form with input elements for name and email. The form should also include a checkbox for agreeing to terms and conditions and a submit button. Additionally, validate the email input to ensure it is a valid email address format. | codefeedback |
Parse the sentence and extract all the verbs and their corresponding tense from it. Sentence: "She ran quickly to catch the bus." | codefeedback |
Strip the white spaces from a given string, but preserve the leading and trailing white spaces.
my_string = " Hello World " | codefeedback |
Generate a dictionary that contains all the words in a string of text, and the number of times each word occurs. The text may contain special characters, such as punctuation marks, and the words should be case-insensitive.
Text: "I like dogs, and cats, and I like cats more than dogs!" | codefeedback |
What do we mean by immutability in Python and how does it differ from mutability? Explain with examples. | codefeedback |
Find the index of the first occurrence of the given element in a list, while considering that the list may contain duplicate elements and the element itself may be a list. Additionally, implement the solution using a recursive approach.
my_list = [2, 5, [6, 8], 8, 10, [8, 12]]
element = [8] | codefeedback |
Create a class named Student. Give it three fields - name, age, and grade. The grade field should be an integer ranging from 0 to 100.
Implement the following methods for the Student class:
1. A constructor that takes in the name, age, and grade as parameters and initializes the corresponding fields.
2. A method name... | codefeedback |
Create a new list object by selecting the names that start with a ‘A’ and have a length greater than 5 from the given list [Alfred, John, Anthony, Paula]. The resulting list should be sorted in descending order based on the length of the names. | codefeedback |
Train a Machine Learning model using scikit-learn that can solve a binary classification problem with the following additional requirements:
- The accuracy of the model should be at least 95% on a test set of 200 samples.
- Use a decision tree algorithm for the model training.
- Implement cross-validation with 5 folds... | codefeedback |
Create a function that takes in a list of dictionaries, where each dictionary contains a person's name, age, and city. The function should return a new list of dictionaries sorted by the person's age in descending order.
Example input:
[{"name": "Alice", "age": 24, "city": "Boston"},
{"name": "Bob", "age": 32, "city"... | codefeedback |
Edit the following Java code so that it will output the length of a string, but you are not allowed to use the built-in length() method or any other existing method or function for calculating the length of a string. You can only use loops and basic string manipulation operations. The input string will only contain low... | codefeedback |
Write a C++ program that takes an integer as input and prints the factorial of that number. The factorial of a number is the product of all positive integers less than or equal to that number. For example, the factorial of 5 is 5*4*3*2*1 = 1 | codefeedback |
Create a rectangle using the turtle library in Python that is filled with a pattern of random colors. | codefeedback |
Construct a matrix using the given list of numbers such that the sum of each row and each column is equal to a prime number.
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | codefeedback |
Use JavaScript to create a class hierarchy that demonstrates multiple levels of inheritance, including abstract classes and interfaces. Provide an example scenario where polymorphism is utilized within this hierarchy. | codefeedback |
Find the index of the first occurrence of the word 'data' in the text 'The data here is important'. The program should handle cases where the word 'data' is followed by punctuation marks or is part of a larger word, such as 'database'. | codefeedback |
Write an XSLT code to transform an XML document into HTML, while applying a specific CSS style to each element based on its attribute values. Additionally, all empty elements should be excluded from the output HTML. | codefeedback |
Make a matrix multiplication program that takes an arbitrary number of matrices as input. Your program should handle matrices of different sizes and perform the multiplication correctly. Additionally, you should implement error handling to detect and handle invalid input, such as non-numeric values or matrices that can... | codefeedback |
Write a computer program to print all twin primes in an inputted range. | codefeedback |
Write a function for removing duplicates from a given list, but the function must preserve the order of the original list. The input list will only contain positive integers. | codefeedback |
Write a program that takes in a string of text and outputs a summary of the text. The summary should be limited to one or two paragraphs and should capture the main ideas and key details of the original text.
You can assume that the input text will always be in English and will not contain any special characters or sy... | codefeedback |
Given a positive integer number, generate the Fibonacci series up to the given number.
Additional constraints:
- The Fibonacci series should be generated using recursion.
- The time complexity of the solution should be O(n).
- The space complexity of the solution should be O(1) (excluding the space used for the output... | codefeedback |
Generate a dictionary with the name of the person as key and the cower letter of their name as value. The names should be provided by the user as input. The program should validate the input and ask for a valid name if the user enters an empty string or a string containing only whitespace characters. Once the dictionar... | codefeedback |
Create a function that takes a string and checks if it's a valid email or not. The string must follow the format of "username@domain.com", where the username can only contain lowercase letters, numbers, periods, underscores, and hyphens, and must start and end with a letter or a number. The domain must consist of at le... | codefeedback |
Write code to determine if a word is a palindrome or not, taking into account punctuation and white spaces.
word = "A man, a plan, a canal: Panama!" | codefeedback |
Assign a random value to each item in a given list, ensuring that no two items have the same value. The list must also be sorted in ascending order.
my_list = [1, 2, 3] | codefeedback |
What should the following function return when calculating the standard deviation of a list of numbers?
The function should return the standard deviation as a floating-point number with 2 decimal places, rounded to the nearest even number. | codefeedback |
Create an Android app to accept user input and calculate the area of a circle. The app should also allow the user to input the radius or diameter of the circle, and provide the option to calculate the circumference and diameter as well. The app should display the results in a visually appealing manner, with proper form... | codefeedback |
Compare two strings and return true if both strings have the same number of characters and if the number of vowels in string1 is equal to the number of consonants in string2. | codefeedback |
What should the following code print out?
```python
def f(n):
if n == 0:
return 0
else:
return n + f(n-1)
print(f(10))
```
#Expected Output#
The code should print out the sum of all numbers from 1 to 10, which is 55. | codefeedback |
Edit this regression model to predict continuous values using a polynomial regression approach.
import numpy as np
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
def model(x):
poly = PolynomialFeatures(degree=3)
x_poly = poly.fit_transform(x.reshape(-1, 1... | codefeedback |
Reverse the words of the following sentence, while preserving the punctuation and capitalization.
This is a sentence | codefeedback |
Suggest a completion of the following code to flatten a nested list:
def flatten(nested_list):
result = []
def recursive_flatten(nested_list):
for item in nested_list:
if isinstance(item, list):
recursive_flatten(item)
else:
result.append(ite... | codefeedback |
Write a program that extracts the city name from a given URL, which follows the format "https://www.example.com/[city_name]". The program should be able to handle URLs with multiple segments before the city name and with or without the "www" prefix.
Example input:
https://www.example.com/los_angeles
Expected output:
... | codefeedback |
Write a SQL query to group all actors by the country they are from, and also include the total number of actors from each country. | codefeedback |
Write a JavaScript function called "calculateRemainder" that takes in two parameters, "num" and "divisor", and returns the remainder when "num" is divided by "divisor". The function should throw an error if "divisor" is not a number or if it is equal to 0. Additionally, the function should handle negative values of "nu... | codefeedback |
Create a quicksort algorithm in the following language: Java.
Additional requirements:
1. Implement the quicksort algorithm using only a single recursive function.
2. The pivot element for partitioning should be the median of the first, middle, and last elements of the array.
3. The algorithm should be capable of sort... | codefeedback |
If a singly linked list is represented only by its head pointer, how would you reverse it? Implement the reversal function without using any extra space or creating a new list. The time complexity of the solution should be O(n), where n is the number of nodes in the linked list. | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.