instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Write a function that takes an input string and finds the number of non-printable characters. Non-printable characters include any character that cannot be displayed on the screen, such as control characters, special characters, and whitespace characters. The function should also return a list of the non-printable char...
codefeedback
Generate a function to create a list of all prime factors for a given positive integer, excluding the number itself. The function should also return the count of prime factors and the sum of all prime factors.
codefeedback
Construct a program in Java for solving the Tower of Hanoi puzzle, with the additional requirement of finding the minimum number of moves needed to solve the puzzle.
codefeedback
Write a function that takes a SQL query as an argument and prints out the results of the query in a tabular format. The function should be able to handle the following types of SQL queries: 1. SELECT statements with multiple columns and multiple tables joined together. Example: SELECT columnA, columnB FROM tableA JOIN...
codefeedback
Generate a python code that takes a list of integers, prints out an array that is all True if the values are in the input list and all False otherwise. If the input list is empty, the program should print an error message. list_of_numbers = [5, 7, 10, 2]
codefeedback
Modify the program to take a given list of integers and returns the maximum and minimum values. The program should not use any built-in functions or methods to find the maximum and minimum values, and it should only iterate through the list once. Additionally, the program should handle the case when the list is empty a...
codefeedback
Create a function that takes in a string as input and checks if the string has unique characters or not. The function should return True if the string has all unique characters, and False otherwise. The input string will only contain lowercase alphabets and can have a maximum length of 10^6 characters. The function sh...
codefeedback
Write a code to change a string to have its first letter capitalized and the remaining characters in lower case. Additionally, handle the scenario where the input string may contain leading or trailing white spaces. mySTRING #Erroneous Code# Write a code to change a string to have its first letter capitalized and the...
codefeedback
Develop a regex pattern to match any valid phone number, where the phone number must include an area code starting with "1", followed by a hyphen ("-"), followed by a three-digit phone number, followed by a hyphen ("-"), followed by a four-digit phone number. The pattern should also allow for optional parentheses aroun...
codefeedback
Generate a random password of length 16 using at least 1 uppercase letter, 1 lowercase letter, 1 number, and 1 special character from the set {!, @, #, $, %, ^, &, *}
codefeedback
Create a script that can predict the next letter in a given string of text, based on a given pattern. The script should take two inputs: the pattern and the string of text. The pattern represents the sequence of letters that appear before the predicted letter. For example, if the pattern is "he", the script should pre...
codefeedback
Implement a class in Java that retrieves data from a database and performs CRUD (Create, Read, Update, Delete) operations on the data. Requirements: 1. The class should have methods for connecting to the database, executing SQL queries, and handling exceptions. 2. The class should be able to retrieve data from multipl...
codefeedback
Create a deep learning model to output a sentence in French when given an English sentence as input. The model should also take into account the sentiment of the input sentence and generate a response in French that reflects the sentiment appropriately.
codefeedback
Sort a list of words by the frequency of their occurrence, and then alphabetically if multiple words have the same frequency. Input: a list of n words (1 <= n <= 10^5), where each word has at most m characters (1 <= m <= 100) Output: a list of words sorted by their frequency in descending order, and then alphabetically...
codefeedback
Write a function that takes a string and returns the number of substrings with exactly k different characters.
codefeedback
Create a class that can represent a 2D coordinate system. The class should have the following functionality: 1. Create a new coordinate system with a specified origin point (x, y). 2. Retrieve the current origin point of the coordinate system. 3. Move the origin point by a specified amount of units in the x and/or y d...
codefeedback
Create a function that can transform a string of text into an object containing the number of occurrences of each letter and digit in the string. The function should handle both uppercase and lowercase letters. The function should also consider whitespace characters and special characters. The output object should be s...
codefeedback
Create a function which takes a list of integers as input, and returns the maximum value of the list. Additionally, the function should handle cases where the input list is empty or contains non-integer elements. In such cases, the function should raise appropriate exceptions or return an error message. Finally, you sh...
codefeedback
Write a function that takes a list of integers and returns the shortest continuous increasing subarray in the list. The subarray must contain an odd number of elements and the sum of all its elements must be a prime number.
codefeedback
Parse a complex XML document and return a nested JSON object containing the data. The XML document will have multiple levels of nested elements, and you should properly represent this nesting in the JSON object. For example: <library> <books> <book> <title>Cat in the Hat</title> <author>Dr. Seuss</au...
codefeedback
Create a class in Python to build a Frequency Table from a given array of numbers. The input array will contain both integers and floating-point numbers. The frequency table should include both the count and the percentage of each number in the array. The frequency table should be sorted in descending order based on th...
codefeedback
Implement a function that takes a 2D matrix and rotates the matrix 90 degrees clockwise. The matrix can be of any size. # Additional Information # The matrix can have any number of rows and columns. You need to rotate the matrix in-place, meaning you should modify the original matrix instead of creating a new one. # ...
codefeedback
Write a function to create a deep copy of a JSON object. Additionally, ensure that any circular references within the JSON object are also properly handled and not causing an infinite loop.
codefeedback
Create a function that takes a multi-level JSON object as an argument and prints out all keys with a value of type string. The JSON object can have nested objects and arrays. You need to recursively traverse the entire JSON object to find all the string values. Example JSON object: { "name": "John", "age": 34, "...
codefeedback
Write a Python function to check whether a string is a palindrome or not, ignoring spaces, special characters, and letter casing. In addition, the function should also return the longest palindrome substring found in the input string. Example: Input: "A man, a plan, a canal, Panama!" Output: (True, "amanaplanacanalp...
codefeedback
Write a function that checks if a given list of integers is sorted in ascending order, without using any built-in sorting functions.
codefeedback
Write an SQL query to identify unique months and years that appear in a table. Table: Appointments id | month | year Provide a piece of erroneous code as a reference to increase misdirection. #Erroneous Code Reference# SELECT DISTINCT month, year FROM Appointments WHERE year = '2021' AND month > '12' ORDER BY month D...
codefeedback
Given a 2D matrix of integers, find a path from the top-left corner to the bottom-right corner that maximizes the sum of numbers. You can only move right, down, or diagonally right-down. [[3,4,7,2], [2,7,4,1], [7,1,2,4], [8,2,2,7]] You can start at any position in the top row and move to the adjacent position in t...
codefeedback
How would you check if a list of integers contains only even numbers and sort the list in ascending order?
codefeedback
Given a 2D matrix of integers, retrieve the maximum sum submatrix. The matrix may contain negative integers. If the matrix is empty, return 0 as the maximum sum. If multiple submatrices have the same maximum sum, return any one of them. Example: Input: [[2,-2,3,4],[-4,-3,1,1],[-1,5,5,-3]] Output: 14 Input: [[-1,-2],...
codefeedback
Rewritten Test: Implement a Python function that takes in a list of integers and returns the sum of all the numbers using the reduce() function. The function should have the following signature: ```python def calculate_sum(numbers: List[int]) -> int: pass ``` The input list `numbers` will contain at least one int...
codefeedback
Write a shell script to print the longest word in a sentence. In addition, print the number of vowels in that word. string = "This is a sentence with words of different lengths"
codefeedback
Given two 2D arrays, array1 and array2, find the indices of the first occurrence of a submatrix in array1 that matches array2. A submatrix is a rectangular section of the larger matrix. The matching is determined by comparing the values in the corresponding positions of the submatrix and array2. For example: array1 =...
codefeedback
Write a script to iterate over all elements in a list, and sum up all integers greater than 5. The script should also exclude any duplicates from the sum and only consider integers that are divisible by 3. Additionally, you should implement the script in a recursive manner and ensure that it has a time complexity of O(...
codefeedback
Modify the JavaScript code given below to return the sum of all even numbers from 0 to 10 (inclusive) using a recursive function. function sum_(start, end) { // TODO return 0; }
codefeedback
Create a function that searches for elements in an array and returns the index position of the element. However, the array can now contain duplicate elements and the function should return the indices of all occurrences of the element in the array. array = [3, 7, 11, 14, 19, 11, 11] element = 11
codefeedback
Find the first occurrence of substring "data" in the given string. The string can contain any combination of uppercase and lowercase letters. The algorithm should be case-insensitive and return the index of the first occurrence. If the substring is not found, the algorithm should return -1. Example: String: "Data Scie...
codefeedback
Create a function that returns the reverse complement of a given DNA string. The reverse complement of a DNA string is formed by reversing the string and then replacing each nucleotide with its complement (A → T, C → G). Example: Input: "ATCGACG" Output: "CGTCGAT"
codefeedback
Pack a string of characters into an array of length 8 while ensuring that each character is unique and preserving their original order. Additionally, you need to implement a function that can handle strings with a variable length between 8 and 20 characters.
codefeedback
Modify the given code to find the factorial of a specified number. The input number should be a positive integer greater than or equal to 1. The function should handle cases where the input is not a positive integer by returning an error message. If the input is a negative number, the function should return the factori...
codefeedback
Create a text-based game in Python that includes a character creation system, multiple branching storylines, and at least three different game endings based on player choices.
codefeedback
Write a procedure in PL/SQL to count the number of employees in a company, but now consider the following additional requirements: 1. The procedure should only count the active employees, i.e., those who have not been terminated. 2. The procedure should take into account the department hierarchy. The count should incl...
codefeedback
Write an SQL query to retrieve customer emails ending in .net, and also include their corresponding order information such as order ID, order date, and total order amount.
codefeedback
Create a boolean condition to check if the value is a real number within the range of -1000 to 1000, inclusive.
codefeedback
Write a loop to iterate over a string and print each character on a new line, but do not use built-in functions or methods to iterate over the string. text = "Hello world!"
codefeedback
Create a function that evaluates the quadratic equation and returns both the real and complex roots. The function should handle quadratic equations with complex coefficients and display the results with a precision of up to 5 decimal places.
codefeedback
Create an array with 1 million random elements.
codefeedback
Create a SQL query to find the least expensive product, excluding any products that have been discontinued. Additionally, the query should also include the product category and supplier name for each product.
codefeedback
You need to trim a string by removing leading and trailing whitespace characters. Additionally, you should also remove any consecutive whitespace characters within the string. string = " hello world "
codefeedback
Implement a machine learning-based text classifier for recognizing phrases that are indicative of anger in a sentence, using at least three different algorithms. The classifier should have an accuracy of at least 90% on a test dataset consisting of 1000 sentences. The implementation should also include a mechanism for ...
codefeedback
Define a recursive function to print out the elements in a list without using a loop. The function should also include a counter to keep track of the number of elements printed and should stop printing after a specified number of elements.
codefeedback
Design a recursive algorithm to generate the Fibonacci sequence, but with the following additional requirement: The algorithm should also compute the sum of all the Fibonacci numbers up to a given index n.
codefeedback
Write a POST request to update a user's name in the following JSON format, ensuring that the name field is between 3 and 30 characters in length and does not contain any special characters or numbers.
codefeedback
Make an algorithm to rotate a matrix by 90 degrees in both clockwise and counterclockwise directions. Input: - A square matrix of size n x n Output: - The rotated matrix Example: Input: [[1,2,3], [4,5,6], [7,8,9]] Output (clockwise rotation): [[7,4,1], [8,5,2], [9,6,3]] Output (counterclockwise rotation): [[3...
codefeedback
Use Polyglot to detect the language of the following sentence and output the confidence score for each detected language. For example, if the sentence is "Dies ist ein Satz.", the expected output should be: - German: 0.9 - English: 0.05 - Dutch: 0.02 - French: 0.01 - Italian: 0.01 You should also handle cases where t...
codefeedback
Create a class in Java that performs the following task: print out all characters of a given string along with their position in the string, but only for vowels.
codefeedback
Write a stack-based language for a simple calculator that can perform the following tasks: Add, subtract, multiply, and divide integers. Additionally, the calculator should be able to handle parentheses to specify the order of operations, and it should support the use of variables to store and retrieve values.
codefeedback
Use regex to extract specific words between two delimiters in a sentence. The delimiters can be any non-alphanumeric characters. For example, given the following sentence: string = "This is a string with multiple words and special characters !@#" Write a function that takes in the sentence as input and returns a list...
codefeedback
Evaluate this code and output the result. x = 5 y = 7 z = 8 Step 1: Add x and y together. Step 2: Subtract z from the result of step 1. Step 3: Multiply the result of step 2 by x. Step 4: Divide the result of step 3 by y. Step 5: Add the result of step 4 to y. Step 6: Subtract z from the result of step 5. Step 7: Outp...
codefeedback
Create a function that filters an array for all numbers greater than the given number, and returns the filtered array in ascending order. #Further Increased Difficulty Test#
codefeedback
Write a SQL query to minimize the output of employee salaries without firing them, while also ensuring that the salary reduction does not exceed a certain threshold.
codefeedback
Create a React component that takes a zipcode as an input and displays the following information about the zipcode in a formatted way: 1. City name 2. State name 3. County name 4. Latitude 5. Longitude 6. Population To achieve this, you can make an API call to a third-party service like OpenWeatherMap or Google Maps G...
codefeedback
Create a function that returns the product of two integers. However, you are not allowed to use the multiplication operator (*) or any built-in multiplication functions. Your function should have a time complexity of O(log n), where n is the value of the larger integer.
codefeedback
Build a web application to display the current time in different countries, but also allow users to select a specific date and time to display in each country.
codefeedback
Create a Tkinter app with a label, a button, and a text entry field. The label should display a random number between 1 and 10 when the app is launched. The button should generate a new random number between 1 and 10 and update the label with the new number when clicked. The text entry field should allow the user to e...
codefeedback
Design an HTML form with five input fields, where the first input field accepts only numeric values, the second input field accepts only alphabetical characters, the third input field accepts only email addresses, the fourth input field accepts only dates in the format of "dd/mm/yyyy", and the fifth input field accepts...
codefeedback
Build a convolutional neural network using tensorflow that takes a single input and classify it into one of three categories. The input data consists of images of handwritten digits from the MNIST dataset. The network should have at least two convolutional layers with different filter sizes, followed by max pooling lay...
codefeedback
Write a highly efficient algorithm that verifies whether an integer is a prime number within a given range, and outputs the total count of prime numbers found within that range. The algorithm should take into account memory constraints and optimize for time complexity.
codefeedback
Use openssl to generate a RSA public/private key pair and store the private key in a password-protected PEM format. Then, write a program to read the private key from the PEM file and decrypt a given ciphertext using the RSA algorithm.
codefeedback
Write a program that uses supervised learning to perform sentiment analysis on customer reviews for a specific product.
codefeedback
Create a multi-threaded web server in Node.js that supports HTTP/2 and can handle thousands of concurrent connections. Implement efficient connection pooling and load balancing algorithms to distribute incoming requests across multiple worker threads. Ensure that the server can handle large file uploads and downloads e...
codefeedback
Create a function to filter out prime numbers from a given array. numbers = [-5, 3, 7, -2, 4, 9] Additional Requirements: 1. The function should return a new array containing only the prime numbers from the input array. 2. The function should not modify the original array. 3. The function should have a time complexit...
codefeedback
Increase the difficulty by asking the test-taker to convert the function from a for loop to a while loop without using any built-in functions or methods (e.g. no use of append()).
codefeedback
Create a REST API for getting information about weather for specific cities. The API should include the following features: 1. Allow users to retrieve weather information for a specific city by providing the city name as a query parameter. 2. The API should return the current temperature, humidity, and wind speed for ...
codefeedback
Given a list of strings, how can we print each string on a new line in C, ensuring that the program runs in O(n) time complexity, where n is the total number of characters in all the strings combined? Additionally, the program should not use any built-in string manipulation functions. The input list will not be empty a...
codefeedback
Write a Ruby program to check for the existence of a given value in an array and return the number of occurrences of that value. Given array: [1,2,3,4,5], value to be checked: 3. The program should also handle cases where the value to be checked is not present in the array and return 0 as the result.
codefeedback
Using the arrays below, write a function in JavaScript to find the pair of elements from array1 and array2 that have the maximum sum. The function should return the sum of the elements and the indices of the elements in their respective arrays. array1 = [1, 2, 3, 4] array2 = [5, 6, 7, 8] Example output: { sum: 15, ...
codefeedback
Increase the difficulty by requiring the program to also remove all numbers from the given string. #Rewritten Test# From a given string, remove all the punctuations and numbers. This is a string with punctuation and 123 numbers.
codefeedback
Write a HTML page that dynamically sets a random background color for each cell in a table. The background color should be a randomly generated hexadecimal color code in the format '#XXXXXX', where each X represents a random hexadecimal digit (0-9, A-F).
codefeedback
Write a JavaScript function that takes a string as input and replaces all non-alphabetical characters with the symbol '#'. The function should then return the modified string. For example, given the string "Hello, world!", the function should return "Hello#####world#". To solve this problem, you can follow these step...
codefeedback
Apply a modulo operation to each element in an integer array and return the sum of all the resulting values. ## Signature ```python def modulo_sum(arr: List[int], m: int) -> int: __input__ : a list arr of n (1 <= n <= 10^5) integers (0 <= arr[i] <= 10^5) an integer m (1 <= m <= 10^9) __output__...
codefeedback
Build a Python program to generate a prime numbers list in a given range, where the range is from 1 to 1,000,000 and the program should use a multi-threading approach to improve performance.
codefeedback
Create a GraphQL query to get the data from the given API, but only retrieve the users whose names start with the letter "A" and their email addresses. Additionally, sort the results in descending order based on the length of their email addresses.
codefeedback
Given an array of numbers, find their least common multiple (LCM). Example: Input: [15, 10, 5, 20] Output: 60 Note: - The input array will contain at least two numbers. - All numbers in the input array will be positive integers. - The LCM should be calculated efficiently, without using the built-in LCM function.
codefeedback
Given the following list, write a program to sort it in ascending order. Additionally, your program should handle duplicate values in the list and should not use any built-in sorting functions. You are allowed to use additional data structures. Original list: [3, 4, -5, 6, 1, -2]
codefeedback
Calculate the nth fibonacci number in the series, where n can be as large as 10^6.
codefeedback
Write a function that transposes a 2D array from column-major format to row-major format. The array is a square matrix where each element is a string representing a binary number. The function should convert each binary number to its corresponding decimal value and transpose the matrix accordingly.
codefeedback
Write an HTML page to display a dynamic table layout that allows users to add, edit, and delete rows. The table should have five columns with headings 'Name', 'Age', 'Occupation', 'Salary', and 'Actions'. The 'Actions' column should contain buttons to edit or delete each row. Additionally, the 'Salary' column should on...
codefeedback
Write a code to check if two rectangles overlap with each other. The rectangles are represented by their top-left and bottom-right coordinates. The input for the code will be two tuples, `rect1` and `rect2`, where each tuple contains the coordinates of the top-left and bottom-right points of a rectangle. The code sho...
codefeedback
Write a shell script that performs the following tasks: 1. Checks if Python 3 is already installed on the system. If it is, display a message indicating that Python 3 is already installed and exit the script. 2. If Python 3 is not installed, download the latest version of Python 3 from the official website. 3. Verify t...
codefeedback
Create a program that prints "Hello World" on the screen, but with the following additional requirements: 1. The program should prompt the user to enter their name before printing "Hello World". The program should then print "Hello, [name]" where [name] is the name entered by the user. 2. The program should also disp...
codefeedback
Write a RegEx expression to find substrings of length 5 that are lowercase and contain at least one special character.
codefeedback
Given a binary tree, write a function to print out the elements in level order. Additionally, implement a function that returns the average value of each level in the binary tree. #New Test#
codefeedback
Write a class in Java to convert a decimal number to its binary equivalent. Your implementation should not use any built-in functions or libraries for converting decimal numbers to binary.
codefeedback
Modify a given program to replace each element in an array with the sum of all elements before it, only using a single loop and without using any additional arrays or data structures. The modified program should have a time complexity of O(n), where n is the length of the input array. [1,2,3,4]
codefeedback
Write a class in JavaScript that can be used to create an instance of a Date. The class should have the following functionalities: 1. Accept a year, month, and day as arguments during instantiation and set them as instance variables. 2. Provide a method to get the current year. 3. Provide a method to get the current m...
codefeedback
Design an algorithm to rotate a given array in clockwise direction by a given index, but with the following additional constraints: 1. The algorithm should rotate the array in place, without using any additional memory. 2. The time complexity of the algorithm should be O(n), where n is the length of the array. 3. The a...
codefeedback
Create a function 'removeLetters' that takes a string and removes all instances of a given letter from it. The function should have a time complexity of O(n) and a space complexity of O(n), where n is the length of the string. The function should not use any built-in functions or libraries for removing characters from ...
codefeedback
Create an algorithm in Python to print the string “welcome” n times, but the number of times the string is printed should be determined by the following conditions: - If n is even, print the string n/2 times. - If n is odd, print the string (n+1)/2 times. - If n is a multiple of 3, print the string 2 times. - If n is a...
codefeedback
Create a Python function 'checkInteger' that takes a number and returns true if the number is an integer, false otherwise. The function should handle negative numbers as well. The number should be within the range of -10^9 to 10^9.
codefeedback