instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Generate a string representation of a binary tree with the following additional requirements:
1. Each node in the tree should be represented as a pair of parentheses containing the node's value.
2. The left subtree should be represented within the parentheses of the node, followed by a hyphen ("-"), and then the right ... | codefeedback |
Create a script that filters the list of strings and returns only the strings that contain the specific, user-specified character. Additionally, sort the resulting list in descending order based on the number of times the specified character appears in each string. If two or more strings have the same number of occurre... | codefeedback |
Create a responsive HTML page with a fixed navigation bar at the top, a main content area in the middle, and a footer at the bottom using CSS Grid instead of Bootstrap. Implement a sticky sidebar on the left side of the main content area that scrolls along with the content, but also collapses into a hidden drawer when ... | codefeedback |
Write a function in Python to remove all occurrences of the element with the value of ‘apple’ from the list, but without using the built-in remove() function. The function should also return the indices of the removed elements. The list may contain duplicate elements and should not be empty.
fruits = ["banana", "appl... | codefeedback |
Write a program that takes a list of data as input and inserts each element into a MongoDB database using Mongoose. Each document should have a unique identifier generated by the program and a timestamp indicating when it was inserted. Before inserting, the program should validate the data to ensure that the name field... | codefeedback |
Return the names of the customers that contain the string "ali" and are not case sensitive, while also excluding customers whose names contain any special characters or numbers. | codefeedback |
Rewrite the given quadratic equation into the standard form y = ax^2 + bx + c, where a is a non-zero integer and b and c are integers: 2x^2 + 3x + 1 = 0. | codefeedback |
Use the input to generate a loop in JavaScript to print an increasing count starting from the given number. However, you must also add a condition that skips any number that is divisible by both 3 and 5. If the number is divisible by 3, print "Fizz" instead of the number. If the number is divisible by 5, print "Buzz" i... | codefeedback |
Generate a valid python loop to print out the elements of a list in reverse order. However, you are not allowed to use the `reverse()` method or slice notation in your solution.
List = [1,2,3,4,5] | codefeedback |
Write a JavaScript code that creates an array of objects having keys "name", "age", "city", and "country". Additionally, each object must have a unique identifier key "id" consisting of a randomly generated alphanumeric string of length | codefeedback |
Generate a list of all pairwise combinations of the numbers in the given list, excluding any duplicate combinations. However, each combination must also include the sum of its elements. | codefeedback |
Implement a function in JavaScript that takes an array and returns an object with the count of each element value. The input array can contain various data types including booleans, numbers, strings, and objects. The function should also handle nested arrays and objects within the input array. Additionally, the functio... | codefeedback |
Write a Java program to clone an array of objects, but the objects in the array must implement a specific interface called "Cloneable". Additionally, the program should check if the objects in the array actually implement the "Cloneable" interface and throw an exception if they don't. | codefeedback |
Implement a function to calculate the sum of the digits of a given positive integer. Additionally, the function should return the count of unique digits present in the number. The function should have a time complexity of O(n), where n is the number of digits in the integer. The space complexity should be O(1). | codefeedback |
Given an array of objects, sort them in descending order according to their age. If two objects have the same age, sort them in ascending order according to their name. However, the age should be sorted based on the number of vowels present in the name of the object, in descending order. If two objects have the same nu... | codefeedback |
Create an algorithm to find the kth largest element in a given list of numbers. The input list may contain duplicate elements.
Input:
- A list of n integers, where n is a positive integer.
- A positive integer k, where 1 <= k <= n.
Output:
- The kth largest element in the input list.
Example:
Input: [2, 5, 7, 4, 3],... | codefeedback |
Write a program that determines the language used to write a given HTML document, taking into account multiple possible language declarations and considering the document's structure.
Your program should:
1. Read the HTML document from a file or from user input.
2. Parse the document to identify the language declarati... | codefeedback |
Using this list, write a Python program to print out all the duplicate elements without using any built-in functions or data structures. Additionally, you must solve the problem in O(n) time complexity and O(1) space complexity.
my_list = [1, 2, 3, 2, 4, 3] | codefeedback |
Design a Python program to read string inputs from a file and print out the reverse of each line, while also removing any duplicate characters in each line. The file path should be passed as a command line argument.
Note: You should not use any built-in functions or methods for string reversal or removing duplicates. | codefeedback |
Design a JSON object containing Book information such as title, author, publication year, and a list of chapters. Each chapter should have a title, page count, and a list of topics covered. The JSON object should also include a list of reviews, with each review containing the reviewer's name, rating, and a comment.
A... | codefeedback |
Explain why JavaScript is called a multi-paradigm language and provide examples of at least two different programming paradigms that JavaScript supports. Additionally, describe the advantages and disadvantages of using each programming paradigm in JavaScript development. | codefeedback |
Find the most suitable 15-lines python code to generate all permutations of a 8 letters word. Additionally, make sure that the code does not use any built-in library functions for generating permutations and has a time complexity of O(n!). | codefeedback |
Write a program that takes a list of integers as input and removes the second to last element from the list. The program should then output the modified list. | codefeedback |
Write a method that produces a random password with the specified number of characters. The password must contain at least one uppercase letter, one lowercase letter, one digit, and one special character. Additionally, the password must not contain any repeating characters.
#Erroneous Code#
```python
import random
imp... | codefeedback |
Create a program in Python which takes a string as an input and prints the number of each character in the string. The program should also handle cases where the input string contains special characters, spaces, and digits. Additionally, the program should ignore the letter case, meaning that uppercase and lowercase ve... | codefeedback |
Create a web application that displays a table with the following columns: "ID", "First Name", "Last Name", and "Email". The table should be interactive, allowing users to sort the data based on any column in ascending or descending order. Additionally, users should be able to filter the data based on the values in any... | codefeedback |
Input a sentence with repeated words and write a Python code to remove all the repeated words. The sentence may contain punctuation marks and the words may be in mixed case. However, your code should also handle cases where the repeated words are not adjacent to each other. For example, if the input sentence is 'The th... | codefeedback |
Write a Ruby method that takes two integers, n and m, as arguments and returns an array containing all the prime numbers between n and m, inclusive. The method should have a time complexity of O(n*sqrt(m)).
m = 1000
n = 1 | codefeedback |
Construct a program to find the result of the following equation, subject to the constraints:
- The program should only use a single for loop.
- The program should not use any built-in mathematical functions or libraries.
- The program should have a time complexity of O(n).
- The program should be able to handle larg... | codefeedback |
Design a Python program which prints the elements in reverse order, without using any built-in functions or methods for reversing the list. Additionally, the program should have a time complexity of O(n) and a space complexity of O(1), where n is the length of the list.
my_list = [1,2,3,4,5] | codefeedback |
Please write a program that takes in two sorted arrays of integers and merges them into one sorted array in ascending order.
Example:
arr1 = [2, 4, 6, 8, 10]
arr2 = [1, 3, 5, 7, 9]
Output:
merged_arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Additional Constraints:
- The input arrays can contain negative numbers and zero.
-... | codefeedback |
Create a function in C# that takes a string and returns true if all the characters are unique in the string. The function should have a time complexity of O(n) and a space complexity of O(1), where n is the length of the string. Additionally, you are not allowed to use any built-in data structures such as arrays, lists... | codefeedback |
Generate a PHP program to accept a string as an input and convert it to uppercase. The program should also remove any duplicate characters in the string and return the result in reverse order. Additionally, the program should only use a single loop to accomplish these tasks.
To increase the difficulty, the program sh... | codefeedback |
Please implement a function that takes in an array and removes all duplicates from the given array. The array can contain integers and strings. The order of the elements should be preserved. The output should be sorted in ascending order. If the array is empty, return an empty array. If there are no duplicates in the a... | codefeedback |
Explain what a while loop is and provide an example of how it can be used in a program. In your example, demonstrate how a while loop can be used to implement a recursive algorithm. Discuss the time and space complexity of your solution. | codefeedback |
What is the most efficient way to insert a new element into an existing unsorted array, without using any built-in array functions or methods? Additionally, ensure that the inserted element is always placed at the beginning of the array. | codefeedback |
Write a SQL query to find the average credit score of users who are 18 years or younger and have a credit score higher than 700. Additionally, include the number of users who meet these criteria in the result set. | codefeedback |
Construct a data structure to store a dictionary of words and their definitions. Implement methods to add a word and its definition, retrieve the definition of a word, update the definition of a word, and delete a word from the dictionary. The data structure should have an efficient retrieval and update time complexity... | codefeedback |
Create a TensorFlow 2.0 program that takes a 3D array and normalizes the values by dividing each element by the sum of all elements in the array. Additionally, you must implement a custom loss function that penalizes the model based on the standard deviation of the normalized array. The loss function should be minimize... | codefeedback |
Reverse a doubly linked list using Python. The doubly linked list should be reversed in place, without creating a new list or using any built-in functions or methods. You must implement your own algorithm to reverse the linked list. Additionally, the time complexity of your algorithm should be O(n), where n is the numb... | codefeedback |
Generate a SQL query to find the names, addresses, and email addresses of all users whose credit scores are lower than 50, have made at least 3 purchases in the last month, and have not made any returns in the last 6 months. | codefeedback |
Given a database schema with the following tables:
1. `Company` table with columns `company_id` (integer), `company_name` (string), `company_address` (string), and `founding_year` (integer).
2. `Location` table with columns `location_id` (integer), `zip_code` (string), `city` (string), `state` (string), and `country` (... | codefeedback |
Write a function to check if the given string `str1` is a permutation of the string `str2`, considering only alphabetic characters and ignoring case.
Additional Instructions:
1. The function should handle strings with different lengths.
2. The function should handle strings containing special characters and spaces.
3.... | codefeedback |
Write a code for a Javascript program to return the nth Fibonacci number, where n is a positive integer provided by the user. Make sure to handle invalid inputs and provide appropriate error messages.
The Fibonacci sequence is defined as follows:
- The first and second numbers of the sequence are 0 and 1, respectively... | codefeedback |
What is the maximum limit of frames which a HTML5 page can hold when using the "seamless" attribute and nested frames, while considering a worst-case scenario with an additional constraint that each nested frame must have unique content? | codefeedback |
Write a program in any programming language that takes a string as input and counts the number of unique characters in the string. The program should then print the count of each unique character in descending order along with the character itself. The program should also ignore whitespace characters and consider upper... | codefeedback |
Write a shell script that takes an address as input and opens the corresponding website in the default web browser. However, the script should also include the following additional features:
1. Validate the address input to ensure it is a valid URL. Use regular expressions to check if the input matches the pattern of ... | codefeedback |
Write a SQL query to find all the students who have scored above 90 in at least 3 subjects and are currently enrolled in more than 4 courses. | codefeedback |
Write a code to reverse a stack without using any additional data structures and return the modified stack. You are not allowed to use any recursion in your solution. The input stack will always have at least 5 elements. | codefeedback |
Write a code in C# to convert a decimal number to binary format without using bitwise operators or the built-in Convert.ToString() function. The converted binary number should be stored as a string.
Constraints:
- The decimal number will be within the range of 0 to 10^9.
Example input: 128
Example output: "10000000" | codefeedback |
Create an array of size 10,000,000 in Java and assign random values from 1 to 10,000,000 to each item of the array. The values in the array should be unique, with no duplicates allowed. The algorithm should run in O(n) time complexity. | codefeedback |
Write a function in C++ that takes an integer array as a parameter and returns the median value in the array. The median is defined as the middle value of a sorted array. If the array has an odd number of elements, the median is the value at the middle index. If the array has an even number of elements, the median is t... | codefeedback |
Extract the sum of all numeric values from the following string in Python. However, you must now implement the solution using only a single line of code. The string may contain multiple occurrences of numeric values, and you must find and extract all of them. | codefeedback |
Please write a program in C to calculate the sum of all prime numbers within a given range.
Input: Two positive integers representing the lower and upper limits of the range.
Output: The sum of all prime numbers within the given range.
Example:
Input: 1, 10
Output: 17 (2 + 3 + 5 + 7 = 17)
Note:
- The input numbers wi... | codefeedback |
Write a CSS property to display an element as a flex item and align it horizontally and vertically in the center of its container, but with the restriction that you are not allowed to use the `justify-content` or `align-items` properties. | codefeedback |
Find the kth largest element in the list in Python. Return the index of the element in the original list.
list = [12, 34, 87, 90, 80, 21]
k = 5
#Solution# | codefeedback |
Create an HTML page that displays one web page with two vertical panels. The left panel should contain a form with at least five input fields and a submit button. The input fields should include validation for specific data types (e.g., email, phone number). Additionally, the form should have a dropdown menu with dynam... | codefeedback |
Find the middle element of a given linked list. If the length of the linked list is odd, return the middle element. If the length of the linked list is even, return the second middle element.
Example:
1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7
Expected output: 4 | codefeedback |
Generate a random password using a given string of characters. The password must contain at least one uppercase letter, one lowercase letter, one special character, and one digit. The length of the password should be between 10 and 20 characters. Additionally, the password must not contain any consecutive repeating cha... | codefeedback |
Assign a numerical value to a given string where each letter is mapped to a prime number and the final value is the sum of all the prime numbers corresponding to the letters in the string. If the string contains any non-alphabetic characters, they should be ignored.
For example:
Input: "Apple"
Output: 26
Explanation:... | codefeedback |
Write a method that takes a parameter, text, and returns the words in the text in reverse order, while preserving the order of the characters within each word. However, the method should also remove any duplicate words from the result.
Example:
text = "Hello, how are you doing today? Hello, how are you doing today?"
... | codefeedback |
Create a web form in HTML with two fields - first name and last name.
Add a validation mechanism to ensure that the first name and last name fields cannot be left empty.
Additionally, implement a character limit for both fields - the first name field should accept a maximum of 20 characters, and the last name field s... | codefeedback |
Design a method in Ruby that can be used to determine if a given number is a prime number or not. The method should use the Miller-Rabin primality test algorithm instead of a basic prime number checking algorithm. The method should also take an additional parameter, k, which represents the number of iterations to perfo... | codefeedback |
Write a class in Scala to define dog characteristics such as color, breed, size, and age. Implement a method to calculate the dog's age in human years based on the following conversion:
- The first year of a dog's life counts as 10.5 human years.
- The second year of a dog's life counts as 8.5 human years.
- After that... | codefeedback |
Generate HTML code for a table that displays the result of multiplication for the numbers from 1 to 100, but exclude any multiplication results that are divisible by both 5 and 7. | codefeedback |
Create a database query that shows the average price of all items, but exclude any items with a price lower than $10 and also exclude any items with a price higher than $100.
Additionally, include only items that were added to the database in the last 30 days.
Furthermore, calculate and display the average price sepa... | codefeedback |
Write a function that takes in a 3 letter acronym as input and returns its full form. The full form should be a phrase or a set of words that represent the meaning of the acronym.
To solve this problem, you should not use a lookup table or dictionary. Instead, you should implement a logic that derives the full form fr... | codefeedback |
Given the following array, delete all occurrences of the number 4 and return the resulting array. Additionally, sort the resulting array in ascending order.
list1 = [4, 3, 4, 2, 3, 4, 4]
#Difficulty Increased Test# | codefeedback |
Generate a method in C++ to sort a given array in descending order. The array may contain duplicate elements. The time complexity of the algorithm should not exceed O(n log n), where n is the size of the array. The space complexity should not exceed O(1). Additionally, the algorithm should be able to handle large array... | codefeedback |
Create a SQL query that selects the top three most recently purchased products, but also excludes any products that were purchased more than once on the same day. Additionally, the query should only consider products that have been purchased at least 5 times in total. Table Name: Purchases Columns: Product Name, Date. | codefeedback |
Write an SQL query to get the number of customers per country, sorted in descending order of the number of customers. Also, exclude any countries with less than 5 customers. Additionally, only include countries where the average age of customers is below 30. | codefeedback |
Develop a machine learning model in Python to predict the credit risk of a customer based on their bank transaction data.
### Problem Statement ###
You are given a dataset consisting of bank transaction data for multiple customers. Each row in the dataset represents a transaction and contains the following information... | codefeedback |
Develop a for loop in JavaScript to output integers from 0 to 100, but skip every third integer and print only the prime numbers. | codefeedback |
Write an SQL query to find all customers in the table 'customers' who have bought more than 3 items from the store, ordered by the total amount spent by each customer. The query should also include the customer's name, email, phone number, and the average price of the items they have bought. | codefeedback |
Design a CSS style to make an element a circle and have a red border. However, the border should only be visible on the left side of the circle. Additionally, the circle should have a 3D effect with a radial gradient background color, and the border color should change to blue when the element is hovered over. | codefeedback |
Use Swift to print a welcome message in the console. The message must include the current date and time in the format "dd/mm/yyyy hh:mm:ss". Additionally, the welcome message should be displayed in a different language based on the user's locale. | codefeedback |
Write a Java program to replace all non-alphanumeric characters with underscores, while ignoring any non-alphanumeric characters within double quotation marks. Additionally, the program should convert all uppercase letters to lowercase before performing the replacement.
Input: "Hello, World! "This is a Test.""
Output: ... | codefeedback |
Create an algorithm that takes two integers and returns the smallest common multiple of the two numbers. If there is no common multiple between the two numbers, return -1.
Example:
x = 9
y = 16
Step 1: Find the prime factors of both numbers.
- Prime factors of 9: 3
- Prime factors of 16: 2, 2, 2, 2
Step 2: Identify ... | codefeedback |
Analyze the following code and suggest a modification.
Modify the hello function to accept an optional argument "name" of type string. The function should then print "Hello, [name]!" if the argument is provided and the length of the string is less than or equal to 10 characters. If the argument is provided but the len... | codefeedback |
Write a SQL query to select customers who have an email address ending with ".com" and whose first name is not "John", and sort the results in descending order of the number of characters in their email address. | codefeedback |
Write a function to take a list of strings and return true if any element in the list starts with the letter "t" and ends with the letter "d". However, if any element in the list starts with the letter "t" and ends with the letter "d", the function should also check if the length of that string is a prime number. | codefeedback |
Develop a SQL query to delete all entries with discount greater than 10 and quantity less than 5, and whose price is greater than 100, in the "products" table. Additionally, the query should only delete entries where the product category is not "Electronics". | codefeedback |
Construct a C++ code snippet to output a Fibonacci sequence with a given number of elements, where the given number of elements can be very large (up to 10^18). Additionally, optimize the code to have a time complexity of O(logn), where n is the number of elements in the Fibonacci sequence. | codefeedback |
Use HTML, CSS, and JavaScript to create a responsive navigation bar that collapses into a hamburger menu on smaller screens and expands on larger screens. The navigation bar should also include a dropdown menu when hovering over certain links.
Additionally, implement a feature where the dropdown menu disappears after ... | codefeedback |
Create a SQL query that returns a list of cities in a given state where the population is above 1 million and the average annual temperature is above 80 degrees Fahrenheit.
state='California' | codefeedback |
Write a function to create a matrix NxN with values of 0 filled in, where N is a prime number. The function should also fill in the diagonal of the matrix with a value of 1. | codefeedback |
Create a program for calculating the surface area of a cube using only bitwise operations, without using any loops or conditionals. The program should have a time complexity of O(1) and a space complexity of O(1). | codefeedback |
Construct an HTML form to collect the name, address, phone number, and email address of a user. The email address must be validated to ensure it follows the proper email format. Additionally, the form should include a password field and a confirm password field. The password and confirm password fields must match and m... | codefeedback |
Design a C++ program to convert a given number from binary to decimal, ensuring that the binary number is no more than 16 bits in length. The program should handle both positive and negative binary numbers and display the decimal result as a signed integer.
Additionally, the program should include error handling to ch... | codefeedback |
Design a function to calculate the GCD (greatest common divisor) of two given integers, a and b. However, you are not allowed to use any built-in functions or libraries to calculate the GCD. You must implement the Euclidean algorithm from scratch and the function must have a time complexity of O(log(min(a, b))). Additi... | codefeedback |
Construct a class to represent a scientific calculator with functions for addition, subtraction, multiplication, and division. The calculator should also include functionality for calculating the square root of a number and raising a number to a power. Additionally, the calculator should have a function to calculate th... | codefeedback |
Write a Python code to generate a random sequence of numbers from the given list [10, 20, 30, 40], ensuring that no number is repeated in the sequence and the sum of the numbers in the sequence is a prime number. | codefeedback |
Generate a function in Python to compute the area of a rectangle. Additionally, implement error handling to ensure that the input dimensions are valid positive numbers. Provide a piece of erroneous code as a reference to increase misdirection. | codefeedback |
Generate a SQL query to return a list of customers who have made at least two orders, each with a different product category, and whose total order amount is greater than $500. | codefeedback |
Construct a HTML form to collect the name, age, gender, and email address of the user. Additionally, include validation for each field to ensure that the name is at least 5 characters long and does not contain any special characters or numbers, the age is a number between 21 and 65, the gender is selected from a radio ... | codefeedback |
Write a Python program to calculate the number of bits needed to represent the maximum possible integer in binary form, but without using any built-in functions or libraries related to binary conversion. | codefeedback |
Construct a script that takes inputs from the user and prints out the Fibonacci sequence up to a given number, but with the following additional requirements:
1. The script should use an iterative function to generate the Fibonacci sequence.
2. The script should implement memoization to optimize the iterative function ... | codefeedback |
Write a SQL query to find the average score of students who are aged between 20 and 23, have a GPA higher than 3.5, and have not taken any elective courses. | codefeedback |
Design a function to input an array and sort it using QuickSort algorithm. Additionally, the function should handle arrays with duplicate elements. The time complexity of the function should be O(n log n), and the space complexity should be O(log n). | codefeedback |
Remove any element from an array that is a prime number and then sort the remaining elements in descending order. | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.