instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Write a code that takes an array of integers and returns an array of all elements in the original array except for the duplicates. The code should have a time complexity of O(n), where n is the length of the array. | codefeedback |
Write a code that takes a list of strings and a string, and returns a list containing all strings from the given list that have the given string as a substring. If the substring appears multiple times in a string, it should only be counted as one occurrence. The search for substrings should be case-sensitive.
Input:
-... | codefeedback |
Use the collections module in python to return the most common phrase from a list of strings, where the phrase must contain at least two words and start with a capital letter. | codefeedback |
Implement a trisection algorithm in Python.
A trisection algorithm is a numerical method used to find the root of a function within a specified interval. It works by repeatedly dividing the interval into three equal parts and determining which part contains the root. The algorithm continues to iterate until a sufficie... | codefeedback |
Write a SQL query to get the sum of sales for each country, but exclude any countries that have a population greater than 100 million. Additionally, include the average sales per person for each country in the result. | codefeedback |
Generate a random password with 10 characters, including upper and lower case letters, numbers, and special characters. Additionally, the password must meet the following requirements:
1. At least 2 uppercase letters.
2. At least 2 lowercase letters.
3. At least 2 numbers.
4. At least 2 special characters.
5. The passw... | codefeedback |
Write a SQL query to group a table of cities by country, but only include countries with more than 3 cities. | codefeedback |
Create a program in python to simulate a game of rock, paper, scissors, lizard, Spock.
Note: In this extended version of the game, each player chooses one of the five options: rock, paper, scissors, lizard, or Spock. The rules of the game are as follows:
- Rock crushes scissors and crushes lizard.
- Paper covers rock... | codefeedback |
Create a 3D scatterplot in Python to visualize 3 different datasets. Additionally, add the ability to rotate and zoom in/out the plot using mouse or keyboard controls. Ensure that the plot is interactive and allows the user to easily navigate and explore the data. | codefeedback |
Train a sentiment analysis model using a corpus of movie reviews, but without using any machine learning libraries or frameworks. You must implement the entire model from scratch, including the preprocessing, feature extraction, and training algorithms. | codefeedback |
Create a function in Python that shuffles the elements of an input list in such a way that no two adjacent elements are consecutive integers. The function should return the shuffled list.
arr = [1, 4, 5, 8, 9, 2]
Example output: [1, 9, 2, 4, 5, 8] | codefeedback |
Construct a regular expression in JavaScript to check if a given string starts with a vowel and ends with a consonant. | codefeedback |
Write Python code to replace all the vowels with an underscore, but leave the first occurrence of each vowel unchanged.
For example, for the string "Hello World!", the output should be "H_ll_ W_rld!". | codefeedback |
Write a function to generate a random 5 letter string, where each letter must be a consonant and no two consecutive letters can be the same. | codefeedback |
Create a new list by changing all the strings in a given list to uppercase and removing any vowels from the resulting strings.
lst = ["apple", "orange", "banana"] | codefeedback |
Construct a query to find a specific record in a database.
Table: Users
Name: John
Age: 25
Country: United States
City: New York
Email: john@example.com
Phone: 123-456-7890
Address: 123 Main St, Apt 4B, New York, NY 10001
The query should return all the information (name, age, country, city, email, phone, and address)... | codefeedback |
Given a class definition, write a method to count the number of objects created in the class. However, you cannot use any built-in Python functions or modules to accomplish this task. | codefeedback |
Write a function in JavaScript that takes a string as a parameter and reverses it, but without using any built-in string manipulation methods or functions. | codefeedback |
Identify if a given array is a palindrome, where the array can contain both integers and strings. The palindrome condition is defined as follows:
- If the array has an odd length, the middle element can be any value.
- If the array has an even length, all elements must be the same value.
- The array must be read the s... | codefeedback |
Validate a credit card number.
Write a function that takes in a string representing a credit card number and returns a boolean value indicating whether the number is valid or not. The function should perform the following steps:
1. Remove any non-digit characters from the input string.
2. Reverse the order of the dig... | codefeedback |
In MongoDB, what does the command 'db.collection.aggregate()' do and what is the expected output? | codefeedback |
Illustrate the usage of a while loop in Java to perform a series of complex mathematical calculations. The program should prompt the user to enter two numbers, and then use a while loop to calculate and display the sum of all prime numbers between those two numbers. The program should terminate when the user enters a n... | codefeedback |
Create a function that checks if a string contains all the vowels in alphabetical order. | codefeedback |
Modify the original list, so that it contains the numbers from 1 to 10. However, you are not allowed to use any built-in functions or libraries.
original_list = [3, 4, 6, 8] | codefeedback |
Create a generator expression to return the squared values of a given list, but exclude any numbers that are divisible by 3.
list_of_nums = [1, 2, 3, 4, 5] | codefeedback |
Create a Python program that takes a string as input and prints the characters of the string in reverse order. The program should also count the total number of vowels in the string and display the count. Additionally, the program should check if the string is a palindrome (a word, phrase, or sequence that reads the sa... | codefeedback |
Create a Bash script that changes all the filenames in a directory to lowercase, but only for files with a specific file extension. The directory should be provided as an argument to the script. The specific file extension should also be provided as an argument to the script. If no file extension is provided, the scrip... | codefeedback |
Write a C program for reversing a singly linked list without using any additional data structures.
Input list: 1 -> 2 -> 3 -> 4 -> 5 | codefeedback |
Write a code to get the top 5 Twitter trends in the US within the last 24 hours, excluding any trends related to politics or entertainment, and sort them in descending order of popularity. | codefeedback |
Write an R program to find the unique values in a vector and return them in descending order. | codefeedback |
Determine the sum of the numbers in a given list using a recursive function. The list may contain both positive and negative integers. The sum should be calculated by adding each element of the list together, without using any built-in sum() function or any loop structure. The function should have a time complexity of ... | codefeedback |
Rewrite the test with increased difficulty:
Given a list of strings, write a program that finds the longest common prefix among all the strings. If there is no common prefix, return an empty string.
# Example #
Input:
["flower","flow","flight"]
Output:
"fl"
# Note #
In the given example, the longest common prefix amo... | codefeedback |
Create a JSON object in JavaScript that stores the data of multiple students, where each student has a name, age, and a list of courses they are enrolled in. The courses should include the name, professor, and time slot. Each student should also have a unique ID, and the JSON object should enforce that the IDs are uniq... | codefeedback |
Construct a secure web page with two-factor authentication, consisting of a login input, a password input, and an additional verification method (e.g., fingerprint or SMS code). | codefeedback |
Convert the given JSON object to XML format. The JSON object may contain nested objects and arrays.
{
"name" : "John",
"age" : 25,
"profession" : "Developer",
"contacts" : {
"email" : "john@example.com",
"phone" : "1234567890"
},
"friends" : [
{
"name" : "Alice",
"age" : 28,
"profession" : "Engineer"
},
{
"name" : "Bob... | codefeedback |
Find the frequency of each letter in the given string while excluding any letters that are vowels. The string will only contain lowercase letters and spaces. Consider the string to be case-sensitive. | codefeedback |
Write a Python program to generate all possible permutations of a given string. | codefeedback |
Create a function that takes a string as input and checks if it contains valid JSON data. The function should return True if the input string is valid JSON, and False otherwise.
Here are the steps you can follow to solve this problem:
1. Import the `json` module in Python, which provides functions for working with JS... | codefeedback |
Write a regex to match the email address format, but also ensure that the domain name of the email address is a valid domain name. | codefeedback |
Implement a function in Python that takes a string as input and returns a list of all possible permutations of that string. The function should not use any built-in functions or libraries for generating permutations. The time complexity of the function should be less than O(n!), where n is the length of the input strin... | codefeedback |
Create a data frame that for a given set of students contains their name, age, grade level, and their favorite subject. The age of each student must be between 16 and 20 (inclusive), and the grade level must be between 9 and 13 (inclusive). The favorite subject must be a string consisting of at least 3 characters and a... | codefeedback |
Calculate the edit distance between the two strings, taking into account the additional constraint that only the following operations are allowed: insertions, deletions, and substitutions. Additionally, the solution must have a time complexity of O(n^2), where n is the length of the longer string.
str1 = "SUPER"
str2 =... | codefeedback |
Suggest a code to select all rows from the table "users" where the user type is "VIP" and the user's age is above 30. | codefeedback |
Suggest a code to sort the list of tuples below in the descending order of scores. If multiple tuples have the same score, sort them in ascending order of names.
my_list = [('John', 70), ('Jane', 80), ('Dave', 65), ('Alex', 70)] | codefeedback |
Write a function that returns the largest number in a list, while also considering the following constraints: the function should handle negative numbers, the list can contain duplicates, and it should ignore any non-integer elements. List: [1, 2, 3, 4, 5, 6, -1, -2, -3, "four"]. | codefeedback |
Create a regex that matches any five-digit zip code and ends with a hyphen and a four-digit extension. | codefeedback |
Write an API call in JavaScript to post a comment to a blog post with the following requirements:
1. The comment must include the following fields: author name, email, comment text, and blog post ID.
2. The API call must handle authentication, requiring an API key for authorization.
3. The API call must use a secure c... | codefeedback |
Write a function to generate a random password based on the given parameters.
Parameters: Length of password must be between 10 and 20 characters, must contain at least two uppercase letters, contain at least two lowercase letters, must include at least two numbers, and must include at least one special character (!@#$... | codefeedback |
Generate a XML structure to store the following information for multiple individuals.
Name: John Smith
Age: 28
Gender: Male
You need to also include additional information for each individual such as:
- Address:
- Phone number:
- Email address:
The XML structure should be able to accommodate any number of individual... | codefeedback |
Write a C++ function that generates a Fibonacci series of numbers up to an integer n, where n can be up to 1,000,000.
#Additional Test Cases#
1. n = 15
2. n = 50
3. n = 100
4. n = 1000
5. n = 10000 | codefeedback |
Convert a list of strings to a list of integers, where each string may contain a floating-point number with optional negative sign and decimal places.
list_of_strings = ["-1.23", "2.5", "-3.14159"] | codefeedback |
Write a while loop that adds the value of 'var' multiplied by 2 to the value of 'var' each time it is iterated until it reaches 1000. The initial value of 'var' is 1. | codefeedback |
Create a HTML form with two input fields, one for passwords and one for confirm passwords. Validate that the passwords should match and have a minimum length of 8 characters, at least one uppercase letter, one lowercase letter, one digit, and one special character, to let the user submit the form. | codefeedback |
Complete the function below to generate a list of n prime numbers and return the result. The function should use the Sieve of Eratosthenes algorithm to find the prime numbers efficiently.
n = 5 | codefeedback |
Extract the text from a given HTML document and count the number of occurrences of each word.
<html>
<head><title>My title</title></head>
<body>
<h1>Hello, world!</h1>
<p>This is a sample HTML document.</p>
</body>
</html> | codefeedback |
You are tasked with building an employee management system for a large company. The system should be able to efficiently store and retrieve information about employees, including their name, telephone number, and additional details such as age, address, and job title. Design a suitable data structure and provide reason... | codefeedback |
Design a responsive CSS template for a website that includes a navigation bar with dropdown menus, a slideshow with animated transitions, and a contact form with form validation. | codefeedback |
Suggest a suitable programming language, considering the performance and memory management requirements, for developing high-performance iOS mobile applications with real-time data processing capabilities. | codefeedback |
Define an application programming interface (API) for a given program.
In addition, implement a method called `addUser` that takes in two parameters: a username (string) and a password (string). This method should add a new user to the program's database, ensuring that the username is unique and the password meets ce... | codefeedback |
Suggest a data structure for storing real-time stock prices of different companies that can handle concurrent updates and provide efficient search and retrieval operations. Additionally, ensure that the data structure supports historical price data and can handle large volumes of data efficiently. | codefeedback |
Suggest a machine learning algorithm to solve a binary classification problem, and provide a detailed explanation of how the algorithm works. Discuss the pros and cons of the algorithm and provide insights into its performance on different types of data. | codefeedback |
Suggest a suitable algorithm for sorting an array of numbers in increasing order, but now you must use only constant space complexity and the sorting algorithm must have a time complexity of O(n log n). | codefeedback |
What is the data type returned by the following code snippet when the value is raised to the power of 8 and then multiplied by 5? | codefeedback |
Increase the difficulty by modifying the code to calculate the factorial using recursion instead of iteration. The modified code should handle large numbers correctly. | codefeedback |
Write a function that takes in a graph and a starting node, and returns a list of all nodes visited in a depth-first search starting from the given node. | codefeedback |
Implement a custom data structure for a student management system in a college. The data structure should allow the following operations:
1. Add a new student to the system.
2. Remove a student from the system.
3. Update the information of a student.
4. Search for a student by their ID.
5. Get a list of all students i... | codefeedback |
Write a dynamic programming algorithm to solve the 0/1 knapsack problem. | codefeedback |
Write a JavaScript function to test if two given arrays are equal. The function should also handle nested arrays and return true only if the arrays have the same elements in the same order, while ignoring any additional elements or elements in different positions. Additionally, the function should have a time complexit... | codefeedback |
Write a function to fill an array of size n with random integers in the range 0...k-1. The function should also ensure that the sum of all the elements in the array is a prime number. | codefeedback |
You are tasked with designing a system for storing and managing employee information for a large company. The system should be able to handle a high volume of data and provide efficient operations for retrieving and updating employee information.
Design a suitable data structure that can store the following employee ... | codefeedback |
Using binary search, find the index of a given number in a sorted array of length n. The array will contain distinct integers and will be in ascending order. The algorithm should have a time complexity of O(log n) and should use a recursive approach. | codefeedback |
Sort a given matrix such that the elements in each row are in increasing order and the elements in each column are in decreasing order. Additionally, the matrix should be sorted diagonally from top left to bottom right. | codefeedback |
Given a list of words, write a Python program to find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome. The program should handle cases where the words are not necessarily lowercase alphabetic characters and may contain punctuat... | codefeedback |
Given a webpage containing multiple paragraphs of text, write a function to increase the font size of each paragraph from 12px to 24px. The function should preserve the original formatting and styling of the webpage.
You should not use any third-party libraries or frameworks for this task. Your solution should be imp... | codefeedback |
What is the most efficient way to search for a specific item in an array, assuming the array is sorted in descending order? | codefeedback |
Build a neural network with one input layer, two hidden layers and one output layer, using Keras. The network must have a minimum of 50 neurons in each hidden layer and use the Adam optimizer with a learning rate of 0.001. Additionally, implement batch normalization in each hidden layer and include dropout with a rate ... | codefeedback |
Develop a function that is able to print a list of consecutive numbers between 1 and N, given an integer N as argument. The function should also check if each number is prime before printing it. The function should return a list of all prime numbers between 1 and N.
N = 10 | codefeedback |
Compute the result of the following equation: (5*3) + (1/2) + 2^3 - 4*2 | codefeedback |
Write an SQL query to update the data of a specific row.
Table name: employee_table
Fields: id, name, age
Update the name to "John" and Age to 25 where the id is equal to 4.
Include error handling in case the row with the specified id does not exist. | codefeedback |
Create a SQL query to delete all records from a table where the user's age is greater than 30 and their country of residence is not "United States".
Table Name: Users | codefeedback |
Create a block of code which sorts the given list in increasing order. Additionally, you should implement the sorting algorithm yourself instead of using a built-in sorting function or library.
List = [10, 4, 5, 7, 2]
#Additional Instructions#
1. You are not allowed to use any built-in sorting functions or libraries.... | codefeedback |
Find the area of a square with a given side length, but also ensure that the side length is a positive integer greater than zero. Side: 6 | codefeedback |
Add an element to the beginning of an array, but do not use any built-in functions or methods that directly add elements to an array (e.g., push, unshift). You can only modify the array by directly manipulating its memory. The resulting array should be [2, 3, 4, 6, 9]. | codefeedback |
Incorporate the PUT method in the given URL and ensure that the request body contains the user data in JSON format. Additionally, implement authentication by requiring a valid API key to be included in the request header. | codefeedback |
Write a Python function that takes a string as input and transforms all characters of the string to upper case. The function should return the modified string.
Example:
Input: 'Hello World!'
Output: 'HELLO WORLD!'
Additional requirements:
1. The function should handle strings with any combination of upper case and low... | codefeedback |
Write a JavaScript function that takes two arguments: a string representing a color and an array of HTML elements. The function should change the background color of each element in the array to the specified color. | codefeedback |
Generate a SQL query to select the name, age, salary, and department of the employees in the table. Additionally, include the average salary for each department in the result set. | codefeedback |
Write a PHP code for sending an email to the current logged in user with the following details:
- Email subject: "Important Information"
- Email body: "Hello [username], this email is to inform you about an important update regarding your account. Please login to your account for more details."
- Sender email: "noreply... | codefeedback |
Please debug the following Java code to calculate the average grade of 4 students. You must use an array to store the grades of the students and iterate over it to calculate the average. Additionally, the program should prompt the user to input the grades of the students instead of hardcoding them. | codefeedback |
Please insert the correction in the following HTML code snippet:
```html
<html>
<body>
<h1> This is a heading <h2>
</body>
</html>
```
Additionally, please explain why the correction is necessary and what the corrected code should look like. | codefeedback |
Describe the difference between static and dynamic programming and provide an example of each. Additionally, discuss the advantages and disadvantages of each approach and when it is appropriate to use them. | codefeedback |
Compare and contrast the time complexity, space complexity, and stability of Insertion Sort and Bubble Sort. Additionally, provide a detailed explanation of the algorithmic steps involved in each sorting algorithm. | codefeedback |
Construct an array of 10 random numbers between 1 and 100, without using any built-in JavaScript functions for generating random numbers. | codefeedback |
Write a function that formats the following JSON string in the following format:
{
"name": "John",
"age": 30,
"city": "New York"
}
Note: The function should handle any valid JSON string with arbitrary key-value pairs and nested objects or arrays. | codefeedback |
Write an SQL query to select the departments with their corresponding average salary, but exclude any departments where the average salary is above a certain threshold. Additionally, include the total number of employees in each department in the query result. | codefeedback |
Use Python to design a function that concatenates two given strings, but ensure that the resulting string is in alphabetical order. For example, given the strings "Hello" and "World", the function should return "Wdelor". | codefeedback |
Write a code that finds the most frequent element in a list, but without using any built-in functions or libraries. The code should be able to handle large lists with millions of elements efficiently. | codefeedback |
Rewritten Test:
Write a program to sort an array of integers in ascending and descending order without using any built-in sorting functions or libraries. | codefeedback |
Implement a method that verifies whether an array of numbers is in increasing order, while also ensuring that all the elements in the array are unique.
arr = [2, 3, 5, 10, 15]
Additional Constraints:
1. The array must have at least 2 elements.
2. The array can contain both positive and negative numbers.
3. The array c... | codefeedback |
Write a function to convert an RGB color to HEX, without using any built-in functions or libraries for color conversions. | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.