instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Write a Bash script for downloading a web page from the internet, parsing its HTML content to extract all the hyperlinks present in the page, and then saving each hyperlink in a separate file.
codefeedback
Sort a string in alphabetical order. The string may contain both uppercase and lowercase letters, as well as special characters. The sort should be case-insensitive and the special characters should be placed at the end of the sorted string. Example: Input: "dcba!ZYX" Output: "abcdXYZ!" Note: The time complexity of...
codefeedback
Write an algorithm in Python to find the number of distinct words in a given sentence, ignoring case sensitivity and excluding any punctuation marks. "The quick brown fox jumps over the lazy dog."
codefeedback
Implement a k-nearest neighbors algorithm to predict point labels. Additionally, handle the case where there are ties in the voting process by implementing a tie-breaking mechanism.
codefeedback
Create a MySQL query that returns all the names of the students who have a grade greater than or equal to 7 and are enrolled in at least two courses. Table 1: Students Columns: student_id, name, grade Table 2: Courses Columns: course_id, course_name, student_id
codefeedback
Create a Java program that removes duplicate elements from an array and sorts the remaining elements in ascending order. The program should also keep track of the number of times each unique element occurs in the array and display the frequency of each element after removing duplicates. The array should contain at leas...
codefeedback
Write a code to select all columns from a table named 'students' where the age is between 22 and 28 and the student has at least one grade above 90.
codefeedback
Write a Python program to get the IP address from a given hostname, google.com. The program should also check if the given hostname is valid and return an error message if it is not. Additionally, the program should provide an option to resolve the IP address using both IPv4 and IPv6.
codefeedback
Create a database query in SQL to filter records within a particular range and sort them in descending order based on the length of the name attribute. Table Name: records Attributes: id (INTEGER), name (TEXT), start_date (DATE), end_date (DATE)
codefeedback
Write a JavaScript function that takes two parameters: the number of columns and the number of rows, and builds an HTML table with the specified number of columns and rows. Each cell in the table should contain a unique number, starting from 1 and incrementing by 1 for each subsequent cell. The table should have altern...
codefeedback
Design a fourth-order elliptic low-pass filter with a passband ripple of 0.1dB and a stopband attenuation of at least 60dB.
codefeedback
Find the largest prime number in an array of numbers. [5, 9, 40, 0.5, 3]
codefeedback
Convert an array from its x-coordinate values to an array of polar coordinates. The input array may contain up to 10^6 points.
codefeedback
In a given list, replace the even numbers by their square and the odd numbers by their cube. The list can contain up to 10^6 elements.
codefeedback
Consider the given list of tuples, remove the third element if it exists and the sum of the first two elements is greater than 8. Additionally, sort the list in descending order based on the first element of each tuple. data = [(1, 5), (3, 4), (2, 6, 4), (7, 2), (9, 1)]
codefeedback
Initialize a 2D array with random integers between 1 and 100. Time complexity requirement: O(n^2), where n is the size of the 2D array. Space complexity requirement: O(n^2), where n is the size of the 2D array. Note: The above requirements ensure that the algorithm runs efficiently even for large input sizes.
codefeedback
Given a 2D array, replace every element with the greatest element on its row. The input array will have at most 10 rows and 10 columns, and all elements will be non-negative integers less than or equal to 100. Additionally, you are required to use dynamic programming to solve this problem efficiently. Implement the fun...
codefeedback
Write a Python function that takes an expression stored as a string and returns the evaluated result. The expression will consist of addition, subtraction, multiplication, and division operations with integers and/or floating-point numbers. The expression may also contain parentheses for grouping operations. The functi...
codefeedback
Make a program that adds two numbers and checks if the sum is a prime number. Additionally, the program should only allow inputs between 1 and 100 and display an error message if the inputs are invalid.
codefeedback
Calculate the number of seconds in a year, considering leap years.
codefeedback
Change the value of the third element in the following array, but you are only allowed to use bitwise operations and must do so in a single line of code. int[] arr = {1, 3, 4, 5};
codefeedback
Create a database schema for managing authentication users, ensuring that each user has a unique username and password. Additionally, the schema should include a table for storing user roles and a table for storing user permissions.
codefeedback
Edit the given function in Python to convert the given list of integers a into a multidimensional list of size len(a) X len(a), where each element in the multidimensional list is a tuple consisting of two elements: the original element from list a and its index position in list a. Example: Input: a = [1, 2, 3] Output...
codefeedback
Write a function to implement a min-heap sort in JavaScript.
codefeedback
Edit the following HTML page to add a table with three rows and two columns. Each cell in the table should contain a random number between 1 and 10. Additionally, the table should have a border of 1px and a background color of light gray. The text in each cell should be centered and have a font size of 16px. The table ...
codefeedback
Implement a function in Python that takes a list of integers as input and returns the sum of all unique pairs of numbers that add up to a given target value. The function should have a time complexity of O(n), where n is the length of the input list.
codefeedback
Given two lists, create a function that finds the common elements between the two lists. The function should have a time complexity of O(n) and a space complexity of O(1), where n is the length of the longer list. list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] list2 = [2, 3, 4, 6, 7, 11, 12, 13, 14, 15] #Example Output# com...
codefeedback
Sort an array of positive integers in descending order using JavaScript. The array should contain at least 10 elements and no duplicates. The solution should have a time complexity of O(n log n) and use a custom sorting algorithm instead of built-in sorting functions. The output should be in the form of a new sorted ar...
codefeedback
Write a code block to return a random value from a given list that is greater than 10 and divisible by 2.
codefeedback
Given a valid XML string, write an XPath query to retrieve all the elements with the attribute "name" starting with the letter "c" and containing at least one subchild element.
codefeedback
Write a Ruby code to convert a double-linked list to a single-linked list without using any built-in methods or data structures.
codefeedback
Write a code to find all control characters, including carriage returns, line feeds, and tabs, inside a given string. The code should return the count of each type of control character found, as well as their respective positions in the string. For example, given the string 'This is a \r\nstring with\t some control ch...
codefeedback
Create a method to calculate the amount of tax to be paid based on the inputs of income, country, and marital status. The tax rates and income brackets for each country are as follows: Ireland: - Single: - Income up to 20000: 20% tax rate - Income between 20001 and 50000: 25% tax rate - Income above 50000: 30% ...
codefeedback
Generate three different sorting algorithms for a list of integers, but the algorithms must be implemented using only recursive functions and not use any built-in sorting functions or loops.
codefeedback
Create a SQL query to show all employee details with their attachments in a specific department, while also including the employee's attendance records for the past month. Additionally, order the results by the employee's salary in descending order.
codefeedback
Create a Ruby method to keep only text from a string and count the occurrences of each unique word. The method should return a hash where the keys are the unique words and the values are the number of occurrences. For example, for the input string "This is a string with numbers such as 1, 2, and 3 in it." the method s...
codefeedback
Read the following code and debug the errors. Implement a function called `double_up` that takes in a string as input and returns a new string that is formed by concatenating the input string with itself. Additionally, the function should return the character at the index equal to the length of the input string. Here ...
codefeedback
Create a HTML form with name, email address, phone number and a submit button. Validate the email address to ensure it is in a correct format. Additionally, use JavaScript to display an error message if the user submits the form without entering all required fields.
codefeedback
Create a class in C++ for a light emitting diode (LED) object that describes the color and intensity of the LED. Implement a method that allows the user to set the color of the LED using an RGB (red, green, blue) color model. Additionally, provide a method to increase or decrease the intensity of the LED by a specified...
codefeedback
Given two strings, write a Python function to check if they are anagrams. An anagram is a word or phrase formed by rearranging the letters of another word or phrase. In this case, consider all characters in the strings, including spaces and punctuation marks, and take their case into account. Return True if the strings...
codefeedback
Write a JavaScript code to sort an array of employee objects from oldest to youngest based on age property. Additionally, implement the following requirements: 1. If two employees have the same age, sort them alphabetically by their name in ascending order. 2. Ensure that the sorting algorithm is efficient and has a t...
codefeedback
Create a HTML form for inputting an email address. The form should have the following requirements: 1. The form should include a label with the text "Email Address". 2. The form should include an input field for entering the email address. 3. The input field should have a placeholder text of "Enter your email address"....
codefeedback
Given a string, replace characters with their corresponding HTML entities. The HTML entities should be determined based on the ASCII value of each character in the string. The ASCII value of a character can be obtained using the ord() function in Python. For each character in the string, if the ASCII value is less tha...
codefeedback
Given a string, the task is to output a new string with all repeating continuous characters collapsed to a single character. The string should only contain alphabetic characters in lowercase. The output string should also maintain the original order of the characters. If a character is repeated multiple times consecuti...
codefeedback
How can we use a list comprehension to make a copy of a given list, while also excluding any duplicate elements from the original list?
codefeedback
Write a TensorFlow program to construct a convolutional neural network with at least three layers and implement batch normalization and dropout.
codefeedback
Modify the following JavaScript code to calculate the sum of the first 100 prime numbers and print the result on the console. var num1 = 10; var num2 = 20; Note: You may need to create a helper function to check if a number is prime.
codefeedback
Create an API request to send a POST request with a body in JSON format to the endpoint "https://example.com/orders". Requirements: 1. The API request must include the following headers: - Content-Type: application/json - Authorization: Bearer {access_token} 2. The request body must contain the following fields...
codefeedback
Write a CSS code snippet to make the <h1> text bold with font size of 24px and apply a text shadow with a blur radius of 2px and a horizontal and vertical offset of 1px.
codefeedback
Transform an array of objects using JavaScript Write a function that takes an array of objects as input and returns a new array with the same objects, but with an additional property called "fullName" that concatenates the "name" and "age" properties. The "name" property should be capitalized and the "age" property sh...
codefeedback
Construct a for-loop to iterate through a given list of strings and print each member one line at a time. However, you should now reverse the order of the strings before printing them. word_list = ["hello", "world", "!"]
codefeedback
Find the square root of the sum of all prime numbers between 1 and 1000 using JavaScript.
codefeedback
Create a function that takes in a string of HTML code and a font size value as parameters. The function should change the font size of all the <p> elements in the HTML code to the specified font size value and return the modified HTML code.
codefeedback
Write a Python function to calculate the sum of all items in a given dictionary with integer values. The dictionary may contain nested dictionaries as values, and the function should recursively calculate the sum of all integers in the dictionary. Example: Input: {'a': 5, 'b': 10, 'c': {'d': 3, 'e': {'f': 2}}} Output:...
codefeedback
Write a C# program to take a given number and print it in words, but with the following requirements: - The number should be limited to a range of 1 to 10,000. - The program should handle negative numbers and print them as "negative" followed by the words for the absolute value of the number. - The program should handl...
codefeedback
Write a Python script to calculate the total, the average, and the median of an array of numbers. If the array has an odd length, the median is the middle element. If the array has an even length, the median is the average of the two middle elements. arr = [56, 23, 89, 17, 13, 10, 42]
codefeedback
Write an SQL query to find all the records in the "Orders" table that have a price greater than $1000 and have an item name that starts with the letter "A".
codefeedback
Sort a JavaScript array of objects by a given property, but only include objects that meet a certain condition. Additionally, the property to sort by should be a nested property within each object. arr = [ {name:"Harry", age:25, address: {city: "New York", country: "USA"}}, {name:"John", age:30, address: {city: "Lon...
codefeedback
Construct an if-statement to check whether the given element is present in a sorted array or not. The array is guaranteed to be sorted in ascending order. The time complexity of the solution should be O(log n), where n is the size of the array. arr = [1, 3, 5, 7, 9, 11] element = 7
codefeedback
Use a regex expression to find all the words that begin with a "t" and end with an "e" in the following sentence. However, the regex expression should not include any words that contain the letter "a" in them. sentence = "The dark night was quite and still"
codefeedback
Using the JavaScript Math object, calculate the sine of an angle within the range of 0 to 90 degrees, rounded to 2 decimal places.
codefeedback
What is the result of performing arithmetic subtraction between two numbers, 5 and 2, using only bitwise operators?
codefeedback
Implement a function that swaps the places of the first and last elements in a list of integers. my_list = [10, 20, 30, 40, 50]
codefeedback
Generate a C++ function to print the Fibonacci series using recursion and memoization.
codefeedback
Using the given variables, create an if-else statement that prints "You are an adult" when age is greater than or equal to 18, otherwise print "You are a minor". Additionally, if the age is less than 0 or greater than 120, print "Invalid age entered".
codefeedback
Implement a function that creates a dictionary from two lists which contain the keys and values, respectively. The function should handle cases where the keys list may contain duplicate values and the values list may contain different data types. Additionally, the function should ignore any keys that are empty strings ...
codefeedback
How would you limit the output of a SQL query to the first 10 rows, only considering the rows with an even ID?
codefeedback
Write a function in R to filter out the words containing more than 8 letters and do not use the built-in R functions like `filter()` or `grep()`.
codefeedback
Create a class "Person" in Kotlin with first name, last name, and age as its fields. However, the age field should be private and can only be accessed through a getter method. Additionally, the class should have a companion object called "Utils" that contains a static method called "calculateAgeInMonths" which takes t...
codefeedback
Write a neural network in Keras that can distinguish between 10 different species of animals.
codefeedback
Write code in Swift to print the Fibonacci Sequence to the first 50 prime numbers.
codefeedback
Take the following code and convert it from a for loop to a While loop. Additionally, you must now only print the squares of the odd numbers in the list "nums". You are not allowed to use the modulus operator (%) to determine if a number is odd or even. You should write a separate function called "is_odd" that takes in...
codefeedback
Write a code that takes two lists and find the longest common starting substring, considering only substrings of length greater than or equal to 3 characters. list1 = ['cat', 'car', 'camel'] list2 = ['carry', 'cap', 'caterpillar']
codefeedback
Write a Python code that takes a string and replace all the non-alphanumeric characters with a given character. The code should handle strings of any length efficiently. string = 'Hello, world!' character = '#' Example Input: string = 'Hello, world!' character = '#' Example Output: 'H#ll#, w#rld#'
codefeedback
Generate a new list from an old list by multiplying each element of the old list with a given number, and sorting the resulting list in descending order. The old list must have at least 3 elements. numbers = [2, 4, 6, 8, 10] multiply = 5
codefeedback
Create a Kendo-UI application to display an interactive grid with the following options: sorting, pagination, search filter, and editable cells. In addition to the above requirements, the application should allow the user to perform CRUD operations on the grid data. The user should be able to add new rows, edit existi...
codefeedback
Sort the given list of words in descending order based on the length of each word. If two or more words have the same length, sort them in alphabetical order. Return the sorted list. words = ['daisy', 'apple', 'cat', 'zebra']
codefeedback
Write a code that takes a positive integer and prints it out in words. The program should handle numbers up to 9999. Example: Input: 567 Output: "Five Hundred Sixty Seven" To achieve this, you should implement the following steps: 1. Read the input number. 2. Define arrays or dictionaries to store the words correspon...
codefeedback
Identify common elements between two given lists and return them in sorted order. The input lists can contain duplicate elements. list1 = [1, 2, 2, 3, 4, 5] list2 = [2, 4, 6, 8, 10, 10] Time complexity should be less than O(n^2) and space complexity should be less than O(n), where n is the length of the longest input ...
codefeedback
Design a database schema for a medical records system that can handle a large volume of data efficiently and ensures data integrity. The system should support the following functionalities: 1. Store patient information, including name, date of birth, gender, contact details, and medical history. 2. Store doctor inform...
codefeedback
Write a code to find the maximum of four numbers using nested if statements.
codefeedback
Generate a recursive function for the following task: Given a list of integers, "find the max element present in the list" using the following steps: 1. If the list is empty, return None. 2. If the list contains only one element, return that element. 3. Divide the list into two halves. 4. Recursively find the maximum ...
codefeedback
Create a function in Python that takes a string and prints the frequency table of all its alphanumeric characters, excluding any special characters or whitespaces. The output should be sorted in descending order of frequency. Example input: string = "Hello world! 123" Expected output: l: 3 o: 2 1: 1 2: 1 3: 1 e: 1 H...
codefeedback
Create a bash script that prints out a sequence of prime numbers between 0 and 100.
codefeedback
Create a program in C++ to find the maximum and minimum elements in an array of fixed size. The program should have a time complexity of O(n) and should not use any built-in sorting functions or data structures. Example: Input: array = [3, 5, 8, 6, 10, 1] Output: Maximum: 10, Minimum: 1 Note: The array will always ha...
codefeedback
Create a SQL query to find all records from the table "licenses" with license state "CA" and expiration date within the next 30 days.
codefeedback
Given a list containing strings, write a Python program to filter out unique strings and return them in descending order based on their lengths. # Example: Input: ["fox", "fox", "cat", "dog", "dog"] Output: ["fox", "cat"] # Constraints: - The input list can contain up to 10^6 strings. - The length of each string can ...
codefeedback
Write a code to print all prime numbers up to 100000. Additional Requirement: - Optimize the code to improve its efficiency.
codefeedback
Create a function that takes in a list of integers and returns a new list containing only the prime numbers in the original list.
codefeedback
Create a class in Java that represents a bank account. The class should have the following private variables: accountNumber (String), accountHolderName (String), accountBalance (double), and isActive (boolean). The class should have a constructor that takes in the accountNumber and accountHolderName as parameters and...
codefeedback
Create a convolutional neural network to classify images of handwritten digits.
codefeedback
Implement a multi-threaded Java program that simulates a bank transaction system. The program should support the following functionalities: 1. Create a bank account with an initial balance. 2. Allow multiple threads to withdraw or deposit funds into the account simultaneously. 3. Ensure thread safety and avoid race con...
codefeedback
Write a C++ program for sorting a given list of numbers using bubble sort algorithm. unsortedList = [7, 6, 5, 4, 3, 2, 1] Requirement: The bubble sort algorithm should be implemented using recursion instead of iteration.
codefeedback
Create a JavaScript function to encode a given string with Base64 encoding. The encoding should be case-sensitive and should not use any built-in Base64 encoding libraries or functions. The output should be in a specific format: each character in the encoded string should be represented by its ASCII value in hexadecima...
codefeedback
Create an array of size ten with every even slot filled with the value "even" and every odd slot filled with the value "odd".
codefeedback
Write an SQL query to select the names, salaries, and ages of employees from a table named 'employees', in ascending order of the salaries. Additionally, only include employees who have been with the company for more than 2 years.
codefeedback
Construct an XPath query to select all <h2> tags from a web page that have a class attribute starting with "title-" and containing the word "heading".
codefeedback
Describe how to access the fifth element in an associative array in PHP and then modify its value to "Hello World".
codefeedback
Write an SQL query to find the average salary for employees with the position of Manager at a company, while excluding any employees who have been with the company for less than 2 years.
codefeedback
Implement a custom sorting algorithm in C that has a time complexity of O(n log n) and sorts elements in descending order.
codefeedback