instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Write a code to delete a 'customer' table from a MySQL database, but also ensure that all data contained in the table is backed up before deletion.
codefeedback
Create a CSS class called "header" with the following styling: - The font size should be 24 pixels. - The background color should be a linear gradient from #ff0000 to #00ff00. - The text color should be white. - The padding should be 10 pixels on all sides. - The border radius should be 5 pixels. - The text should be c...
codefeedback
Write a SQL query to find all employees over the age of 30 who have been with the company for more than 5 years and have a salary greater than $50,000.
codefeedback
Write a function that calculates the result when a power of 10 is raised to the power of n, where n is a positive integer less than or equal to 100. Your solution should have a time complexity of O(n) and a space complexity of O(1).
codefeedback
Generate a unique seven-digit number that satisfies the following constraints: the first digit must be odd, the second digit must be a prime number, the third digit must be a multiple of 3, the fourth digit must be greater than 5, the fifth digit must be a perfect square, the sixth digit must be a single-digit prime nu...
codefeedback
Create a React component that updates itself with the current time every second. Additionally, implement a button that, when clicked, stops the time update. Once stopped, the component should display a countdown from 10 to 1, updating every second. After reaching 1, the component should display a message saying "Time's...
codefeedback
Write a JavaScript function to find the number of matching items in two arrays. The function should also account for duplicate items in the arrays. arr1 = [1, 2, 3, 4, 4] arr2 = [3, 4, 5, 6, 6, 6] Example: findMatchingItems(arr1, arr2) should return 2, since 3 and 4 are the only matching items in the arrays. Note: -...
codefeedback
Write a PHP script to print the current week number and the day of the week for each day in the current week.
codefeedback
Update the following Java code to print the difference between two dates in years, months, days, hours, minutes, and seconds. import java.time.LocalDateTime; public class DateTime { public static void main(String[] args) { LocalDateTime dateTime1 = LocalDateTime.of(2020,11,5,14,45); LocalDateTim...
codefeedback
Write a query with window functions in PostgreSQL to calculate the average salary per department, including only those departments where the average salary is higher than a certain threshold value.
codefeedback
Create a SQL database schema for storing customers, their payments, and their payment history. Each payment history should include the payment ID, customer ID, amount, date, and a description of the payment. Additionally, include a table for storing the payment methods available to customers. customer(id, name, email,...
codefeedback
Sort the following array from smallest to largest using the bubble sort algorithm. [4, 6, 2, 8]
codefeedback
Create a Migration Script in Node.js for creating a table for customers with the following columns: 1. customer_id (primary key) - this column should be an auto-incrementing integer to uniquely identify each customer. 2. first_name (string) - this column should store the first name of the customer. 3. last_name (str...
codefeedback
Write a code snippet that checks whether a number is odd or even. The code should also handle negative numbers and decimals, and it should return an error message if the input is not a number.
codefeedback
Create an HTML form for inputting user details including name, age, email, and phone number. Add validation to ensure that the name field only accepts alphabetic characters and is between 2 and 30 characters long. Add validation to ensure that the age field only accepts numeric characters and is between 18 and 99 yea...
codefeedback
Complete the following javascript code to perform a task. const items = [ { company: 'A', date: '02-09-19' }, { company: 'B', date: '18-4-19' }, { company: 'C', date: '03-12-19' }, { company: 'A', date: '29-07-18' }, ]; // Complete code here // You need to sort the items array based on the date in ascending o...
codefeedback
Create a JavaScript class called "Vehicle" with the following properties and methods: 1. brand: a string that represents the brand of the vehicle. 2. model: a string that represents the model of the vehicle. 3. year: an integer that represents the manufacturing year of the vehicle. 4. getAge(): a method that returns th...
codefeedback
Modify the following code to make it more efficient by using a while loop. Additionally, implement a binary search algorithm to find the position of a target number in a sorted list of integers. # Given Test # num = 10 i = 1 while i <= 10: print(i * num) i += 1 # Rewritten Test #
codefeedback
Suggest an alternative for the following code snippet which is faster and less memory intensive, while ensuring that the resulting pairs are in ascending order and contain only prime numbers. arr = [2, 3, 5, 7] result = [] for i in range(len(arr)): for j in range(i + 1, len(arr)): if is_prime(arr[i]) and is_prime...
codefeedback
Suggest an elegant way to print out a list of numbers in reverse order without using a loop in Python. lst = [1, 2, 3, 4]
codefeedback
Implement a function that takes 2 numbers as parameters and returns the greatest common divisor of both numbers. The function should not use any built-in library or function for finding the greatest common divisor. Additionally, the function should be able to handle large numbers efficiently. Example: a = 9876543210 ...
codefeedback
Write code to convert a given number expressed in hexadecimal representation to its corresponding decimal representation.
codefeedback
Classify each word in this sentence into its specific part of speech: noun, verb, adjective, adverb, pronoun, preposition, conjunction, or interjection.
codefeedback
Edit this piece of Python code to implement a function that finds the median of a list of numbers. The function should return the median value. If the list has an even number of elements, the median should be the average of the two middle values. Your implementation should have a time complexity of O(nlogn) or better. ...
codefeedback
Create a script to multiply each element in a list by 10, without using the multiplication operator (*) and with a space complexity of O(1). input_list = [1,2,3,4]
codefeedback
Convert the following sentence into camelCase, ensuring that each word begins with a capital letter and removing all spaces between words. Additionally, the program should handle sentences with punctuation marks and multiple consecutive spaces.
codefeedback
Make a program to return the longest word in a given list of strings. The program should handle cases where multiple words have the same maximum length and return all of them. The input list may contain words with different capitalization and the program should consider them as different words. The program should also ...
codefeedback
How can you use object serialization to implement a distributed messaging system, where multiple nodes communicate with each other asynchronously and maintain a consistent state across the network?
codefeedback
Implement an algorithm with Big O notation of O(n log n) that sorts an array of integers in ascending order.
codefeedback
Check if the given statement is syntactically correct by verifying the validity of each word and the overall sentence structure. Input: A string representing the statement to be checked. Output: A boolean value indicating whether the statement is syntactically correct or not. The difficulty has been increased by addin...
codefeedback
Find the surface area of a cube with a side length of 6 cm, but only using a recursive function.
codefeedback
Create a function that takes two strings and outputs the number of similar characters in both strings. The function should be case-sensitive and consider spaces as characters as well. For example: String 1: "Coding" String 2: "debugging" The function should return 3, as both strings have the letters 'd', 'i', and 'g' ...
codefeedback
Using MySQL, find the top 10 customers who have made the most orders, considering only orders placed within the last 6 months. Additionally, display the total number of orders made by each of these top 10 customers and the average order value for each customer.
codefeedback
Rewritten Test: Design a database schema for a social media platform that can handle millions of users and their posts efficiently. Include the necessary tables, relationships, and indexes to optimize performance and ensure scalability.
codefeedback
Insert a record into a database table named 'customers' with the following values. The table has the following columns: - ID: integer - Name: string - Age: integer - Address: string The record to be inserted has the following values: - ID: 123 - Name: John Doe - Age: 35 - Address: 123 Main St The function should val...
codefeedback
Write an SQL query to list the names of the top 3 students who scored the highest average marks across all exams.
codefeedback
You need to code a program that prints out the nth Fibonacci number. However, the program should have a time complexity of O(1). n=10
codefeedback
Your program needs to read a matrix of integers and then print out the sum of each row and each column separately. The matrix can have variable dimensions and can contain both positive and negative numbers. matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, -11, 12]] The time complexity of y...
codefeedback
Code a function that takes an array of positive integers and returns the sum of the prime numbers in it. Example: input_array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] output: 17 Note: The function should only consider positive integers greater than 1 as prime numbers.
codefeedback
Develop a program that picks a random item from a given list of strings. However, the program should not use the built-in random function or any external libraries. The program should have a time complexity of O(1) for picking the random item.
codefeedback
Generate a function that takes a given list of strings and orders them by their lengths in descending order. The function should also handle cases where multiple strings have the same length, in which case they should be ordered alphabetically. The function should have a time complexity of O(n log n), where n is the le...
codefeedback
Write a SQL query for creating a table named "users" with columns for "name", "email", "age", and "address". Additionally, add a constraint to ensure that the email column only accepts unique values.
codefeedback
Write a Python program to calculate the sum of all prime numbers between 1 and N, where N is a number entered by the user.
codefeedback
Write an SQL query for finding the average salary of employees in a table whose age is greater than 25 and their last name starts with the letter "S".
codefeedback
Write a class in Python for representing a rectangle. This class should store the length and width of the rectangle, and be able to compute its area. Additionally, the class should have a method to compute the perimeter of the rectangle. The rectangle should also have a method to check if it is a square or not.
codefeedback
Write a CSS code to display a web page with a centered container of width 800px and a height of 400px. The container should have a border radius of 10px and a background color gradient that starts from #FFC0CB at the top left corner and ends with #FF69B4 at the bottom right corner. The text inside the container should ...
codefeedback
Write a function to calculate the weighted standard deviation of data points in Python. The function should take in two lists as input: one containing the data points and the other containing the corresponding weights for each data point. The function should return the weighted standard deviation of the data points.
codefeedback
Generate a list of numbers starting from 10 to 50, where each number is a multiple of 3 and ends with the digit 5.
codefeedback
Create a JavaScript object that keeps track of event data such as time, attendees, location, and additional details. The object should also include methods to add and remove attendees, update the event time and location, and retrieve the event details. Requirements: 1. The object should have a property to store the ev...
codefeedback
How would you convert a binary number to decimal in JavaScript while also checking for any invalid input? #Explanation# In order to convert a binary number to decimal, we need to perform the following steps: 1. Start by checking if the input is a valid binary number. 2. Iterate through each digit of the binary number ...
codefeedback
Implement a recursive algorithm to find the nth Fibonacci number. The Fibonacci sequence is defined as follows: the first two numbers in the sequence are 0 and 1, and each subsequent number is the sum of the previous two numbers. Write a function called fibonacci that takes an integer n as input and returns the nth F...
codefeedback
Generate a program in Go for printing the first 100 prime numbers, using a concurrent approach.
codefeedback
Edit the following C program so that it prints the factorial of a number. However, you are not allowed to use any loop structures (such as for, while, or do-while) to calculate the factorial. You must find an alternative method to solve this problem.
codefeedback
Using an existing loop, create code to calculate the sum of all prime numbers up to a given number.
codefeedback
Create a class for a 2D vector in Java that has the following functionalities: 1. Ability to initialize the vector with x and y coordinates. 2. Ability to retrieve the x and y coordinates of the vector. 3. Ability to set the x and y coordinates of the vector. 4. Ability to calculate the magnitude of the vector. 5. Abil...
codefeedback
Format a given decimal number as a percent value, considering that the decimal number can have up to 4 decimal places.
codefeedback
Slice a string after the nth character and reverse the resulting substring. Python.
codefeedback
Implement a function that retrieves the value of a specific key from a given dictionary, while ignoring the built-in dictionary methods. The function should handle nested dictionaries as well. Example: Input: dictionary = {'name': 'John', 'age': 30, 'occupation': 'teacher', 'info': {'location': 'New York', 'hobbies': ...
codefeedback
Write a function that returns True if a given number is a prime number and False if it is not. Additionally, the function should return the list of all prime factors of the given number. #Clarifications# - The function should take an integer as input and return a boolean value indicating whether the number is prime or...
codefeedback
Edit the following program so that it prints out the result of x multiplied by y, but you are not allowed to use the multiplication operator or any built-in functions related to multiplication. x = 7 y = 5 print(sum([x] * y))
codefeedback
Design a class to hold calendar date-related information, including the ability to perform various operations on dates such as addition, subtraction, and comparison. The class should have the following attributes: - Year: an integer representing the year. - Month: an integer representing the month. - Day: an integer ...
codefeedback
Write a recursive function in Python to calculate the nth term of the Fibonacci sequence.
codefeedback
Using React, create a component that displays a greeting with the current time. Additionally, implement a feature that allows the user to change the displayed time format between 12-hour and 24-hour formats.
codefeedback
What is the Big-O notation of a given algorithm that solves the traveling salesman problem (TSP) using a brute-force approach?
codefeedback
Provide a solution for the following coding challenge: Challenge: Given an array of integers, return the maximum sum of any contiguous subarray of the array. The subarray should contain at least one positive integer. Example: [34, -50, 42, 14, -5, 86] Erroneous Code: def max_subarray_sum(arr): max_sum = 0 cur...
codefeedback
Design an algorithm to traverse a binary tree in level-order and print the nodes at each level in reverse order.
codefeedback
Using HTML and CSS, code a responsive navigation bar that includes dropdown menus and a search bar. The navigation bar should be sticky and remain visible when scrolling. The dropdown menus should display on hover and have smooth animations. The search bar should have auto-complete functionality and provide search sugg...
codefeedback
Design an algorithm to print out the prime numbers between 1 and 100 that are also palindromic numbers.
codefeedback
Write a function in Clojure that takes in a list of words and a target word, and returns the index of the target word in the list. If the target word does not exist in the list, return -1. The function should have a time complexity of O(n), where n is the length of the list. Example: ``` (lookup-index ["apple" "banan...
codefeedback
Construct an object-oriented program to print out the numerals from 1 to 10, where the program must use at least two classes and implement inheritance.
codefeedback
Convert the number to a string, but only using a recursive function. The input number must be a positive integer.
codefeedback
Create a JavaScript function to traverse an array and return true if the given element exists in the array. The function should also return the index of the element if it exists in the array. The array should contain at least 10 elements and the function should handle cases where the element may be repeated multiple ti...
codefeedback
Develop a function in Rust to print the prime factors of a given number. Number: 15
codefeedback
Develop a Java program to input a string and reverse the order of words while ignoring any numbers in the input. The program should also ensure that the reversed words are in uppercase and that the reversed sentence starts with a capital letter and ends with a punctuation mark.
codefeedback
Create a function in Dart to generate a series of random numbers within a specified range. Start: -100 End: 100 The function should also check if the generated numbers are divisible by 3 and return the total count of such numbers. Additionally, the function should calculate the sum of all generated numbers and return ...
codefeedback
Update the following JavaScript code to use object-oriented programming and implement a more complex calculator with additional functionalities. Requirements: 1. Create a Calculator class with the following properties: - number1: a number representing the first operand. - number2: a number representing the secon...
codefeedback
Create a class in Java to store the information about a user, with the following requirements: 1. The user's first name should be stored as a string. 2. The user's last name should be stored as a string. 3. The user's email address should be stored as a string. 4. The user's age should be stored as an integer. 5. The ...
codefeedback
How to create a responsive HTML page with a dynamic navigation menu using JavaScript?
codefeedback
Compute the sum of all prime numbers between 1 and 100,000.
codefeedback
Create a function in JavaScript to find the longest substring in a given string without repeating characters. The function should also handle cases where the input string contains special characters and numbers. Additionally, the function should return the length of the longest substring found. String: "abcabcbb123@#!"
codefeedback
Explain the concept of pointers in C++ and how they differ from regular variables. Provide examples to illustrate your explanation.
codefeedback
Create a new array 'b' from array 'a' containing only even numbers. Additionally, the new array 'b' should be sorted in ascending order. The input array 'a' should contain at least 10 elements. a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
codefeedback
You are given a string and asked to find the frequency of each character in the string, while ignoring case sensitivity and considering only alphabets. The output should be sorted in ascending order of the characters' ASCII values. str = "GPT Model"
codefeedback
Write a loop to sum all the elements in list 'l' that are greater than 2 and less than 10. The final sum should be stored in a variable named 'total'. l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
codefeedback
Create a URL for the given information with the following constraints: - The URL must start with the protocol "https://" - The subdomain can only contain lowercase letters and digits - The subdomain must be at least 3 characters long and at most 10 characters long - The domain can only contain lowercase letters - The p...
codefeedback
Create an object for making a copy of a string, but the copy should only include the first occurrence of each character in the original string. String: "Hello"
codefeedback
Find and return the longest string that starts with a vowel in the given array. ["hello", "how", "are", "you", "doing"]
codefeedback
Using the given data structure, find and return the 3 highest numbers in descending order. The algorithm should have a time complexity of O(n log n) and use constant space. The input array will contain at most 10^5 integers, ranging from -10^9 to 10^9.
codefeedback
Print all prime numbers within a given range and arrange them in ascending order. Lower range: 100 Upper range: 200
codefeedback
Increase the difficulty of the given programming test question by modifying the code and asking the candidate to solve a specific problem. Problem: Given an array of integers, find the two numbers that sum up to a target value. Print the indices of these two numbers. #include <iostream> #include <vector> #include <u...
codefeedback
Use the input data to create a bar chart and display it in a graphical user interface (GUI). Data: [("Apple", 20), ("Samsung", 16), ("Google", 11), ("Sony", 14)] The GUI should have the following features: 1. The bar chart should be displayed horizontally, with the bars representing the values scaled appropriately. 2....
codefeedback
Create a program that sorts the integers in the input list into ascending order. The program should have a time complexity of O(n^2) and should not use any built-in sorting functions or libraries. The input list may contain duplicate values and negative numbers. List: [10, -5, 7, 2, 5, -3, 10, 2, 7, 0]
codefeedback
Implement a recursive function to print the Fibonacci sequence up to the 30th term, without using any loops or temporary variables.
codefeedback
Design a function to retrieve the records from a deeply nested json structure, where the nesting level is not known in advance. The function should be able to handle any level of nesting and return the values of all the leaf nodes. { "products": { "book": { "title": "Alice in Wonderland", "author": "...
codefeedback
Create a loop that prints all prime numbers between 1 and 100, excluding 2 and 3.
codefeedback
Create a program to enter the data for user registration, ensuring that each user must provide their full name, email address, and a strong password (containing at least 8 characters, including uppercase and lowercase letters, numbers, and special characters). The program should also validate the email address format a...
codefeedback
Convert the decimal number 595 to hexadecimal representation, but you are not allowed to use any built-in functions or libraries for conversion. You must implement the conversion algorithm from scratch.
codefeedback
What is the best way to test for memory leaks in a C++ program? Provide a piece of erroneous code that could potentially lead to memory leaks and explain how you would detect and fix the leaks.
codefeedback
Multiply two matrices of size 4x4. mat1 = [[1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,16]] mat2 = [[17,18,19,20], [21,22,23,24], [25,26,27,28], [29,30,31,32]]
codefeedback
Construct a query in SQL to find out how many users have the same name and are also born on the same day.
codefeedback