instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
Given a string of length n, find the number of distinct continuous substrings in the string. Constraints: - 1 ≤ n ≤ 10^6 - The string can contain uppercase and lowercase letters, digits, and special characters. Time complexity requirement: O(n^2) Space complexity requirement: O(n)
codefeedback
Rewrite the given string 'Hello World' to 'World Hello' using only constant space complexity (O(1)) and without using any built-in string manipulation functions.
codefeedback
Design a function to get the user input for a list of numbers and print the maximum among them. Additional requirements: 1. The function should handle both positive and negative numbers. 2. The function should handle floating-point numbers. 3. The function should handle cases where the user inputs invalid or non-numer...
codefeedback
Given a list of numbers, sort them in increasing order without using any built-in sorting functions or libraries. The solution should have a time complexity of O(n^2), where n is the length of the list, and a space complexity of O(1). nums = [10, 7, 3, 8, 2]
codefeedback
How can you efficiently find and prioritize the severity of multiple errors in a large codebase using an automated error tracking system?
codefeedback
Given two lists ``a`` and ``b``, calculate their difference and store the result in a list ``c``. The difference of two lists is defined as the elements that are present in ``a`` but not in ``b``. ``` a = [1, 2, 3] b = [2, 3, 4] ``` The expected output is: ``` c = [1] ```
codefeedback
Rearrange the given fragments of code in order to build an ``if ... else ...`` statement in Python. The code should include a nested if statement and an additional condition comparing the values of two variables. Print 'Success!' if the condition is true, otherwise print 'Failure!'.
codefeedback
Write a code to make an API call to a remote server and retrieve a list of users. Each user should have the following attributes: name, age, email, and address. Parse the response and display the information of each user in a formatted manner. Additionally, implement error handling to handle any possible exceptions tha...
codefeedback
Copy the following string without the middle word. If the middle word is 'brown', the expected output should be 'The quick fox'.
codefeedback
Create a function that finds all anagrams of a given word while also ensuring that the length of each anagram is less than or equal to the length of the given word. The function should return a list of anagrams in alphabetical order. word = "abbac"
codefeedback
How do you debug a multi-threaded application in Python using the `pdb` module and ensure thread synchronization with a global lock?
codefeedback
You are given a large text file with multiple lines of data. Each line contains a combination of alphanumeric characters and symbols. Write a Python function that uses regular expressions to extract all valid email addresses from the text file. Assume that an email address consists of a local part followed by the "@" s...
codefeedback
Write a Python code to solve a system of linear equations with two variables. Given the equations: 2x + 5y - 7z = 9 3x + 4y + 2z = 6 Your code should take the coefficients of x, y, and z as inputs, and return the values of x, y, and z that satisfy both equations.
codefeedback
How would you update the following code to iterate over a list of strings and print each string in reverse order? list_of_ints = [1, 2, 3, 4] for n in list_of_ints: print(str(n)[::-1])
codefeedback
Describe the result of running this code. obj = { 'a': 1, 'b': 2, 'c': 3 } for key in sorted(obj.keys()): print(key + ': ' + str(obj[key])) #Additional Instructions# 1. The code should run in O(n log n) time complexity, where n is the number of keys in the 'obj' dictionary. 2. Do not use any built-in...
codefeedback
Write a function that takes in a character and a positive integer N, and prints the character N times. The function should also check that the character is a letter (a-z or A-Z) before printing, and if it is not a letter, it should raise an exception with a custom error message. Additionally, the function should only a...
codefeedback
Find the area of a circle with radius 2, using only mathematical operations and without using any built-in functions or libraries.
codefeedback
Write a Python function that takes a list of strings as parameter and returns a dictionary with the strings as keys and the length of each string as value. The function should also handle cases where the input list contains duplicate strings, and the returned dictionary should only include the length of the first occur...
codefeedback
Write a Python program to create a function that takes two numbers as arguments and returns a list of all prime numbers between them. start_range = 2 end_range = 20
codefeedback
Write a Python program to convert an integer to a Roman numeral. The program should be able to handle input numbers up to 3999.
codefeedback
Write a Python program to remove duplicates from a list of dictionaries based on their values for a given key. The given key should be dynamically provided by the user as input. The program should then remove duplicates based on the provided key. The original_list should also be sorted based on the provided key in asce...
codefeedback
Write a Python program to compare two given lists and return True if their contents are the same, while also ensuring that the order of elements is also the same. list1 = [1, 3, 8, 9] list2 = [9, 1, 3, 8]
codefeedback
Write a SQL statement to retrieve the average salary of all employees for each department.
codefeedback
Explain the concept of polymorphism in object-oriented programming and provide an example code snippet to demonstrate its implementation.
codefeedback
Suggest a Python code for sorting a list of dictionaries based on ascending order of a given key. The key should be case-insensitive, meaning that the sorting should not be affected by the capitalization of the key's value. Additionally, if two or more dictionaries have the same value for the given key, they should be ...
codefeedback
Without using any built-in functions, generate a Python code to remove the duplicated elements in a list while maintaining the original order of the elements.
codefeedback
Write a MongoDB query to find which roles have both Permission 2 and Permission 3, and sort the result in descending order by the number of users assigned to each role.
codefeedback
Write a python script to print out a list comprehension that prints out all the prime numbers in a given range from 1 to 100.
codefeedback
Generate a complete javascript code that calls the fetch() API with a certain url https://www.example.com. The code should handle any potential errors that may occur during the API call, such as network issues or server errors. Additionally, the code should also include a timeout mechanism that cancels the API call if ...
codefeedback
Write a SQL statement to sort a list of employees in descending order based on their salary. Additionally, display the number of years each employee has been with the company and include a calculated column to show the average salary of all employees.
codefeedback
Create a loop to print out all prime numbers from 0 to 100.
codefeedback
Compute the cosine similarity of two vectors. Vectors: [2, 3, 1] and [4, -5, 2]
codefeedback
Write a PHP script to compare two strings and return the number of characters and words which are common in both strings, while ignoring case sensitivity. Additionally, you must exclude any common words that appear in a common dictionary.
codefeedback
Create a SQL query to list all the customers from the US who have made at least 5 purchases in the last month and have a total purchase amount greater than $1000.
codefeedback
Default a convolutional neural network architecture to classify the handwritten digit from 0 to 9. Additionally, implement a custom loss function that combines cross-entropy loss with a regularization term to prevent overfitting.
codefeedback
Create a function to generate Pythagorean Triples up to a given limit. The generated triples should satisfy the additional constraint that the sum of the three sides of each triple must be equal to or less than 50. Limit: 20
codefeedback
Given an array of integers, write a JavaScript function that removes all duplicate items from the array. The function should return the modified array without altering the order of the remaining elements. Example: Input: [20, 30, 20, 15, 30, 45] Output: [20, 30, 15, 45] You should not use any built-in functions or d...
codefeedback
Create a C# program to implement a search algorithm which returns the index or position of a given key in a two-dimensional array. The two-dimensional array should be dynamically generated and filled with random numbers between 1 and 100. The program should prompt the user to enter a key to search for, and then display...
codefeedback
Create a web page that prints out all of the array elements in reverse order using a doubly linked list. arr = [1, 2, 3, 4, 5]
codefeedback
What is the result of 3 + 4 * 9 - 2 + 5 / 3?
codefeedback
Convert the following SQL query into a Python pandas DataFrame. SELECT product.name, store.location, store.country FROM product INNER JOIN store ON product.store_id = store.store_id WHERE product.price > 100 (Note: The above query returns the name of the product, the location of the store, and the country of the store...
codefeedback
Create a function in C++ that takes an input string and removes all vowels from it. The function should also handle uppercase and lowercase vowels. The function should return the modified string. Input: "Hello, World!" Expected output: "Hll, Wrld!"
codefeedback
Create a function to print an inverted triangle. The function should take two parameters: the number of lines and the number of asterisks in each line. The function should display the specified number of lines with the specified number of asterisks in each line. The time complexity of the function should be O(n^2), wh...
codefeedback
Create a program to print the FizzBuzz series up to the 100th term.
codefeedback
Write a SQL query that returns all customers from the USA, along with their total number of orders and the average order value.
codefeedback
Write a regex pattern to match all words in a string that start with a lowercase letter and end with an uppercase letter.
codefeedback
Write a few lines of code that prints out a multiplication table up to 20x
codefeedback
Explain the time complexity of a sorting algorithm and describe one with a time complexity of O(n log n).
codefeedback
Write a code snippet that prints the current date and time in the format YYYY-MM-DD HH:MM:SS, taking into account the user's time zone and accounting for daylight saving time if applicable.
codefeedback
Create a program that takes a given string and returns the frequency of each alphabet character in descending order. Additionally, the program should ignore case sensitivity and consider only lowercase characters.
codefeedback
Write an algorithm to find the kth to last element in a singly linked list, where k is a positive integer less than or equal to the length of the list.
codefeedback
Create an array that contains the elements 1, 3, 5, 7, and 9 in random order, ensuring that no two adjacent elements have a difference of 2 or less.
codefeedback
Create a function that takes two strings and finds the longest common substring between them. The function should have a time complexity of O(n*m), where n is the length of the first string and m is the length of the second string.
codefeedback
Create an array containing 100 random numbers between 0 and 1000, such that no two numbers are the same.
codefeedback
Create a MySQL trigger to perform a data validation check when a new row is created. The trigger should validate that the inserted data satisfies a specific condition based on the values in other tables, and should rollback the transaction if the condition is not met.
codefeedback
How would you implement a simple object oriented Programming concept in Python while ensuring encapsulation and inheritance are properly utilized?
codefeedback
Write a code to edit a given column in an SQL table, while ensuring data integrity by implementing proper error handling and validation checks.
codefeedback
Define an operator which adds two points of a given type. Additionally, ensure that the operator can handle points of different dimensions and return the sum point accordingly.
codefeedback
Write a function which takes a C-style string as a parameter and reverses it in place, without using any additional storage. The function should modify the original string and return the reversed string.
codefeedback
Write a SQL query to return all data from the "customers" table where the customer's age is greater than 26 and their last name starts with the letter "S".
codefeedback
Identify and explain five major differences between C and C++. Additionally, provide an example of code that is valid in C but would result in a compilation error in C++.
codefeedback
Use a loop to print out a list of numbers, but each number should be squared and printed in reverse order.
codefeedback
Create an event handler for a double click event that updates a specific text field only when the mouse cursor is within a certain region on the screen.
codefeedback
Convert the given positive integer number less than 4000 to a Roman Numeral. The Roman Numeral should be in uppercase letters and follow the standard Roman Numeral representation.
codefeedback
Create a script in Python that plots a bar chart showing the count of beers sold in a bar in a particular week. The bar chart should also include the corresponding days of the week as x-axis labels. beer_sales = [200, 500, 600, 100, 800] week_days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'] Make sure t...
codefeedback
Implement a 3D vector class with the following methods: 1. Constructor: Initialize the vector with three components (x, y, z). 2. Dot product: Compute the dot product between two vectors. 3. Normalization: Normalize the vector to have a magnitude of 1. The vector class should also support the following operations: 4...
codefeedback
Rewrite the following SQL query into an active record query in Rails: SELECT c.name, o.order_date, COUNT(o.id) as order_count FROM customers c JOIN orders o ON c.id = o.customer_id GROUP BY c.name, o.order_date HAVING COUNT(o.id) > 5 ORDER BY c.name ASC, o.order_date DESC
codefeedback
Create a function in Python that takes a sentence as an argument and returns the formatted sentence with the first letter of each word capitalized. Additionally, the function should handle cases where the sentence starts with a number or special character, ensuring that the first letter of the first word is capitalized...
codefeedback
What is the purpose of the primary key in a database table and how is it different from a foreign key?
codefeedback
Write a R script that reads in a dataset containing information about different movies and performs the following tasks: 1. Calculate the average rating for each genre of movies. 2. Identify the movie with the highest rating in each genre. 3. Create a new dataset that includes only the movies with a rating above 8. 4....
codefeedback
Compress the given string using the Huffman Coding and provide the decompression function as well. Reference Erroneous Code: ``` def huffman_compress(string): freq_dict = {} for char in string: if char in freq_dict: freq_dict[char] += 1 else: freq_dict[char] = 1 sor...
codefeedback
Come up with a SQL statement to select only the names of customers whose age is higher than 30 and have made at least 5 purchases in the last month.
codefeedback
Modify the following python code to calculate the median of a list of numbers. def list_median(numbers): '''This function will calculate the median of a list of numbers.''' # Additional Instructions: 1. Do not use any built-in functions or libraries to calculate the median. 2. The input list of numbers may co...
codefeedback
Create a function in Ruby to convert a Fahrenheit temperature to Celsius, ensuring that the input temperature is within the range of -459.67 to 1000 Fahrenheit. The function should return an error message if the input temperature is outside this range.
codefeedback
Come up with a Python generator expression to iterate over a given list and return only even elements. Additionally, the generator expression should exclude any even elements that are also multiples of 3. The input list can contain duplicate elements and can have a maximum length of 1000. [1, 2, 3, 4, 5, 6, 7, 8]
codefeedback
Write a C language function to check if a given number is prime or not.
codefeedback
Modify the following Java code to reverse a given string without using any additional memory space. public class SimpleStringReverser { public static String reverse(String str) { char[] charArray = str.toCharArray(); int start = 0; int end = charArray.length - 1; while (start < end...
codefeedback
Implement a live search functionality for a website using AJAX. The live search should display the results as the user types, without requiring a page reload. Additionally, the search results should be fetched from an external API and displayed in a visually appealing manner. The website should also handle any errors t...
codefeedback
Generate a random password with at least 8 characters, including at least 1 uppercase letter, 1 lowercase letter, 1 number, and 1 special character.
codefeedback
Come up with a Matlab expression to generate a random permutation of size 10, without using the built-in functions `randperm` or `shuffle`.
codefeedback
Create a MySQL query to get the name corresponding to the second highest id.
codefeedback
Create a Java program to validate a credit card number using Luhn's algorithm, but with the additional requirement that the program must also validate the expiration date of the credit card. The expiration date should be in the format "MM/YY" and must be validated to ensure it is a valid future date.
codefeedback
Find the most frequent name in a given array of names. The array may contain up to 10^6 names. ["John", "John", "Sandra", "Sandra", "Sandra", "Tom", ... (10^6 names)] Note: The time complexity of your solution should be O(n), where n is the number of names in the array.
codefeedback
What is the logic and time complexity behind bubble sort algorithm?
codefeedback
Use the bisection method to approximate the root of the given equation: x^3 - 2x^2 - 4x + 8. In addition to finding the root, also find the local maximum and minimum values of the equation within the given interval [a, b]. To do this, first, you need to calculate the derivative of the equation, which is 3x^2 - 4x - 4...
codefeedback
Rewrite the binary search tree traversal algorithm using an iterative approach instead of a recursive approach.
codefeedback
For a given array of numbers, find the length of the longest increasing subsequence. An increasing subsequence is a sequence of numbers where each number is greater than the previous number. If there are multiple subsequences with the same length, return the one that appears first in the original array. Example: Inpu...
codefeedback
Write a Python program that generates a list of prime numbers between a given range, and then debug any errors in the code.
codefeedback
Given an array of integers, sort the array in-place using quick sort. **Function Signature** ```python def quick_sort(arr: List[int]) -> None: pass ``` **Input** - `arr`: an array of integers where 1 <= len(arr) <= 10^5 and -10^6 <= arr[i] <= 10^6 **Output** - The input array `arr` should be sorted in-place. **...
codefeedback
Construct a GraphQL query to show all blog posts created by a specific user, ordered by the number of comments they have received, excluding any posts that have more than 100 comments.
codefeedback
Create a python program that takes a keyword as an input and prints the top 10 relevant Wikipedia articles for that keyword. However, the program should also implement a search functionality that allows the user to search for the keyword within each article and return the number of occurrences of the keyword in each ar...
codefeedback
Create a Node.js script to read from a MongoDB database and perform a complex aggregation query.
codefeedback
Write an assembly program to subtract two numbers using only bitwise operations.
codefeedback
Construct a React component to show a blog post. The component should include a like button that updates the number of likes when clicked. The blog post should also display the author's name and the date it was published. Additionally, the component should have a comment section where users can leave comments. The comm...
codefeedback
Write a shell script to run a long-running process in the background, but restrict the use of commonly used shell commands such as `nohup`, `&`, or `disown`. Instead, you should use low-level system calls to achieve the desired functionality.
codefeedback
Generate a 10x10 multiplication table in Python. The table should only include prime numbers and the output should be formatted in a visually appealing way.
codefeedback
Write a function in JavaScript to reorder the given list in ascending order. The list may contain duplicate elements and can have a maximum length of 10000. The function should have a time complexity of O(n log n) and should not use any built-in sorting functions or external libraries.
codefeedback
Construct a HTML form for user registration that includes the following specific requirements: 1. The form should have fields for the user's first name, last name, email address, password, and a confirm password field. 2. The first name and last name fields should be mandatory and should only allow alphabetic characte...
codefeedback
Construct a responsive HTML template using Bootstrap with the following features: 1. A navbar with a logo and a dropdown menu. 2. A header section with a background image and a centered title. 3. A two-column layout for content, with a sidebar and a main content area. 4. The sidebar should have a fixed position and dis...
codefeedback
Write a Python program to divide the numbers in the list by a given number, but the division must be implemented using only basic arithmetic operations (+, -, *, /). The input list can contain negative numbers as well. Example: Input: [2, 4, -10, 6], 2 Output: [1, 2, -5, 3]
codefeedback