conversations
listlengths
2
2
category
stringclasses
1 value
generator
stringclasses
2 values
[ { "from": "user", "value": "Given an array of integers, return the length of the longest increasing subsequence. However, for this task, the subsequence can only contain even numbers.\ninput array = \\[$1, 3, 6, 7, 9, 4, 10, 5, 6\\]$\n\nReference Solution (Wrong):\n```python\ndef longest_increasing_subseque...
code
DeepSeek-R1
[ { "from": "user", "value": "Modify the `find_mode` function to support a new `limit` parameter. If the number of modes is greater than this limit, return a list containing only the first `limit` most frequently occurring numbers, in order of their first occurrence.\n\nExample:\nInput: [1, 2, 3, 2, 4, 4, 4, ...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a Python program that prompts the user to enter a number and then print a list from 1 to that number.\nWrite a Python program that prompts the user to enter a number and then print a list from 1 to that number. However, the list must only contain prime numbers. Also, the pr...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a python function `find_product(lst)` that takes a list `lst` of integers as an argument and returns a dictionary mapping every unique integer `k` in `lst` to the product of all integers in `lst` except for `k`. If an integer is not in `lst`, it should not appear in the dic...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "**Even Integer Filter Function**\n================================\n\n### Description\n\nThis function takes a list of integers as input, filters out the odd integers, and returns a new list containing only the even integers.\n\n#...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Write a function that receives a list of integers and a target integer. The function should return `True` if all the integers in the list are non-negative, less than the target integer, and are in ascending order. Otherwise, return `False`. Do not use the built-in function `all()...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "### Incorrect Solution Analysis\nThe provided reference solution has several issues:\n* It only returns the position of the last pair of integers with the smallest absolute difference, not all pairs.\n* It does not count the occur...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Write a Python program to extract unique values from a list that contains duplicate values, but modify the list into a tuple before extracting the unique values. List = ('a', 'a', 'b', 'b', 'c', 'c', 'c')\n\nReference Solution (Wrong):\n```\n# Given List\nlist_with_duplicates = (...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "### Solution\n#### Problem Statement\nGiven a list of integers `nums` and a number `n`, find the nth largest unique integer in the list. If there are less than n unique integers in the list, return the largest unique integer.\n\n#...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Write a code to find the intersection of two lists. Return the intersection as a new list. The intersection of two lists is the set of elements that are common to both lists.\n\\[1, 2, 3\\], \\[3, 4, 5\\]" }, { "from": "assistant", "value": "<think>\nOkay, I need to f...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a program that uses a stack to reverse a string.\nI love Python" }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python program that reverses a string using a stack. Let's think about how stacks work. A stack is a LIFO structure, so the last...
code
DeepSeek-R1
[ { "from": "user", "value": "The task now requires implementing a Python function named `invert_binary_tree`. The function should take in two parameters - the root node of a binary tree and the depth of that tree. The function should return a dictionary with three keys:\n\n1. `tree`: This key should contain ...
code
DeepSeek-R1
[ { "from": "user", "value": "Could you write a Kotlin function that reverses a given list of integers, but keep the order of elements with even indexes intact? The function should accept a list of integers and return a new reversed list.\nCould you write a Kotlin function that reverses a given list of intege...
code
DeepSeek-R1
[ { "from": "user", "value": "Could you provide a Python script to count the number of occurrences of each character in a given string?\n\"Hello World!\"" }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python script that counts the number of occurrences of each character in a...
code
DeepSeek-R1
[ { "from": "user", "value": "Given a list of integers, write a Python function that calculates the product of all the integers in the list. If the list is empty, return 1." }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python function that calculates the product of all inte...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a program to reverse a string using recursion.\ntext: \"Hello World\"" }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python program to reverse a string using recursion. Let's see. Hmm, recursion means the function will call itself with a s...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a program that calculates the sum of all integers from 1 to a given number, but only if the integers are prime numbers. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.\nA number: 100\n\nOriginal Instruction:\nWrite a ...
code
DeepSeek-R1
[ { "from": "user", "value": "Given a list of non-negative integers, write a function to find the maximum sum of a contiguous subarray of a given size, ensuring that at least two even numbers are present in the subarray. Return an error message if no such subarray exists." }, { "from": "assistant", ...
code
DeepSeek-R1
[ { "from": "user", "value": "Reference Solution (Wrong):\n\n```python\ndef reorderArray(nums):\n nums.sort()\n return nums\n```\n\nPlease provide the correct implementation for the given problem without sorting the entire array. The new implementation must also have a time complexity lower than O(nlogn...
code
DeepSeek-R1
[ { "from": "user", "value": "Add the following condition to the original problem:\n\nYou can no longer assume that both `m` and `n` are odd numbers. They can now be even as well.\n\nUpdate the original instruction with this new condition. Your solution should return the arithmetic mean of the two numbers in ...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a JavaScript function to find the smallest element in a given array. [1, 2, 3, 4, 5, 6, 7]" }, { "from": "assistant", "value": "<think>\nOkay, the user asked for a JavaScript function to find the smallest element in an array, but they want the solution in Python...
code
DeepSeek-R1
[ { "from": "user", "value": "Given an m x n grid, return the length of the shortest path. You may start at any cell and move to any adjacent cell in any of the four directions: up, down, left, and right.\n\\[\\[0, 1, 0, 0\\],\n\\[1, 1, 1, 0\\],\n\\[0, 0, 1, 0\\],\n\\[0, 1, 0, 0\\]\\]" }, { "from": "a...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a Python function that accepts a list of integers and strings. The function should concatenate all string elements in the list, convert each integer to a binary representation, concatenate those binary representations, and return the resulting string.\n\nOriginal Instructio...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "**Simple Calculator Program**\n\n### Overview\nThis program implements a simple calculator that supports addition, subtraction, multiplication, and division operations. It takes user input for the operation and the numbers to use....
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Write a Python function that receives a list of integers as an argument, and returns the pair of adjacent elements that have the largest product. Return None if the input list is empty." }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python funct...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a Python function that takes a string and returns the string in reverse.\n\"Hello, World!\"" }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python function that reverses a string. Let's see. The input is a string, like \"Hello, World!\", an...
code
DeepSeek-R1
[ { "from": "user", "value": "Given a list of integers, return the first pair of elements that add up to a target sum. Return an empty array if no such pair exists. The elements are guaranteed to be unique in the array and the array is unsorted.\nnums = \\[10, 15, 3, 7\\], target = 17\nModify the original pro...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a Python code that defines a function called is_prime that takes an integer as input and returns True if the integer is prime and False otherwise. Your function should also handle the case when the input is negative or 0 and return False.\nNow, instead of writing a function...
code
DeepSeek-R1
[ { "from": "user", "value": "Instead of using bitwise XOR, use the lesser-known \"bitwise TRIPLE XOR\" operation. Bitwise TRIPLE XOR operation is defined as follows: For each bit position, if the number of bits set to 1 is not divisible by 3, then the result for that position is 1, otherwise it's 0. If there...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a function \"find_substring\" that takes two parameters, a string \"s\" and a string \"t\", and checks if \"t\" can be found inside \"s\". It should return a list of starting indices where \"t\" occurs inside \"s\". Return an empty list if \"t\" does not occur inside \"s\" ...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "## Depth First Search (DFS) in Python\n### Overview\n\nThe following Python function performs a depth-first search on a graph represented as an adjacency list. The function returns a list of nodes in the order they were visited.\n...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Write a program that translates a string to pig Latin. Input: \"Hello world\"" }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python program that translates a string into Pig Latin. Let me think about how Pig Latin works. From what I remember, th...
code
DeepSeek-R1
[ { "from": "user", "value": "Implement a function that generates all binary strings of length `n`.\n6" }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python function that generates all binary strings of length n. Hmm, binary strings are sequences of 0s and 1s. So for n=3, th...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "```python\ndef longest_substring_with_k_distinct_chars(l, k):\n def expand_around_center(s, k):\n max_length = 0\n max_substring = \"\"\n max_distinct_chars = 0\n for i in range(len(s)):\n ...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "In this task, you are required to write a program that encodes a string into modified Morse code. In this modified version of Morse code, sequences of three or more identical characters are to be encoded as a single Morse character, but with the length of the signal duration prop...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a Python function to check if a given sentence is a palindrome, excluding spaces, punctuation, and case sensitivity, as well as ensuring it contains at least two unique words.\nrace a car, a man, a plan, a canal, Panama\n\nPlease provide the solution without including any h...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "Of course! I'll outline a solution to create a function that reverses the characters in a given string. This response will guide you through the implementation of the function. Here is the Python implementation:\n\n```python\ndef ...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Write a Python function, `clone_graph`, that takes a node of the connected, acyclic, and undirected graph and returns a deep copy of the graph using breadth-first search. The function should accept a Node class as its argument, and the Node class should contain a value and a list...
code
DeepSeek-R1
[ { "from": "user", "value": "Given a string `str = 'Hello, Python World'`, write a program to remove the word 'Python' from the string." }, { "from": "assistant", "value": "<think>\nOkay, I need to remove the word 'Python' from the string 'Hello, Python World'. Let me think about how to do this i...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "### Factorial Function in Python\n#### Overview\nThe following Python function calculates the factorial of a given number `n`. This function uses recursion to compute the factorial.\n\n#### Code\n```python\ndef factorial(n):\n ...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Given a list of strings, write a program that returns a new list that contains only the strings that start with a vowel and are less than or equal to 5 characters in length. If the input list is empty, the program should return an empty list. The program must ignore case sensitiv...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a program in Python to get the first n prime numbers. Ask the user for the number n. You should write a separate function to check if a number is prime." }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python program that gets the first n pr...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a function in Python that takes a list of integers as input and returns a new list with all the elements that are powers of two." }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python function that takes a list of integers and returns a new...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a function that takes as input a list of integers and returns the product of all the numbers in the list." }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python function that takes a list of integers and returns the product of all the numbe...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a Python program that reads a line of text from the user and prints a table containing each word in the line, the length of the word, the frequency of the word in the line, and the position of the word in the line using 1-indexing. The input line will contain words separate...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "Of course! I'll help you create a Python function that sorts a list of strings in alphabetical order according to a specified encoding type, handling potential errors for non-string elements and unencodable strings. Here is the im...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Write a program that accepts a list of strings and returns a dictionary where each key is a word in the list and the value is the length of that word. `['Hello', 'World', 'Code', 'GPT']` should return `{'Hello': 5, 'World': 5, 'Code': 4, 'GPT': 3}`." }, { "from": "assista...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a program that implements a basic calculator. It should prompt the user to enter an expression (with spaces between the operators and the numbers) and then print out the result. The expression can include addition, subtraction, multiplication, and division, but no parenthes...
code
DeepSeek-R1
[ { "from": "user", "value": "Given a binary tree, find its minimum depth.\n\nThe minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.\n\n**Note:** A leaf is a node with no children.\nThe given binary tree may have duplicate node values. Modify the tre...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a Python program to take a date and return the day of the week." }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python program that takes a date and returns the day of the week. Hmm, how do I approach this? Let's think.\n\nFirst, the user w...
code
DeepSeek-R1
[ { "from": "user", "value": "Implement a Python function that takes a list of numbers and a number (`target`) and returns True if there are any two numbers in the list that add up to the `target`, otherwise it returns False. Write also a main function for testing.\nnumbers = \\[10, 15, 3, 7\\], target = 17" ...
code
DeepSeek-R1
[ { "from": "user", "value": "Convert a nested list into a pandas DataFrame. You may assume that all sublists contain the same number of elements. data = \\[\\['Name', 'Age', 'Gender'\\], \\['John', 30, 'M'\\], \\['Jane', 25, 'F'\\]\\]" }, { "from": "assistant", "value": "<think>\nOkay, I need to ...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a JavaScript function that filters out non-numeric values from an array of mixed data.\n['123', 456, 'hello', 789, 0.123, '4.56']" }, { "from": "assistant", "value": "<think>\nOkay, I need to write a JavaScript function that filters out non-numeric values from a...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a function that sorts an array of positive integers in reverse order without using any built-in sorting functions." }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python function that sorts an array of positive integers in reverse order, an...
code
DeepSeek-R1
[ { "from": "user", "value": "Given an integer array `arr` and an integer `d`, move the elements of the array such that all elements at index `i` in the new array are at index `i + d` in the original array. If `i + d` is out of bounds, wrap around to the front of the array. Implement a Python function that ta...
code
DeepSeek-R1
[ { "from": "user", "value": "Convert the following binary number `1101101` into decimal." }, { "from": "assistant", "value": "<think>\nOkay, I need to convert the binary number 1101101 to decimal. Let me think about how to do this.\n\nFirst, I remember that each digit in a binary number represent...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a program that converts a decimal number into its binary equivalent. For example, 12 would be represented as 1100 in binary.\ndecimal\\_num = 12\nImplement a program that converts a given decimal number into its binary equivalent, however, include an additional step where y...
code
DeepSeek-R1
[ { "from": "user", "value": "Your mission is to write a C++ code snippet that will take a number, 5 in this case, as input and calculate its factorial." }, { "from": "assistant", "value": "<think>\nOkay, I need to write a C++ code snippet that calculates the factorial of 5. But wait, the user ask...
code
DeepSeek-R1
[ { "from": "user", "value": "Now, write a Python program that can delete all duplicates from a sorted linked list such that each element appears only once and return the linked list sorted as well, using the following LinkedList class:\n\n```python\nclass ListNode:\n def __init__(self, x):\n self.v...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a function that accepts two sorted arrays and merges them into a single sorted array.\narr1 = \\[1, 3, 5], arr2 = \\[2, 4, 6]" }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python function that merges two sorted arrays into a single sorted...
code
DeepSeek-R1
[ { "from": "user", "value": "You are given a string with integers representing points on a 2D plane separated by spaces. Points are written as \"X Y\", where X and Y are integers. Each point is represented by a pair of X and Y coordinates. Write a function in Python that sorts the list of points by X coordin...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a program to reverse a linked list.\nInput Linked List: 1 -> 2 -> 3 -> 4 -> 5 -> NULL" }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python program to reverse a linked list. Let's see. The input is 1->2->3->4->5->NULL, and the output shoul...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a function to find the minimum number of coins required to make up a given total, using coins of the following denominations: `1, 5, 10, 25`." }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python function that calculates the minimum number...
code
DeepSeek-R1
[ { "from": "user", "value": "You have a list of phrases and you want to find out which phrase is the longest. Write a program that will take a list of phrases and return the longest phrase in the list.\nphrases = \\[\"hello world\", \"good day\", \"short\", \"very long phrase\"]\nYou have a list of phrases. ...
code
DeepSeek-R1
[ { "from": "user", "value": "Given an input string, return the longest palindromic substring. For example, if the input is \"babad\", the output should be \"bab\" or \"aba\". If the input is \"cbbd\", the output should be \"bb\".\nGiven an input string, return the longest palindromic substring that is also a...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "## Implementing the Palindrome Function\n\n### Description\nThis function checks whether a given string is a palindrome or not. It takes into account the case sensitivity and spaces or punctuation in the string.\n\n### Code\n\n```...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "## Step 1: Define the problem and constraints\nWe need to select a team of 5 players from 11 players with the following constraints: at least 1 forward, at least 2 midfielders, and at least 1 defender.\n\n## Step 2: Determine the ...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Given a 2D list, write a program that transposes the rows and columns." }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python program that transposes a 2D list. Transposing means converting rows into columns and vice versa. Let me think about how...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a Julia function that takes a string as input and returns the string with all vowels removed." }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Julia function that removes all vowels from a given string. Wait, but the user asked for Python co...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a program that will find all the islands in a 3D binary grid and return the number of islands. An island is a group of 1s connected in 6-directionally (horizontal, vertical, and 4-diagonally.)\n\nOriginal Instruction:\n- Create a function to process the grid.\n- Iterate ove...
code
DeepSeek-R1
[ { "from": "user", "value": "Include a user-specified tolerance range and a separate function to validate if the converted temperature falls within this range. The function must take the tolerance as an argument, along with the Réaumur temperature. It must then check if the Réaumur temperature falls within t...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "Certainly! I'll outline a step-by-step solution to insert a new value as the deepest leftmost child of a binary tree represented as a list. This will involve creating a function that can handle various tree structures and insert t...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Write a Python function that finds the longest substring without repeating characters." }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python function to find the longest substring without repeating characters. Hmm, how do I approach this? Let me...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "**Longest Common Prefix Function**\n====================================\n\n### Function Description\n\nThe `longest_common_prefix` function takes a list of strings as input and returns the longest string that is a prefix of all t...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Write a function that computes the `n`th Fibonacci number using memoization. The function should take an integer `n` as input and return the `n`th Fibonacci number, using memoization to avoid redundant computation.\nImplement the same function, but now also allow it to handle neg...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a function that takes a list of integers and returns the second largest number in the list. The list may contain duplicate values.\nnums = \\[5,2,9,3,5,6,7,1,2,9\\]" }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python function that finds ...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a Python program to find the smallest number that can be expressed as the sum of the cubes of the digits of a given number n in base 10.\nn = 4150" }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python program that finds the smallest number...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "# Step-by-step analysis of the problem:\n1. **Understanding the function's purpose**: The function `find_string_length` is supposed to return the length of a given sentence, but with a limit of 5 characters. This means if the sent...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Write a program to find the average of all the numbers in a file named `numbers.txt`." }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python program that finds the average of all the numbers in a file called numbers.txt. Let me think about how to...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a Python program to convert a list of tuples into a dictionary.\nList of Tuples: [('k1', 'v1'), ('k2', 'v2'), ('k3', 'v3')]" }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python program that converts a list of tuples into a dictionary. Let...
code
DeepSeek-R1
[ { "from": "user", "value": "Increase the difficulty of the given problem by including a requirement to return `null` or `None` if the input graph contains a cycle. Make sure your solution handles this situation without altering the original method's time complexity (O(V + E)) for topological sort.\n\nNew In...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "Here is a Python program that solves the problem:\n\n```python\ndef largest_odd(numbers_list):\n \"\"\"\n This function takes in a list of integers 'numbers_list' and returns the largest odd number that occurs more than once...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Write a Python function that takes as input a dictionary with key-value pairs representing the grades of a student in various subjects. The function should return the average of all these grades.\n{'Mathematics': 85, 'Physics': 90, 'Chemistry': 88, 'English': 95, 'History': 82}\n...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a Python program that generates all permutations of a given string. You can use the built-in `permutations()` function from the `itertools` module. ``` from itertools import permutations def all_permutations(input_string): ```\n\"abc\"" }, { "from": "assistant", ...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a Python program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both included). The numbers obtained should be printed in a comma-separated sequence on a single line." }, { "from": "assistant", "valu...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "```python\ndef find_cards(deck):\n card_indices = {\n 'Jack_green': None,\n 'Queen_red': None,\n 'King_blue': None,\n 'Joker_yellow_first': None,\n 'Joker_yellow_second': None\n }\n\n fo...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "### Calculating Average Score from a Text File\n#### Program Description\n\nThis program reads scores from a text file, converts them to float, and calculates the average score.\n\n#### Code\n\n```python\ndef average_score(filenam...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Write a Python function that takes a string as input and returns a new string with the first and last characters swapped.\nInput String: \"example\"" }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python function that swaps the first and last cha...
code
DeepSeek-R1
[ { "from": "user", "value": "Can you write a python code that will take a list of strings as input and return a new list that contains the same strings but sorted by length? The list: `[\"python\", \"is\", \"easy\", \"to\", \"learn\", \"i\", \"love\", \"it\"]`" }, { "from": "assistant", "value": ...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "### Calculating Distance between Two Points\n#### Function Description\nThe function `calculate_distance` calculates the distance between two points given by their x, y coordinates.\n\n#### Code\n```python\nimport math\n\ndef calc...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Given an integer `n`, return _the decimal representation of the **binary** number_ _that_ _has_ _a_ _trailing_ _zeros and a_ _leading_ _zeros_ in its binary representation. Consider the decimal representations of integers as binary strings. s = 2, a = 1, b = 3" }, { "from...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a Python program to create a dictionary from a string. The string is: `'First=1&Second=2&Third=3&Fourth&Fifth&'`. You are required to handle missing values, multiple delimiters, and empty keys. In case of missing value, assign 'N/A'. For empty keys, assign 'KEY_EMPTY'. Main...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "Certainly! I'll provide a comprehensive solution to implement a function that replaces all occurrences of a specific pattern in a given string with a given replacement, considering both literal strings and regular expressions as p...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Now, implement a Python function to calculate the factorial of a given number. The function should return the result." }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python function to calculate the factorial of a number. Let's think about how fa...
code
DeepSeek-R1
[ { "from": "user", "value": "Edit the following function to add one to each item in the input list:\n```\ndef increment_list(lst):\n for i in lst:\n i += 1\n```\nUpdate the given function to add one to each item in the input list and also to double the length of the input list. Initially, fill the ...
code
DeepSeek-R1
[ { "from": "user", "value": "" }, { "from": "assistant", "value": "**Digit Sum Function**\n=======================\n\n### Description\nThis function calculates the sum of digits of a given positive integer.\n\n### Code\n```python\ndef sum_of_digits(n: int) -> int:\n \"\"\"\n Calculate the s...
code
Llama-3.3-70B-Instruct
[ { "from": "user", "value": "Implement a Python function named `detect_anagrams` that takes two strings as input and returns True if they are anagrams of each other and False otherwise. Anagrams are words or phrases formed by rearranging the letters of a different word or phrase using all the original letter...
code
DeepSeek-R1
[ { "from": "user", "value": "You are now given a **sparse binary tree** where each level of the tree is sparsely filled, with many NULL nodes. The binary tree has the following definition:\n\nstruct Node {\n int val;\n Node *left;\n Node *right;\n Node *next;\n}\n\nPopulate each next pointer to point to ...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a program that takes in a list of numbers and outputs a new list that consists of just the odd numbers, then sorts the odd numbers in increasing order.\n\\[-34, -5, -4, -3, 45, 34, 0, 23, -21, 54, 67, 8, 9\\]\nAdditionally, implement a mechanism to remove duplicates from th...
code
DeepSeek-R1
[ { "from": "user", "value": "Write a function named `is_even(n)` in Python that takes an integer `n` as input and returns `True` if `n` is an even number, otherwise `False`.\nn = 6" }, { "from": "assistant", "value": "<think>\nOkay, I need to write a Python function called is_even that checks if ...
code
DeepSeek-R1