instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Write a program that reads a list of URLs from a file and checks if each URL is reachable or not. The program should print the status code and response time for each URL. The program should handle the following requirements: - The file path should be passed as a command-line argument. - The program should use multi-th...
codefeedback
Create an endpoint in Express.js which prints out the request path when hit by a POST request. Additionally, the endpoint should log the IP address of the client making the request and the timestamp of when the request was received. The IP address should be logged in a separate log file for security purposes. Implement...
codefeedback
Describe the different ways to manage memory in C++ and provide examples of each method. Explain the advantages and disadvantages of each method in detail. Additionally, discuss common memory management pitfalls in C++ and provide thorough explanations on how to avoid them.
codefeedback
Find the number of days in a month given the year, month, the day of the week of the first day of the month, and the fact that the month is a leap year. Year: 2020, Month: April, First Day of the Month: Wednesday, Leap Year: True.
codefeedback
Explain in detail the differences between HTTP and HTTPS, including their underlying protocols and security mechanisms. Discuss the advantages and disadvantages of using each protocol in various scenarios, considering factors such as performance, scalability, and authentication. Additionally, provide a code snippet tha...
codefeedback
Write a stored procedure in SQL for inserting records into the table "Students". Additionally, implement a validation check to ensure that the inserted records do not violate any unique constraints on the table. In addition to this, the stored procedure should also handle any errors that may occur during the insertion ...
codefeedback
Create a React component for displaying a profile card with the properties of name, age, and a list of hobbies. The hobbies should be displayed as clickable tags and should be editable. Implement a feature that allows users to add new hobbies to the list and delete existing ones. Additionally, include a feature that al...
codefeedback
Define an interface in Java that includes a method with a default implementation and at least two static methods. Additionally, the interface should extend another interface and override one of its default methods.
codefeedback
Create a method in Java for encrypting a string using the RSA (Rivest-Shamir-Adleman) algorithm with a key size of 2048 bits. The method should accept both the plaintext string and the public key as input parameters. The output should be the encrypted string in hexadecimal format. Additionally, implement a separate me...
codefeedback
Create a SQL query to list all the employees who have a salary greater than the average salary of their department and have been with the company for at least 5 years, ordered by their salary in descending order. Table name: "Employees" Columns: "emp_name", "emp_dept", "salary", "years_of_service"
codefeedback
Write a C# method for converting a string to its equivalent integer value. You are not allowed to use any built-in conversion functions or libraries. #Additional Information# 1. The input string can contain both positive and negative numbers. 2. The input string can have leading and trailing white spaces, which should...
codefeedback
Write a function in Java that takes an array of integers and sorts it in ascending order. The time complexity of the algorithm should not exceed O(n log n). Additionally, you are not allowed to use any built-in sorting functions or libraries. You must also ensure that the sorting algorithm is stable, meaning that the r...
codefeedback
Create a type-safe generic class in C# for storing objects of any data type. The class should also implement the IEnumerable interface, allowing the stored objects to be iterated over. Additionally, the class should have the following methods: 1. `Add(T item)`: Adds an item of type T to the collection. 2. `Remove(T i...
codefeedback
Create a React web page with two app components that fetches data from an API and displays it in a table. The page should also have a search functionality that allows users to filter the data based on specific criteria. Additionally, implement pagination for the table, allowing users to navigate through multiple pages ...
codefeedback
Create a C++ class for managing a generic dictionary, in which keys and values can be of any data type. Additionally, the dictionary should have the following requirements: 1. Implement a method to add an entry to the dictionary, which takes a key and a value as parameters. The key and value can be of any data type. T...
codefeedback
Modify the given Java program to generate the Fibonacci series till the provided number of terms and display only the prime numbers in the series. int n = 10; **Note:** A prime number is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers.
codefeedback
Implement a stack to store and retrieve items in last-in first-out order. Additionally, implement the following operations: - getMin(): Retrieve the minimum element in the stack in constant time complexity. - getMax(): Retrieve the maximum element in the stack in constant time complexity. - popAll(): Remove all element...
codefeedback
Convert the following NFA (Non-Deterministic Finite Automaton) to DFA (Deterministic Finite Automaton). State S0, S1, S2, S3, S4, S5, S6 Transition Function: S0 - a -> S1 S0 - b -> S2 S1 - b -> S0 S1 - a -> S2 S2 - a -> S2 S2 - b -> S1 S3 - a -> S4 S3 - b -> S3 S4 - a -> S4 S4 - b -> S3 S5 - a -> S6 S5 - b -> S5 S6 - a...
codefeedback
Modify the given Swift code to compute the product of two numbers using only bitwise operations and print the result. However, you are not allowed to use the '*' operator for multiplication or any other arithmetic operators like addition, subtraction, and division. a = 5 b = 8
codefeedback
Design a responsive HTML page with a header, footer, and a body section. The header should contain a navigation bar with dropdown menus. The body section should have a grid layout displaying images and descriptions. Each image should have a hover effect that reveals additional information about the image. The footer sh...
codefeedback
Create a C++ function to compute the area of a triangle with three given edges. The function should also check if the given edges form a valid triangle, and if not, it should return an appropriate error message. Additionally, the function should handle input validation to ensure that the given edges are positive non-z...
codefeedback
Create an SQL query to get the second highest salary from a table named 'employee' where the salary must be greater than 50000, the employee must have been hired within the last 3 years, and the department of the employee must not be 'Sales'. #Reasoning Steps# 1. Select all the distinct salaries from the 'employee' ta...
codefeedback
Create a JavaScript function that checks if all elements of an array are twin prime numbers or not. Twin prime numbers are pairs of prime numbers that differ by two, such as (3, 5), (11, 13), and (17, 19).
codefeedback
Design a Java program to display the prime numbers from 1 to 1000 in a tabular format. The program should also calculate and display the sum of all prime numbers in the table. Additionally, the program should use multi-threading to enhance performance by calculating prime numbers in parallel.
codefeedback
Create a C program that sorts an array in either ascending or descending order, depending on the user’s selection. The program should implement the QuickSort algorithm for sorting. Requirements: 1. The program should allow the user to input the size of the array. 2. The program should allow the user to input the eleme...
codefeedback
Generate a correct assembly language code to execute the following: Add two numbers and store the result in memory address 2000. However, the program must only use bitwise operations (AND, OR, XOR, SHIFT, etc.) to perform the addition and store the result. Additionally, the program must handle negative numbers and perf...
codefeedback
Construct an HTML form as a comment in the below code. Additionally, add an input field that only accepts numeric input and has a maximum value of 100. The form should also include a dropdown menu with multiple options, and the selected option should be displayed as the default value when the form is loaded.
codefeedback
Write a Java script to filter out repeat elements in an array, sort the remaining elements in descending order, and remove all odd numbers from the resulting array. [5, 2, 3, 2, 4, 4, 1, 5]
codefeedback
Create a function in Python that executes the below pseudocode. Input: A list of integers For each integer: If the integer is divisible by 3, multiply it by 2 and add 1 to the list If the integer is divisible by 5, divide it by 2 and subtract 1 from the list If the integer is divisible by 7, add 5 to the l...
codefeedback
Write a HTML/CSS code to implement a responsive design that adapts to different screen sizes and devices, while also incorporating a sticky header that remains fixed at the top of the page as the user scrolls. Additionally, the design should include a navigation menu that changes its layout depending on the screen size...
codefeedback
Write a Ruby function to find the most frequently occurring elements in an array, but exclude any elements that are divisible by both 3 and 5. Additionally, the function should also exclude any elements that contain the digit 7 in their decimal representation.
codefeedback
Write a SQL statement that joins five tables and returns the fields of interest, while also including multiple additional filter conditions and logical steps. Table 1 (tbl_person): person_id, person_name, age Table 2 (tbl_course): course_id, course_name, credits Table 3 (tbl_enroll): enroll_id, person_id, course_id Tab...
codefeedback
Extract all characters from the given text and store them in a new string. However, you are not allowed to use any built-in string manipulation functions or methods, including for loops or recursion. Your solution should have a time complexity of O(n) and a space complexity of O(n), where n is the length of the input s...
codefeedback
Reverse the words in the following sentence: "Hello World! How are you?"
codefeedback
Write a function in Python that takes in two parameters, a string and a list of words, and returns true if the string is an anagram of a word in the list. The list may or may not be alphabetically sorted. Example: Input: string = "listen" word_list = ["silent", "enlist", "list", "tin"] Output: true Input: string = "...
codefeedback
Please write a class in Java that represents a student's academic record. The class should have the following attributes: - name: a String representing the student's name - age: an integer representing the student's age - grades: an array of integers representing the student's grades in different subjects The class s...
codefeedback
Write a MySQL query to calculate the average temperature for each user, given a table of log data. However, the average temperature should only be calculated for users who have logged in at least 10 times in the past month and have a temperature sensor with a precision of at least 0.01 degrees. Additionally, the query ...
codefeedback
Identify all person names in the given text using python. The program should be able to handle text that includes additional punctuation marks such as commas, periods, and exclamation marks. Only consider names that are at least two characters long. Additionally, the program should be able to handle cases where a perso...
codefeedback
Write an SQL query to find the top 10 users with the highest temperature reading in the past 24 hours. Additionally, display the average temperature for each user in the result.
codefeedback
Given an array of integers, write a function that returns the index of the smallest prime number in the array. If there are multiple occurrences of the smallest prime number, return the index of the first occurrence. Example: array = [3, 1, 9, 6, 17] Expected output: 4 Explanation: The smallest prime number in the a...
codefeedback
Create a function in HTML that checks to make sure the provided input is a prime number. Additionally, the function should also check if the input is a perfect square and return true if it is.
codefeedback
Sort the elements in an integer array in non-decreasing order, using only constant space complexity and without using any built-in sorting functions or libraries. Constraints: - The length of the array will be between 1 and 1000. - Each element in the array will be between -1000 and 1000. arr = [4, 23, 1, 7, 10] #Di...
codefeedback
Write a method in C that prints out all the lexicographically smallest permutations of a given string. String: ABCD Erroneous Code: ```c #include<stdio.h> #include<string.h> void swap(char *x, char *y) { char temp; temp = *x; *x = *y; *y = temp; } void permute(char *str, int l, int r) { int i;...
codefeedback
Please replace the placeholder in the given HTML document with the corresponding table, where the table data is fetched from an external API. <html> <body> <!-- replace placeholder with table --> </body> </html> Fetch the data from the API endpoint: `https://example.com/api/users` which returns an array of us...
codefeedback
Concatenate the strings in the given list using Java. However, there are additional conditions: 1. The final concatenated string should be sorted in alphabetical order. 2. Only strings with an even length and containing at least one uppercase letter should be included in the final concatenated string. 3. If there are n...
codefeedback
Please implement a function that takes in two strings, `pattern` and `text`, and replaces all occurrences of `pattern` with the word "lessons" in `text`. The function should return the modified text. Additional Requirements: - The function should be case-insensitive, meaning it should replace occurrences of `pattern` ...
codefeedback
Calculate the sum of the even numbers in the given array using the Java 8 Stream API. nums = [2, 4, 6, 10, 11, 14, 20] **Difficulty increased version:** Write a Java program that uses the Java 8 Stream API to calculate the sum of the even numbers in the given array. The program should follow the steps below: 1. Ini...
codefeedback
Given two integers, implement a function in C to swap their values without using a temporary variable and without using any arithmetic operators (+, -, *, /). int a = 3; int b = 5; You may not use a temporary variable, arithmetic operators, or any other data structure to store the values. Your function should directl...
codefeedback
Generate the code to append the item "banana" to the end of the list called fruits, but only if the list does not already contain the item "banana". If the list already contains "banana", remove all instances of it and print the number of occurrences removed. Additionally, after appending the item, sort the list in des...
codefeedback
Edit the given SQL query to return the number of employees from each team, along with the average age of the employees in each team, ordered by the team with the highest number of employees first. SELECT team, COUNT(*) as num_employees, AVG(age) as average_age FROM Employees GROUP BY team ORDER BY num_employees DES...
codefeedback
Create an SQL query to get the names, ages, and salaries of the top 5 highest-paid employees who have a job title of "Software Engineer" and are over 30 years old. Additionally, the query should only include employees whose salaries are within the top 10% of the salaries for employees with the same job title. Table: ...
codefeedback
Code a function in JavaScript to find the area of a triangle given the lengths of its three sides. The function should have a time complexity of O(n^2), where n is the maximum length among the three sides. Note: The function should also handle cases where it is not possible to form a triangle with the given side lengt...
codefeedback
Given a nested HTML page, parse the page to extract all <h1> tags and their corresponding text content. The nested tags can have arbitrary levels of depth. Example: Input: <html> <head> <title>Page Title</title> </head> <body> <h1>This is a heading 1</h1> <h2>This is a heading 2</h2> <p>This is a parag...
codefeedback
Design an algorithm to detect whether two given strings are permutations of each other. The algorithm should account for case sensitivity, spaces, and punctuation marks. Additionally, optimize the algorithm to have a time complexity of O(n log n) and space complexity of O(1).
codefeedback
Implement a program in Java that reverses a string input given by the user. The program should not use any built-in string manipulation functions or libraries. The input string can have a maximum length of 100 characters. Additional requirements: 1. The program should handle cases where the input string contains speci...
codefeedback
Write C++ code to implement a doubly linked list with the following additional requirements: - The list should support adding elements at the front and back, as well as removing elements from the front and back, in constant time complexity. - The list should have a method to check if it contains a specific element, wit...
codefeedback
Modify the given code so it prints a prime number table up to a given limit, where the limit is a Fibonacci number. table_limit = 144
codefeedback
Create a JavaScript function called `customArrayMethods` that mimics the functionality of the `.push()`, `.pop()`, `.shift()`, and `.unshift()` methods in JavaScript arrays. The function should take two parameters: an array and a value. The function should modify the array based on the following rules: - `.push()` sho...
codefeedback
Determine the sum of all the digits in a given string, excluding any punctuation marks or special characters. my_string = "Hello, world! 123"
codefeedback
Write a JavaScript program to randomly select unique items from an array, without using any built-in array methods. The program should ensure that each item is selected only once and that all items have an equal chance of being selected. Additionally, the program should implement a weighted selection algorithm, where e...
codefeedback
Write a C# class which implements two-dimensional array searching using binary search algorithms. The two-dimensional array contains sorted rows and columns in ascending order. The class should have the following methods: 1. `SearchValue(int[,] arr, int target)`: This method takes in the two-dimensional array `arr` an...
codefeedback
Generate Python code to find the compound interest for a given principal amount, rate, and time period, while also considering any additional contributions made to the principal amount at regular intervals. The code should take as input the principal amount, the annual interest rate (as a decimal), the time period in ...
codefeedback
Given an array of numbers, build an array of objects where each object has three properties: the number itself, its square root, and its factorial. However, the factorial should be calculated using a recursive function. Additionally, the square root should be rounded to the nearest whole number. arr = [1, 2, 3, 4, 5]
codefeedback
Parse a JSON string into an object in JavaScript. The JSON string will have nested objects and arrays. Handle the nested structure and parse it into the corresponding object and array structures in JavaScript. Additionally, handle any possible errors that may occur during the parsing process, such as invalid JSON synta...
codefeedback
Generate a Flask route that handles both GET and POST requests. The route should return the sum of two numbers passed as query parameters in the URL for a GET request, and return the product of two numbers passed as JSON in the body for a POST request. Additionally, the route should validate the input and handle error ...
codefeedback
Construct an SQL query to delete all the rows from a table where the value of a column is less than a given value and the value of another column is greater than a given value. However, the table has a third column called "gender" and you should also consider deleting rows where the value of this column is not equal to...
codefeedback
Construct an SQL query to get the names, job titles, and total compensation (salary + bonus) of the employees who earn more than a given salary, have a job title of "Manager", and have worked in the company for at least 2 years. The total compensation should be calculated by summing the salary and bonus columns from th...
codefeedback
Write an SQL query to return the top 10 most frequent values of a given column from a table, along with their count. The column name is "gender". Additionally, exclude any values where the count is less than 100.
codefeedback
Construct an SQL query to find the average temperature for each month in the year, considering only the days when the temperature was above a certain threshold (e.g. 30 degrees Celsius). Additionally, retrieve the highest and lowest temperature for each month. Note: You can assume that the temperature values are store...
codefeedback
Clone a given repository and create a pull request with the following additional requirements: 1. Ensure that the pull request includes a detailed description of the changes made, including the reasoning behind the changes and any potential drawbacks. 2. Implement unit tests for all functions in the repository, achievi...
codefeedback
Write a SQL query for selecting all the people who were born after January 1st, 1960, have a last name that starts with the letter 'S', and have at least one child who was born after January 1st, 2000.
codefeedback
Construct an SQL query to select all the unique values of one column from a table that appear more than twice and are not NULL. Include the count of each unique value in the result set. The column must be of type VARCHAR(255) and must not contain any special characters or numbers.
codefeedback
Increase the difficulty of the given programming test question by adding a requirement to handle nested elements in the XML document. XML document: ```xml <?xml version="1.0"?> <catalog> <book id="bk101"> <author>Kerridge, Alan</author> <title>The Kitchen Diaries</title> <price>29.99</price> <reviews> <re...
codefeedback
Construct an SQL query to find the number of records where the value in a certain column is greater than a specified value, but the query should not use the ">" operator and should only use subqueries and aggregate functions.
codefeedback
Create a class in Python with one method called "talk" that prints a string when invoked. The method should only print the string if it is called within a specific time window of 9 AM to 5 PM. Additionally, the talk method should only print the string if it is called by a user with administrative privileges. To deter...
codefeedback
Write a CSS code to style a table such that each row alternates between three different colors. Additionally, the first row should have a different font color, background color, and font size than the rest of the rows.
codefeedback
Create an array of objects in JavaScript, each object should have four properties: "name", "age", "gender", and "occupation". The "name" property should be a string representing the name of the person, the "age" property should be a number representing the person's age, the "gender" property should be a string represen...
codefeedback
Write a SQL query to update all the records in the table with new values from another table, but also add a condition that only updates records where a specific column in the original table matches a value in the new table. Additionally, you are required to implement this query without using any subqueries or joins.
codefeedback
Create a Python class for a user object that includes a name, email, and age field. Additionally, the user object should have a method called `send_email` which takes a subject and body as parameters, checks if the user is above 18 years old, and prints out the email that will be sent. If the user is not above 18 years...
codefeedback
Create a SQL query for selecting the top 10 records in a table based on a given rating, and also display the average rating for those records. Additionally, filter the records to only include those with a rating higher than the average rating of all records in the table. #Solution# ```sql SELECT TOP 10 *, AVG(rating...
codefeedback
Create a MySQL query to list the authors along with the number of books they wrote, where the number of books should be greater than 5 and the authors should have at least one book published in the last year. Additionally, the query should exclude any authors who have more than 10 books published in total, and the resu...
codefeedback
Suggest changes to the following Java code so that it sorts an array of strings by the number of vowels in each string. Additionally, modify the code to sort the strings in descending order of the number of vowels. String[] data = {"Hello","Hi","Bye"}; Arrays.sort(data, new Comparator<String>() { @Override pu...
codefeedback
Write an Objective-C code to create a loop that iterates 10 million times, printing out the iteration number each time. However, for every prime iteration number, print out the iteration number followed by the square of the iteration number. Additionally, the code should not use any built-in Objective-C libraries or fu...
codefeedback
Create a CSS style to make all paragraphs with a bottom margin of 10px and a font size of 16px. Additionally, ensure that the paragraphs have a background color of #F5F5F5 and a text color of #333333. The style should only apply to paragraphs that are within a div element with the class "content". Furthermore, the para...
codefeedback
Create a Mongoose schema for a blog post with the following fields: title (String), body (String), isPublished (Boolean), and comments (Array of Objects). Each comment object should have the following fields: - author (String) - content (String) - createdAt (Date) The comments should be stored in chronological order...
codefeedback
Rewrite the following Python code to a Bash program. Write a Bash script that takes a single command line argument, which is a file name. The script should read the contents of the file, remove any blank lines, and print each non-blank line to the console. If the file does not exist or is not readable, the script shoul...
codefeedback
Create a React component that renders a text input field and a submit button. When the submit button is clicked, the input value should be displayed below the text input field. Additionally, the input value should be cleared after it is displayed. However, the component should also have a feature that allows the user t...
codefeedback
Produce an R code snippet to randomly sample k elements from vector x without using the built-in function `sample`. The value of k should be passed as an argument to the function. Additionally, ensure that the function has a time complexity of O(n) and a space complexity of O(1), where n is the length of vector x.
codefeedback
Generate a random 6-digit integer that does not contain any repeating digits. Then, calculate the sum of its digits.
codefeedback
Write a PHP code to validate a date in the format MM/DD/YYYY, considering leap years and the number of days in each month. Additionally, ensure that the date falls within a specified range, such as between 1900 and the current year.
codefeedback
Design a suitable data structure to hold a series of student records, considering the following requirements: 1. Each student record should contain the following information: - Student ID (unique identifier) - Name - Age - Grade - Address 2. The data structure should support the following operations: ...
codefeedback
Explain the difference between a for loop and a for...in loop in JavaScript, and provide specific use cases for when you would use each one to iterate through the elements in an array. Additionally, discuss the potential drawbacks or limitations of each type of loop and provide examples of alternative loop structures t...
codefeedback
Using recursion, write a Python program to find the sum of all prime numbers in a given range. Range: 1 to 100
codefeedback
Create a program to calculate the mean of the following list. However, you must only use a single line of code to achieve this. Additionally, you should handle any potential errors that may arise, such as empty lists or invalid input. #Erroneous Code# Create a program to calculate the mean of the following list. Howev...
codefeedback
Parse the given string and return a list of words. The implementation should be case-insensitive, meaning that the string "This is a Test String" should also be correctly parsed. In addition to being case-insensitive, the implementation should remove any punctuation marks from the string before parsing. Punctuation ma...
codefeedback
Compare the two strings using the given regular expression and return the number of matching characters. Additionally, if there are any characters that are present in string1 but not in string2 or vice versa, consider them as non-matching characters. Regular Expression: /^[a-z]+$/ Strings: string1 and string2 Constrain...
codefeedback
Write a query to select all rows from a table with the name "products" and the columns "price" and "quantity" where the price is greater than 10 and the quantity is less than 100. Also, include a condition where the product name starts with the letter "A" or ends with the letter "Z". Finally, sort the results in descen...
codefeedback
Rewrite the test to be more difficult: Write a program that validates whether a given string is a valid JSON object or not. In addition, your program should also check if the JSON object contains any nested objects or arrays, and validate their structure as well. You should implement this without using any built-in JS...
codefeedback
Return the number of elements in a dictionary, excluding any elements whose keys are numbers or whose values are dictionaries. If a value is a nested dictionary, you should count the number of elements in that dictionary as well. Additionally, handle cases where the dictionary is empty or where the dictionary values ar...
codefeedback
What are the two basic components of a computer system, and how do they interact with each other to perform tasks efficiently? Explain how this interaction is affected by the use of multithreading and how it can be optimized for parallel processing.
codefeedback