instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Formulate an SQL query for finding the students who have scored over 80% in the test, and rank them based on their scores in descending order.
codefeedback
In CSS, how can the width of a div element be set to 100% of its parent's width while ensuring that it only takes up half of the available height and has a minimum width of 200 pixels?
codefeedback
Implement a Java program that demonstrates the concept of multiple inheritance using interfaces and abstract classes.
codefeedback
Write a JavaScript function that takes in an array of numbers and returns two arrays: one containing all the even numbers and one containing all the odd numbers.
codefeedback
Sort the array of strings lexicographically in reverse order and exclude any strings that start with a vowel. arr = ["james", "john", "bob", "michelle"]
codefeedback
Design a SQL query to retrieve data from multiple tables and perform a complex calculation on one of the columns.
codefeedback
Merge two sorted arrays in ascending order while removing duplicates and maintaining the original order of the elements. The merged array should have no more than twice the length of the original arrays. The input arrays are guaranteed to be non-empty and contain only positive integers.
codefeedback
Given an array of size n, find the kth largest element by using a Heap. You are not allowed to use any built-in sorting or priority queue functions. The time complexity of your algorithm should be O(n log k), and the space complexity should be O(k). [9, 8, 7, 6, 5], k=2
codefeedback
Write a Java program to implement a binary search on a sorted array of integers. However, instead of searching for a specific element, the program should find the index of the smallest element that is greater than or equal to a given target element. If the target element is greater than all elements in the array, the p...
codefeedback
Convert a given binary tree to a doubly linked list in-place, without using any extra data structures.
codefeedback
Suggest a SQL query to retrieve the 10 most populous cities in the USA, sorted in descending order of population. Additionally, exclude any cities with a population less than 1 million from the result.
codefeedback
Produce an alphabetically sorted list from a given set containing both strings and integers. The list should only include elements that are strings or integers. The original set, s, can contain duplicates and empty strings. Ensure that the final list does not contain any duplicates and excludes any empty strings. Retur...
codefeedback
Rewritten Test: Write a Python function that takes a string as input and returns the same string, but with the first occurrence of the word "bold" wrapped in a `<strong>` HTML tag. Example: Input: "This is a bold statement." Output: "This is a <strong>bold</strong> statement." Note: The input string will always co...
codefeedback
Compare two given arrays and find the common elements present in both, while maintaining the relative order of the elements. arr1 = [1, 2, 3, 5, 5, 7, 7, 8, 9], arr2 = [3, 5, 7, 8] Additional Requirements: 1. The time complexity of the solution should be O(n), where n is the length of the longer array. 2. The space co...
codefeedback
Write a JavaScript program to count the occurrences of each element in an array and return the elements in descending order based on their occurrence count.
codefeedback
Using the input list, write a function to calculate the sum of all the elements in the list. Additionally, if the sum is divisible by 2, the function should return the sum multiplied by 2. Otherwise, the function should return the sum divided by 2. my_list = [1, 2, 3, 4]
codefeedback
Suggest code to delete an element from a doubly linked list in Java, where each node contains a reference to both its previous and next nodes. Additionally, handle the case when the element to be deleted is the first or last element in the list.
codefeedback
Assign a value of 123 to the variable x and convert it into a string representation using a recursive function.
codefeedback
Write a function in Python to calculate the number of minutes a user has been logged in. The log_in_time and log_out_time will be in the format 'HH:MM:SS' where 00 ≤ HH ≤ 23, 00 ≤ MM ≤ 59, and 00 ≤ SS ≤ 59. The function should handle cases where the user logs in and out on different days.
codefeedback
Write a jQuery script to hide an element on the page only when a specific condition is met. The condition should be that the element has a certain class assigned to it and that class should have a specific value. Additionally, after hiding the element, add a new class to another element on the page.
codefeedback
Develop a Python script to print out a given string 10 times, but with each repetition, remove a random character from the string. The removed character should be different each time. The final output should be the original string printed 10 times with a progressively shorter string each time. str = "Hello World!"
codefeedback
Compute the product of two matrices using parallel computing. The program should distribute the computation across multiple cores or processors for improved performance. Additionally, the matrices should have dimensions that are not commonly used, such as A with dimensions (4x6) and B with dimensions (6x8).
codefeedback
Write a JavaScript program to make an AJAX request to a specific API endpoint and display the response in a modal pop-up window.
codefeedback
Create a PHP script to store data in a MySQL database. Additionally, implement a feature that allows the user to update existing records in the database.
codefeedback
Construct a while loop that prints the numbers from 10 to 100 incrementing by the smallest prime number greater than 4 with each iteration.
codefeedback
Construct a function called "classify_number" that takes an integer as an argument and returns the following classifications: - "positive" if the value is greater than 0 - "negative" if the value is less than 0 - "zero" if the value is equal to 0 You are not allowed to use any if-else statements or any comparison oper...
codefeedback
Construct a React component to display a login form with the following requirements: 1. The login form should include input fields for username and password. 2. The username field should have a minimum length of 6 characters and should only accept alphanumeric characters. 3. The password field should have a minimum le...
codefeedback
Compare two strings and identify the first index of a mismatch. The length of the strings will be between 1 and 1000 characters.
codefeedback
Rewritten Test: Convert this function written in Python to JavaScript code. Additionally, you need to handle the following scenarios: 1. If both 'a' and 'b' are integers, return the result of dividing 'a' by 'b' as an integer. 2. If both 'a' and 'b' are floating-point numbers, return the result of dividing 'a' by 'b'...
codefeedback
Rewrite the given code snippet using a different loop structure while ensuring that the loop iterates exactly 5 times.
codefeedback
Create a function to reverse a list without using the reverse() method and without using any built-in Python functions or methods.
codefeedback
Write a Python script to Iterate over a given list and print the square of the numbers in the list. The script should only print the squares of the numbers that are divisible by 2 and less than 10. The output should be formatted as a comma-separated string. The script should also calculate and print the sum of all the ...
codefeedback
Implement a function in Python to reverse the contents of a given dictionary, ensuring that all keys and values are of type string. The function should also handle dictionaries nested within the original dictionary and reverse their contents as well. The input dictionary should have at least 5 key-value pairs.
codefeedback
Parse data from a given JSON object and return the names of the individuals whose age is greater than 25. Additionally, ensure that the solution is implemented using recursion. data: { "data": [ { "name": "John", "age": 24 }, { "name": "Bob", "age": 26 }, { "name": "...
codefeedback
Find the maximum and minimum values in a given array, but you are not allowed to use built-in functions or methods such as max() or min(). Additionally, you should find the maximum and minimum values in the array in a single traversal of the array. The array may contain duplicate values. array = [2, 3, 5, 1, 9]
codefeedback
Given an array of n elements and an integer k, find the subarray with the maximum sum less than k. The subarray must have a length greater than or equal to m, where m is a positive integer. Additionally, the subarray must contain at least one negative number. arr = [1, 4, 6, 8, -5, 7], k = 11, m = 2
codefeedback
Write a script to sort a linear array in descending order, but with the following additional constraints: 1. The sorting algorithm must be a variation of quicksort. 2. The array must be sorted in-place, without using any additional data structures. 3. The time complexity of the sorting algorithm must be O(nlogn). 4. Th...
codefeedback
Assume you are given two integer variables, b and c, write a program to multiply these two numbers without using the asterisk (*) operator and any arithmetic operators (+, -, /). The only operators you can use are bitwise operators (&, |, ^, ~, <<, >>). Additionally, you must solve this problem in O(log n) time complex...
codefeedback
Sort an array of integers according to their frequency of occurrence. If multiple integers have the same frequency, sort them in descending order. arr = [1, 1, 2, 2, 2, 3, 4, 4, 5, 5, 5]
codefeedback
Create a program that prints out the set of all prime divisors of a given number. The user will input a number, and the program will determine the set of all prime divisors of that number. For example: Input: 50 Output: {2, 5} Explanation: The prime divisors of 50 are 2 and 5, since 50 can be expressed as 2 * 5 * 5....
codefeedback
Insert a given element into the correct position of a sorted list in ascending order. The list may contain duplicate elements. list = [1,2,2,3,4,5] element = 2 #Explanation# In the given test, we need to insert the element 2 into the correct position of the list [1,3,4,5]. This can be done by finding the correct index...
codefeedback
Design a program that takes a date in the format dd/mm/yyyy as input and prints the day of that given date, considering leap years. 01/02/2020 Additional instructions: - Validate the input to ensure it is in the correct format and within a reasonable range of dates. - Implement the program using object-oriented progr...
codefeedback
Using the given array, write a Javascript program to sort the elements in descending order, without using any built-in sorting methods such as sort() or reverse(). Additionally, ensure that the program has a time complexity of O(n^2) or less. let numbers = [2, 10, 5, 4, 3];
codefeedback
Create a dictionary to store the phone numbers of your friends, where each friend has multiple phone numbers. The phone numbers can be in any format (e.g., with or without country code, with or without dashes or spaces). list_friends = ["John", "Doe", "Jane", "Smith"] #Additional Instructions: 1. Each friend can have ...
codefeedback
Write a SQL query to list the names of employees who are 25 years or older and have at least 5 years of work experience.
codefeedback
Write a function to normalize a vector in C++ with the following constraints: the function should handle both integer and floating-point vectors, the function should throw an exception if the vector has zero magnitude, and the function should handle vectors of any dimensionality.
codefeedback
Define a function in JavaScript that takes an array of numbers as an argument and returns the smallest one. Additional requirements: 1. The function should handle arrays of any length, including empty arrays. 2. If the array contains any non-numeric elements, the function should ignore them and only consider the numer...
codefeedback
Write a function to rearrange the elements of an array in such a way that no two consecutive numbers are adjacent to each other. The numbers in the array are unique. mylist = [2, 5, 9, 2, 1, 5, 9, 0]
codefeedback
Translate a given string of comma-separated words into a list of words in Python, but only include words that start with a vowel and have an odd number of characters. For example: Input: "apple, orange, grape, banana, kiwi" Output: ["apple", "orange", "banana"]
codefeedback
Create a shell script that will run a specified command every 5 minutes, but also: 1. Prompt the user to enter the command they want to run. 2. Check if the entered command exists before executing it. 3. Allow the user to specify the interval at which the command should be executed (in minutes). 4. Implement error han...
codefeedback
Create a web form in HTML that captures a user's name, address, and a select box for their favorite color. The form should include client-side validation to ensure that the user's name is at least 5 characters long and that the address is a valid physical address with a street name, city, state, and postal code. Additi...
codefeedback
Create a SQL query to retrieve a list of the ten most expensive items that have been sold in the last month.
codefeedback
Create a class in Java named 'Circle' that has an attribute named 'radius' of type 'double' and a method named 'getArea' to calculate the area of a circle. The 'getArea' method should return the area as a 'BigDecimal' object rounded to 2 decimal places. Additionally, the 'Circle' class should have a static variable nam...
codefeedback
Create a programming language syntax to print "Hello, World!" but restrict the use of any built-in print or display functions.
codefeedback
Generate a SQL query to display the employee name, city, and department for employees who have worked for the company for more than 5 years and have a salary greater than $50,000. Order the results by the employee's hire date in descending order.
codefeedback
What is the time complexity of the following python snippet? defbinarySearch( arr, low, high, x): if high >= low: mid = (high + low) // 2 # Check if x is present at mid if arr[mid] == x: return mid # If x is greater, ignore left half elif arr[mi...
codefeedback
Modify the following C code so it will display the average of numbers in an array and handle negative numbers correctly. #include <stdio.h> int main() { int nums[] = {1, -2, 3, 4}; int sum = 0; int count = 0; for (int i = 0; i < sizeof(nums)/sizeof(nums[0]); i++) { sum += nums[i]; count++; }...
codefeedback
Develop a SQL query to get all the customer data with the customer age more than 25 years, and whose last name starts with the letter "S".
codefeedback
Write a function to remove any leading and trailing whitespaces from a given string. Additionally, the function should also remove any whitespace characters in between the words of the string. For example, given the input string " Hello World !", the function should return "HelloWorld!".
codefeedback
Develop an algorithm in Java for finding all the possible combinations of a given list of numbers, with the additional requirement that each combination must have at least one odd number. lst = [1, 2, 3, 4]
codefeedback
Please write an SQL query to find the records that have a value higher than the average of all values, and order them by the difference between their value and the average in descending order.
codefeedback
Create a list comprehension that returns a new list containing only the odd numbers from the given list of numbers: nums = [1, 2, 3, 4, 5]. The list comprehension should use only a single line of code and should have a time complexity of O(n), where n is the length of the input list.
codefeedback
How can you sort a list of integers by their absolute value in Python, without using any built-in sorting functions or methods?
codefeedback
Please write an SQL query to calculate the average age of people born in the year 1980, excluding those who were born on February 29th.
codefeedback
Write a shell script to find all even numbers from 1 to 50 that are also divisible by 3.
codefeedback
Find the length of the longest substring without repeating characters that contains at least one uppercase letter and one digit. string = "aB1Cabcbb"
codefeedback
Implement a SQL query to find the longest string present in a column, but only consider strings that contain at least one uppercase letter and one numeric digit.
codefeedback
Implement a Go program that takes a string as input and prints its reverse, but with the following additional requirements: - The program must use a recursive function to reverse the string. - The program must not use any built-in string manipulation functions or methods, such as `len()`, `substring()`, or `reverse()`.
codefeedback
Write Java code to calculate the area and circumference of a circle with radius 12 cm. Use a constant value for PI and round the calculated area and circumference to two decimal places.
codefeedback
Please write an SQL query to find all records with a corresponding score greater than or equal to a given score, and order the results in descending order of scores.
codefeedback
Convert this deeply nested JSON object to a PHP associative array. { "name": "John Smith", "age": 35, "address": { "streetAddress": "21 2nd Street", "city": "New York", "state": "NY", "postalCode": "10021", "coordinates": { "latitude": 40.7128, ...
codefeedback
Write a Python program that reads a CSV file and performs the following tasks: 1. Calculate the sum of a specific column (specified by the user) and print the result. 2. Find the minimum and maximum values in a specific column (specified by the user) and print the results. 3. Sort the rows in the CSV file based on a sp...
codefeedback
Implement a Java class that encapsulates a basic for loop. The class should include the following functionalities: 1. The loop should iterate from a given start value to an end value (inclusive). 2. The loop should be able to handle both ascending and descending iterations. 3. The loop should allow the user to specify...
codefeedback
Sort this array of numbers from low to high using a sorting algorithm with a time complexity of O(n^2). The array may contain duplicate numbers and have a maximum length of 1000.
codefeedback
Write Java code to generate random numbers between 0 and 10,000, with a time complexity of O(1) and a space complexity of O(1).
codefeedback
Write a SQL query to select all the books written by a specific author and published before a given year. author: "Robert Louis Stevenson" year: 1900
codefeedback
Write an Android app for creating and playing a quiz competition that allows for multiplayer functionality, where multiple players can join and compete in real-time.
codefeedback
Develop a web application that converts text to speech. The application should have a user authentication system that allows users to register and login. Additionally, the application should support multiple languages and have the capability to save the generated speech as an audio file.
codefeedback
How can we inverse the numerical order of elements stored in an array while also ensuring that the time complexity of the solution is O(n log n)?
codefeedback
Write a Recurrent Neural Network (RNN) in Keras for sentiment analysis on a large dataset of movie reviews. The model should achieve an accuracy of at least 85% on a test set of 10,000 reviews, with a maximum training time of 1 hour.
codefeedback
Create a Java class for car objects that includes the following features: 1. Implement a constructor that takes parameters for the car's make, model, and year of manufacture. 2. Include private instance variables for the car's make, model, year of manufacture, color, and current speed. 3. Implement getter and setter...
codefeedback
Design an algorithm that sorts a given array of integers in ascending order. The algorithm should have a time complexity of O(n log n) and should not use any built-in sorting functions or libraries. The sorted array should be stored in a new array and the original array should remain unchanged. The algorithm should als...
codefeedback
Create a user registration system in JavaScript that includes the following functionalities: 1. Allow users to sign up with their email address and password. 2. Validate the email address format using regular expressions. 3. Ensure that the password meets the following criteria: a. Contains at least 8 characters. ...
codefeedback
Construct an XML document for storing a collection of books and their authors, with the following additional requirements: 1. Each book should have a unique identifier. 2. Each book should have a title, author, and publication year. 3. Each author should have a name and nationality. 4. Add the ability to include multi...
codefeedback
Design a function that provides the square root of a number x, with a time complexity of O(log n).
codefeedback
Write a SQL query to find all the unique (distinct) values in a column named "Name" that are at least 5 characters long and start with a vowel.
codefeedback
Find the runtime complexity of the following algorithm in Big-O notation. def add_array_elements(arr): n = len(arr) sum_elements = 0 for i in range(0, n): sum_elements += arr[i] for j in range(0, n): for k in range(0, n): sum_elements += arr[j] + arr[k] return sum_elem...
codefeedback
Construct an object in JavaScript to model a car with make, model, year, color, price, and mileage as attributes. Implement a method to calculate the average fuel consumption of the car based on the mileage and fuel tank capacity. Additionally, create a function to compare the fuel efficiency of two cars and determine ...
codefeedback
Reverse the words of the sentence "The quick brown fox jumps over the lazy dog" without using any built-in string manipulation functions. Additional requirement: - Ensure that leading and trailing spaces in the sentence are preserved in the reversed sentence. - Handle multiple consecutive spaces between words appropri...
codefeedback
Write a CSS code to make the background color of all paragraph elements in a page alternate between blue and red every second.
codefeedback
How would you calculate the sum of all odd integers between two given integers?
codefeedback
Create a type with 4 fields, including "name", "address", "phone", and "email". The "name" field should only accept alphabetical characters and have a maximum length of 50 characters. The "address" field should only accept alphanumeric characters, spaces, commas, and periods, and have a maximum length of 100 characters...
codefeedback
Given a list of prices, use a comprehension to calculate the average price. However, you are not allowed to use the built-in functions sum() or len() to calculate the average. Instead, you must implement your own algorithm to calculate the average. prices = [2.50, 3.25, 4.00, 1.75]
codefeedback
How would you create a socket connection between two computers in a network, and then implement a chat application using this connection?
codefeedback
Given the following function that takes in a string and returns true if it is a palindrome. Rewrite the function to make it more optimized. def is_palindrome(s): s = str(s).lower().replace(" ", "") for i in range(len(s) // 2): if s[i] != s[len(s) - 1 - i]: return False return True #Err...
codefeedback
Process the given HTML code to get the output as shown. The output should include the number of words in the article, the number of unique words in the article, and the number of words starting with a capital letter. The article should only be processed if it contains at least one hyperlink. The output should be displa...
codefeedback
Sort the following list of dictionaries by the values of the keys in descending order. lst = [ {'a':2}, {'a':3}, {'a':1} ] Additional Instructions: 1. Implement the sorting algorithm yourself instead of using a built-in function. 2. If two dictionaries have the same value for the key, sort them by the length of their...
codefeedback
Add the `color` and `size` parameters to this function and make sure it works properly. The `size` parameter should specify the size of the shape to be printed. The shape should be printed in the specified color and size. The function should also validate the inputs and handle any invalid inputs appropriately. def pri...
codefeedback
Write a SQL query to find the average age of people living in the UK, who have at least one child and own a house.
codefeedback
Using JavaScript, write an algorithm to print all the Fibonacci numbers up to a given number n, where n is a positive integer less than or equal to 1,000. Your algorithm should have a time complexity of O(n) and a space complexity of O(1).
codefeedback