instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Find the most suitable 15-lines python code to generate all permutations of a 4 letters word. Additionally, make sure that the code does not use any built-in library functions for generating permutations.
codefeedback
Input a sentence with repeated words and write a Python code to remove all the repeated words. The sentence may contain punctuation marks and the words may be in mixed case. sentence = 'The the, cat cat! sat sat... on on the the mat!'
codefeedback
Construct a program to find the result of the following equation: (x-1)^2 + (2x-3)^2 + (3x-5)^2 + ... + (nx-(2n-1))^2 where n is a positive integer and x is any real number.
codefeedback
Write a Ruby method that takes two integers, n and m, as arguments and returns an array containing all the prime numbers between n and m, inclusive. If there are no prime numbers between n and m, the method should return an empty array. m = 20 n = 1
codefeedback
Input an array and remove all duplicates from the given array. The array can contain integers and strings. The order of the elements should be preserved. The output should be sorted in ascending order. If the array is empty, return an empty array. If there are no duplicates in the array, return the original array. Exa...
codefeedback
Create a function in C# that takes a string and returns true if all the characters are unique in the string. The function should have a time complexity of O(n) and a space complexity of O(1), where n is the length of the string.
codefeedback
Create a TensorFlow 2.0 program that takes a 3D array and normalizes the values by dividing each element by the sum of all elements in the array. Additionally, you must implement a custom loss function that penalizes the model based on the standard deviation of the normalized array. The loss function should be minimize...
codefeedback
Generate a PHP program to accept a string as an input and convert it to uppercase. The program should also remove any duplicate characters in the string and return the result in reverse order. Additionally, the program should only use a single loop to accomplish these tasks.
codefeedback
What is the most efficient way to insert a new element into an existing unsorted array, without using any built-in array functions or methods?
codefeedback
Construct a data structure to store a dictionary of words and their definitions. Implement methods to add a word and its definition, retrieve the definition of a word, update the definition of a word, and delete a word from the dictionary. The data structure should have an efficient retrieval and update time complexity...
codefeedback
Reverse an array of integers using Python. The array should be reversed in place, without creating a new array. You are not allowed to use any built-in functions or methods for reversing the array. You must implement your own algorithm to reverse the array. Additionally, the time complexity of your algorithm should be ...
codefeedback
Create an HTML page that displays one web page with two vertical panels. The left panel should contain a form with at least three input fields and a submit button. The right panel should display a table that dynamically updates with the submitted form data. The form should include validation for the input fields, ensur...
codefeedback
Rewrite the following Ruby method using an empty line between each statement. Additionally, the function should only multiply elements in the array that are greater than 5.
codefeedback
Write a shell script that takes an address as input and opens the corresponding website in the default web browser. However, the script should also include the following additional features: 1. Validate the address input to ensure it is a valid URL. 2. Implement a timeout feature, where if the website does not load wi...
codefeedback
Given a SQL table of user accounts, write a SQL query to find the account with the lowest number of login attempts. Additionally, return the account with the highest number of failed login attempts.
codefeedback
Write a program in any programming language that takes a string as input and counts the number of unique characters in the string. The program should then print the count of each unique character in descending order along with the character itself. The program should also ignore whitespace characters and consider upper...
codefeedback
Write a code to reverse a stack without using any additional data structures and return the modified stack. Stack: [1, 2, 3, 4, 5]
codefeedback
Write a code in C# to convert a decimal number to binary format without using bitwise operators or the built-in Convert.ToString() function. The converted binary number should be stored as a string. Example input: 15 Example output: "1111"
codefeedback
Create an array of size 1,000,000 in Java and assign random values from 1 to 1,000,000 to each item of the array.
codefeedback
Write a SQL query to find all the students with a last name beginning with 'D' and whose first name contains at least 3 vowels.
codefeedback
Find the 5th largest element in the list in Python. Return the index of the element in the original list. list = [12, 34, 87, 90, 80, 21] #Solution#
codefeedback
Extract the sum of all numeric values from the following string in Python. myString = "The length of the tree is 25 meters, and the height of the tree is 15 meters"
codefeedback
Given a list of student's grades, write a program to calculate their average. However, the program should only consider grades that are above 70. If there are no grades above 70, the program should output a message indicating that there are no valid grades. Additionally, the program should also calculate and display th...
codefeedback
Find the middle element of a given linked list. If the length of the linked list is odd, return the middle element. If the length of the linked list is even, return the second middle element. Example: 1 -> 2 -> 3 -> 4 -> 5 -> 6 Expected output: 4
codefeedback
Create a query in SQL to find the product IDs and names of all items having a given color and a price lower than a certain threshold. color = "red" max_price = 100
codefeedback
Generate a random password using a given string of characters. The password must contain at least one uppercase letter, one lowercase letter, one special character, and one digit. The length of the password should be between 10 and 20 characters.
codefeedback
Assign a numerical value to a given string where each letter is mapped to a prime number and the final value is the product of all the prime numbers corresponding to the letters in the string. For example: Input: "Apple" Output: 120 Explanation: The prime numbers corresponding to the letters in the string "Apple" are...
codefeedback
Create a web form in HTML with two fields - first name and last name. Add a validation mechanism to ensure that the first name and last name fields cannot be left empty. Additionally, implement a character limit for both fields - the first name field should accept a maximum of 20 characters, and the last name field s...
codefeedback
Create a regex pattern in Python that can extract URLs from a text string. The URLs can be in any format (e.g. http://www.example.com, www.example.com, example.com) and can have additional query parameters or anchors. The extracted URLs should be stored in a list and printed out. If there are no URLs found, print "No U...
codefeedback
Design a method in Ruby that can be used to determine if a given number is a prime number or not. The method should use the Miller-Rabin primality test algorithm instead of a basic prime number checking algorithm. number = 13
codefeedback
Generate a method in C++ to sort a given array in descending order. The array may contain duplicate elements. The time complexity of the algorithm should not exceed O(n log n), where n is the size of the array. The space complexity should not exceed O(1). Additionally, the algorithm should be able to handle large array...
codefeedback
Analyze the following code and answer the following question: Is there a bug in this code? def foo(num): if num == 0: return 1 else: return foo(num + 1) # Erroneous Code # def foo(num): if num == 0: return 1 else: return foo(num - 1) + 1
codefeedback
Develop a machine learning model in Python to predict the credit risk of a customer based on their bank transaction data. ### Problem Statement ### You are given a dataset consisting of bank transaction data for multiple customers. Each row in the dataset represents a transaction and contains the following information...
codefeedback
Generate HTML code for a table that displays the result of multiplication for the numbers from 1 to 10, but exclude any multiplication results that are divisible by 5.
codefeedback
Given the following array, delete all occurrences of the number 4 and return the resulting array. list1 = [4, 3, 4, 2, 3, 4, 4] #Difficulty Increased Test#
codefeedback
Create a method to convert a given number to Roman numeral format. The number will always be less than or equal to 3999. Example: Input: 2020 Output: MMXX
codefeedback
Write an SQL query to find all customers in the table 'customers' who have bought more than 3 items from the store, ordered by the total amount spent by each customer. The query should also include the customer's name, email, and phone number.
codefeedback
Design a CSS style to make an element a circle and have a red border. However, the border should only be visible on the left side of the circle.
codefeedback
Write a function to take a list of strings and return true if any element in the list starts with the letter "t". However, if any element in the list starts with the letter "t", the function should also check if the length of that string is greater than 3.
codefeedback
Construct a C++ code snippet to output a Fibonacci sequence with a given number of elements, where the given number of elements can be very large (up to 10^9).
codefeedback
Create a program in python that sorts a given list of integers in descending order, without using any built-in sorting functions or methods.
codefeedback
Generate a Python code snippet to print the list of numbers from 0 to 1000, excluding all numbers that are divisible by 3 or 5.
codefeedback
Create a function that processes an array to remove all the duplicated elements, and then sorts the array in ascending order. Example: Input: [1, 1, 2, 5, 6, 6, 10] Output: [1, 2, 5, 6, 10] Note: - The input array can contain positive and negative integers. - The input array can be of any length. - The output array s...
codefeedback
Design a C++ program to convert a given number from binary to decimal, ensuring that the binary number is no more than 8 bits in length. The program should also handle negative binary numbers and display the decimal result as a signed integer. <<noinput>>
codefeedback
Construct a class to represent a basic calculator with functions for addition, subtraction, multiplication, and division. The calculator should also include functionality for calculating the square root of a number and raising a number to a power. The calculator should only accept positive numbers as input and should h...
codefeedback
Write a function to create a matrix NxN with values of 0 filled in, where N is a prime number.
codefeedback
Create a program for calculating the surface area of a cube using only bitwise operations.
codefeedback
Design a function to calculate the GCD (greatest common divisor) of two given integers. However, you are not allowed to use any built-in functions or libraries to calculate the GCD. You must implement the algorithm from scratch.
codefeedback
Design a function to input an array and sort it using QuickSort algorithm. Additionally, the function should handle arrays with duplicate elements.
codefeedback
Construct a script that takes inputs from the user and prints out the Fibonacci sequence up to a given number, but with the following additional requirements: 1. The script should use a recursive function to generate the Fibonacci sequence. 2. The script should implement memoization to optimize the recursive function a...
codefeedback
Write a Python code to generate random numbers from the given list [10, 20, 30, 40], ensuring that no number is repeated in the generated sequence.
codefeedback
Write a Python program to calculate the number of bits needed to represent the maximum possible integer in binary form.
codefeedback
Generate a SQL query to return a list of customers who ordered more than three items and whose total order amount is greater than $100.
codefeedback
Remove any element from an array that is greater than 10 and less than 20, and then sort the remaining elements in descending order. [3, 5, 10, 20, 7]
codefeedback
Write a SQL query to find the average score of students who are aged between 20 and 23 and have a GPA higher than 3.5.
codefeedback
Write a multi-line comment in Python describing what the following program does, and include an intentional error in the code snippet. def hello(): print("Hello World" #Erroneous code reference# Write a multi-line comment in Python describing what the following program does, and include an intentional error in the...
codefeedback
Find the largest key in a dictionary that contains both positive and negative integers, and return its corresponding value. You are not allowed to use built-in functions for sorting or finding the maximum value. The dictionary may contain duplicate keys and the largest key may have multiple values. {'a': -3, 'b': 5, 'c...
codefeedback
Given a matrix of X, Y coordinates, write a Python function that returns the angle between the two points. The coordinates are represented as tuples (X, Y). X1 = 2 Y1 = 3 X2 = 7 Y2 = 10 For example, for the given coordinates (2, 3) and (7, 10), the function should return the angle in degrees. Note: The angle should...
codefeedback
Create a function that takes in two sorted arrays of integers and returns a new array containing the common elements between the two arrays. The function should handle arrays of any size and there should be no duplicate elements in the output array. Additionally, the function should have a time complexity of O(n), wher...
codefeedback
Create a MongoDB query to get the average salary for all employees who have been with the company for at least 5 years and have a job title of "Senior Software Engineer".
codefeedback
Convert the Python code using the range function in the for loop to a list comprehension statement. The list comprehension statement should also filter out numbers that are multiples of 3. The resulting list should only contain numbers that are multiples of 2. my_list = [] for i in range(10): if i % 3 == 0: continue if...
codefeedback
Write a program that prompts the user to enter a list of temperatures in Celsius and converts them to Fahrenheit. The program should then calculate and display the average, minimum, and maximum temperature in Fahrenheit. #Additional Requirements# 1. The program should validate the input to ensure that only valid tempe...
codefeedback
Write an SQL query to find the oldest user in the users table, considering only users who have at least 5 years of active membership.
codefeedback
Write a JavaScript code snippet to sort an array of objects by a given property name in descending order. Additionally, if two objects have the same property value, sort them by another property called "weight" in ascending order. If "weight" is also the same for two objects, sort them by the "name" property in alphabe...
codefeedback
In the following JavaScript function, edit the function body so that it returns the number stored in the variable 'currentNum' divided by 5 and then subtracted by 3. function subtractFive(currentNum) { // TODO }
codefeedback
Create a function in Java to remove values from an array that are greater than a given number, but only if the sum of their digits is a prime number.
codefeedback
Write a JavaScript code to print the characters of a string one by one in an alert message, but with a twist. Instead of using the usual alert function, you must create a custom function called "printCharacter" that takes in a string and displays each character individually. The function should also handle any errors t...
codefeedback
Create a Java program for finding the first non-repeated character in a string, while ignoring any whitespace characters. String: hello world
codefeedback
Create a C++ program for computing the sum of the digits in a number, where the number can have up to 10^9 digits.
codefeedback
Find the slope of this line, given a set of n points (x, y).
codefeedback
Identify the wrong statement about the recursive function in the given code. The function should also return the number of times the recursive function was called.
codefeedback
Generate a regular expression that matches strings containing any number of digits, but does not contain any non-digit character. Additionally, the regular expression should not match any string that ends with a digit.
codefeedback
Write an angular directive to highlight the selected word in a text, but only if it is preceded by a certain pattern of letters and followed by a certain pattern of letters.
codefeedback
Write an HTML program to create a complex page layout with multiple columns, responsive design, and a sticky navigation bar.
codefeedback
Edit the given HTML code so that the paragraphs are numbered in ascending order starting from 1. Each paragraph should be enclosed within a <div> tag. The numbering should be displayed on the left side of each paragraph.
codefeedback
Create a regular expression to match a string that contains a number followed by a letter and is at least 6 characters long.
codefeedback
Edit the SQL query to get the users from Canada who joined within the last 6 months and have made at least 5 purchases. SELECT * FROM users INNER JOIN purchases ON users.id = purchases.user_id WHERE users.country = 'Canada' AND users.join_date >= DATE_SUB(NOW(), INTERVAL 6 MONTH) GROUP BY users.id HAVING COUNT(purchase...
codefeedback
Write a Java program to calculate the exponential value of a number using only basic arithmetic operations (addition, subtraction, multiplication, and division) and loops. Do not use any built-in libraries or functions for exponentiation.
codefeedback
Generate a unique ID string in Java that adheres to the following requirements: the string must contain at least 10 characters, it must start with a capital letter, it must include at least one special character, and it must not contain any repeating characters.
codefeedback
Develop a high-level algorithm for pathfinding that can handle large graphs efficiently, with a maximum time complexity of O(n log n).
codefeedback
Using React, create a component to display a table containing a list of cities. The table should have the following columns: City Name, Population, Average Temperature, and Number of Tourist Attractions. The table should be sortable by each column in both ascending and descending order. Additionally, the component shou...
codefeedback
Extract the digits from a given string and return them as a list, without using any built-in functions or regular expressions. The input string may contain both letters and digits, and may have leading or trailing whitespace. The output list should contain the digits in the same order as they appear in the string. You ...
codefeedback
Write a JavaScript function to convert the given string to title case, but excluding certain words from being capitalized. The excluded words are: "the", "and", "or", "but".
codefeedback
Write a React component to display a list of all the countries, sorting them alphabetically. Additionally, the component should allow users to filter the countries based on their population size, with options to display only countries with populations above 10 million or below 1 million.
codefeedback
Write a SQL query to retrieve all unique customers who have made more than 10 purchases in the past month, ordered by the total amount spent.
codefeedback
Write a C program to find the difference between the maximum and minimum values in an array, without using any loops or recursion. You are only allowed to use the following functions: malloc(), free(), printf(), and scanf(). arr = {2, 8, 10, 9}
codefeedback
Solve the following problem. Given an array of positive integers, return an array with the elements multiplied by three and sorted in descending order. arr = [4, 12, 8, 6]
codefeedback
How can you validate a credit card number using JavaScript, while also considering potential errors in the code and adding error handling mechanisms?
codefeedback
Calculate the value of PI using the Leibniz formula, but ensure that the calculation is accurate up to at least 100 decimal places.
codefeedback
Write a SQL query to get the names, total number of orders, and average order amount for each customer in a table called 'orders'.
codefeedback
Write a C++ program to print the first N terms of the following sequence: 1, 3, 7, 15, 31, 63, .... where each term is obtained by adding 2 raised to the power of its position index starting from 0. For example, the first term is 1 (2^0), the second term is 3 (2^1 + 2^0), the third term is 7 (2^2 + 2^1 + 2^0), and so o...
codefeedback
Write a function in C++ that takes in a string of text and removes all the punctuation from the string. Additionally, the function should also remove any numbers from the string. The function should return the modified string.
codefeedback
Read a code that prints out the Fibonacci Series up to a given number. The code should also calculate and print the sum of all the numbers in the Fibonacci Series.
codefeedback
You are given a list of integers and need to calculate the maximum number in the list. However, you are not allowed to use any built-in functions or methods to find the maximum value. You need to implement your own algorithm to solve this problem. Also, the list may contain negative numbers. You need to handle this ca...
codefeedback
Create a Python class for a movie instance with the following fields: name (string), director (string), year (integer), and rating (float). Implement the following methods: 1. `get_name()`: Returns the name of the movie. 2. `get_director()`: Returns the name of the director of the movie. 3. `get_year()`: Returns the y...
codefeedback
Create a function in JavaScript that squares a given number, but with the restriction that you cannot use the multiplication or exponentiation operators.
codefeedback
Create a code that recognizes if an inputted string is a palindrome or not. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward. The code should handle cases with spaces and punctuation marks as well. #Further Explanation# - The code should ignore any space...
codefeedback
Create a function in Python that prints out all prime numbers between two given numbers. Additionally, the function should implement error handling to handle cases where the given numbers are negative or the second number is smaller than the first number.
codefeedback
Create a function in JavaScript that calculates the area of a rectangular room given its width and length. The function should also handle irregular-shaped rooms by accepting an optional parameter for the number of sides in the room, and an array of lengths for each side. Additionally, the function should validate the ...
codefeedback
Explain the practical application and limitations of sorting algorithms in the context of large-scale data processing and real-time systems.
codefeedback