instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Write a C# program to create a function that takes an integer as parameter and prints its double value. However, the function should not use the multiplication operator (*) to calculate the double value. Instead, you should find an alternative algorithm or mathematical formula to calculate the double value. | codefeedback |
Write a SQL query to select the top 2 most recently hired employees, considering that the 'hire_date' column in the 'employees' table is stored as a string in the format 'yyyy-mm-dd'. | codefeedback |
Write a Java program to print out a triangle of stars with the following requirements:
1. The program should take an integer as input to determine the number of rows in the triangle.
2. The input integer should be greater than or equal to 3.
3. The program should check if the input is valid and display an error message... | codefeedback |
Generate a valid JSON object that describes the given user information, which includes additional details.
Name: John
Age: 33
Location: New York
Job Title: Software Engineer
Company: ABC Corp
Salary: $100,000
Skills: ["Python", "Java", "JavaScript"]
Education:
- Degree: Bachelor of Science in Computer Science
- Univer... | codefeedback |
Write an SQL query to find the names of all students with a score higher than 75, and order the results in descending order based on their scores. | codefeedback |
Create a class to store and print information about a book. The book should have the following attributes: title, author, year, and genre. Additionally, include a method called "print_info" that will display all the information about the book in a formatted manner. | codefeedback |
Edit the given HTML structure to center the content in the page. However, you are not allowed to use CSS properties or styles to achieve this. Instead, you must use JavaScript to dynamically center the content.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device... | codefeedback |
Write a SQL query to find all customers whose first name is 'John' and whose last name starts with 'S'. | codefeedback |
Create a function to sort the given array of numbers in descending order. The function should implement a sorting algorithm such as bubble sort or selection sort instead of using built-in sorting functions. Additionally, the function should be able to handle arrays with duplicate numbers and negative numbers as well.
... | codefeedback |
Convert a 2D array into a 1D array, where each element in the 2D array is multiplied by 2.
array = [[1, 2], [3, 4]] | codefeedback |
Create a JavaScript function that switches between two div components based on a specific condition, such as a button click. The function should also update the text content of the divs dynamically based on the condition. Additionally, the function should include error handling to display an alert message if the divs c... | codefeedback |
Provide an answer to the following question: What is the maximum size of a multidimensional array in Java, given that each dimension must have a size greater than or equal to 1 and less than or equal to 1000? | codefeedback |
Write a function that produces a copy of an array [1, 2, 3, 4] while also ensuring that the copy is sorted in ascending order and contains only unique elements. | codefeedback |
Write a java program to print the frequencies of all characters in a string. However, you must implement this program using a custom data structure instead of using any built-in data structures like maps or hash tables. | codefeedback |
Generate an algorithm that sorts the elements of an array in descending order using the quicksort algorithm.
[6, 3, 8, 9, 4] | codefeedback |
Explain how you would loop over a list of dictionaries to extract all the values, but now consider the following additional requirements:
1. Exclude certain keys: In addition to extracting all values, you need to exclude specific keys from being included in the extracted values.
2. Handle nested dictionaries: The lis... | codefeedback |
Write a function that converts an expression from postfix notation to infix notation. The function should handle arithmetic operations (+, -, *, /) and parentheses. The input expression will only contain valid operators and operands. The output should be a string representing the expression in infix notation.
Note: Yo... | codefeedback |
Generate a Python script that implements a Circular Linked List data structure. | codefeedback |
Create a function in PHP to check a given string for palindromes, but without using any built-in string manipulation functions or recursion. The function should have a time complexity of O(n) and a space complexity of O(1). | codefeedback |
Write a function in Java that sorts a given array of integers in descending order using the bubble sort algorithm. | codefeedback |
Develop a C program to compute the factorial of a given number n using recursion and without using any built-in factorial functions. The program should also handle negative inputs by displaying an error message. | codefeedback |
Develop a Ruby program to check a given string for palindromes. However, you are not allowed to use any built-in string manipulation methods or libraries (such as `reverse`, `gsub`, etc.) in your solution. | codefeedback |
Create a SQL query to find the top 3 performing products in a given store, where the products must have a rating of at least 4 and have sold more than 100 units in the last month.
Table Name: products | codefeedback |
Create a Dockerfile to containerize an existing web application. The Dockerfile should include the necessary steps to install and configure a reverse proxy server for load balancing. Additionally, the web application should be deployed on multiple containers running on different ports, and the Dockerfile should specify... | codefeedback |
Implement a machine learning model in Python to predict customer churn. Your model should have an accuracy score of at least 85% on the test dataset. You are required to use a support vector machine algorithm for the model implementation. | codefeedback |
Write a SQL query to retrieve all the rows from the table "Products" that contain the product category "Furniture" and have a price greater than $500. | codefeedback |
Convert a string representation of a JSON object to an actual JSON object in Python, while also validating the data types of the values. The JSON object will always have the following structure:
{
"name": string,
"age": integer,
"city": string
}
For example, given the string '{"name": "John", "age": 30, "city":... | codefeedback |
Calculate the sine of a given angle using JavaScript without using the Math.sin() function or any built-in trigonometric functions. Additionally, optimize the algorithm to have a time complexity of O(log n), where n is the given angle in radians. | codefeedback |
Normalize multiple columns "Weight" and "Height" in a Pandas dataframe. | codefeedback |
Generate a random password of length 10 using Python. The password must contain at least one uppercase letter, one lowercase letter, one digit, and one special character (!,@,#,$,%,&,*). | codefeedback |
Edit a given HTML string so that every word is displayed in bold, except for words that contain the letter "e".
<div>This is a sample sentence.</div> | codefeedback |
Create a JavaScript object to store a user's information, where the user's email must be unique among all users in the system. Additionally, implement a method to validate the user's password strength, which should have a minimum length of 8 characters, at least one uppercase letter, one lowercase letter, one number, a... | codefeedback |
Implement an algorithm to sort the following array in descending order without using any built-in sorting functions.
[3, 5, 4, 6, 1, 2] | codefeedback |
Identify the key differences between a set and a dictionary in Python and provide examples of when each data structure would be most appropriate to use. | codefeedback |
Given a list of numbers, find the number which appears the most times in the list. If multiple numbers appear the same maximum number of times, return the smallest one. If the list is empty, return None.
For example, for the input [2, 3, 4, 2, 3, 2, 3, 2], the output should be 2. | codefeedback |
Convert a given string to its lowercase version. The input string will have a maximum length of 100 characters. The program should also remove any leading or trailing white spaces before converting the string to lowercase. Python | codefeedback |
What is the best approach to solve this problem?
Given an array of integers, find the longest continuous increasing subarray within the array. If there are multiple subarrays with the same length, return the one with the smallest starting index.
To solve this problem, we can use a sliding window approach. We initializ... | codefeedback |
How can you execute a beta test for a complex web application with multiple user roles and features? | codefeedback |
Explain the concept of a priority queue and design a class that implements a priority queue using a binary heap data structure. Your implementation should include methods for adding elements, removing the highest priority element, and checking if the priority queue is empty. Additionally, the priority queue should supp... | codefeedback |
Write a sorting algorithm that can efficiently sort a large data set 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 data structures. Additionally, the algorithm should be stable, meaning that elements with equal values shoul... | codefeedback |
Write code in Java to find the sum of all the unique elements in an array. | codefeedback |
Create a search query in MySQL to find users whose names start with a specific letter and have an email domain that ends with ".com". The query should return the user's id, name, and email. The search letter and email domain should be provided as parameters to the query. | codefeedback |
Create a function that takes a sentence as a string and returns a string containing the sentence in reverse order. The sentence may contain special characters, punctuation, and multiple whitespaces.
# Example
sentence_reverse("I am learning to code!")
# Output: "!edoc ot gninrael ma I" | codefeedback |
Create a function that takes three arguments: a number, a string, and a boolean value. The function should return the string repeated the specified number of times, but only if the boolean value is true. If the boolean value is false, the function should return an empty string. The time complexity should not exceed O(n... | codefeedback |
Write a Node.js program to create a server that can handle concurrent requests and supports HTTPS. | codefeedback |
Design a web page using HTML, CSS, and JavaScript. The web page should include a form that allows users to enter their personal information (such as name, email, and phone number). Upon submitting the form, the web page should validate the input and display an error message if any of the fields are empty or if the emai... | codefeedback |
Write a function in SQL to find the maximum value in a table, but the table also includes a column for the date and time of each score. The function should return the maximum score for a specific date and time range. | codefeedback |
Create a Java program that takes two strings s and t as input and checks if t is an anagram of s. An anagram is a word or phrase formed by rearranging the letters of another word or phrase. Your program should return true if t is an anagram of s and false otherwise.
Time Complexity Requirement: Your program should run... | codefeedback |
Write a SAS Procedure to generate a boxplot for a specific variable within a given dataset. Additionally, include a feature to customize the appearance of the boxplot, such as changing the color or style of the boxes and whiskers. | codefeedback |
Create a Macros in Excel to transpose a given set of data. The data set contains a combination of numbers, strings, and formulas. The macros should be able to handle any size of data set, with a maximum of 1 million cells. Additionally, the macros should be able to transpose the data in-place without using any addition... | codefeedback |
Write a C++ program to find the kth smallest element in an unsorted array using minimum number of comparisons. Additionally, your program should have a time complexity of O(nlogk), where n is the size of the array and k is the given parameter. | codefeedback |
Create a SQL query to list the customers who have not completed any orders and whose total order amount is greater than $5000. | codefeedback |
Write a JavaScript program to classify a given array of strings into three groups - one which contains elements that can be parsed into integers, one which can be parsed into floating-point numbers, and one which can't be parsed into numbers at all. The program should also sort each group in ascending order. | codefeedback |
Write an SQL query to list the customer names, the total amount of orders placed by them, and the average order amount for each customer. Additionally, display only the customers who have placed more than 5 orders. | codefeedback |
Write a SQL query to list the name, email, and phone number of customers along with their associated shipping addresses, where the customers must have placed at least 3 orders and their shipping addresses must be within a specific region. | codefeedback |
Write a Java program to find the common characters in two given strings and count the frequency of each common character. | codefeedback |
Create a function to convert a string containing numbers in scientific notation to an integer. The string may also contain decimal numbers.
inputString: "1.2345e10" | codefeedback |
Write a Java method that takes a string and an integer as input, and returns the string in reverse with the integer repeated at the end. The string can contain special characters and digits, and may have a maximum length of 100 characters. The integer should be a positive number between 1 and 1000. The method should ha... | codefeedback |
Create a SQL query to calculate the total cost of an order taking into account the quantity, unit cost, and tax rate of each item. Additionally, include a discount column in the result set that shows the discount amount applied to each item based on its unit cost and quantity. | codefeedback |
Implement an algorithm to split a string of numbers (integers or floats) into two parts with an even sum. The inputString will contain a comma-separated list of numbers.
The algorithm should follow these steps:
1. Parse the inputString and convert each number to its appropriate data type (integer or float).
2. Calcula... | codefeedback |
Create a function to check which HEX color can be generated from the given RGB value. The RGB value consists of three integers ranging from 0 to 255.
For each RGB component (red, green, blue), convert the decimal value to its hexadecimal representation.
If the hexadecimal value for a component is a single digit, pre... | codefeedback |
Write a SQL query to select all records from a table with a given name, where the table has a column 'status' with values 'active' and 'inactive' and the selected records should have a column 'created_at' with a timestamp greater than or equal to a given date. | codefeedback |
Write an HTML page to display a given data table, where the table should be sortable by clicking on the table headers. Additionally, implement pagination for the table, with each page displaying a maximum of 10 rows and a navigation bar to switch between pages. | codefeedback |
Propose a JavaScript function that takes in a string and returns a new string with the characters reversed. The function should have a time complexity of O(n), where n is the length of the input string. | codefeedback |
Construct a JS code snippet to add a class "active" to an HTML element with an id "example" only if the element also has a data attribute called "toggle" with a value of "true". | codefeedback |
Construct a sql query to select the names and age of all employees who have a salary greater than 45000 and have been with the company for at least 2 years. | codefeedback |
Use the following function and SQL query and write a JavaScript program to insert data into a given table. The program should also handle any errors that may occur during the data insertion process.
function insertData(arr) {
let sqlQuery = "INSERT INTO <table_name> (NAME, AGE) VALUES ?";
// Your code here
... | codefeedback |
Build a neural network for binary classification using TensorFlow, but with the following additional requirements:
1. Implement a custom loss function that combines binary cross-entropy loss with L1 regularization. The regularization term should penalize large weights in the network.
2. Utilize a different activation... | codefeedback |
Write a single-line lambda expression that calculates the factorial of a given number. | codefeedback |
Create a python function that takes a string of characters as an argument and returns a list of all unique combinations of characters possible, excluding any combination that includes a repeating character.
Example:
Input: 'abc'
Output: ['a', 'b', 'c', 'ab', 'ac', 'bc'] | codefeedback |
Write a C++ program to calculate the difference between two dates using the following function. Additionally, handle cases where the input dates are in different time zones and account for daylight saving time changes. | codefeedback |
Generate a css code block to create a white text shadow with a blur radius of 10px and a spread radius of 5px for a given HTML element. | codefeedback |
Build an HTML form containing 3 input elements (name, email, password) and a submit button. Implement a client-side validation to check if the entered email is in the correct format (i.e., it should contain the "@" symbol and a valid domain name). Additionally, implement a server-side validation to check if the entered... | codefeedback |
Generate a JS code snippet to switch between four colours (red, blue, green, and yellow) in a circular pattern while hovering the mouse pointer over an HTML element. Each colour should be displayed for 1 second before transitioning to the next colour. The code should also include a delay of 2 seconds before starting th... | codefeedback |
Create a dictionary where each key is a unique prime number and the value of each key is the corresponding product of the two given numbers. The first given number, x, is guaranteed to be a prime number greater than 10,000, and the second given number, y, is guaranteed to be a prime number greater than 1,000. | codefeedback |
Generate a list of all prime numbers between 1 and 100 in descending order. | codefeedback |
Write a Java method to replace all spaces from a given string with a provided character, without using any built-in string manipulation methods or regular expressions.
The method signature is:
public static String replaceSpaces(String str, char replaceChar)
The input parameters are:
- str: a string containing alphan... | codefeedback |
Using the numpy library, reshape the given matrix array to have 3 rows and 4 columns. | codefeedback |
Given a list of strings, replace all empty strings with a default value and remove any duplicates from the modified list. Return the final modified list in alphabetical order.
Original list: ["apple", "", "grapes", "", "bananas"]
Default value: "unknown"
Steps:
1. Initialize an empty list called "modified_list" to st... | codefeedback |
Write a code to reverse the order of characters in a string, but without using any built-in string reversal functions or libraries. | codefeedback |
How to check if a given year is a leap year and a prime number in Python? | codefeedback |
Compress a given string by counting the occurrences of each character. The compressed string should be represented as a combination of the character and its count. Implement a function `compress_string` which takes in a string as input and returns the compressed string. The compressed string should only include charact... | codefeedback |
Using a while loop, write a program to print the Fibonacci sequence up to the nth term, where n is a user input greater than 2. | codefeedback |
Write a Visual Basic Script to find the sum of the first N prime numbers, where N is the input provided by the user. | codefeedback |
Develop Python code to find and print the largest prime factor of a given number.
30 | codefeedback |
Given a sentence as input, check if the sentence is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, disregarding any spaces, punctuation, and capitalization.
To solve this problem, we can follow these steps:
1. Remove all spaces and punctu... | codefeedback |
Write a code to form a triangle pattern with the character '$', where the number of rows is determined by user input.
#Additional Instructions#
1. Prompt the user to enter the number of rows for the triangle.
2. Validate the user input to ensure it is a positive integer.
3. Handle invalid input gracefully by displayin... | codefeedback |
Describe what an abstract class is used for in the context of implementing a concurrent linked list data structure. | codefeedback |
Create an object-oriented program in Java to calculate the area and perimeter of a rectangle, with the following additional constraints:
- The program should include at least two classes, one for the rectangle and one for the main program.
- The rectangle class should have private instance variables for the length and... | codefeedback |
Write a SQL query to get the count of records in a table, but with the condition that the table contains millions of records and the query should run within 1 second. | codefeedback |
Create an algorithm to generate a random password with the following requirements:
1. The password should be at least 8 characters long.
2. The password should contain at least one uppercase letter, one lowercase letter, one digit, and one special character (e.g., !, @, #, $, etc.).
3. The password should not contain a... | codefeedback |
Generate an HTML form element to input a password and include 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, and one number.
3. The form must include a confirmation field where the user re-enters the passw... | codefeedback |
Create a class in Ruby to store information about shopping items and their prices. The class should also include methods to calculate the total price of all items, calculate the average price of the items, and find the item with the highest price. Additionally, the class should have a method to add a discount to the it... | codefeedback |
Write a C# program to remove all occurrences of an item from an array. The array can contain both integers and strings. The program should be able to handle large arrays with up to 1 million elements efficiently. Additionally, the program should minimize the memory usage and perform the removal operation in place witho... | codefeedback |
Write SQL to create a database called Products that has five columns: id, name, price, quantity, and description. Additionally, add a constraint to ensure that the id column is a primary key and auto-incremented. | codefeedback |
How can a user increase performance with SQL queries in a database with a large number of records and multiple tables? | codefeedback |
Create a Java method to print a binary tree in level order, but without using any additional data structures or recursion. | codefeedback |
Write a JavaScript program to generate a random password of length 10 that includes at least one uppercase letter, one lowercase letter, one digit, and one special character. | codefeedback |
Create a JavaScript function to compare 2 strings to determine if they are anagrams (words with the same letters as each other). The function should have a time complexity of O(n log n), where n is the length of the longer string. Additionally, the function should not use any built-in JavaScript methods for sorting or ... | codefeedback |
Write a JavaScript code to add all the odd numbers between 1 and 100. | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.