instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
How would you write a program to determine the greatest common divisor (GCD) of two non-negative integers, without using any built-in mathematical functions or libraries?
codefeedback
Create a software program that encrypts a text message using a combination of substitution and transposition techniques. The program should prompt the user to enter a plaintext message and a secret key. The program should then perform the following steps: 1. Convert the plaintext message to uppercase and remove any sp...
codefeedback
Generate a list of 20 random numbers between -1000 and 1000 in Python. Sort the list in ascending order and remove any duplicates.
codefeedback
Write an SQL query to select all rows from the table "customers" that have the same age as the given customer and are from the same country. customer = ("John Smith", 32, "United States")
codefeedback
Write a function to start a timer with the specified duration and return a unique identifier for the timer. #Additional Reasoning Steps# 1. Generate a random alphanumeric string to serve as the unique identifier for the timer. 2. Create a dictionary to store the timers, with the unique identifier as the key and the du...
codefeedback
How would you sort an array of integers using Merge Sort algorithm? Write a recursive function that sorts the array in descending order, while also keeping track of the number of swaps made during the sorting process.
codefeedback
Create a Python function to remove duplicates in a given list, but without using any built-in Python functions or data structures. list_of_numbers = [2, 3, 3, 5, 5]
codefeedback
Write a SQL query to retrieve the id, name, and salary column from the Employee table, where the salary is above the average salary of all employees.
codefeedback
Edit the code to extract the data from the given dictionary and calculate the sum of all the numbers found in the dictionary. data = { 'name': 'John', 'age': 23, 'address': { 'street': '123 Main Street', 'city': 'Los Angeles' }, 'numbers': [1, 2, 3, 4, 5] } The output should be the sum of all the numbers in the...
codefeedback
Suggest an algorithm to find the number of leaf nodes in a binary tree.
codefeedback
Write a predicate to check for valid email syntax. Additionally, ensure that the domain name is a valid and registered domain.
codefeedback
Parse the given JSON response and fetch the name of the person with the highest id.
codefeedback
How can we optimize the performance of the given code by minimizing the time complexity? Implement a solution to print all elements in the myList without using a for loop and with a time complexity of O(1) or better.
codefeedback
Using the below Python code, Write a code snippet to index all the values of an array. However, you cannot use any built-in functions or libraries. arr = [3, 8, 2, 5, 1]
codefeedback
Remove duplicates from the list and sort the list in ascending order. list = [1,2,3,2,5,6,5] #Additional Requirements# - The solution should have a time complexity of O(nlogn), where n is the length of the list. - The solution should be implemented using a sorting algorithm such as merge sort or quick sort. You canno...
codefeedback
Generate Python code to extract only the keys from the given dictionary while ignoring any keys that start with the letter 'a' and have a value that is not a string. The extracted keys should be sorted in descending order. The dictionary may contain nested dictionaries as values.
codefeedback
Trace the given code and explain the operations. Write a function `concatenate_arrays` that takes in two lists `a` and `b`, and concatenates them into a new list `c` using the `+` operator. Ensure that the length of `c` is equal to the sum of the lengths of `a` and `b`. Also, ensure that all elements in `c` are integer...
codefeedback
Answer the following multiple-choice question: Which of the following statements about program execution is true? a) Every program executes instructions sequentially b) Program execution can be parallelized to improve performance c) Program execution can be non-deterministic and unpredictable d) Program execution is a...
codefeedback
Given the following code, write a function to find the sum of all the prime numbers between 0 and n. n = 5
codefeedback
Convert the given HTML string into well-formed XML by ensuring that each opening tag has a corresponding closing tag, and any nested tags are properly indented.
codefeedback
Write a Python program to create a numerical addition table where the values are multiplied by a random number generated between 1 and 10.
codefeedback
Write an SQL query to find the student's average marks in a particular course, where the average should only include marks obtained within the last 6 months.
codefeedback
Create a program in C++ that converts a given Celsius temperature to Fahrenheit using only bitwise operators and without using any arithmetic operators.
codefeedback
Implement a function in JavaScript which checks whether a given number is prime or not. The function should only use a maximum of O(sqrt(n)) time complexity and should not use any built-in prime-checking functions or libraries. The function should handle both positive and negative integers as input and return a boolean...
codefeedback
Construct a SQL query to find all customers with a first name of "John" and a city of "New York", and order the results by their last name in descending order.
codefeedback
Describe a procedure to multiply two numbers using Bash scripting. Also, handle the case where one or both of the numbers are negative.
codefeedback
Utilize Python to implement an algorithm which finds the kth largest number in an array, where k is given as input. Additional requirements: 1. The algorithm must have a time complexity of O(n) or better, where n is the size of the array. 2. The algorithm must not modify the original array. 3. You are not allowed to u...
codefeedback
Create a Java program which calculates the area of a circle, but restrict the use of the Math library. Instead, you must implement your own function to calculate the value of pi to at least 10 decimal places.
codefeedback
Specify the minimum version of the Java platform and at least two environment variables needed to run a Java program, ensuring that the program can only be executed if the specified version is installed and the environment variables are correctly set.
codefeedback
Implement a function in C# to generate Fibonacci numbers up to a given limit, while ensuring that each generated number is a prime number.
codefeedback
Name five differences between Strings and StringBuffer in Java and provide a detailed explanation for each difference.
codefeedback
Write a query to find users who have at least one friend with a given age in MongoDB. given_age = 25
codefeedback
What are the key advantages of utilizing the MapReduce programming model in conjunction with the Hadoop framework? Provide at least three distinct advantages and elaborate on each.
codefeedback
Given a stream of blog posts from a certain website, how would you filter out posts with more than 50 comments and also have the word "Python" mentioned in the title in Python? stream_of_blog_posts = [{'title': 'post1', 'comments': 35}, {'title': 'post2 Python', 'comments': 52}, {'title': 'post3', 'comments': 19}]
codefeedback
Modify the following JavaScript for loop so it will loop through the array in reverse order. Additionally, you must implement the loop without using the array.reverse() method and without creating a new array.
codefeedback
How to create an empty data frame in Pandas with a specified shape and index?
codefeedback
Explain the differences between List, ArrayList, Vector, and LinkedList in Java. Discuss the advantages and disadvantages of each data structure in terms of performance, memory usage, and thread safety. Additionally, provide examples of use cases where each data structure would be most suitable.
codefeedback
Given a list of integers, find the numbers which are greater than the given number X and less than or equal to the given number Y. List: [-3, 0, 3, 5, 9], X = 4, Y = 8
codefeedback
How can we use the set() method, ensuring a time complexity of O(n), to find the unique elements in a given list of integers in C# without using any additional data structures?
codefeedback
Implement a function in Python to find the maximum number from a list of integers. The function should handle cases where the input list is empty or contains non-integer elements. The function should also handle cases where the list contains duplicate maximum numbers. If the list is empty or contains non-integer elemen...
codefeedback
Write a script to launch a web server listening on port 8080, but the web server should only accept incoming requests from a specific IP address range.
codefeedback
Create a React component to render a list of items with its title and description. However, the description should only be displayed if it is longer than 10 characters. title: 'My List', items: [{title: 'Item 1', description: 'short'}, {title: 'Item 2', description: 'this is a very long description that should be dis...
codefeedback
Create a JavaScript function which takes in an array of numbers and returns the second largest number. The function should also check if the array contains duplicate numbers and return an error message if so.
codefeedback
Create a command to delete a folder with all its contents, but also ensure that a backup of the folder is created before deletion. The backup should be stored in a separate directory called "/root/backup".
codefeedback
Write a SQL query to join three tables (Users, Orders, and Products) on User_ID and Product_ID.
codefeedback
Create a JavaScript class to find the difference of two given dates, taking into consideration leap years and timezones.
codefeedback
EDIT this JavaScript function to return a list of the square roots of all numbers in a given input array. However, the solution should have a time complexity of O(n) and should not use any built-in functions or methods that directly calculate square roots. function squareRoots(arr) { // EDIT THIS }
codefeedback
Sort this array of integers in ascending order using JavaScript. You are not allowed to use any built-in sorting functions or libraries. Implement your own sorting algorithm. const array = [26, 4, 11, 56, 23, 39] #Difficultied Test#
codefeedback
Write a JavaScript program to filter out prime numbers from an array [1,2,3,4,5,6,7,8,9,10].
codefeedback
Create a Python program to find all the perfect cubes between 1 and n, where n is a positive integer provided by the user.
codefeedback
Write a Java program to find the index of the first occurrence of the given element in an array, but without using any built-in methods or loops. int[] array = {1, 7, 3, 6, 4, 7}; int num = 7;
codefeedback
Create a Bash script for finding the most frequent word in a given text file. The script should take a text file as input and output the word(s) that appear(s) most frequently in the file. If there is a tie for the most frequent word(s), all tied words should be returned. Assume that the text file contains only alpha...
codefeedback
Using the given three arrays, classify each array element as either prime numbers or not prime numbers. Then, for each prime number, find the sum of all its divisors. Finally, sort the prime numbers based on the sum of their divisors in descending order. arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9]; arr2 = [4, 6, 9, 10, 12, 15,...
codefeedback
Create a function to determine if a given string is a palindrome of another. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, ignoring spaces, punctuation, and capitalization.
codefeedback
Suggest a SQL query to return all users with an age between 18 and 25, who have made at least 10 transactions in the past month.
codefeedback
Construct a SQL query that returns all users who did not login in the last 24 hours and have more than 1000 followers.
codefeedback
Implement a logic to separate even and odd numbers from an array in JavaScript. The array must contain at least 10 elements. The output should be two separate arrays, one containing even numbers and the other containing odd numbers. The even numbers array should be sorted in descending order, while the odd numbers arra...
codefeedback
Execute the following bash shell script. Write a bash script that reads a file containing a list of names and their corresponding ages (one name and age per line, separated by a comma). The script should calculate and print the average age of all the people listed in the file. For example, if the input file "people.t...
codefeedback
Write a python program to convert a number from base 10 to base 8. The program should also handle negative numbers and should return the converted number as a string.
codefeedback
In Ruby, write a program that prints out all the prime numbers between 0 and 50, but also implement a function that checks if a given number is a prime number.
codefeedback
Create a new branch in Git to fix a bug in the application. Once the branch is created, write code to identify the root cause of the bug by analyzing the application's codebase. Develop a plan to fix the bug and implement the necessary changes in the code. Finally, merge the bug-fix branch back into the main branch and...
codefeedback
Implement a machine learning algorithm in Python that predicts the stock prices of a specific company based on historical trading data. The algorithm should use a deep learning neural network with at least three hidden layers. The input data should include not only the stock prices but also other relevant financial ind...
codefeedback
Write a shell script to calculate the sum of two numbers given as command line argument. The script should only use built-in shell commands and should not use any external utilities or functions. Additionally, the script should handle input validation, ensuring that the numbers provided as command line arguments are va...
codefeedback
Create a SQL query to get the list of employees working in the IT department, sorted by their salary in descending order. Additionally, the query should only include employees who have been with the company for more than 5 years.
codefeedback
Create a Python class for circles with radius, color, and center as its properties. The center should be a tuple representing the coordinates (x, y) of the center of the circle. Additionally, the class should have the following methods: 1. `get_area()`: This method should return the area of the circle. 2. `get_circum...
codefeedback
Create an HTML table with 5 rows and 6 columns. Each cell in the table should contain a unique number starting from 1 and incrementing by 1 for each cell. The table should have alternating background colors for each row, with the first row being a different color from the rest. Additionally, add a button at the bottom ...
codefeedback
Generate a JavaScript function to perform a binary search for a given array, but with the additional requirement that the array must be sorted in descending order.
codefeedback
Create a SQL query to select the name, address, email, and total amount spent of customers who placed an order in the last 30 days. The results should be ordered by the total amount spent in descending order. Additionally, include only customers who have placed at least 3 orders in the last 30 days.
codefeedback
Calculate the volume of a sphere with radius 6m.
codefeedback
Write C++ code to convert a given Fahrenheit temperature degree to Celsius, using only bitwise operations and without using any multiplication or division operations. Fahrenheit = 100
codefeedback
Create a React component named "DateTimeDisplay" that displays the current date and time in a specific format: "YYYY-MM-DD HH:MM:SS". The date and time should be automatically updated every second without refreshing the page. Additionally, the component should include a button labeled "Toggle Format" that toggles betwe...
codefeedback
Create an Android function to get the current battery level, but you are not allowed to use the Android BatteryManager API.
codefeedback
Create a PHP script to authenticate a user against a certain database given the user's username and password. The script should include the following steps: 1. Prompt the user to enter their username and password. 2. Retrieve the entered username and password from the user. 3. Connect to the database named "users". 4....
codefeedback
Create a machine learning classifier that can classify the sentiment of a text based on multiple features, such as the presence of positive or negative words, the length of the text, and the context in which it appears. The classifier should be able to handle different types of text, including reviews, social media pos...
codefeedback
Create a JavaScript function to return the sum of the digits in a given number, but without using any built-in string or number manipulation methods (such as toString(), split(), parseInt(), etc.). #Explanation# This rewritten test increases the difficulty by restricting the use of commonly used methods in solving the...
codefeedback
Create a Python program to return the longest word in a sentence, excluding any words that contain the letter 'a'. For example, given the sentence "The dog likes to run around the yard", the program should return "yard" as the longest word, as it is the longest word without the letter 'a'.
codefeedback
Using PHP, write a program that takes a string as input and checks if it contains only alphabets. The program should also check if the string is palindrome, meaning it reads the same forwards and backwards. Additionally, the program should ignore any special characters and whitespace when determining if the string is a...
codefeedback
Write a Java code snippet to declare a two-dimensional array of size 2×3 and initialize it with random integer values between 1 and 100. Then, calculate the sum of all the elements in the array and print it.
codefeedback
How can you call a function named "myFunction" in both JavaScript and Python, while also passing an argument to the function?
codefeedback
Write a Python function that finds the second largest element in a list. The function should return the second largest element in the list. If the list has less than two elements, the function should return None. The function should have a time complexity of O(n).
codefeedback
In JavaScript, develop a function to be able to determine if an object has a specific property or not, and the function should not use the built-in method `hasOwnProperty()`. Additionally, the function should return true if the property exists and its value is not null or undefined, and false otherwise. The object can ...
codefeedback
In Java, write a method which takes a two-dimensional array of integers as input and prints it in spiral order. The array will always be square (n x n) and n will be a prime number.
codefeedback
Write a SQL query that returns the name of the author who has more than two books published in the current year and whose total number of book sales is greater than 1000.
codefeedback
Implement a Swift code to find all prime numbers within a given range of numbers.
codefeedback
Using HTML and CSS, create a responsive web page structure for a blog post with a header, main content section, sidebar, and footer. The header should include a logo and a navigation bar. The main content section should include a title, image, text content, and a "Read More" button. The sidebar should include a list of...
codefeedback
Write an SQL query to retrieve a student's grade from a student table, but also include the student's name and the name of the course they are enrolled in. The student table has the following columns: student_id, student_name, course_id, course_name, and grade.
codefeedback
Write a SQL query to list customers who have placed orders for more than $100 in the past month and have made at least 3 orders.
codefeedback
Complete a code to detect the type of triangle from its three side lengths. The code should have a time complexity of O(1) and should not use any loops or conditionals. // Given triangle side lengths float side1 = 4; float side2 = 4; float side3 = 4;
codefeedback
Create a function in Python to delete an element from a given list at a specified index, without using any built-in functions or methods. list = [1, 2, 3, 4, 5] index = 2
codefeedback
Create an HTML page with a form that includes a text box and a submit button. When the user enters data into the text box and clicks the submit button, store the entered data in the local storage. Additionally, retrieve the stored data from the local storage and display it on the page. To increase the difficulty of th...
codefeedback
Using React, write a function to render a text area element with the text provided as the input for the function. Additionally, implement a character counter that updates in real-time as the user types in the text area. The character counter should display the number of characters currently entered in the text area. R...
codefeedback
Create a C++ program to calculate the median of an array of integers, where the size of the array is given as input and the array elements are randomly generated within a specific range.
codefeedback
Create a script in PowerShell to list the computers in a local network and display additional information such as their IP addresses, MAC addresses, and operating systems. Additionally, the script should include error handling to gracefully handle any connectivity issues or inaccessible machines in the network.
codefeedback
Create a program to create a new string where the first and last occurrence of each character is removed, but only for lowercase letters. 'Hello World'
codefeedback
Find a code that returns the union set of two given sets. The code should only use a single line of code and should not use any built-in functions or methods for set operations. Additionally, the code should have a time complexity of O(n) where n is the total number of elements in both sets combined. s1 = {1,2,3,4} s2 ...
codefeedback
Create a function that takes a string of characters and returns the minimal number of division/multiplication operations needed to make all characters within the string the same. The length of the string will be between 1 and 100, and it will only contain lowercase alphabets.
codefeedback
Create a new function that takes two lists as input and returns a new list consisting of elements which are not in the other list. However, the function should not use any built-in Python functions or methods such as set() or any form of list comprehension. The time complexity of the function should be O(n^2), where n ...
codefeedback
Write a JavaScript code snippet to validate a string for a US phone number, ensuring that the number is formatted correctly and contains a valid area code and exchange code.
codefeedback
Create a function to convert a given decimal number to its corresponding hexadecimal value. Additionally, implement error handling to check if the input is a valid decimal number.
codefeedback
How would you implement a webhook using Flask, where the incoming webhook payload needs to be encrypted using AES-256 encryption before processing?
codefeedback