instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Manipulate a given list in Python where every element in the list has to be doubled. The resulting list should be sorted in ascending order. Additionally, the original list should not be modified, and the manipulation should be done using list comprehension.
my_list = [1, 2, 3, 4] | codefeedback |
Create an HTML page that displays two columns consisting of the numbers 1 to 10. Additionally, the numbers in the left column should be in ascending order, while the numbers in the right column should be in descending order. The columns should be styled with alternating background colors, and each number should be clic... | codefeedback |
Write a Python program that generates a 10x10 grid of random colors and displays it using the turtle graphics library. Each cell in the grid should be filled with a random color, and the grid should be displayed on the screen. | codefeedback |
Create a tensorflow model that recognizes handwritten digits from the MNIST dataset, but with the following additional requirement: the model should be able to classify digits that are written using only straight lines and without any curves. | codefeedback |
Create a program in Java that simulates a fruit shop. Implement a class called "FruitShop" which contains a HashMap to store the name of fruits and their corresponding prices. The program should have the following functionalities:
1. Add a fruit and its price to the shop.
2. Remove a fruit from the shop.
3. Update the... | codefeedback |
Write a query in MongoDB to find all documents with the value of field "city" as "Berlin" and the field "population" greater than 1 million. | codefeedback |
Write a Lua function that calculates the sum of all even numbers between 1 and a given input number, inclusive. | codefeedback |
Write a SQL query to find the number of students living in zipcode 90001 who are also enrolled in at least two courses. | codefeedback |
Parse an XML document using Python and extract specific data points based on certain conditions. | codefeedback |
Create a HTML page to display a table in the following format, but the table must be generated dynamically using JavaScript instead of being hardcoded in the HTML. | codefeedback |
Create a Python script that converts temperatures from Fahrenheit to Celsius and also includes the option to convert temperatures from Celsius to Fahrenheit. Additionally, the program should handle input validation to ensure that the user enters a valid temperature value. | codefeedback |
Design a responsive HTML page with a header, navigation bar, and 3 sections. The header should include a logo and a search bar. The navigation bar should include links to at least 4 different pages. The sections should each have a background image and contain different types of content such as text, images, and videos.... | codefeedback |
Transform the following Ruby code into its JavaScript equivalent. The JavaScript code should utilize arrow functions instead of traditional function declarations. Additionally, the output of each book should be displayed on a new line. Finally, the JavaScript code should only utilize built-in array methods, such as for... | codefeedback |
Create a loop that prints out numbers from 0 to 15, but skip numbers 6, 7, and 12. Additionally, skip every even number after the skipped numbers. | codefeedback |
What is the time complexity of an iterative mergesort algorithm if the input array contains duplicate elements? | codefeedback |
Create a bash program that takes a directory path as input and lists the contents of the directory in reverse alphabetical order, excluding any subdirectories. The program should only display files that have a size greater than 1MB and were last modified within the past 24 hours. | codefeedback |
Write code in Python to retrieve the top 10 Rated Movies in IMDB. Additionally, display the movie genre, director, and runtime for each movie. | codefeedback |
Write a code to infer the data type of a lambda expression, while also considering nested lambda expressions and type inference based on the lambda body. | codefeedback |
Write code in Python to create a dictionary with names as keys and phone numbers as values. The names should be in uppercase and the phone numbers should be in the format "+1-XXX-XXX-XXXX" where XXX-XXX-XXXX is a random 10-digit number. The dictionary should be sorted in descending order based on the length of the name... | codefeedback |
Given a list of integers, find the longest common substring of the list, considering the numbers in the list as characters. The substring should consist of consecutive integers in the list, and the characters in the substring should be in strictly increasing order. If there are multiple substrings that meet this criter... | codefeedback |
Write an algorithm for finding the square root of a number using only integer operations. | codefeedback |
Write a JavaScript code snippet to open a pop-up window with a width of 600px and a height of 400px. Additionally, the pop-up window should have a maximum of 2 tabs and should only be allowed to close after a user has entered a specific password. | codefeedback |
Store the text "Hello World!" in a variable in Ruby and reverse the order of the characters in the string. | codefeedback |
Write a SQL query to select customer names whose city is Tokyo and age is greater than 25, ordered by the number of times they have made a purchase in descending order.
TABLE customers
Columns:
customer_id
name
city
age
TABLE purchases
Columns:
purchase_id
customer_id
purchase_date | codefeedback |
Write a PHP statement to create a MySQL table with four columns: id, name, age, gender. Additionally, add a fifth column called "address" of type VARCHAR(100) to the table. | codefeedback |
Construct an API call in Python that returns information about a given book, but you are not allowed to use any external libraries or frameworks for making the API call. | codefeedback |
Write a query in SQL to find all users whose first name starts with "J" and last name starts with "D". | codefeedback |
Generate a pseudorandom sequence of hexadecimal numbers with length 10, where each number must be divisible by 3. | codefeedback |
Create an array of size 10, initialize the array elements with random prime numbers between 1 to 100. | codefeedback |
Create an Android application with a Button and a TextView. When the button is clicked, the TextView should be populated with the text "Hello, World!". Additionally, the button should change its background color to red after being clicked, and the TextView should display the number of times the button has been clicked ... | codefeedback |
Design an algorithm to detect the pattern of spikes in an EEG while ensuring that the algorithm can handle EEG data with varying levels of noise and artifacts. | codefeedback |
Construct an SQL query to list the name, age, and email address of all female students who are taking the course ‘Data Science’ and have scored above 90 in the midterm exam. | codefeedback |
Write a Java method to convert a given decimal number to its equivalent English words. | codefeedback |
Write a code to update a given column using the data from another table, but the update should only happen if certain conditions are met.
Table1: Student
Table2: Course
Column to be updated: Student.CourseId
Conditions:
- The update should only happen if the CourseId from Table2 is greater than 5.
- The update should ... | codefeedback |
Write an `int main()` routine to print the first 100 prime numbers. | codefeedback |
Create an array with five different strings. Sort the array in alphabetical order. Print the first and last element of the sorted array. | codefeedback |
Create and initialize a two-dimensional array of size 8x8 with randomly generated integers between 1 and 100 (inclusive). | codefeedback |
Generate a function to calculate the grade of a student based on their marks. The grading system is as follows:
- Marks above or equal to 90% are given an 'A' grade.
- Marks between 80% and 89% (inclusive) are given a 'B' grade.
- Marks between 70% and 79% (inclusive) are given a 'C' grade.
- Marks between 60% and 69%... | codefeedback |
Write a code to train a random forest classifier for a given dataset.
Dataset features: 10 features, 500 instances, 5000 estimators.
Additionally, please implement the following steps:
1. Split the dataset into training and testing sets with a 70:30 ratio.
2. Preprocess the data by standardizing the features using t... | codefeedback |
Suggest a strategy to reduce the memory requirement of a given application while ensuring optimal performance and minimal impact on code readability. Additionally, provide a code snippet demonstrating a common memory-related error and explain how to fix it. | codefeedback |
Generate a function to check for the largest common divisor between two numbers that runs in O(log(min(a,b))) time complexity and uses constant space. | codefeedback |
Write a code to simulate Conway's Game of Life with the following additional rules:
1. In addition to the standard rules of Conway's Game of Life, cells that are alive and have exactly 2 or 3 neighbors will change their state to dead.
2. Implement a "glider" pattern, where a pattern of cells moves diagonally across th... | codefeedback |
Design a class that can create objects with a unique ID, ensuring that the IDs are sequential and cannot be repeated, while also maintaining thread-safety in a multi-threaded environment. | codefeedback |
Generate a random password which contains 16 characters including uppercase letters, lowercase letters, digits, and symbols. The password should not contain any repeating characters and should have at least one character from each category (uppercase letters, lowercase letters, digits, symbols). | codefeedback |
Generate a web page which shows the top 10 trending movies of the year, where each movie must have at least 100,000 votes and be rated above 8.0 on a scale of 10. | codefeedback |
Edit this code to make the function take an integer n as an argument and print the fibonacci series till the nth term, using a recursive approach.
def fibonacci(n):
if n <= 0:
return None
elif n == 1:
return 0
elif n == 2:
return 1
else:
return fibonacci(n-1) + fibonacci... | codefeedback |
Write a code in Python to convert a string of text to its equivalent uppercase characters, without using any built-in string methods or libraries.
str_lower_case = "hello world" | codefeedback |
Design a password validation system using Python code. The system should meet the following requirements:
1. The password must be at least 8 characters long.
2. The password must contain at least one uppercase letter, one lowercase letter, one digit, and one special character (!@#$%^&*).
3. The password must not contai... | codefeedback |
Define a function that takes in two numbers, and calculates the power of the first number raised to the power of the second number. The function should have a time complexity of O(log(n)) where n is the value of the exponent. Additionally, the function should not use any built-in exponentiation or logarithmic functions... | codefeedback |
Create a code that takes in a sentence and outputs counts of each word and its frequency (how often it occurred), excluding common words such as "the", "is", and "to". The code should also ignore punctuation and handle case sensitivity. sentence = "This is an example sentence to test the word count code." | codefeedback |
Write a code that takes in a list of names and creates a dictionary with the names as keys and their lengths as values. The code should ignore any names that contain numbers or special characters. The dictionary should be sorted in descending order based on the lengths of the names. Additionally, the code should remove... | codefeedback |
Create a code to input a 2D matrix of integers (with each integer between -1000 and 1000) and output the sum of each row, excluding any rows where the sum is less than 10 or greater than 1000.
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]] | codefeedback |
Create a class in Python to represent an employee and define the attributes. Additionally, implement a method that calculates the employee's annual bonus based on their performance rating. The performance rating is a decimal value between 0 and 1, with 0 being the lowest and 1 being the highest. The bonus is calculated... | codefeedback |
Create a code which takes in a list of strings, and returns a string with all the characters of the strings sequentially. The input list can contain duplicate strings. The output string should only contain unique characters.
Example:
Input: ["Hello", "World", "World"]
Output: "HeloWrd"
Note:
- The input list can cont... | codefeedback |
Generate the appropriate code for a for-loop that iterates through a list, but only print out the words that contain the letter 'o' and are longer than 5 characters.
list_words = ["Hello", "World", "GPT", "Model"] | codefeedback |
Given a string, write the appropriate regex pattern that checks if the string contains exactly two consecutive digits. | codefeedback |
Compose a query to find the titles of the movies released in 2021 which produce revenue more than $2,000,000, sorted in descending order of revenue, and limit the results to the top 10 movies only.
movies_table = 'movies' | codefeedback |
Write a function that takes a NumPy array as input and converts it to a list. However, the function should also sort the elements in descending order before converting it to a list.
import numpy as np
my_array = np.array([[9,8,7], [6,5,4], [3,2,1]]) | codefeedback |
Establish a secure database connection using the inputs given and ensure that the password is encrypted. Only allow connections from the specified hostname "localhost". The database username should be at least 8 characters long and contain at least one uppercase letter, one lowercase letter, one digit, and one special ... | codefeedback |
Given a list of strings, write a Python program to capitalize the first letter of each word and convert all remaining letters to lowercase. The program should handle cases where words may contain special characters or numbers.
words = ['ThE', 'quIck', 'BRoWn', 'fOx', 'jUmP5'] | codefeedback |
Given a document, remove all numbers from the content. The document can contain multiple lines and can have up to 10^6 characters. The algorithm should have a time complexity of O(n), where n is the number of characters in the document, and should use only O(1) space. The document can contain any printable ASCII charac... | codefeedback |
Given a string, classify the sentiment of the text as either positive or negative. The sentiment classification should take into account both the overall sentiment of the text as well as the sentiment associated with each individual word in the text. The sentiment of each word should be determined based on a pre-traine... | codefeedback |
Create a SQL query for finding the number of orders made each day in a given month, but exclude orders with a status of 'cancelled'. The orders_table has the following columns: order_id, customer_id, order_date, status. Additionally, the query should also calculate the total order value for each day. Use the orders_tab... | codefeedback |
Which Boolean value is returned by the == operator when comparing two variables of different data types? | codefeedback |
Write a MySQL query to select the name of the customer, the total sales made by each customer, and the number of products purchased by each customer in a given month. Additionally, display the percentage of total sales that each customer contributed to in the given month.
tables:
customers_table = 'customers';
sales_t... | codefeedback |
Create a C++ code to generate 10 random numbers between 1-100 and store them in an array. Sort the array in ascending order and then find the sum, average, and standard deviation of the numbers. Finally, display the sorted array, sum, average, and standard deviation to the user. | codefeedback |
Implement a function to check if two binary trees are structurally identical or not. Two binary trees are considered structurally identical if they have the same structure and the same node values at each corresponding position.
To solve this problem, follow these steps:
1. Define a function named `isStructurallyIdent... | codefeedback |
Write a SQL statement to retrieve the name and age of all employees who are older than 33 and have been with the company for more than 5 years. | codefeedback |
How to convert a pandas DataFrame to a python list while excluding null values and ensuring the list is sorted in descending order based on a specific column? | codefeedback |
Describe a use case of the ternary operator in Python and provide an example code snippet demonstrating its usage. The code must include at least two nested ternary operators and use a user-defined function within the conditionals. | codefeedback |
Create a function that takes in two integers, `rows` and `cols`, and returns a `rows x cols` matrix using nested lists.
The matrix should be initialized with random integer values between 1 and 10 (inclusive).
Constraints:
- 1 <= rows, cols <= 10^3 | codefeedback |
Create a Java program for solving cubic equations. | codefeedback |
Design a JavaScript function that takes two inputs (a and b) representing the lengths of two sides of a right triangle and calculates the length of the hypotenuse. The function should also handle cases where the inputs are negative or zero.
Additionally, the function should include error handling to ensure that the in... | codefeedback |
Create a PHP function that returns the difference between two dates in months, weeks, and days, considering leap years. The function should also validate the input dates to ensure they are in the format 'YYYY-MM-DD' and fall within a specified range of 1900-01-01 to 2100-12-31. Additionally, the function should handle ... | codefeedback |
Create a Python program for identifying the common elements between two lists. The program should return a list containing all the common elements, without any duplicates, in ascending order.
list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
list2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
The program should have a time complexity... | codefeedback |
Write an Angular typescript code to validate a complex input form that includes the following fields:
1. Name: Must be between 3 and 30 characters long and contain only alphabetic characters.
2. Email: Must be a valid email address.
3. Password: Must be at least 8 characters long and contain at least one uppercase let... | codefeedback |
Print out the 16-bit binary representation of the given number and count the number of ones in the binary representation.
Example:
Input: 50
Output:
Binary representation: 0000000000110010
Number of ones: 3 | codefeedback |
Convert the given integer to a 16-bit binary, ensuring that the most significant bit represents the sign of the number (1 for negative, 0 for positive). | codefeedback |
Suggest a code segment to render a greeting message in a terminal window using Python. However, the message should be displayed in a different color than the default color of the terminal. | codefeedback |
Create a Java class to represent a point (x, y, z) in a three-dimensional space. Implement the following methods:
1. `getX()` and `setX(int x)`: Get and set the x-coordinate of the point.
2. `getY()` and `setY(int y)`: Get and set the y-coordinate of the point.
3. `getZ()` and `setZ(int z)`: Get and set the z-coordina... | codefeedback |
Suggest a code segment to generate a random integer in the range of 0 to 1000 using Python, without using any built-in functions or libraries for generating random numbers. | codefeedback |
Write a JavaScript function that toggles a given CSS class on an element with a given ID. The function should also accept an optional third argument, which specifies the delay in milliseconds before the class is toggled. If no delay is specified, the class should be toggled immediately. The function should return a pro... | codefeedback |
Suggest an approach to debug a complex recursive function written in JavaScript that is not returning the expected result. Additionally, provide a code snippet with a logical error to mislead the candidate during the debugging process. | codefeedback |
Construct a regular expression to match and extract street names from a given address. The street names should include any suffixes such as "Street," "Avenue," or "Road," and should not include any numbers or special characters. | codefeedback |
Write a Nodejs function to print out the ASCII art for a given (input) text. The function should also allow the user to customize the font style and size of the ASCII art. | codefeedback |
Create a program that reads in a text file and counts the frequency of each unique word in the file. Display the words and their respective frequencies in descending order. Exclude common words such as "the", "and", "is", etc. from the word count. | codefeedback |
Write a JavaScript function that sorts an array of positive integers in ascending order, using the bubble sort algorithm. The function should also calculate and return the total number of comparisons made during the sorting process. Additionally, the function should validate the input array to ensure it only contains u... | codefeedback |
Write a Python program that can accept a 2D array and returns the column-wise sum of the given array. The input array will contain n rows and m columns, where 1 <= n, m <= 10^3. The elements of the array will be integers between -10^3 and 10^3.
Example:
Input:
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
Output:
[12, 15, 18]
... | codefeedback |
Write a program that takes an integer n as input and creates a list with the squares of the numbers from 0 to n-1. The program should then find the sum of all the elements in the list and return it. Your solution should have a time complexity of O(n) and a space complexity of O(1). | codefeedback |
Create an algorithm in Java to print all the prime numbers between a given range, while minimizing the time complexity as much as possible. | codefeedback |
Write a SQL query to fetch records from a table where the sum of a specific column is greater than a given value, and the results should be sorted in descending order based on another column. | codefeedback |
Write a C++ code to store the marks of a student in an array, and calculate the average of the marks. | codefeedback |
Create a class to create a Complex Number with real and imaginary parts. Include the following methods:
1. A method to add two complex numbers together and return the result as a new complex number.
2. A method to subtract two complex numbers and return the result as a new complex number.
3. A method to multiply two c... | codefeedback |
How can you use an AJAX callback to retrieve data from a web page while also handling error cases and optimizing the performance of the AJAX request? | codefeedback |
Use SQL to add a new record to a table, but ensure that the record being added does not violate any constraints defined on the table (e.g., primary key, unique key, foreign key constraints). | codefeedback |
Use the list comprehension feature of Python to create a list of words with length more than 10. Additionally, the words should not contain any vowels. | codefeedback |
Write a function to calculate the largest possible number from the given list of integers, considering that the numbers can be negative as well. The function should also handle if the list contains duplicates. [1, -8, 4, 12, -7, 4] | codefeedback |
Add new constraints and requirements to the original problem, adding approximately 10 additional words.
#Rewritten Test#
Given a string `message` of maximum length 1000, implement a function `function(message)` that returns a reversed version of the input string. The function should also handle cases where the input s... | codefeedback |
Create a MySQL database table with three columns: id, message, and timestamp. The id column should be the primary key and auto-incremented. The message column should be a text column that can store up to 1000 characters. The timestamp column should store the current date and time whenever a new row is inserted.
Write ... | codefeedback |
Write a function that takes in a decimal value as input and returns its binary equivalent. The function should have a time complexity of O(log n), where n is the decimal value. | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.