instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Generate a random password with 15 characters, including upper and lower case letters, numbers, and special characters. Additionally, the password must meet the following requirements:
1. At least 3 uppercase letters.
2. At least 3 lowercase letters.
3. At least 3 numbers.
4. At least 3 special characters.
5. The passw... | codefeedback |
Create a program in python that takes a number as input and checks if it is a prime number. Additionally, the program should only accept positive integers as input and should provide an error message and ask for input again if a non-integer value is entered or if the input is negative.
Furthermore, the program should... | 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, start with a capital letter, and end with a punctuation mark. Additionally, the returned phrase should be in all uppercase letters and should not include any numbers or special... | codefeedback |
Write a SQL query to group a table of cities by country, but only include countries with more than 5 cities. | codefeedback |
Construct a regular expression in JavaScript to check if a given string starts with exactly two vowels, followed by one or more consonants, and ends with exactly three consonants. | 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 |
Construct a loop in Python to invert the order of each word in a string. The words in the string will be separated by spaces. Additionally, any word with an even number of characters should have the middle character removed. For example, given the string "Hello World!", the loop should produce the string "!drW oleH". | codefeedback |
Create a dictionary that contains 10 entries, where each key-value pair represents a student's name and their corresponding score in a specific subject. The subject must be one of the following: Advanced Mathematics, Quantum Physics, Organic Chemistry, Human Physiology, English Literature, World History, Cultural Geogr... | codefeedback |
Train a sentiment analysis model using a corpus of movie reviews, without using any machine learning libraries or frameworks. You must implement the entire model from scratch, including the preprocessing, feature extraction, and training algorithms. Additionally, the model should be able to handle different types of te... | 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 |
Design a function in Python to find all the elements in an array that are divisible by 3.
However, there are two additional requirements:
1. The function must not use the modulo operator (%) or any other division operation to check for divisibility. You need to come up with an alternative approach to solve this prob... | codefeedback |
Calculate the area of a rectangle given the coordinates of its top-left and bottom-right corners, but the coordinates must be represented as complex numbers.
top_left = 1 + 3j
bottom_right = 6 + 1j | codefeedback |
Create a new list by changing all the strings in a given list to uppercase and removing any vowels from the resulting strings. Additionally, sort the list in descending order based on the length of each string.
lst = ["apple", "orange", "banana"] | 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!".
Additional Requirements:
1. The code should be case-insensitive, meaning it should replace both uppercase and lowerca... | codefeedback |
Increase the difficulty of the programming test question by adding the following constraints and requirements:
1. The input array must be validated to ensure it contains exactly three positive integers. If the input array does not meet this requirement, the function should return an error message or throw an exception... | 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. Additionally, the generated string must be a valid English word according to a provided dictionary.
#Reasoning Steps#
1. Read the provided dictionary file and store all the valid... | codefeedback |
Write a function in JavaScript that takes an array of integers as a parameter and returns a new array where each element is the sum of all the elements in the original array except for the corresponding element. The function should not use any built-in array manipulation methods or functions. The time complexity of the... | codefeedback |
Create a JSON representation of a Person object with the following properties:
- name: The name of the person (string, 1-100 characters, only alphabetical characters allowed)
- age: The age of the person (integer, between 1 and 100, divisible by 5)
- address: The address of the person (string, 1-200 characters, must st... | 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, and you cannot use any variables or data structures outside of the method to accomplish this task. | codefeedback |
Create a 3D scatterplot in Python to visualize 3 different datasets. Each dataset contains 1000 data points. 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.
To increase th... | codefeedback |
What is the command to create a new branch named "feature" in the Git repository, set its upstream branch to "origin/feature", and then push it to a remote repository named "upstream"? | codefeedback |
Modify the original list, so that it contains the numbers from 1 to 1000. However, you are not allowed to use any built-in functions or libraries. The solution should have a time complexity of O(n) and a space complexity of O(1).
original_list = [3, 4, 6, 8, ...] | codefeedback |
Create a function that checks if a string contains all the vowels in alphabetical order and has no repeated vowels, while also ensuring that the length of the string is less than or equal to 100 characters. | codefeedback |
Increase the difficulty of the given programming test question by adding additional validation steps and optimizing the code.
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 st... | codefeedback |
Create a Java class that contains three methods. The first method takes two integers as parameters and returns their sum as the result. The second method takes an additional integer as a parameter and returns the sum of the three integers as the result. The third method takes two additional integers as parameters and r... | 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 |
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 positive integers and a maximum limit, and then use a while loop to calculate and display the sum of all prime numbers between those two numbers, which are also less tha... | codefeedback |
Write a recursive function in Python that implements depth-first search on a binary tree. The function should take in a binary tree as input and return a list of all the nodes visited during the search in the order they were visited. Additionally, modify the function to keep track of the depth of each node visited and ... | codefeedback |
Write a program that prompts the user to enter a positive integer and prints the sum of the cubes of all the digits in the number.
#Erroneous Code Reference#
Below is a piece of erroneous code that tries to calculate the sum of the cubes of all the digits in a number, but contains a logic error:
```
sum_of_cubes = 0
... | codefeedback |
Help the user enter a list of numbers and print the sum of all the numbers accurately to two decimal places. The program should also calculate and print the average, maximum, and minimum values from the list.
#Additional Information#
- The user can enter any number of numbers in the list.
- The numbers can be positiv... | codefeedback |
Write a function in Python to generate a list containing the sum of corresponding elements given two lists. However, the function should also handle cases where the lengths of the two input lists are not equal. If the lengths are not equal, the function should return a list containing the sum of corresponding elements ... | 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 |
How would you create a debug statement to help identify an error in code, ensuring that it prints the error message and the line number where the error occurred, while also restricting the use of any built-in debugging tools or libraries? Additionally, you must ensure that the debug statement can handle nested function... | codefeedback |
Write a SQL query to extract employees who have been employed for more than 5 years and have a salary greater than 200,000, and whose employee name starts with the letter 'J', from the Employees table. | 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 |
Create an array of 10 people in Python, ensuring that each person object contains attributes for their name, age, nationality, and occupation. Additionally, implement a function that sorts the array of people based on their age in ascending order and their nationality in descending order. The age of each person must be... | codefeedback |
Write a code to get the top 10,000 Twitter trends worldwide within the last 7 days, excluding any trends related to politics or entertainment, and sort them in descending order of popularity. Additionally, you need to implement a real-time update feature that continuously fetches and updates the trends every 10 seconds... | codefeedback |
Write a script that generates a random integer within a given range. The minimum value and maximum value are inputted by the user.
1. Prompt the user to enter the minimum value.
2. Read and store the minimum value.
3. Validate the input to ensure it is a positive integer. If not, display an error message and ask the u... | codefeedback |
Create an SQL query for finding the total number of customers with the name "John" who have made at least 5 purchases in the last month. Additionally, display the total number of purchases made by each of these customers and sort the results in descending order based on the number of purchases. | codefeedback |
Write an R program to find the unique values in a vector and return them in descending order. Also, add an error handling mechanism to handle cases where the vector contains non-numeric values. | codefeedback |
Write a C program for reversing a singly linked list without using any additional data structures and with a time complexity of O(n).
Input list: 1 -> 2 -> 3 -> 4 -> 5
#Additional Requirements#
1. Do not use recursion.
2. Do not modify the original linked list, create a new reversed linked list.
3. The program should ... | codefeedback |
Rewrite the test with increased difficulty:
Given a list of strings, write a program that finds the longest common suffix among all the strings. If there is no common suffix, return an empty string.
# Example #
Input:
["happy","baby","candy"]
Output:
"y"
# Note #
In the given example, the longest common suffix among ... | 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 |
Develop a program to generate an array of random integers ranging from 1 to 100. The size of the array should be determined by the user input. Then, sort the array in ascending order using the bubble sort algorithm. Finally, output the sorted array along with the number of swaps performed during the sorting process. | codefeedback |
Create a function that takes in two parameters ``str_1``and ``str_2``and returns a boolean indicating whether or not ``str_1`` is contained in ``str_2``. The function should be case-insensitive and ignore any leading or trailing whitespace in both strings.
The function should have a time complexity of O(n), where n is... | codefeedback |
Convert the following hexadecimal value to its decimal equivalent and display it as a binary number.
hex_value = "0XFG"
**Additional Requirements:**
- Validate the input to ensure that it is a valid hexadecimal value.
- Handle the scenario where the input contains uppercase and lowercase letters.
- Handle the scenario... | codefeedback |
Write a Python program to generate all possible permutations of a given string with length up to 10. | 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.
Provide a piece of erroneous code as a reference to increase misdirection.
#Example#
Given the string: "hello world"
... | codefeedback |
Fetch the latest version of the package "abcd" and save it to your local environment. The package must be downloaded within a time limit of 5 seconds and saved in a specific directory named "packages". Additionally, ensure that the package is saved in a subdirectory named after the current date in the format "YYYY-MM-D... | codefeedback |
Convert the given JSON object to XML format. The JSON object may contain nested objects and arrays. The resulting XML format should include a custom attribute "id" for each nested object and array element. | 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). Additionally, implement a timeout feature that logs out the user automatically after 5 minutes of inactivity. | codefeedback |
Create a new class 'Dog' with a private attribute 'name' and two public methods 'bark' and 'setName'.
However, the 'setName' method should now have a validation check that the name is unique among all instances of the 'Dog' class. If the input name is not unique, the method should raise a custom exception 'DuplicateN... | 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!) and the space complexity should be less t... | codefeedback |
Write a Python program to find the number of days in a month specified by the user. The program should also handle leap years correctly.
The program should prompt the user to enter the month and the year. It should then determine if the year is a leap year or not.
If the year is a leap year, the program should chec... | 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 and that the email address does not belong to a disposable email service. | 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 5 characters and a... | codefeedback |
Create a vector in R with the following entries: the first 100 prime numbers. | 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, time slot, and a list of textbooks required for the course. Each student should also have a unique ID, and the JSO... | codefeedback |
Create a template for a new React Component with the following requirements:
- The component should have a prop called "title" which accepts a string value and displays it as the header text.
- The component should have a state variable called "isHidden" which is initially set to false.
- The component should have a bu... | codefeedback |
Suggest a code to select all rows from the table "users" where the user type is "VIP", the user's age is above 30, and the user's email address ends with ".com". | codefeedback |
Write a Python function that takes in two parameters: a list of integers and a specific integer value. The function should return the index of the last occurrence of the value in the list. If the value is not found in the list, the function should return -1.
Example:
Input: [1, 2, 3, 4, 5, 4], 4
Output: 5
Note: You s... | 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 descending 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. Additionally, the function should have a time complexity of O(n), where n is the leng... | codefeedback |
Explain the purpose of a nested for-loop in C++ and provide an example code snippet to demonstrate its usage. Additionally, include a piece of erroneous code within the example to increase misdirection. | codefeedback |
Suggest a way to dynamically render the background colour of a div element to blue based on a specific condition, ensuring that the change occurs only when the user hovers over the element and reverts back to its original colour when the mouse pointer is moved away. Additionally, the original colour of the div element ... | codefeedback |
Create a for-loop in Python that iterates through a list of numbers and prints out only the numbers in the list that are divisible by 7 and greater than 25, while also counting the total number of divisible numbers. The program should then print the sum of all the divisible numbers. Additionally, include error handling... | 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 |
Write a SQL query to find all the customers in the 'customers' table who are from the United States and have made at least 3 purchases in the past month. Additionally, include the total amount spent by each customer in the result set.
#Reasoning Steps#
1. Join the 'customers' table with the 'orders' table using the co... | codefeedback |
Create a MySQL query to join three tables, 'customers', 'orders', and 'products'. Select the customer name, order date, product name, and quantity for all orders where the total amount is greater than $500. Additionally, exclude any orders where the product quantity is less than 10. | codefeedback |
Create a mobile application with a button that allows the user to log in. When the button is clicked, a biometric authentication prompt (such as fingerprint or face recognition) should appear asking for the user's verification. After the user successfully verifies their identity, the application should validate the inp... | codefeedback |
Write a PHP program to generate a multiplication table for the numbers 1 to | 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. Additionally, round each floating-point number to the nearest whole number before converting it to an integer.
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. Additionally, after each iteration, check if the value of 'var' is a multiple of 5. If it is, print the value of 'var' and the number of iterations it to... | 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:
- Street:
- City:
- State:
- Zip Code:
- Phone number:
- Home:
- Mobile:
- E... | codefeedback |
## New Test ##
Write a function to generate a random password based on the given parameters.
Parameters:
- Length of password must be between 12 and 25 characters.
- Must contain at least three uppercase letters.
- Must contain at least three lowercase letters.
- Must include at least three numbers.
- Must include at... | codefeedback |
Reorder the lines of the code to make the program run correctly. Additionally, add error handling to handle cases where 'a' is not defined or is not an integer. Also, instead of using a try-except block, implement a custom error class called 'CustomError' and raise it when 'a' is not defined or is not an integer.
clas... | codefeedback |
Write an HTML page that displays a Javascript alert when a button is clicked. Additionally, the alert message should dynamically display the current date and time in the format "YYYY-MM-DD HH:MM:SS". Furthermore, the alert should only be displayed if the button is clicked exactly 5 times within a 10-second interval. | codefeedback |
Create a secure 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 10 characters, at least one uppercase letter, one lowercase letter, one digit, one special character, and must not contain any consecutive repeated char... | codefeedback |
Create a class called "Sentence" that takes a string parameter in its constructor. The class should have a method called "make_statement" that returns the sentence with the first letter of each word capitalized. Additionally, the class should have a method called "replace_word" that takes two string parameters: the wor... | codefeedback |
Complete the function below to generate a list of n prime numbers that are also Fibonacci numbers and return the result. The function should use the Sieve of Eratosthenes algorithm to find the prime numbers efficiently. | codefeedback |
Suggest a suitable programming language, considering the performance, memory management, and security requirements, for developing high-performance iOS mobile applications with real-time data processing capabilities. Additionally, provide a code snippet in the chosen language demonstrating how to efficiently process an... | codefeedback |
Parse the following JSON string and extract all the keys into a list. Then, sort the list in alphabetical order.
jsonString = '{"name": "John", "age": 20, "location": "New York", "hobbies": ["reading", "playing", "coding"], "friends": {"Alice": 25, "Bob": 23, "Charlie": 22}}'
#Expected Output: ['age', 'friends', 'hob... | codefeedback |
Extract the text from a given HTML document and count the number of occurrences of each word. Implement the solution using a binary search tree to store the word occurrences in sorted order. The solution should also handle cases where the HTML document contains nested tags and extract only the text content within those... | codefeedback |
Create a new string from the given string by replacing any character with its opposite. The opposite of a character is determined by its position in the alphabet. If the character is in the first third of the alphabet (A-I), its opposite will be the character that is exactly 9 positions away from it in the alphabet. If... | codefeedback |
You are tasked with building an employee management system for a large multinational company with multiple branches worldwide. 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, job title, departme... | codefeedback |
Suggest a suitable language and framework to build a web application, considering factors such as scalability, performance, security, and ease of development. Justify your choice by explaining how each factor is addressed by the language and framework.
Additionally, provide a piece of erroneous code that demonstrates ... | 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.
Furthermore, the dat... | 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.
Additionally, provide a piece of erroneous code that attempts to... | 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. Additionally, introduce a random element that determines whether the recursion should be performed from the beginning or the end of the number. This ran... | 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). Additionally, you are not allowed to use any built-in sorting functions or libraries. | codefeedback |
Write a dynamic programming algorithm to solve the 0/1 knapsack problem, with the additional constraint that each item can be taken at most once. | 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. Additionally, implement a search bar with autocomplete functionality, where the suggestions are fetched asynchronously from a server-side API... | 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. Additionally, the function should return the array in ascending order. | 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.
## Constraints
* The graph is represented as an adjacency list, where each key is a node and the corresponding value is a list of nodes that it is connected to.
* T... | 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. Additionally, you are required to implement the solution using only c... | 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 |
Given a list of strings, write a Python program to find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two strings, i.e. words[i] + words[j] is a palindrome. The program should handle cases where the strings can contain any characters, including uppercase letters, punctuation, ... | 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 |
Output a list that contains all the non-repeating vowels from a given string. However, you must exclude any vowels that appear more than once consecutively in the string.
Provide a piece of erroneous code that attempts to solve the problem using a different approach, such as counting the total number of vowels in the... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.