instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
Create an HTML form containing four text inputs: Name, Email, Phone Number and Address. Add a button that triggers a JavaScript function to validate the form. The validation function should check if all fields are filled out correctly. If any field is empty or if the email format is invalid, display an error message. | codefeedback |
Create a PHP function to check if a given string starts with a given substring. The function should be case-sensitive and also check if the substring appears in the middle of any word in the string. | codefeedback |
Using CSS, write a code snippet to display a text shadow with a blur radius of 15px and a color gradient that changes from red to blue. | codefeedback |
Write a PHP script to print out all the prime numbers between 10 and 100. | codefeedback |
Write HTML code to create a dynamic table that allows users to add and remove rows. The table should contain the following information: Name, Age, Gender, and a button to delete the row. Additionally, implement a feature that allows users to sort the table by any column in ascending or descending order by clicking on t... | codefeedback |
Using C++, write a program to sort an array of strings alphabetically in descending order. | codefeedback |
Construct a for loop to iterate over a range of 10 positive integers, printing out the square of each number. Each number in the range should be greater than 10 and divisible by 3. | codefeedback |
Create a function that given two strings, returns a new string with the characters of the two strings alternating. If one string is longer than the other, append the remaining characters of the longer string to the end of the new string.
Example:
Input:
string1 = 'abcd'
string2 = 'efgh'
Output:
'aebfcgdh' | codefeedback |
Write Android code for creating an intent for taking a photo, but also include functionality for adding filters to the captured image before saving it to the device's storage. | codefeedback |
Create a dictionary from a given list of tuples, where each key in the dictionary is a string and each value is a list of integers. The input list will have at most 1000 tuples. Each tuple will have a string of length at most 10 as the key, and a randomly generated integer between 1 and 1000 (inclusive) as the value. T... | codefeedback |
Using HTML and CSS, create a responsive layout that consists of a header, a sidebar, and a main content area. The header should have a background color of blue, the sidebar should have a background color of gray, and the main content area should have a background color of white. The header should have a height of 100 p... | codefeedback |
Write a code to get the current US Dollar to Euro exchange rate from the European Central Bank. Your code should handle situations where the European Central Bank's API is unavailable or returns an error. Additionally, your code should implement a caching mechanism to store and retrieve previously fetched exchange rate... | codefeedback |
Write a function that takes a string as input and converts each character to uppercase. The function should return the modified string.
Example:
Input: "gpt is great"
Output: "GPT IS GREAT"
Note: You are not allowed to use any built-in functions or libraries for string manipulation. You need to implement the conversi... | codefeedback |
Please write a Python program to find the 4 terms in a geometric progression whose sum is 120 and the common ratio is 2. | codefeedback |
Using HTML and CSS, create a responsive navigation bar with 5 links "Home", "About", "Products", "Services", and "Contact". The navigation bar should have a dropdown menu for "Products" and "Services" that expands when hovered over. The "Home" link should be highlighted as the current page. The navigation bar should ha... | codefeedback |
Calculate the standard deviation of the given set of numbers, ensuring that the solution has a time complexity of O(n). Additionally, the solution should not use any built-in functions or libraries for calculating standard deviation. The input set of numbers will have a length of at least 100 and a maximum value of 100... | codefeedback |
Generate an object using JavaScript that contains the numbers from 1 to 1000. | codefeedback |
Write a MySQL statement to select the first 5 customers in the 'customers' table, ordered by the date they made their first purchase, in descending order. | codefeedback |
Write a HTML tag to create an ordered list with the following requirements:
1. The list should start counting from 10.
2. The numbers in the list should be displayed in Roman numerals.
3. Each list item should have a unique identifier attribute. | codefeedback |
Write a program that takes user input for the radius of a circle and the color of the circle, and then creates an SVG code to draw the circle with the given radius and color. The program should also prompt the user to specify the position of the circle on the SVG canvas. | codefeedback |
You are given two strings, s1 and s2. Your task is to determine if s1 is an anagram of s2. An anagram is a word or phrase formed by rearranging the letters of another word or phrase. For example, the strings "listen" and "silent" are anagrams of each other.
To solve this problem, you should perform the following steps... | codefeedback |
Write a regular expression to check if a string starts with a vowel, followed by at least one consonant, then a digit, and ends with a special character. | codefeedback |
Construct a function in Python that checks if a given list of integers is sorted in ascending order. The function should return True if the list is sorted in ascending order, and False otherwise. The time complexity of the function should be O(n), where n is the length of the list. | codefeedback |
Write an SQL query to get the name, date of birth, and address of all the people born in the year 1975, whose address is in a specific city, and their age is between 30 and 40 years. | codefeedback |
Create a JavaScript function that generates a random number between 1 and 1000, and returns the sum of all the digits in the generated number. The function should have a time complexity of O(log n), where n is the generated number. | codefeedback |
Design a while loop in C++ that prints every prime number between 1 and 100. | codefeedback |
Compute the median of the following list: [2, 5, 9, 12, 7]. | codefeedback |
Create a string with alternating characters from two other given strings, but only include characters that are vowels.
string str1 = "HELLO";
string str2 = "WORLD"; | codefeedback |
Write a function that takes in an array of strings as input and returns the longest string in the array. If there are multiple strings with the same maximum length, return the one that appears first in the array.
Example:
Input: ["Apple", "Banana", "Orange"]
Output: "Banana"
Input: ["Cat", "Dog", "Elephant", "Giraffe... | codefeedback |
Update a variable to be the negative of its value, but without using the negation operator or any arithmetic operations.
x = 5 | codefeedback |
Build a Bash script that takes two arguments and writes a function to swap the values of the arguments using bitwise operations. Use the bitwise XOR operator (^) in the function to swap the values without using a temporary variable.
Example:
Input:
a = 10
b = 20
Output:
a = 20
b = 10 | codefeedback |
Calculate the probability of drawing four aces from a standard deck of cards, given that the cards are drawn without replacement and the first two cards drawn must be red cards. | codefeedback |
Construct an object that contains the properties for an employee's name, phone number, salary, and a list of their previous job positions. Each job position should include the company name, job title, start date, and end date. | codefeedback |
Given an array of strings, find the string that is the most common in the array. The array can contain duplicates and may have a large number of elements.
Example:
Input: ["Apple", "Banana", "Apple", "Orange", "Banana", "Banana"]
Output: "Banana"
Note:
- The input array can have a maximum length of 10^6.
- The length... | codefeedback |
Write a Java program that searches an array for a given value and returns the index at which it is found. The array contains unique integers in ascending order. Implement a binary search algorithm to solve this problem.
int[] arr = {3, 4, 6, 7, 8, 10};
int searchValue = 8;
#Difficulty increased#
The original test was... | codefeedback |
Use a while loop to iterate over a list of numbers and find the first even number. If the sum of the digits of the even number is divisible by 3, print the number and exit the loop. Otherwise, continue searching for the next even number.
numbers = [7, 3, 5, 11, 13, 12, 15, 24, 21] | codefeedback |
Make the following sentence capitalized and reverse the order of the words.
fox brown quick the | codefeedback |
Parse a given JSON string and extract all the values of the key "name" that are of type string.
json_str = '{"name": "Jack", "age": 22, "status": "Active"}' | codefeedback |
Count the number of occurrences of each character in a given string and print the output in descending order of occurrence count.
str = "abbabbabbb" | codefeedback |
How can this code be optimized to find the longest common subsequence between two strings?
Write a function called "longest_common_subsequence" that takes in two strings, a and b, and returns the length of the longest common subsequence.
The longest common subsequence is defined as the longest sequence of characters ... | codefeedback |
Compute the sum of two integer inputs separated by a space, and handle the case where one or both of the inputs are negative numbers.
-1 5 | codefeedback |
Increase the difficulty of the programming test question by proposing a more complex problem:
#Given Test#
Debug this Python code and explain why it was not running.
```python
def string_split(string, n):
words = string.split(" ")
for x in words[:n]:
print(" ".join(words[:x]))
```
#Rewritten Test#
Wr... | codefeedback |
Calculate the number of days between two given dates in Python, considering leap years.
date1 = '2020-09-13'
date2 = '2021-02-06'
# Additional Requirements:
1. Implement error handling for invalid date inputs.
2. Account for leap years when calculating the number of days between the two dates.
3. Implement a function ... | codefeedback |
Write a loop to print the characters of a string in reverse order, but without using any built-in functions or data structures. The loop should have a time complexity of O(n), where n is the length of the string. | codefeedback |
Create a web application that allows users to register, login, and manage a class list of students. Users should be able to perform the following actions:
- Add a new student to the class list, including their name, age, and grade level.
- Edit the details of an existing student, including their name, age, and grade le... | codefeedback |
Print the fibonacci sequence of length n, where n is a prime number between 10 and | codefeedback |
Given a list of numbers, compute the average of the positive integers greater than 5.
[2, 6, 10, 4, 7, 9] | codefeedback |
Sort the elements of an array in ascending order using Quick Sort algorithm in C++. The pivot element should be chosen as the median of the first, middle, and last elements of the array. The array size will always be odd.
arr[] = {7, 2, 9, 5, 1, 6, 4} | codefeedback |
Check if the two strings are anagrams but with an additional constraint: you are not allowed to use any built-in sorting or hashing functions or libraries. | codefeedback |
Suggest a valid JSON dictionary for the following data with the requirement that the "Name" field should be a non-empty string and the "Age" field should be an integer greater than 18, and the "Profession" field should be a string consisting of alphabets only, not exceeding 50 characters. | codefeedback |
Suggest a JavaScript code to generate a random alphanumeric string of 16 characters that contains at least one uppercase letter, one lowercase letter, one digit, and one special character. | codefeedback |
Describe a method to solve a quadratic equation of the form ax^2 + bx + c = 0. | codefeedback |
Extract the following records from the given table using a SQL query and sort them in descending order based on the student's average score.
Table name: Student
Columns:
- student_id (integer)
- student_name (string)
- subject (string)
- score (integer) | codefeedback |
Write a JavaScript program that prints all the prime numbers from 0 to a given number n.
n = 100
#Higher Difficulty Explanation#
Finding prime numbers is a more complex task compared to finding even numbers. It requires additional computations such as checking if a number is divisible by any other number besides 1 and... | codefeedback |
Write a JavaScript program to find the greatest common divisor (GCD) of two given positive numbers.
The program should have a time complexity of O(log min(x, y)).
x = 198
y = 132 | codefeedback |
About a given number n, can you write a JavaScript program to find the sum of all the prime numbers that are greater than 0 and less than n?
n = 10 | codefeedback |
Create a C program which implements the following algorithm:
Given an array of size n (1 ≤ n ≤ 10^6), print all distinct elements in the array in sorted order. The program should use only constant extra space and should run in O(n) time complexity. | codefeedback |
What data type is best suited to store a list of students' names, considering that each student can have multiple names and there might be duplicate names in the list? | codefeedback |
Write a function in Python to compress a given string. The compressed string should consist of each character followed by the count of consecutive occurrences of that character. For example, the string "aabcccccaaa" should be compressed to "a2b1c5a3".
The function should have a time complexity of O(n), where n is the... | codefeedback |
Create a responsive HTML web page which displays the top 10 news articles of the day fetched from a News API. Implement infinite scrolling feature to dynamically load more news articles as the user scrolls down the page. Additionally, include a search functionality that allows the user to search for news articles based... | codefeedback |
Create a MySQL query that returns the sum of the points scored by all students, but only include the points scored by students who have scored above the class average. | codefeedback |
Using Python, write a function to format a given date and time.
Date and Time: "2021-02-14 18:30:45"
Format: "dd/mm/yyyy hh:mm:ss"
Additional Requirements:
1. The function should validate the input date and time to ensure it is in the correct format.
2. The function should handle various date and time formats, such as... | codefeedback |
Create a function to print a Diamond shape with a minimum size of 5 and a maximum size of 10. The input size should be an odd number. The diamond shape should be printed using asterisks (*) and should have an additional row of dashes (-) at the top and bottom. | codefeedback |
Create a function to append a new element to a list, but only if the element is not already present in the list. If the element is already present, raise a custom exception indicating that the element cannot be appended again. | codefeedback |
Rewrite this function using a recursive algorithm and without using any loops or iterative constructs.
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1) | codefeedback |
Compute the Fibonacci sequence upto n, where n is a positive integer less than or equal to 1000. The solution should have a time complexity of O(n) and a space complexity of O(1). | codefeedback |
Explain the concept of static typing in programming and provide examples of statically typed programming languages. Additionally, discuss the advantages and disadvantages of static typing compared to dynamic typing. | codefeedback |
Create an expression tree for the expression (2+3)/(4-1) using a recursive approach. | codefeedback |
Compile a piece of code written in Python language and include at least one custom defined class and one inheritance relationship. | codefeedback |
Design a function to remove all duplicate words from a sentence while also preserving the order of the remaining words.
Input: A sentence string consisting of words separated by spaces.
Output: A modified sentence string with all duplicate words removed.
Example:
Input: "This is this is a sentence with with repeats r... | codefeedback |
Write a function to classify a news article by its tone and sentiment. | codefeedback |
Implement a method to sort a list of numbers using the quick sort algorithm. The method should have a time complexity of O(n log n) and should use an in-place sorting algorithm.
The input list may contain duplicates and negative numbers. The method should handle these cases correctly and return a sorted list in ascend... | codefeedback |
Write a code to implement an LRU (Least Recently Used) cache with the following constraints:
- The cache should have a maximum capacity of N elements, where N is a positive integer.
- The cache should support the following operations:
- Inserting a key-value pair into the cache.
- Retrieving the value associated wi... | codefeedback |
Create a SQL query to extract all the "first_name", "last_name", and "age" columns from the "students" table, sorted in descending order based on the "age" column. | codefeedback |
Implement a stack data structure using linked lists and ensure that it supports the following operations:
1. Push: Add an element to the top of the stack.
2. Pop: Remove and return the element from the top of the stack.
3. Peek: Return the element from the top of the stack without removing it.
4. Size: Return the numbe... | codefeedback |
Print the first 10 Fibonacci numbers using a loop, but each number must be raised to the power of 3 before printing. | codefeedback |
Explain what a linked list is and what operations can you perform on it. Additionally, provide a piece of erroneous code that attempts to delete a node from a linked list and explain why it is incorrect. | codefeedback |
Implement an efficient algorithm to find the number of occurrences of a non-overlapping substring in a string that is case-sensitive and accounts for leading and trailing whitespace characters. The substring must have a length between 2 and 10 characters and can contain alphanumeric characters, punctuation, and special... | codefeedback |
Create a CSS style sheet to set font size of all headings to 20px, font weight to bold, color to blue, and add a 1px solid border around each heading. | codefeedback |
Identify the type of join used in the following SQL query and explain its purpose and implementation in detail:
SELECT *
FROM orders
JOIN customers
ON orders.customer_id = customer.id
GROUP BY orders.order_id
HAVING COUNT(*) > 1
ORDER BY orders.order_date DESC | codefeedback |
Create a JavaScript function that takes three parameters: a number, a sign, and another number. The function should use the sign to determine which arithmetic operation it should perform and output the result.
Additionally, introduce a piece of erroneous code within the function to increase misdirection. | codefeedback |
Write a function that sorts its arguments in descending order, but only for numbers greater than or equal to 5.
nums = [4, 8, 10, 3, 5] | codefeedback |
Write a JavaScript code snippet that will add two numbers, each with up to 10^6 digits. | codefeedback |
Write a function to find the index of the point that lies closest to the origin. The origin is represented by the point [0, 0].
points = [[1, 1], [-1, 2], [3, -4]]
Your function should return the index of the closest point in the list. If there are multiple points with the same closest distance, you can return any on... | codefeedback |
Given two strings, write a Python code to delete all occurrences of the second string from the first string. The solution should have a time complexity of O(n), where n is the length of the first string.
str1 = "abcabcabcabcabcabcabcabcabcabc"
str2 = "abc"
#Additional Information#
- The input strings can contain any... | codefeedback |
Make a C++ program that counts the number of unique elements in an array and prints the unique elements in ascending order.
int arr[] = {1, 5, 3, 6, 2, 3, 5};
Requirements:
- The program should have a time complexity of O(n log n), where n is the number of elements in the array.
- The program should have a space comp... | codefeedback |
Create an algorithm to detect plagiarized code in a given codebase, taking into consideration not only identical code segments but also similar code segments with minor modifications such as variable name changes or rearranged lines of code. | codefeedback |
Rewrite the following SQL query into its equivalent MongoDB query, considering the following conditions:
1. The 'customers' collection has a nested 'personal_info' field that contains the customer's age.
2. The 'age' field in the 'personal_info' document is a string representation of the age, not a numeric value.
SELE... | codefeedback |
Create an HTML email template with placeholder information from a JavaScript object. The email template should also include dynamic data retrieved from a remote API endpoint. The API endpoint should return an array of objects, where each object represents a contact with properties such as name, email, and phone number.... | codefeedback |
Design a class in Python to store a user profile information such as name, age, city, etc. The class should also include methods to calculate the user's BMI (Body Mass Index) based on their height and weight. The class should also have a method to validate the user's email address using regular expressions. | codefeedback |
Create an algorithm to encourage work-life balance and productivity in remote work by developing a system that tracks and manages employees' work hours and breaks.
Requirements:
1. Design a system that allows employees to log their daily work hours, including the start and end time of each work session.
2. The system ... | codefeedback |
Create a function in JavaScript to input two strings and output their combined length. However, you must implement the function without using the built-in JavaScript functions such as length(), concat(), or any other string manipulation functions. You are only allowed to use basic string operations such as indexing, it... | codefeedback |
Write a script in JavaScript to find the sum of all the numbers in an array. The array may contain negative numbers as well. The script should not use any built-in array methods such as `reduce` or `forEach` to calculate the sum. The time complexity of the script should be O(n), where n is the length of the array. | codefeedback |
Create a function that takes a string as input and returns a copy of the string with all punctuation marks removed. Punctuation marks include any characters that are not letters or numbers.
For example, if the input string is "Hello, world!", the function should return "Hello world".
Your solution should handle edge ... | codefeedback |
Design a class in Python to store information about a car, such as its make, year, mileage, and current fuel level. The car should have a method to calculate and return its current range based on its fuel efficiency and fuel level. Additionally, implement a method to update the fuel level and raise an exception if the ... | codefeedback |
Write a function that takes two strings and searches for all the occurrences of the first string in the second. Return the positions of the pattern within the string, considering only unique occurrences. Additionally, the function should ignore any occurrences of the pattern that are within a specified range of positio... | codefeedback |
Create a numerical sequence using Ruby code with 10 elements. The sequence should follow a pattern where each element is the sum of the previous two elements. | codefeedback |
Design a class in Python to store a book's title, author, number of pages, and publication date. The publication date should be stored as a separate class that includes the year, month, and day.
The class should also include the following methods:
1. A method to calculate and return the average number of pages read pe... | codefeedback |
Create a function that converts any negative or decimal number to its hexadecimal representation. The function should handle numbers with up to 15 decimal places accurately. | codefeedback |
We have a given string. Replace every occurrence of 'a' with 'A', but also replace every occurrence of 'e' with 'E'.
string = 'I like apples' | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.