instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Write a SQL query to generate a table that contains the number of customers per county, sorted in descending order. Additionally, include the percentage of customers each county represents out of the total number of customers. The query should only include counties that have more than 100 customers.
codefeedback
Create a function in Python that takes one parameter, a list of integers, and outputs the list in reverse, without using the built-in `reverse()` method, the `[::-1]` slicing syntax, or any temporary data structures such as lists or arrays. The function should only use basic operations like swapping elements, indexing,...
codefeedback
Please create a class called Employee in Java which contains the name, age, salary, and department of the employee. Implement methods to calculate the yearly bonus based on the employee's salary and department. The bonus should be calculated as follows: - For employees in the sales department, the bonus is 5% of their ...
codefeedback
Edit this code to fix the bug in the program. The program should now print the longest word(s) in the given list of words. The program should also ignore any words that contain numbers or special characters. The program should be case-insensitive, meaning that it should treat "Hello" and "hello" as the same word. The p...
codefeedback
Reverse the words of a given sentence but keep the order of the words intact, while also ensuring that any punctuation marks are preserved in their respective positions. The sentence can contain multiple sentences and paragraphs, and the program should handle them accordingly. Additionally, the program should ignore an...
codefeedback
Create a function to convert a given sentence to title case, where each word starts with a capital letter. The sentence may contain alphabetic characters, spaces, and punctuation marks. Handle cases where certain words should not be capitalized, such as prepositions and conjunctions (e.g. "and", "the", "of").
codefeedback
Please write a Java program that converts a given string to all lowercase letters, removes any duplicate characters, and sorts the characters in descending order based on their frequency. 1. Start by declaring a string variable called "myString" and assign it the value "HeLlO WoRlD". 2. Create a new string variable ca...
codefeedback
Generate a random password of length N (where N is a positive integer) that complies with the following conditions: 1. The password must contain at least one uppercase letter, one lowercase letter, one digit, and one special character. 2. The password must not contain any repeated characters. 3. The password must not c...
codefeedback
Create a query that displays the employees who are completed more than 20 years in the company, have received at least one promotion during their tenure, and have worked in multiple departments during their career. Include the list of departments they have worked in and the total number of promotions they have received...
codefeedback
Create a function that can accurately classify the sentiment conveyed in a given sentence or set of sentences. The function should consider both the presence of positive or negative words and the overall context of the sentence(s). It should be able to handle multiple sentences, negation words and phrases, contextual c...
codefeedback
Given an array of integers and a target number, find three elements in the array that sum up to the target number. The three elements must also be consecutive in the array.
codefeedback
Given an array of strings, reverse the order of the elements inside it so that the last string becomes the first and vice versa. Additionally, ensure that all strings starting with a vowel are placed at the beginning of the reversed array, followed by the strings starting with a consonant. Maintain the original order o...
codefeedback
Create a script to transpose a matrix. A matrix is represented as a list of lists, where each inner list represents a row of the matrix. To transpose a matrix, we need to convert its rows into columns and its columns into rows. Write a function called transpose_matrix(matrix) that takes a matrix as input and returns...
codefeedback
Create a program to convert a bi-dimensional array into a single array while maintaining the order of the elements. Your program should handle cases where the input array can have up to 100 sub-arrays, and each sub-array can contain up to 1000 elements. The program should also handle cases where the elements in the sub...
codefeedback
Write a SQL query to list the salary of all employees as a percentage of the salary of the highest paid employee, but only for employees who have been with the company for more than 5 years, have received at least one promotion, and have an employee ID that is a prime number. Note: The prime number check should be imp...
codefeedback
Write a function that given a list of unique integers, returns the sum of the non-duplicated integer elements. Additionally, the function should handle negative integers, zero, and floating-point numbers. The function should also handle cases where the list may contain duplicate elements and remove all duplicate elemen...
codefeedback
Create an algorithm that takes two numbers a and b and returns the largest number. However, you are not allowed to use any arithmetic operators such as +, -, *, /, or %. You can only use bitwise operators and logical operators. a = 5, b = 6
codefeedback
Using PHP, write a code to print out the current date and time in the following format: Thursday, December 18 at 4:30 PM. Additionally, implement a function that takes in a string input representing a date and time in the format "YYYY-MM-DD HH:MM" and returns the corresponding day of the week. The code should handle ti...
codefeedback
Implement a sorting algorithm to sort a given array of size 1000 in descending order. array: [432, 123, 567, 654, 987, 321, 678, 876, 901, 234, ...] Please note that the algorithm should be efficient and have a time complexity of O(n log n).
codefeedback
Given a string, print all its permutations. Example: Input: "british" Output: "british" "britsih" "britihs" "british" "britsiih" ... (Note: The output list will contain all possible permutations of the input string) Now, additionally, you need to ensure that the output list contains only unique permutations.
codefeedback
You are given a list of integers. Write a program that formats the list such that each element is in a new line. Additionally, print the sum of all the numbers in the list. Higher difficulty requirements: - The program should have a time complexity of O(n), where n is the length of the list. - The program should have ...
codefeedback
Increase the difficulty of the programming test question by modifying the logic and adding constraints: ## Modified Test ## You are given a positive integer `n`. Write a function that returns an array with all the prime numbers between 2 and `n`, inclusive. However, the code provided contains a logical error that nee...
codefeedback
Design a function in Ruby to calculate the exponent of a given base and exponent, without using any built-in Ruby exponentiation methods or operators. Your function should also handle negative exponents correctly. #Erroneous Code Example# Below is a reference code that attempts to calculate the exponent, but contains ...
codefeedback
Create a code to sort this list in a descending order while ignoring any duplicate values. The code should also ensure that the time complexity of the sorting algorithm is O(nlogn). Additionally, the code should not use any built-in sorting functions or libraries. my_list = [1,9,3,5,7,3,7]
codefeedback
Create a lambda function in Python that collects all the prime numbers between 0 and 100. The function should return the product of all the collected prime numbers.
codefeedback
Given a list of integers, delete the last three elements from the list and print the remaining elements in descending order. **Example:** **Input:** my_list = [1, 4, 6, 7, 6, 8, 9] **Output:** [6, 4, 1]
codefeedback
Extend the range from 25 to 35 and ensure that the sum of all elements in the list is greater than 500. Additionally, the list should contain only prime numbers. my_list = list(range(25))
codefeedback
Write a program that takes a string as input and outputs the word that has the maximum frequency in the string. In case of multiple words with the same maximum frequency, output the word that occurs first in the string. Additional Requirements: 1. Ignore punctuation marks and consider only alphabetic characters in the...
codefeedback
Generate an HTML table with a given list of dictionaries, where each dictionary represents a person with the keys 'name' and 'age'. The table should have a border, a caption that says "Person Details", and each row should have alternating background colors. Additionally, the table should only include people whose age i...
codefeedback
Compute the average of the following numbers: 45, 20, 15, 100, 75, but exclude any numbers that are divisible by 5 and also contain the digit 7.
codefeedback
Write a regular expression to match the following sentence: "Mary had a little lamb that followed her everywhere she went and it was very cute." The regular expression should also capture and return the number of times the word "she" appears in the sentence.
codefeedback
Create a class called "ComplexVector" with x and y coordinates. The class should have the following methods: 1. A method called "add" that takes another ComplexVector object as a parameter and returns a new ComplexVector object that is the result of adding the two complex vectors together. 2. A method called "subtrac...
codefeedback
Using GraphQL, write a query to get the name, age, address, email, and total number of students taught by each instructor in a training center who have at least 5 years of teaching experience and are certified in at least 3 different programming languages. Additionally, sort the instructors based on the number of stude...
codefeedback
Write a C++ code snippet to create an infinite loop that calculates the sum of all numbers from 1 to a given positive integer 'n', but the loop must exit when the sum exceeds a given limit 'k'. Additionally, implement a function to handle invalid inputs where 'n' is a negative integer or 'k' is a non-positive integer.
codefeedback
Modify the following Keras model to add two 1D convolutional layers before the last layer. Additionally, add a batch normalization layer after each convolutional layer to improve model performance. model = Sequential() model.add(Dense(64, activation='relu', input_dim=100)) model.add(Conv1D(32, 3, activation='relu')) m...
codefeedback
Create a function to take two positive integers and return the larger one. The function should also validate that both input integers are prime numbers between 1 and 100, inclusive. If any of the integers are not prime numbers or are outside the range of 1 to 100, the function should raise a ValueError with a descripti...
codefeedback
Implement a function, sumOfSquares, that takes an array of integers and calculates the sum of the squares of all the prime numbers in the array. #Example: Input: [1, 2, 3, 4, 5, 6] Output: 29 #Note: - You should ignore any non-prime numbers in the array. - The array may contain negative integers. - You should handle ...
codefeedback
Write a HTML form to take in two user inputs, validate the inputs, perform a calculation on the inputs, and display the result. The form should include additional fields for the user to select the type of calculation to perform (addition, subtraction, multiplication, or division) and the number of decimal places to rou...
codefeedback
Write a JavaScript function that takes a string as an argument and produces a new string with the duplicated characters removed. The function should have a time complexity of O(n) and a space complexity of O(1), where n is the length of the input string. #Additional Instructions# 1. The function should be case-insens...
codefeedback
Write a MySQL query to find the names of all the students who took both math and science classes and achieved a score of at least 80 in both subjects, while also considering the class and semester in which the students took the classes.
codefeedback
Automate complex financial calculations in Excel by writing a VBA program to calculate the weighted average of three columns, considering a specific weighting factor for each column. Ensure that the program handles scenarios where the input data contains both positive and negative values, and where the weighting factor...
codefeedback
Construct an SQL query to select the total number of employees in the table 'Employees' and sort the result in descending order based on their salaries. Additionally, include the average salary for each department in the result set, and only include departments with more than 10 employees.
codefeedback
Explain the concept of memoization and provide an example of a recursive function that can be optimized using memoization. Describe the benefits and drawbacks of using memoization in terms of time complexity and space complexity.
codefeedback
Generate a random string containing 20 characters, consisting of 10 lowercase alphabets and 10 random numbers between 0 and 9 using JavaScript. The string should be in a specific format where the letters and numbers are interspersed. For example, the string could be in the format of "a1b2c3d4e5f6g7h8i9j0". Make sure th...
codefeedback
Update the given JSON array to increment the "age" value of every user by 5 years, but only if the user's name starts with a vowel and their age is less than 40. If the user's name starts with a consonant or their age is 40 or greater, the "age" value should remain unchanged. The updated array should be sorted in desce...
codefeedback
Use CSS and JavaScript to create a dark mode version of the following website. Additionally, implement a toggle button that allows users to switch between light mode and dark mode. The toggle button should persist the user's preference across page reloads using local storage. The dark mode should not only change the ba...
codefeedback
Using MapReduce, calculate the average age of the users in a given dataset. Additionally, exclude any users who are below the age of 18 from the calculation. The dataset contains millions of user records, and each record consists of the following fields: user_id, name, age, gender, and location. The dataset is stored i...
codefeedback
Construct an SQL query to delete all records from the table 'Employees' with a given salary that have been employed for at least 5 years. However, the query should also update another table called 'Salaries' to set the salary for these deleted records to 0 and increase the salary of all remaining employees by 10%.
codefeedback
Develop a Java program that prints all the prime numbers up to a given limit using the Sieve of Eratosthenes algorithm.
codefeedback
Write the SQL query to return a list of unique values from a table called products with a column called categories, but only for products that have a quantity greater than 10 and are priced higher than the average price of all products in the same category. Additionally, sort the result in descending order based on the...
codefeedback
Construct an HTML form with five input fields: First Name, Last Name, Username, Password, and Email. The Username field should only allow alphanumeric characters and be case-sensitive. The Password field should have a minimum length of 12 characters and require at least two uppercase letters, two lowercase letters, two...
codefeedback
Create a function that takes a float number, a positive integer, and a boolean as input. The function should format the number to have exactly the specified number of decimal places. The function should also round the number if necessary and should truncate the number if the boolean is set to True. Example: Input: for...
codefeedback
Write a function in JavaScript that takes in an existing dictionary and a key-value pair. The function should add the key-value pair to the dictionary only if the key does not already exist. If the key does exist, the function should update the value associated with the key. The function should have a time complexity...
codefeedback
Replace every character in a given string with its corresponding ASCII code, remove any duplicate characters, and reverse the resulting string. The input string should only contain alphabetic characters.
codefeedback
Write a query in SQL to count the number of users with a given email address, excluding any users with a status of "deleted" and whose usernames start with a vowel. Table: users Email address: example@example.com
codefeedback
Generate a Python code to calculate the compound interest for multiple time periods, taking into account the possibility of variable interest rates. You are given the following inputs: Principal: the initial amount of money invested (in dollars) Rate of Interest: a list of annual interest rates (as decimals) for each ...
codefeedback
Please write a JavaScript function called "addUniqueFruits" that takes an array of fruits as a parameter and adds three new fruits to it. The function should return the updated array. Example: Input: ['apple', 'banana'] Output: ['apple', 'banana', 'orange', 'mango', 'grape'] Note: - The function should only add fruit...
codefeedback
Print all unique combinations of an array of integers, where the combination must include at least three elements and the sum of the elements in each combination must be a prime number. Additionally, the prime number must be a palindrome. nums = [1,2,3,4,5]
codefeedback
Write a SQL query that returns all records from the "customer" table sorted by first name, but with the following additional conditions: 1. Exclude any records where the first name is empty or null. 2. Group the records by the first letter of the first name, and sort each group by the first name in descending order. 3...
codefeedback
Create a program that creates a dictionary containing only the squares of numbers up to n, excluding any perfect squares. Additionally, the program should output the sum of all the squares in the dictionary. n = 10000
codefeedback
Write a query in SQL to display all records from the 'Users' table, excluding any records where the 'status' column is set to 'inactive'. Also, sort the records in descending order based on the 'created_at' column.
codefeedback
Given a list of words, write a Python function to print the frequency of occurrence of each word in the list, sorted in descending order by frequency. The function should have a time complexity of O(n log n), where n is the number of words in the list. Example: Input: ['foo', 'bar', 'foo', 'baz', 'bar', 'baz', 'qux',...
codefeedback
Using a hash table, construct a program to find all of the pairs of an array whose sum is equal to a given target. Additionally, the program should handle duplicate elements in the array and return the count of unique pairs found. The program should also have a time complexity of O(n), where n is the length of the arra...
codefeedback
Design an API to pull company data from an external source. Ensure that the API supports authentication, rate limiting, and data validation to prevent abuse and ensure data integrity. Additionally, implement error handling to gracefully handle any connection issues, incorrect data returned by the external source, and p...
codefeedback
Rewrite the given test with increased difficulty: Design and implement a CNN-LSTM model using Keras and TensorFlow for image classification with the CIFAR-10 dataset. The model should have the following specifications: 1. The CNN component should consist of at least three convolutional layers with different filter si...
codefeedback
Create a function to convert a given quantity of money from one currency to another. The function should be able to handle multiple conversions in a single call. amount: 1000 from_currency: USD to_currency: GBP, EUR, AUD, CAD, JPY, CNY, INR, MXN, BRL, ZAR The function should be able to handle a large number of curren...
codefeedback
Write a query in SQL to find all records where the value of a field is greater than 50, and also include the records where the value is equal to 50. Additionally, sort the records in descending order based on another field called "date_modified".
codefeedback
Develop a Python function to calculate a Fibonacci number based on a given index, but without using recursion and without using any loops.
codefeedback
Write a JavaScript program that given an array of integers, prints the maximum and minimum value of the array, as well as the average value. Additionally, the program should remove any duplicate values from the array before performing the calculations. The program should also find the median value of the array, which i...
codefeedback
Develop a function in Python to delete the duplicate characters of a given string and return the remaining characters in reverse order while maintaining the original order of the non-duplicate characters. The function should also handle case sensitivity and special characters. The string can have a maximum length of 10...
codefeedback
Implement a function in Python that calculates the median of a given input array. The array can contain both positive and negative integers. The length of the array can be odd or even. The array can contain duplicate elements. For odd-length arrays: 1. Sort the array in ascending order. 2. Calculate the index of the m...
codefeedback
Create a method in Java that takes in a string and prints its contents in reverse, while ensuring that the method does not use any built-in string manipulation functions such as reverse() or StringBuilder. The method should also handle special characters and whitespace, and should have a time complexity of O(n) and spa...
codefeedback
Please define a class in Python to represent a college student, with the following attributes: name, age, major, and list of courses enrolled. Additionally, include the following methods: 1. A method to add a course to the student's list of courses enrolled. 2. A method to remove a course from the student's list of c...
codefeedback
Create a PHP script to broadcast messages on a given web page, but with the following additional requirements: 1. The script should be able to handle multiple web page URLs as input, and for each URL, it should validate the SSL certificate before broadcasting the message. 2. The script should allow the user to specify...
codefeedback
Create an Android application with an activity that displays a string "Welcome to Android" and a button below it. When the button is clicked, the text should change to "Hello, World!" and the button should disappear. Additionally, implement a feature where if the user shakes their device, the text changes back to "Welc...
codefeedback
Use Tensorflow to classify a given input dataset of animals as cats, dogs, or birds, while maintaining an accuracy of at least 95% on a validation set of images. The model should be able to handle grayscale images in addition to RGB images. In order to improve the model's generalization, it should be trained on a dat...
codefeedback
Explain the concept of recursion in programming and when it would be more advantageous to use recursion instead of a for loop. Additionally, provide an example of how recursion can be used to solve a complex mathematical problem efficiently.
codefeedback
Write a function in a programming language of your choice that takes in a list of integers and outputs an ordered list in descending order using a sorting algorithm of your choice.
codefeedback
Given a string, develop a function to find out how many words are present in it. Each word should be at least 3 characters long and consist only of alphabetic characters. The function should also consider words that have hyphens or apostrophes in them as separate words. Additionally, the function should ignore any lead...
codefeedback
Write a SQL query to delete a row from the "CITY" table where the city is "Frankfurt" and the population is greater than 1 million, and the country is "Germany" and the average temperature is above 15 degrees Celsius.
codefeedback
Create a function in Python that takes two lists as arguments and returns a dictionary with elements of the first list as keys and elements of the second list as values. The function should handle cases where the lengths of the input lists are not equal, returning a dictionary with keys from the longer list and values ...
codefeedback
```python # Erroneous code for misdirection list = [1,2,3,4,5] for x in list: if x % 2 == 0: print(x) # Functional style code list = [1,2,3,4,5] even_numbers = map(lambda x: x % 2 == 0, list) print(list(even_numbers)) ``` Explanation: In the rewritten code, the filter function is replaced with the map fun...
codefeedback
Suppose you have a dictionary containing the records of some student marks. Write a Python program to calculate the average marks of all the students. The dictionary may contain nested dictionaries representing different subjects and their respective marks for each student. student_mark_dict = { 'John': {'Math': [...
codefeedback
Write a JavaScript code to loop over all elements in a given array and check if each element is a prime number. If an element is a prime number, print it out. If an element is not a prime number, check if it is divisible by any prime number less than its square root and print out the divisors. arr = [1, 2, 3, 4, 5, 6,...
codefeedback
Increase the difficulty of the given programming test question: Add a method in JavaScript for an object to find the sum of all its elements, considering that some of the elements may be nested arrays or objects. class MyObject { constructor(elements) { this.elements = elements; } sumElements() { ...
codefeedback
Inspect the given code and find any possible bugs. The list of numbers should not contain any negative numbers. Additionally, the sum should be calculated using a recursive function instead of a loop. Implement the function `calculate_sum()` that takes in a list of numbers as a parameter and returns the sum of the numb...
codefeedback
Create a function in PHP that takes an array of strings as an argument and returns an array containing only the strings with at least 5 characters and without any repeated characters. Example: input: ['programming', 'algorithm', 'test', 'excellent', 'challenge'] output: ['programming', 'algorithm', 'excellent', 'chall...
codefeedback
Write a query to find the sum of all authors' books published after the year 2010 in the database, excluding any books that have a rating below 4.
codefeedback
Create a deep learning model using convolutional neural networks to predict a multi-class classification problem with 10 classes. Additionally, implement data augmentation techniques such as random rotation and zoom to improve the model's performance.
codefeedback
Write a Ruby program to remove duplicate elements from the given array, while maintaining the original order of elements. The program should have a time complexity of O(n) and should not use any additional data structures or methods like `uniq` or `uniq!`. Additionally, you are not allowed to use the `each` or `map` me...
codefeedback
Develop an algorithm to calculate the circumference of a circle provided the radius. The radius is given as a string input and may contain additional characters. The function should also handle radius inputs in other units such as inches or meters. Additionally, the function should validate the input to ensure that the...
codefeedback
Add code to this function to return the sum of all the squares of the even digits in the input number.
codefeedback
Create a function in Java that filters a given array by a specific number and returns a new array containing only the elements that are greater than or equal to the specific number. The function should also ensure that the returned array is sorted in ascending order. The function should handle arrays of size up to 10^6...
codefeedback
Construct an SQL statement that deletes all records from the "blog_posts" table where the "status" column is set to "draft" and the "created_at" column is older than 30 days. Additionally, ensure that the deletion operation is performed in a single transaction to maintain data integrity.
codefeedback
Write a query to find the author with the highest number of books published in each year, excluding any authors who have published less than 5 books in that year. Additionally, the query should return the average rating of the books published by each author in the respective year.
codefeedback
Update the code to sum the numbers from 0 to 1000 and store the result in the 'total' variable. Additionally, multiply each number by 2 before adding it to the total. Implement the solution using a recursive function, where each recursive call calculates the sum of a sub-range of numbers. The sub-ranges should be divid...
codefeedback
Write a function to compare two strings. The function should return true if the strings are equal and false if the strings are not equal. The strings may contain any printable ASCII characters. Additionally, the function should ignore any leading or trailing white spaces in the strings while comparing them. The functio...
codefeedback
Suppose you are given an array of integers. Write a program to sort the given input array in ascending order. Your program should have a time complexity of O(n log n) and space complexity of O(1).
codefeedback
Create a program in Python that takes two numbers as input and prints the result of the multiplication of those numbers, but without using the multiplication operator (*). Additional requirement: The program should handle negative numbers as well. num_1 = -10 num_2 = 15 Your task is to write a function `multiply_wit...
codefeedback
Compile the given piece of code and identify any errors. Additionally, optimize the code to print "Hello World!" 1000 times without using any loops or recursion. The code should also be modified to use a data structure other than an array to store the string "Hello World!".
codefeedback