instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Write a code which reverses the order of items in an array without using the reverse() method. The input array should remain unchanged after the reversal. Additionally, you are not allowed to use any built-in sorting or reversing functions in your code. You must implement the reversal algorithm yourself. You can only u... | codefeedback |
Design a database schema to store the following information of a job applicant's resume while ensuring data integrity and security. Additionally, implement appropriate security measures to protect the data.
1. Define the tables and relationships:
a. Create a table "Applicant" to store general information about the ... | codefeedback |
Please write a Python program that extracts specific words from a given URL. The program should perform the following steps:
1. Take a user input for the URL.
2. Make a HTTP request to the provided URL and retrieve the HTML content.
3. Remove all HTML tags from the content using regular expressions.
4. Split the conte... | codefeedback |
Write a Bash script that displays a message if you enter a wrong command. Additionally, the script should count the number of times a wrong command is entered and display a final tally of wrong commands entered at the end. The script should also log the wrong commands in a separate file for future reference. | codefeedback |
Calculate the perimeter and area of a triangle with the given length of sides. Length of sides: 6, 8, 10. The program should also check if the given sides form a valid triangle. Additionally, the program should handle cases where the sides do not form a valid triangle by providing appropriate error messages. | codefeedback |
Use the NLTK library to tokenize the following sentence, but exclude any punctuation marks and convert all words to lowercase. Additionally, remove any stop words from the sentence before tokenizing.
sentence = "This is a sentence!" | codefeedback |
Write a Python code to fetch the top ten trending topics from Twitter, sort them in alphabetical order, and print them out. | codefeedback |
Increase the difficulty by asking the following:
Rewrite the program to print "The answer is 3" without using any arithmetic operations, literals, or predefined functions. | codefeedback |
Write a function in Python to convert a 2D array into a single column array, but also ensure that the function handles the case when the input array contains nested arrays with varying lengths. The function should flatten the 2D array while maintaining the order of the elements and handling the varying lengths of the n... | codefeedback |
Construct a SQL query to find out three most expensive items in a product table, but excluding any items that are out of stock. Additionally, the query should only consider items that have been purchased at least twice and have a rating of 4 or above. | codefeedback |
How can you detect if there is an infinite loop in a code, given that the code includes nested loops, recursive function calls, and asynchronous operations? | codefeedback |
Create a program that draws an inverted triangle with stars (*) with a given height. The program should also randomly assign different colors to each row of stars, and the number of stars in each row should be equal to the row number multiplied by 2. Additionally, the program should output the total number of stars in ... | codefeedback |
Write a JavaScript program to find the object with the largest number of properties. The program should also handle nested objects and arrays within the objects. Additionally, the program should ignore properties that have a value of null or undefined when counting the number of properties. | codefeedback |
Use the HTML form below and provide the corresponding JavaScript code that will validate the form. Your JavaScript code should meet the following additional requirements:
1. Validate that the name field is not empty and contains at least two characters.
2. Validate that the email field is not empty and contains a vali... | codefeedback |
Parse the following XML data to get a list of country names along with their ranks, years, GDP per capita, and neighboring countries. Implement a function that takes in the XML data as input and returns a list of country objects. The country object should have attributes for name, rank, year, gdppc, and a list of neigh... | codefeedback |
Create a CSS class for making a font bold and italicized. The class should only be applied to the first letter of each word in a paragraph and should not affect any other letters in the paragraph. | codefeedback |
Generate a comprehensive list of project requirements for a large-scale web development project that must include a highly optimized and responsive design across various devices and screen sizes, ensuring compatibility with popular browsers such as Chrome, Firefox, Safari, and Edge. Additionally, the project should int... | codefeedback |
Create a Java program that prompts the user to enter two integers, divides them, rounds the result to the nearest integer, and then calculates the square root of the rounded result. The program should handle input validation and error handling for division by zero and non-integer inputs. | codefeedback |
Write a code to initialize an array with 10 elements of value 0 and then randomly assign each element a unique value between 1 and 100. Ensure that no two elements have the same value and that the array is sorted in ascending order after assigning the values. | codefeedback |
Create a function that takes in a string and returns the reverse of that string. The function should not use any built-in string reverse or string manipulation functions.
#Example#
Input: "hello"
Output: "olleh" | codefeedback |
Create an SQL query to extract the name, age, and email of all users whose age is between 25 and 30, and whose email contains the domain "gmail.com". Additionally, filter out any users whose email address contains the word "admin". Order the results by age in descending order. | codefeedback |
Given two lists of integers, find all unique pairings where the sum of the pair equals to a given number. The pairs should be ordered in descending order and should not contain duplicate elements. Each element in the pair can only be used once. The lists may contain duplicate elements. The resulting pairs should be ret... | codefeedback |
Generate a list of valid HTML tags used to structure content in a page, ensuring that the tags are ordered in a specific way based on their hierarchical relationships. Additionally, optimize the algorithm to minimize time complexity and space complexity. | codefeedback |
Write a program that prompts the user to enter their name, and then outputs a personalized greeting message to the console. The program should validate the input to ensure that the user enters a non-empty string as their name. If the user enters an empty string or just spaces, the program should display an error messag... | codefeedback |
Calculate the maximum depth of a Binary Search Tree that satisfies the condition that all nodes at an even level have even values, and all nodes at an odd level have odd values. Additionally, the solution should have a time complexity of O(log n), where n is the number of nodes in the tree.
TreeNode* root = new TreeNod... | codefeedback |
Writing a function to calculate the area of a triangle where the three sides are given. Additionally, you need to check if the given sides form a valid triangle.
side1 = 5, side2 = 5, side3 = 10
Steps:
1. Check if the given sides form a valid triangle. A valid triangle should satisfy the triangle inequality theorem, ... | codefeedback |
Write a JavaScript code snippet to update the style color attribute of a HTML element when a button is clicked. The button element has an id of "button1".
Requirements:
- The code should be written in plain JavaScript without the use of any libraries or frameworks.
- The code should use event delegation to handle the ... | codefeedback |
Create a Ruby class called "Movie" that represents a movie. The class should have instance variables for the movie's title, release year, director, and genre. Implement getter and setter methods for each instance variable. Additionally, the class should have a method called "calculate_average_rating" that takes in an a... | codefeedback |
Find the area of a triangle whose sides measure a= 7, b= 9, and c= 12. The sides of the triangle must satisfy the condition that the sum of any two sides is greater than the third side, and the triangle must also be an isosceles triangle with one of its angles being a right angle. | codefeedback |
Implement a recursive function that calculates the factorial of a non-negative integer n. If n is a negative number, the function should return an appropriate error message. The function should have a time complexity of O(n). | codefeedback |
Create a function that removes all the repeated elements from a list and returns a new list with only the unique elements. The function should take in a list of integers as input and iterate through each element in the list. For each element, it should check if it has already been encountered in the list and if it is a... | codefeedback |
Construct an SQL query to select all students who have a grade of 90 or greater, have taken more than 5 courses from the 'Student' table, and have a GPA higher than 3.5. | codefeedback |
Create a parameterized query in Python to find the details of a person, ensuring that the query retrieves data from at least two related tables and includes a join condition. Additionally, add a filtering condition to the query to retrieve only the records where the person's age is greater than a given value.
#Solutio... | codefeedback |
Make the following piece of code functional for priority queues, ensuring that the implementation is based on a max heap and that the priority queue supports the following operations: insert(value), deleteMax(), and getMax(). The implementation should also have a time complexity of O(log n) for insert and deleteMax ope... | codefeedback |
Design a function to clean binary data (strings) by keeping only printable characters. Additionally, convert any lowercase letters to uppercase. The function should also remove any whitespace characters from the binary data.
binary_data = b'h\x9Fl\x04o' | codefeedback |
Edit the code to make the string word_list case-insensitive, remove any duplicate words from the list, and sort the words in alphabetical order.
word_list = ["cat", "DOG", "bird", "Dog", "Bird"] | codefeedback |
Evaluate the expression "(7 + 4) * 3 - 6 / 2" with JavaScript. The solution should be implemented as a function that takes in the expression as a string and returns the result as a floating-point number. The function should also handle parentheses in the expression, ensuring that the correct order of operations is foll... | codefeedback |
Write a program that displays an alert message with the text "Hello, World!" when a specific key combination (e.g. Ctrl + Shift + A) is pressed. Additionally, the program should keep track of the total number of times the key combination has been pressed and display it in the alert message. The program should also have... | codefeedback |
Modify the code to display a specific error message whenever a parameter is passed as a string. Additionally, ensure that the function only accepts numerical values for the parameters. The function should throw a custom error if either parameter is not a number, with the error message stating the exact parameter that c... | codefeedback |
Given an array of JavaScript objects, process each object and produce a string of the object's properties in alphabetical order, excluding properties that are objects themselves. Additionally, each property should be followed by its corresponding value. | codefeedback |
Make the following code work in a multithreading environment with two threads and add the requirement to ensure that the value of x never exceeds a certain limit.
x = 0
limit = 10
def incrementer():
# TODO
# Instructions for Incrementer Function
1. Create a lock object.
2. Acquire the lock before updating the val... | codefeedback |
Generate a JSON response which contains the age, name, and email of all users in the database, sorted in ascending order of age. The time complexity of your solution should not exceed O(n log n), where n is the number of users in the database. Additionally, your solution should use constant space complexity, meaning it... | codefeedback |
Return an array which contains all the unique words of the given string in reverse order, while ignoring any punctuation marks and considering uppercase and lowercase letters as the same word.
string = "This is a test sentence, and this is another test sentence." | codefeedback |
For the given Python dictionary, list all its keys and values in the following format. However, for nested dictionaries, only display the keys and values if the key starts with the letter 'a'. Additionally, for nested dictionaries within nested dictionaries, only display the keys and values if the key starts with the l... | codefeedback |
Convert pyramid of numbers to a single number, where each number in the pyramid is either positive or negative. The pyramid may contain up to 100 rows. Find the maximum sum from the top to the bottom of the pyramid, following a specific set of rules:
1. You can only move downwards or diagonally to the left or right.
2... | codefeedback |
String concatenation is the process of combining two individual strings into one. Write a Python program to concatenate two strings using the + operator. In addition, your program should also capitalize the first letter of the resulting string. The program should have a time complexity of O(n), where n is the length of... | codefeedback |
Write an SQL query for finding customers who live in a given zipcode, have made at least two purchases in the last month, and their total purchase amount is greater than $500. | codefeedback |
Create a code to read a textfile line by line and print out the lines that have the word "Python" or any of its variations, such as "python" or "PYTHON". Additionally, the code should count and display the total number of times the word "Python" or any of its variations appear in the text file. However, the code should... | codefeedback |
Write a function to sort the elements of a list based on their frequency. The output list should contain the elements in descending order of frequency. If multiple elements have the same frequency, they should be sorted in ascending order. The function should have a time complexity of O(n log n) and a space complexity ... | codefeedback |
Write a Python function that takes in a string, a substring, and a replacement string as inputs. The function should search for all occurrences of the substring in the string and replace them with the replacement string. The function should be case-sensitive and should return the modified string.
However, the input st... | codefeedback |
Convert the given HTML code into its corresponding DOM elements using JavaScript.
```
<body>
<h1>Welcome to my website</h1>
<div>
<p>This is a paragraph.</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</div>
<footer>© 2022 My Website. All rights reserved.</footer>... | codefeedback |
Create a class constructor to initialize the values of a person. The constructor should also include a validation check to ensure that the age of the person is a positive integer between 18 and 65 (inclusive). If the age is not within this range, the constructor should throw an IllegalArgumentException with an appropri... | codefeedback |
Design an interactive web page using HTML and JavaScript that allows users to create and customize their own avatar. The avatar should have at least five customizable features, such as hairstyle, facial features, clothing, accessories, and background. Users should be able to select different options for each feature an... | codefeedback |
Write an SQL query to find customers who live in a given city and have purchased a given product. Additionally, include the total number of times each customer has purchased the product in the result set.
Furthermore, sort the result set based on the total number of times the customer has purchased the product in des... | codefeedback |
Create a React component for a dropdown menu.
The menu should list the following options: Home, About, Contact.
The dropdown menu should also have a search functionality, allowing users to search for specific options within the dropdown menu.
In addition to the above requirements, the dropdown menu should have the fol... | codefeedback |
What is the most efficient way to iterate through a list of dictionaries in Python, without using any built-in functions or methods like `for` loops, list comprehensions, or `map()`? Additionally, you are not allowed to use any third-party libraries or modules for iteration. | codefeedback |
Create a program for sorting a given array in O(n) time complexity. The array consists of positive integers ranging from 1 to 1000.
Additionally, the program should sort the array in descending order instead of ascending order.
Furthermore, the program should be implemented using a recursive approach instead of an it... | codefeedback |
Write a C++ algorithm for finding the longest common substring between two strings. The algorithm should have a time complexity of O(n^2), where n is the length of the longer string. Additionally, the algorithm should handle strings containing both uppercase and lowercase letters. The algorithm should also handle cases... | codefeedback |
Write an SQL query to delete a record from a table named 'user' where the email is 'example@example.com' and the user's age is greater than 18. Additionally, you need to ensure that the user has made at least 5 purchases in the past month and the total amount spent by the user is above $1000. | codefeedback |
Comment on the following code:
Write a function called `power` that takes in two parameters: `base` and `exponent`. The function should return the result of raising the base to the power of the exponent.
- Check if both `base` and `exponent` are numbers. If either of them is not a number, throw an error with the messa... | codefeedback |
Create a UI element in ReactJS that consists of a button and a text input field. When the button is clicked, the value entered in the text input field should be displayed in an alert box. Additionally, the button should change its background color randomly every time it is clicked. However, the random background color ... | codefeedback |
Explain the significance of the 'const' keyword in C++, and provide an example of how it can be used to create a constant member function in a class. Additionally, the constant member function should have a return type of a user-defined data structure and should be implemented using template specialization. | codefeedback |
Write a TensorFlow code to build a convolutional neural network to predict the digits from the MNIST dataset. Additionally, include a custom loss function that penalizes misclassifying odd numbers more heavily than even numbers. In addition to this, you are required to implement a dynamic learning rate scheduler that d... | codefeedback |
Create a Node.js server that serves a simple "Hello, World!" page. However, instead of directly sending the "Hello, World!" text as the response, the server should fetch the message from a separate JSON file and display it dynamically. The JSON file should contain an array of messages, and the server should randomly se... | codefeedback |
Create a program to detect the type of a given character, but the program should only consider characters from the Unicode Supplementary Multilingual Plane (SMP) range. | codefeedback |
Given a list of dictionaries, each containing information about a person, write a function that converts the list to a JSON string representation.
The function should have the following signature:
```
def convert_to_json(list_of_dictionaries: List[Dict[str, Union[str, int]]]) -> str:
```
The input `list_of_dictionari... | codefeedback |
Create an Android application for calculating monthly loan payments.
The application should be able to calculate the monthly payments for different loan types, such as car loans, home loans, personal loans, etc. Each loan type may have different interest rates and loan durations.
The user should be able to input the ... | codefeedback |
Can you print out a multiplication table of size 15 by 15, but only include the prime numbers in the table?
#Erroneous Code Reference#
Provide a piece of code that attempts to print out a multiplication table of size 15 by 15, but only includes the odd numbers in the table instead of the even numbers. | codefeedback |
Create a web application that allows users to register for an event. The application should include a HTML form with the following fields:
1. Name: A text field where users can enter their full name.
2. Email: A text field where users can enter their email address. The email address must be in the format "example@exam... | codefeedback |
Design an HTML form to register users on a website. Include the following fields:
- Full name (required, must contain at least one special character)
- Email address (required, must be a valid email format)
- Password (required, minimum 12 characters, must contain at least one uppercase letter, one lowercase letter, o... | codefeedback |
Compose a Python script to convert a string to an all-uppercase string, while excluding any vowels in the string. Additionally, remove any punctuation marks from the string before converting it to uppercase.
String: 'Experiment!' | codefeedback |
Create a JSON object that contains "name" and "age" fields, where the "name" field must be a string of maximum 100 characters and must not contain any special characters or numbers. The "age" field must be an integer between 1 and 1 | codefeedback |
Create a Swift program to make a request to an API using URLSession and display the response in the console. The program should include error handling for network errors and API errors. Additionally, the program should implement authentication using OAuth 2.0 with the API's provided client ID and secret.
Furthermore,... | codefeedback |
Design a code to generate Fibonacci numbers within a given range of values, where the range is specified by the user as the maximum and minimum values. The code should also validate the input range to ensure that the minimum value is smaller than the maximum value.
However, the code should now be implemented using an ... | codefeedback |
Write a Java program to sum the elements of an array except for the maximum and minimum, and also excluding any negative numbers. Additionally, the program should calculate and display the sum of the remaining elements multiplied by the factorial of the count of negative numbers in the array.
Array: [1, -2, 3, -4, 5] | codefeedback |
Design an algorithm for multiplying two matrices.
A = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
B = [[10, 11, 12],
[13, 14, 15],
[16, 17, 18]]
Write a program that takes two matrices as input and returns their product matrix.
The dimensions of the input matrices should be validated to ensure that th... | codefeedback |
Compose a JavaScript function to detect whether two strings are punctuated versions of the same word. The function should be case-insensitive and ignore any leading or trailing spaces. Both strings must have at least 2 characters and should not contain any special characters or numbers. Additionally, the function shoul... | codefeedback |
Create an efficient algorithm in Java to search for a given value in a sorted array of integers. The algorithm should have a time complexity of O(log n), where n is the size of the array. Additionally, you are not allowed to use any built-in search functions or libraries in your implementation.
The input array will be... | codefeedback |
Write a Python function that takes in a string and returns a float representation of the string, without using any built-in conversion functions or libraries. The string will only contain a valid positive decimal number with up to 5 decimal places. The function should handle leading and trailing whitespace in the strin... | codefeedback |
Implement a C# program that reads an array of strings and sorts them in alphabetical order. However, you are not allowed to use any built-in sorting functions or libraries. You must implement your own sorting algorithm. Additionally, you should handle cases where the input strings contain special characters or numbers,... | codefeedback |
Develop a JavaScript function to convert a date string from the ISO-8601 format to a human-readable format. The function should also handle time zone conversions and display the date and time in the user's local time zone. Additionally, the function should validate the input date string to ensure it is in the correct f... | codefeedback |
Create a GCP Cloud Function that sends an email with input "name" and "message". Additionally, ensure that the email is sent asynchronously and provide a retry mechanism in case of failures. Implement a rate limiting mechanism to limit the number of emails that can be sent per minute. Add error handling to handle scena... | codefeedback |
Write a program that takes an array of integers as input and prints all the unique elements in the array, sorted in ascending order. The program should have a time complexity of O(nlogn), where n is the size of the input array.
In addition to the above requirements, modify the program to also print the frequency of ea... | codefeedback |
Write a RegEx to extract text inside HTML paragraph tags, but only if the paragraph tags are nested within a div tag with the class "content". For example:
<div class="content">
<p>This is a test</p>
</div>
Note: The RegEx should not match if the paragraph tags are not nested within a div tag with the class "content... | codefeedback |
Create a graphql mutation that adds a new user to the system with the following requirements: the user's name must be between 5 and 20 characters long and should not contain any special characters, the email must be a valid email address and not already registered in the system, and the user's password must be at least... | codefeedback |
Write code to check if a given string contains only alpha-numeric characters and has a minimum length of 5 characters. Additionally, the code should check if the string contains at least one uppercase letter, one lowercase letter, and one special character (i.e., any character that is not a letter or a digit). | codefeedback |
Create a permutation of characters in a string with the additional constraints:
1. The string must have at least 3 characters and at most 10 characters.
2. The permutation must include all uppercase letters of the English alphabet.
3. The permutation must not contain any consecutive duplicate characters.
4. The permuta... | codefeedback |
Implement the Levenshtein distance algorithm in Python, but with the additional constraints that you are not allowed to use any built-in string manipulation functions or libraries, and you must optimize the algorithm to have a time complexity of O(n*m), where n and m are the lengths of the two input strings. | codefeedback |
Given an array of English words, find all pairs of words which are anagrams of each other in the same array. Return the list of these pairs. The time complexity of the solution should be O(n^2). The input array will contain at most 10^5 words and each word will have at most 100 characters. All words in the array will b... | codefeedback |
Increase the difficulty of the given programming test question by adding more reasoning steps and complexity.
# Revised Test #
Change the following PHP code to use the new syntax from PHP 7 and also add error handling to handle any potential exceptions thrown during execution.
```php
<?php
try {
$array = ['a', 'b... | codefeedback |
Using the given code snippet, reverse the words of the string while also capitalizing the first letter of each word and ensuring that all vowels within each word are capitalized. | codefeedback |
Identify the salient feature in the given piece of code and optimize the function to only use a single line of code. Additionally, the optimized code should use a recursive algorithm instead of an iterative one. | codefeedback |
Given an array containing words and a string, find the shortest word in the array that is a substring of the string. The array may contain duplicates. The string may contain special characters and spaces. The words in the array and the characters in the string are case-sensitive. The output should be in lowercase. The ... | codefeedback |
Please write a Java program to calculate the compound interest.
Principal (P): 1000
Time (T): 2
Rate of Interest (R): 10
Number of Compounds (N): 4
The program should also be able to handle the following scenarios:
1. The user should be able to input different values for P, T, R, and N.
2. The program should validate... | codefeedback |
Write a SQL query to select all employees who have a salary greater than the average salary of all employees in the department with the code 'IT' and whose job title is 'Software Engineer'. | codefeedback |
Use set operations to obtain the intersection of two given sets. The program should also remove any duplicates from the resulting intersection set, sort the elements in descending order, and return the sum of all elements in the intersection set. Additionally, the program should output the number of elements in the int... | codefeedback |
Perform K-Means Clustering on this dataset using the Euclidean distance metric.
dataset = [[5,7], [1,2], [7,9], [10,2], [2,5]]
Cluster the dataset into two clusters.
The algorithm should terminate when the centroids of the clusters do not change by more than 0.01 for five consecutive iterations.
To increase the diffic... | codefeedback |
Explain the use of webhooks in server-side applications and provide a code example using a specific programming language of your choice. Additionally, your solution should include error handling, demonstrate how the webhook payload can be securely transmitted using encryption, and implement a rate limiting mechanism to... | codefeedback |
Write a R code to create a vector with a sequence of 15 prime numbers starting at 4 and ending at 24. Additionally, the code should also include a function to check whether a given number is prime or not. | codefeedback |
Implement a function in TypeScript that takes in an array of numbers and returns the sum of all the prime numbers in the array.
#Sample Input/Output#
Input: [1, 2, 3, 4, 5, 6]
Output: 2+3+5 = 10
Input: [10, 11, 12, 13, 14, 15]
Output: 11+13 = 24 | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.