target
stringlengths
29
3.65k
data_source
stringclasses
12 values
prompt
listlengths
1
1
ability
stringclasses
1 value
reward_model
dict
extra_info
dict
import re def count_unique_words(sentence): # Extract all words, including those with apostrophes words = re.findall(r"[a-zA-Z']+", sentence) unique_words = set() for word in words: # Remove apostrophes and convert to lowercase cleaned_word = word.replace("'", "").lower() if cle...
simplelr_Filter
[ { "content": "Question:\nConstruct a Python function to count the number of unique words in a given sentence. The function should disregard any punctuation marks and consider words that are in different cases (e.g., \"This\" and \"this\") as the same word.\nAnswer:\nLet's think step by step.\n", "role": "us...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3700, "level": 1, "question": "Construct a Python function to count the number of unique words in a given sentence. The function should disregard any punctuation marks and consider words that are in different cases (e.g., \"This\" and \"this\") as the same word.", "split": "train"...
def remove_comments_from_json(file_path): with open(file_path, 'r') as f: content = f.read() output = [] i = 0 n = len(content) in_string = False string_type = None escape_next = False while i < n: if escape_next: output.append(content[i]) escape...
simplelr_Filter
[ { "content": "Question:\nAs a data scientist, you have been provided with a dataset that contains information about different products, including their prices and categories. The dataset is in a JSON file, and you want to read it into a pandas DataFrame for further analysis. However, when you try to read the JS...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3701, "level": 1, "question": "As a data scientist, you have been provided with a dataset that contains information about different products, including their prices and categories. The dataset is in a JSON file, and you want to read it into a pandas DataFrame for further analysis. H...
import wave import struct def normalize_wav(input_filename: str, output_filename: str) -> None: """ Normalizes the audio levels of a WAV file. Args: input_filename (str): The filename of the input WAV file. output_filename (str): The filename where the normalized output should be saved. ...
simplelr_Docs
[ { "content": "Question:\n### Audio Processing with the `wave` Module\n\n#### Problem Description\n\nYou are tasked with writing a Python function that processes an input WAV audio file to normalize its audio levels. The function should read the input WAV file, normalize its audio levels so that the loudest part...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3702, "level": 1, "question": "### Audio Processing with the `wave` Module\n\n#### Problem Description\n\nYou are tasked with writing a Python function that processes an input WAV audio file to normalize its audio levels. The function should read the input WAV file, normalize its au...
from collections import Counter def canFormPalindrome(s): count = Counter(s) odd_count = 0 for v in count.values(): if v % 2 != 0: odd_count += 1 n = len(s) if n % 2 == 0: return "YES" if odd_count == 0 else "NO" else: return "YES" if odd_count == 1 else "NO"...
simplelr_Taco
[ { "content": "Question:\nGiven a string, Geek wants to determine if the string can be converted to a palindrome by rearranging its characters. If it is possible, return \"YES\", otherwise return \"NO\".\nExample 1:\nInput:\ns = \"civic\"\nOutput: \"YES\"\nExplanation: The string \"civic\" is already a palindrom...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3703, "level": 1, "question": "Given a string, Geek wants to determine if the string can be converted to a palindrome by rearranging its characters. If it is possible, return \"YES\", otherwise return \"NO\".\nExample 1:\nInput:\ns = \"civic\"\nOutput: \"YES\"\nExplanation: The stri...
def filter_long_strings(input_list): return [s for s in input_list if len(s) > 5]
simplelr_Filter
[ { "content": "Question:\nI want to create a function that takes a list of strings and returns a new list with only the strings that have a length greater than 5 characters. How can I do this in Python?\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3704, "level": 1, "question": "I want to create a function that takes a list of strings and returns a new list with only the strings that have a length greater than 5 characters. How can I do this in Python?", "split": "train" }
def max_subarray_sum(arr): if not arr: return 0 # Handles empty array case current_max = max_so_far = arr[0] for num in arr[1:]: current_max = max(num, current_max + num) if current_max > max_so_far: max_so_far = current_max return max_so_far
simplelr_Filter
[ { "content": "Question:\nIs it possible to implement a function in Python that can find the maximum sum of a subarray in an array with a time complexity of O(n)? If so, how can it be done?\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3705, "level": 1, "question": "Is it possible to implement a function in Python that can find the maximum sum of a subarray in an array with a time complexity of O(n)? If so, how can it be done?", "split": "train" }
import bisect def longest_increasing_subsequence(transactions: list[int]) -> int: tails = [] for x in transactions: index = bisect.bisect_left(tails, x) if index == len(tails): tails.append(x) else: tails[index] = x return len(tails)
simplelr_Data_Structure
[ { "content": "Question:\nLongest Increasing Subsequence\n\n**Context**: You are a software engineer tasked with analyzing and optimizing a dataset for an e-commerce platform. The platform wants to better understand the patterns in user transaction sequences, and your task is to identify the longest subsequence ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3706, "level": 1, "question": "Longest Increasing Subsequence\n\n**Context**: You are a software engineer tasked with analyzing and optimizing a dataset for an e-commerce platform. The platform wants to better understand the patterns in user transaction sequences, and your task is t...
def firstNonRepeatingCharacter(s): freq = {} for char in s: if char in freq: freq[char] += 1 else: freq[char] = 1 for char in s: if freq[char] == 1: return char return ""
simplelr_Apps
[ { "content": "Question:\nImplement a function that takes a string consisting of lowercase letters and returns the first non-repeating character in it. If all characters are repeating, return an empty string.\n\n\nYou may assume that the string is non-empty.\n\n\nNote:\nThe input string will contain only lowerca...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3707, "level": 1, "question": "Implement a function that takes a string consisting of lowercase letters and returns the first non-repeating character in it. If all characters are repeating, return an empty string.\n\n\nYou may assume that the string is non-empty.\n\n\nNote:\nThe inp...
def minOperations(num1: int, num2: int) -> int: set_bits = bin(num1).count('1') if set_bits <= num2: return set_bits else: return -1
simplelr_Leetcode
[ { "content": "Question:\nYou are given two positive integers `num1` and `num2`. You can perform the following operation any number of times: choose a non-negative integer `k` such that `2^k` is less than or equal to `num1`, and subtract `2^k` from `num1`. Additionally, each time you perform this operation, `num...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3708, "level": 1, "question": "You are given two positive integers `num1` and `num2`. You can perform the following operation any number of times: choose a non-negative integer `k` such that `2^k` is less than or equal to `num1`, and subtract `2^k` from `num1`. Additionally, each ti...
def spaced_binary(n): return ' '.join(bin(n)[2:])
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes an integer n as input and returns a string that represents the binary equivalent of n, but with each bit separated by a space for better readability. For example, for input 5, the function should return the string \"1 0 1\".\nAnswer:\nLet's think step by ste...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3709, "level": 1, "question": "Create a function that takes an integer n as input and returns a string that represents the binary equivalent of n, but with each bit separated by a space for better readability. For example, for input 5, the function should return the string \"1 0 1\"...
from typing import List, Dict, Any def most_expensive_order(orders: List[Dict[str, Any]]) -> Dict[str, Any]: return max(orders, key=lambda order: order['total_amount'])
simplelr_Algorithm
[ { "content": "Question:\n### Coding Assessment Question:\n\n#### Scenario:\nYou are developing a utility for a large-scale online shopping platform. One crucial feature is an order summarization tool that aggregates essential statistics about orders placed by customers. One of the key statistics is determining ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3710, "level": 1, "question": "### Coding Assessment Question:\n\n#### Scenario:\nYou are developing a utility for a large-scale online shopping platform. One crucial feature is an order summarization tool that aggregates essential statistics about orders placed by customers. One of...
def int_to_hex(n): if n == 0: return '0' sign = False if n < 0: sign = True n = -n hex_digits = '0123456789abcdef' digits = [] while n > 0: rem = n % 16 digits.append(hex_digits[rem]) n = n // 16 hex_str = ''.join(reversed(digits)) if sign:...
simplelr_Prefill
[ { "content": "Question:\nWrite a function to convert a given integer to its hexadecimal representation.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3711, "level": 1, "question": "Write a function to convert a given integer to its hexadecimal representation.", "split": "train" }
def find_smallest_missing_positive(nums): if not nums: return 1 return nums[-1] + 1
simplelr_Leetcode
[ { "content": "Question:\nGiven an array of unique integers `nums` sorted in an increasing order, you are asked to find the smallest positive integer that is not present in the array `nums` and is also larger than the last element in `nums`. Return this smallest positive integer. If such an integer does not exis...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3712, "level": 1, "question": "Given an array of unique integers `nums` sorted in an increasing order, you are asked to find the smallest positive integer that is not present in the array `nums` and is also larger than the last element in `nums`. Return this smallest positive intege...
def accum(s): segments = [] for i, c in enumerate(s): segment = c.upper() + c.lower() * i segments.append(segment) return '-'.join(segments)
simplelr_Taco
[ { "content": "Question:\nCreate a function `accum(s)` that takes a string `s` and returns an accumulated format of each character, where each character's position determines its repetition and each repetition starts with a capitalized letter. Each element should be joined with a hyphen ('-').\n\nFor example, gi...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3713, "level": 1, "question": "Create a function `accum(s)` that takes a string `s` and returns an accumulated format of each character, where each character's position determines its repetition and each repetition starts with a capitalized letter. Each element should be joined with...
def create_student(student): grade_gpa = {'A': 4.0, 'B': 3.0, 'C': 2.0, 'D': 1.0, 'F': 0.0} student_copy = student.copy() student_copy['gpa'] = grade_gpa.get(student['grade'], 0.0) return student_copy
simplelr_Filter
[ { "content": "Question:\nCreate a function called `create_student` that expects a dictionary with keys 'name' and 'grade' (both strings), and returns a new dictionary with the added key 'gpa' which is the grade point average calculated from the 'grade' key in the input dictionary.\nAnswer:\nLet's think step by ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3714, "level": 1, "question": "Create a function called `create_student` that expects a dictionary with keys 'name' and 'grade' (both strings), and returns a new dictionary with the added key 'gpa' which is the grade point average calculated from the 'grade' key in the input diction...
def get_neighbors(graph, node): return graph.get(node, []) # Example usage: graph = { 'A': ['B', 'C'], 'B': ['A', 'D', 'E'], 'C': ['A', 'F'], 'D': ['B'], 'E': ['B', 'F'], 'F': ['C', 'E'] } print(get_neighbors(graph, 'B')) # Output: ['A', 'D', 'E'] print(get_neighbors(graph, 'X')) # Outpu...
simplelr_Filter
[ { "content": "Question:\nHow can I find the immediate neighbors of a specific node in a graph represented in a dictionary format in Python? Given a graph where each key is a node and its value is a list of its neighbors, how can I retrieve the neighbors of a particular node?\nAnswer:\nLet's think step by step.\...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3715, "level": 1, "question": "How can I find the immediate neighbors of a specific node in a graph represented in a dictionary format in Python? Given a graph where each key is a node and its value is a list of its neighbors, how can I retrieve the neighbors of a particular node?",...
def sum_of_list(numbers): total = 0 for num in numbers: total += num return total
simplelr_Filter
[ { "content": "Question:\nYou are given a list of numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9]. You need to write a Python function that will take this list as an input and return the sum of all the numbers in the list. You should use a loop to iterate over the list and add up the numbers.\nAnswer:\nLet's think step by ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3716, "level": 1, "question": "You are given a list of numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9]. You need to write a Python function that will take this list as an input and return the sum of all the numbers in the list. You should use a loop to iterate over the list and add up the numb...
from typing import List def cumulative_sum(numbers: List[int]) -> List[int]: current_sum = 0 result = [] for num in numbers: current_sum += num result.append(current_sum) return result
simplelr_Evol
[ { "content": "Question:\nYou are given a list of integers. Your task is to create a new list where each element at position `i` is the cumulative sum from the start of the list up to the position `i` in the original list. Write a function `cumulative_sum` that takes a list as input and returns the new list with...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3717, "level": 1, "question": "You are given a list of integers. Your task is to create a new list where each element at position `i` is the cumulative sum from the start of the list up to the position `i` in the original list. Write a function `cumulative_sum` that takes a list as ...
def find_missing_number(arr): n = len(arr) + 1 total = n * (n + 1) // 2 sum_of_arr = sum(arr) return total - sum_of_arr # Example usage: # arr = [1, 2, 4, 5, 6] # print(find_missing_number(arr)) # Output: 3
simplelr_Evol
[ { "content": "Question:\nCreate a function named `find_missing_number` that takes a list of unique integers ranging from 1 to n (inclusive), where one number is missing. The function should find and return the missing number. For example, if the input list is `[1, 2, 4, 5, 6]`, the output should be `3` since `3...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3718, "level": 1, "question": "Create a function named `find_missing_number` that takes a list of unique integers ranging from 1 to n (inclusive), where one number is missing. The function should find and return the missing number. For example, if the input list is `[1, 2, 4, 5, 6]`...
def run_length_encoding(input_string: str) -> str: """ Encodes the input string using Run Length Encoding (RLE). Parameters: input_string (str): The string to be encoded. Returns: str: The RLE encoded string. """ if not input_string: return "" current_char = input_string[0]...
simplelr_Algorithm
[ { "content": "Question:\n### Problem Statement:\nYou are tasked with implementing a simple compression algorithm known as **Run Length Encoding (RLE)**, which is a basic form of lossless data compression. The idea is to take a string and count consecutive occurrences of each character, encoding them as the char...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3719, "level": 1, "question": "### Problem Statement:\nYou are tasked with implementing a simple compression algorithm known as **Run Length Encoding (RLE)**, which is a basic form of lossless data compression. The idea is to take a string and count consecutive occurrences of each c...
def evaluate_expression(expression: str) -> float: tokens = expression.split() precedence = {'+': 1, '-': 1, '*': 2, '/': 2, '(': 0} output = [] stack = [] for token in tokens: if token == '(': stack.append(token) elif token == ')': while stack and stack[...
simplelr_Taco
[ { "content": "Question:\nWrite a function that takes a string containing a mathematical expression with positive integers and the operators +, -, *, and / (addition, subtraction, multiplication, and division respectively). It will be in a valid infix format, where each operator and operands are separated by spa...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3720, "level": 1, "question": "Write a function that takes a string containing a mathematical expression with positive integers and the operators +, -, *, and / (addition, subtraction, multiplication, and division respectively). It will be in a valid infix format, where each operato...
def print_max(a, b): print(max(a, b))
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes two arguments and prints the maximum of the two.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3721, "level": 1, "question": "Create a function that takes two arguments and prints the maximum of the two.", "split": "train" }
def find_duplicates(lst): counts = {} duplicates = [] for num in lst: if num in counts: counts[num] += 1 if counts[num] == 2: duplicates.append(num) else: counts[num] = 1 return duplicates
simplelr_Filter
[ { "content": "Question:\nGoal: Implement a Python function named `find_duplicates` that takes a list of integers as input and returns a new list containing only the duplicate elements from the input list.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3722, "level": 1, "question": "Goal: Implement a Python function named `find_duplicates` that takes a list of integers as input and returns a new list containing only the duplicate elements from the input list.", "split": "train" }
def rental_cost(days: int) -> int: total = days * 40 discount = 0 if days >= 7: discount = 50 elif days >= 3: discount = 20 return total - discount
simplelr_Apps
[ { "content": "Question:\nCar Rental Discounts\n\nYou are the manager of a car rental company, and you want to offer special discounts to loyal customers. Customers who rent cars are eligible for a discount based on the number of days they rent.\n\nHere are the rules for the discounts:\n- If a customer rents a c...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3723, "level": 1, "question": "Car Rental Discounts\n\nYou are the manager of a car rental company, and you want to offer special discounts to loyal customers. Customers who rent cars are eligible for a discount based on the number of days they rent.\n\nHere are the rules for the di...
def mean_squared_error(predictions, actuals): return sum((p - a) ** 2 for p, a in zip(predictions, actuals)) / len(predictions)
simplelr_Package
[ { "content": "Question:\nYou need to write a function that evaluates the mean squared error (MSE) between two lists of numbers. Mean squared error is a metric often used to measure the average squared difference between predicted and actual values, common in regression analysis. \n\nYour task is to create a fun...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3724, "level": 1, "question": "You need to write a function that evaluates the mean squared error (MSE) between two lists of numbers. Mean squared error is a metric often used to measure the average squared difference between predicted and actual values, common in regression analysi...
def group_strings_by_vowel_ending_count(string_list): vowels = {'a', 'e', 'i', 'o', 'u'} freq = {} for s in string_list: if s in freq: freq[s] += 1 else: freq[s] = 1 result = {} for s, count in freq.items(): if len(s) > 0 and s[-1].lower() in vowe...
simplelr_Filter
[ { "content": "Question:\nCreate a python function that takes a list of strings as an argument and then returns a dictionary where each key is an integer representing the number of times a string in the argument list ends with a vowel, and the value is a list of strings that end with a vowel and occur the number...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3725, "level": 1, "question": "Create a python function that takes a list of strings as an argument and then returns a dictionary where each key is an integer representing the number of times a string in the argument list ends with a vowel, and the value is a list of strings that en...
def missing_number(nums): n = len(nums) sum_total = n * (n + 1) // 2 sum_nums = sum(nums) return sum_total - sum_nums
simplelr_Leetcode
[ { "content": "Question:\nGiven an array of integers `nums` containing `n` distinct numbers in the range `[0, n]`, return the only number in the range that is missing from the array. You must solve this in **O(n)** time complexity using **constant extra space**.\nAnswer:\nLet's think step by step.\n", "role"...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3726, "level": 1, "question": "Given an array of integers `nums` containing `n` distinct numbers in the range `[0, n]`, return the only number in the range that is missing from the array. You must solve this in **O(n)** time complexity using **constant extra space**.", "split": "t...
def sum_of_digits_divisible_by_3(n): total = 0 n = abs(n) while n > 0: digit = n % 10 if digit % 3 == 0: total += digit n = n // 10 return total
simplelr_Prefill
[ { "content": "Question:\nWrite a function to calculate the sum of the digits of a given number `n` that are divisible by 3. For example, if `n` is 12345, the function should return 9 because 3 + 6 = 9 (3, 6 are the digits of 12345 that are divisible by 3).\nAnswer:\nLet's think step by step.\n", "role": "us...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3727, "level": 1, "question": "Write a function to calculate the sum of the digits of a given number `n` that are divisible by 3. For example, if `n` is 12345, the function should return 9 because 3 + 6 = 9 (3, 6 are the digits of 12345 that are divisible by 3).", "split": "train"...
def first_duplicate(arr): seen = set() for num in arr: if num in seen: return num seen.add(num) return None
simplelr_Filter
[ { "content": "Question:\nGiven an unsorted array of integers, design an algorithm and write the code to find the first duplicate in the array. \nFor the array [2,1,3,5,3,2], the output should be 3 because 3 is the first duplicate in the array.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3728, "level": 1, "question": "Given an unsorted array of integers, design an algorithm and write the code to find the first duplicate in the array. \nFor the array [2,1,3,5,3,2], the output should be 3 because 3 is the first duplicate in the array.", "split": "train" }
def strip_url_params(url: str, params_to_strip: list = None) -> str: """ Remove duplicate and unwanted query parameters from the URL. Parameters: - url (str): The URL string from which to remove query parameters. - params_to_strip (list): A list of parameter keys to remove from the URL query string...
simplelr_Data_Structure
[ { "content": "Question:\n### URL Query Parameter Processor\n\n### Context:\nYou are working on an SEO tool that needs to clean up URLs by removing redundant query parameters and specified undesired parameters. URLs often contain repeated parameters or parameters that are irrelevant to the points being analyzed....
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3729, "level": 1, "question": "### URL Query Parameter Processor\n\n### Context:\nYou are working on an SEO tool that needs to clean up URLs by removing redundant query parameters and specified undesired parameters. URLs often contain repeated parameters or parameters that are irrel...
def count_unique_elements(arr1, arr2): unique_arr1 = set(arr1) set_arr2 = set(arr2) count = 0 for num in unique_arr1: if num not in set_arr2: count += 1 return count
simplelr_Leetcode
[ { "content": "Question:\nYou are given two arrays of integers `arr1` and `arr2`, possibly of different lengths. Your task is to find the number of distinct elements in `arr1` which are not present in `arr2`. Return the count of such unique elements. Note that the elements of the arrays can only be integers with...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3730, "level": 1, "question": "You are given two arrays of integers `arr1` and `arr2`, possibly of different lengths. Your task is to find the number of distinct elements in `arr1` which are not present in `arr2`. Return the count of such unique elements. Note that the elements of t...
def next_greater_elements(nums): stack = [] result = [] for num in reversed(nums): while stack and stack[-1] <= num: stack.pop() if stack: result.append(stack[-1]) else: result.append(-1) stack.append(num) return result[::-1]
simplelr_Filter
[ { "content": "Question:\nWrite a Python function to find the next greater element for each element in a given list of integers. If no greater element exists, the function should return -1 for that element. The function should have a time complexity of O(n).\nAnswer:\nLet's think step by step.\n", "role": "u...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3731, "level": 1, "question": "Write a Python function to find the next greater element for each element in a given list of integers. If no greater element exists, the function should return -1 for that element. The function should have a time complexity of O(n).", "split": "train...
def find_gcd(a, b): a = abs(a) b = abs(b) while b: a, b = b, a % b return a # Example usage print(find_gcd(48, 18)) # Output: 6
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes two integers as parameters and returns the greatest common divisor (GCD) of those two numbers. The function should be called `find_gcd()`. Additionally, provide an example of how to call the function with two integers.\nAnswer:\nLet's think step by step.\n",...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3732, "level": 1, "question": "Create a function that takes two integers as parameters and returns the greatest common divisor (GCD) of those two numbers. The function should be called `find_gcd()`. Additionally, provide an example of how to call the function with two integers.", ...
def most_expensive_item(items): if not items: return None most_expensive = max(items, key=lambda x: x['price']) return most_expensive['name']
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to identify the most expensive item in a list of items, each represented as a dictionary with keys 'name' and 'price'. The function should return the name of the most expensive item. If the list is empty, the function should return None.\nAnswer:\nLet's think ste...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3733, "level": 1, "question": "Write a python function to identify the most expensive item in a list of items, each represented as a dictionary with keys 'name' and 'price'. The function should return the name of the most expensive item. If the list is empty, the function should ret...
def add_key_if_not_empty(dictionary, key, value): if not dictionary: print("Error: Dictionary is empty. Cannot add new key-value pair.") else: dictionary[key] = value
simplelr_Filter
[ { "content": "Question:\nWrite a code to add a new key and value to a given dictionary, but only if the dictionary is not empty. If the dictionary is empty, print an error message stating that the dictionary is empty. The dictionary should have at least one existing key-value pair.\nAnswer:\nLet's think step by...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3734, "level": 1, "question": "Write a code to add a new key and value to a given dictionary, but only if the dictionary is not empty. If the dictionary is empty, print an error message stating that the dictionary is empty. The dictionary should have at least one existing key-value ...
def rotate_90_clockwise(matrix): reversed_matrix = matrix[::-1] transposed = zip(*reversed_matrix) rotated = [list(row) for row in transposed] return rotated
simplelr_Filter
[ { "content": "Question:\nCan you provide a Python function to rotate a 2D matrix 90 degrees clockwise?\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3735, "level": 1, "question": "Can you provide a Python function to rotate a 2D matrix 90 degrees clockwise?", "split": "train" }
def reverse_list(lst): n = len(lst) for i in range(n // 2): lst[i], lst[n - 1 - i] = lst[n - 1 - i], lst[i] return lst
simplelr_Filter
[ { "content": "Question:\nCreate a function to reverse a list without using the reverse() method and without using any built-in Python functions or methods that directly manipulate the list. Additionally, you are not allowed to use any additional data structures such as a stack or queue. The function should have...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3736, "level": 1, "question": "Create a function to reverse a list without using the reverse() method and without using any built-in Python functions or methods that directly manipulate the list. Additionally, you are not allowed to use any additional data structures such as a stack...
def contains_duplicates(lst): seen = set() for num in lst: if num in seen: return True seen.add(num) return False
simplelr_Filter
[ { "content": "Question:\nYou've been tasked with designing an algorithm to detect whether a given list of integers contains duplicate elements. The algorithm should return `True` if duplicates exist and `False` otherwise. \n\nWhat would be an efficient approach to solve this problem, and how would you implement...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3737, "level": 1, "question": "You've been tasked with designing an algorithm to detect whether a given list of integers contains duplicate elements. The algorithm should return `True` if duplicates exist and `False` otherwise. \n\nWhat would be an efficient approach to solve this p...
def vector_addition(a, b): max_len = max(len(a), len(b)) result = [] for i in range(max_len): if i < len(a) and i < len(b): result.append(a[i] + b[i]) elif i < len(a): result.append(a[i]) else: result.append(b[i]) return result
simplelr_Filter
[ { "content": "Question:\nWrite a function to perform vector addition for two 1D arrays. The function should also handle cases where the lengths of the two arrays are not equal.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3738, "level": 1, "question": "Write a function to perform vector addition for two 1D arrays. The function should also handle cases where the lengths of the two arrays are not equal.", "split": "train" }
from typing import List def find_missing_positive(cards: List[int]) -> int: positive = set(x for x in cards if x > 0) i = 1 while True: if i not in positive: return i i += 1
simplelr_Codeforces
[ { "content": "Question:\nIn a card game, each unique card has a value from 1 to N. However, the deck can contain duplicates, and the cards may not be sorted in any particular order. You are required to identify the smallest missing positive integer from the deck.\n\nYou are given an array of integers representi...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3739, "level": 1, "question": "In a card game, each unique card has a value from 1 to N. However, the deck can contain duplicates, and the cards may not be sorted in any particular order. You are required to identify the smallest missing positive integer from the deck.\n\nYou are gi...
def findOOVWords(sentences, vocab): oov_dict = {} for sentence in sentences: words = sentence.split() oov_words = [word for word in words if word not in vocab] oov_dict[sentence] = oov_words return oov_dict
simplelr_Filter
[ { "content": "Question:\nWrite a python function named `findOOVWords` that identifies Out-Of-Vocabulary (OOV) words from a list of sentences compared to a given vocabulary set. The function should return a dictionary where keys are the sentences, and the values are lists containing the OOV words found in each c...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3740, "level": 1, "question": "Write a python function named `findOOVWords` that identifies Out-Of-Vocabulary (OOV) words from a list of sentences compared to a given vocabulary set. The function should return a dictionary where keys are the sentences, and the values are lists conta...
def max_count_after_operations(m: int, n: int, ops: list[list[int]]) -> int: """ Given dimensions of the grid (m, n) and a list of operations (ops), find the number of maximum integers in the matrix after performing all the operations. """ if not ops: return m * n r_min = min(r for r, c ...
simplelr_Algorithm
[ { "content": "Question:\n### Problem Statement\n\nYou are given a grid of size `m x n` initialized with all `0`s. You are also given several update operations. Each update operation is represented by a 2D array, where each element is `[r, c]` and represents incrementing all elements of the submatrix starting at...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3741, "level": 1, "question": "### Problem Statement\n\nYou are given a grid of size `m x n` initialized with all `0`s. You are also given several update operations. Each update operation is represented by a 2D array, where each element is `[r, c]` and represents incrementing all el...
def check_prime_or_smallest_factor(n): if n < 2: return None for i in range(2, int(n**0.5) + 1): if n % i == 0: return i return n
simplelr_Filter
[ { "content": "Question:\nCan you write a Python function to determine if a number is prime? The function should return `True` if the number is prime and `False` otherwise. Additionally, can you modify the function to return the smallest prime factor of the number if it is not prime? If the number is prime, the ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3742, "level": 1, "question": "Can you write a Python function to determine if a number is prime? The function should return `True` if the number is prime and `False` otherwise. Additionally, can you modify the function to return the smallest prime factor of the number if it is not ...
def num_subarray_product_less_than_k(nums, threshold): if threshold <= 0: return 0 count = 0 n = len(nums) for i in range(n): product = 1 for j in range(i, n): product *= nums[j] if product < threshold: count += 1 else: ...
simplelr_Apps
[ { "content": "Question:\nYou are given an integer array `nums` and an integer `threshold`. Return the number of non-empty subarrays of `nums` whose product is strictly less than `threshold`.\n\nA subarray is a contiguous part of an array.\n\nExample 1:\nInput: nums = [10, 5, 2, 6], threshold = 100\nOutput: 8\nE...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3743, "level": 1, "question": "You are given an integer array `nums` and an integer `threshold`. Return the number of non-empty subarrays of `nums` whose product is strictly less than `threshold`.\n\nA subarray is a contiguous part of an array.\n\nExample 1:\nInput: nums = [10, 5, 2...
def find_max_with_index(lst): if not lst: return (None, None) max_value = lst[0] max_index = 0 for index in range(1, len(lst)): if lst[index] > max_value: max_value = lst[index] max_index = index return (max_value, max_index) # Example usage: numbers = [5, 2,...
simplelr_Filter
[ { "content": "Question:\nHey Qwen, can you help me with a Python script? I need to find the maximum number in a list of integers, but I want to do it in a way that also returns the index of the maximum number. Can you provide a simple script for that?\nAnswer:\nLet's think step by step.\n", "role": "user" ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3744, "level": 1, "question": "Hey Qwen, can you help me with a Python script? I need to find the maximum number in a list of integers, but I want to do it in a way that also returns the index of the maximum number. Can you provide a simple script for that?", "split": "train" }
def delete_indices(original_list, indices_to_delete): delete_set = set(indices_to_delete) return [elem for idx, elem in enumerate(original_list) if idx not in delete_set]
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to delete a list of indices from a list and return the resulting list without those indices.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3745, "level": 1, "question": "Write a python function to delete a list of indices from a list and return the resulting list without those indices.", "split": "train" }
from collections import Counter def topKFrequent(words: list[str], k: int) -> list[str]: count = Counter(words) word_counts = list(count.items()) word_counts.sort(key=lambda x: (-x[1], x[0])) result = [word for word, cnt in word_counts[:k]] return result
simplelr_Taco
[ { "content": "Question:\nYou are given an array of strings `words` and an integer `k`. The task is to return a list of the `k` most frequent words from the array. The result should be sorted by frequency from highest to lowest. If two words have the same frequency, then the word with a lower alphabetical order ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3746, "level": 1, "question": "You are given an array of strings `words` and an integer `k`. The task is to return a list of the `k` most frequent words from the array. The result should be sorted by frequency from highest to lowest. If two words have the same frequency, then the wo...
import math def min_bills(bills: list[int], target: int) -> int: if target == 0: return 0 dp = [math.inf] * (target + 1) dp[0] = 0 for i in range(1, target + 1): for bill in bills: if bill <= i: dp[i] = min(dp[i], dp[i - bill] + 1) return d...
simplelr_Algorithm
[ { "content": "Question:\n### Problem Statement\n\nYou are given a list of integers representing an amount of cash and a target amount that you want to get by using the least number of bills from the list. Write a function that returns the number of bills needed to reach the target amount using a Dynamic Program...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3747, "level": 1, "question": "### Problem Statement\n\nYou are given a list of integers representing an amount of cash and a target amount that you want to get by using the least number of bills from the list. Write a function that returns the number of bills needed to reach the ta...
def int_to_roman(num: int) -> str: roman_numerals = [ (1000, 'M'), (900, 'CM'), (500, 'D'), (400, 'CD'), (100, 'C'), (90, 'XC'), (50, 'L'), (40, 'XL'), (10, 'X'), (9, 'IX'), (5, 'V'), (4, 'IV'), (1, 'I') ] result = '' for value, symbol in roman_numerals: while num >= ...
simplelr_Data_Structure
[ { "content": "Question:\n### **Coding Assessment Question**\n\nDesign a function that converts an integer to its Roman numeral representation. The Roman numerals should follow the standard rules of numeral formation based on the integer's place value (units, tens, hundreds, thousands). \n\n#### Function Signatu...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3748, "level": 1, "question": "### **Coding Assessment Question**\n\nDesign a function that converts an integer to its Roman numeral representation. The Roman numerals should follow the standard rules of numeral formation based on the integer's place value (units, tens, hundreds, th...
def flip_bit_longest_seq(num: int) -> int: if num == 0: return 1 binary_str = bin(num)[2:] if '0' not in binary_str: return len(binary_str) + 1 max_length = 0 for i in range(len(binary_str)): if binary_str[i] == '0': left = 0 j = i - 1 whil...
simplelr_Data_Structure
[ { "content": "Question:\n### Flip Bit to Win: Maximize Sequence of 1s\n\nYou are working as a software developer, and one of your tasks in an optimization project involves fine-tuned bit manipulations. Your current task is to find the longest sequence of 1s that can be obtained by flipping exactly one bit from ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3749, "level": 1, "question": "### Flip Bit to Win: Maximize Sequence of 1s\n\nYou are working as a software developer, and one of your tasks in an optimization project involves fine-tuned bit manipulations. Your current task is to find the longest sequence of 1s that can be obtaine...
import re def remove_vowels(s): return re.sub('[aeiouAEIOU]', '', s) # Example usage: print(remove_vowels("Hello World")) # Outputs: "Hll Wrld" print(remove_vowels("Python is fun")) # Outputs: "Pythn s fn"
simplelr_Filter
[ { "content": "Question:\nOkay, let's get into it.ocoderPATH = 'C:/Users/John/Documents/Python developments/py programs ('\n\nI want to write a Python script that removes all of the vowels from a given string. \nMy COMP6211 assignment requires that it accepts both upper case and lower case letters. \nI assume we...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3750, "level": 1, "question": "Okay, let's get into it.ocoderPATH = 'C:/Users/John/Documents/Python developments/py programs ('\n\nI want to write a Python script that removes all of the vowels from a given string. \nMy COMP6211 assignment requires that it accepts both upper case an...
def pascals_triangle_row(n): """ Computes the nth row of Pascal's Triangle. Parameters: n : int The row index in Pascal's Triangle to compute. Returns: list : A list of integers representing the nth row of Pascal's Triangle. Raises: ValueError : If an invalid t...
simplelr_Algorithm
[ { "content": "Question:\n### Pascal's Triangle Row Calculation\n\n**Scenario**:\nYou are developing a module that involves combinatorial mathematics, specifically to generate rows from Pascal's Triangle, which has applications in algebra and probability. Your task is to create a function that computes the `n'th...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3751, "level": 1, "question": "### Pascal's Triangle Row Calculation\n\n**Scenario**:\nYou are developing a module that involves combinatorial mathematics, specifically to generate rows from Pascal's Triangle, which has applications in algebra and probability. Your task is to create...
from typing import List def min_trucks(package_weights: List[int], truck_limit: int) -> int: package_weights.sort(reverse=True) trucks = [] for weight in package_weights: placed = False for i in range(len(trucks)): if trucks[i] >= weight: trucks[i] -= weight ...
simplelr_Apps
[ { "content": "Question:\nYou are developing software for a logistics company to efficiently manage their deliveries. The company uses trucks to transport different packages, and each truck has a weight limit. Given the list of package weights the company needs to deliver and the weight limit for each truck, you...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3752, "level": 1, "question": "You are developing software for a logistics company to efficiently manage their deliveries. The company uses trucks to transport different packages, and each truck has a weight limit. Given the list of package weights the company needs to deliver and t...
morse_code = { 'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-.....
simplelr_Filter
[ { "content": "Question:\nI've been trying to work on a program to translate morse code to text. I've been working with this code, which is in Python:\n\n```python\nmorse_code = {\n 'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', \n 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', '...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3753, "level": 1, "question": "I've been trying to work on a program to translate morse code to text. I've been working with this code, which is in Python:\n\n```python\nmorse_code = {\n 'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', \n 'G': '--.', 'H'...
def is_valid_parenthesis(s: str) -> bool: count = 0 for char in s: if char == '(': count += 1 else: count -= 1 if count < 0: return False return count == 0
simplelr_Codeforces
[ { "content": "Question:\nWrite a function to check if a given string containing just the characters `(` and `)` is valid. A string is considered valid if:\n\n1. Open parentheses must be closed by the same type of parentheses.\n2. Open parentheses must be closed in the correct order.\n3. Every close parenthesis ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3754, "level": 1, "question": "Write a function to check if a given string containing just the characters `(` and `)` is valid. A string is considered valid if:\n\n1. Open parentheses must be closed by the same type of parentheses.\n2. Open parentheses must be closed in the correct ...
def can_form_arithmetic_progression(arr): arr.sort() n = len(arr) if n <= 2: return True d = arr[1] - arr[0] for i in range(2, n): if arr[i] - arr[i-1] != d: return False return True
simplelr_Apps
[ { "content": "Question:\nGiven an array of integers, determine whether the elements of the array can be re-arranged to form an arithmetic progression. \n\nAn arithmetic progression is a sequence of numbers whereby the difference between any two consecutive terms is constant.\n\nThe function should return a bool...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3755, "level": 1, "question": "Given an array of integers, determine whether the elements of the array can be re-arranged to form an arithmetic progression. \n\nAn arithmetic progression is a sequence of numbers whereby the difference between any two consecutive terms is constant.\n...
from collections import Counter def contains_all_elements(list1, list2): return Counter(list1) >= Counter(list2)
simplelr_Prefill
[ { "content": "Question:\nCreate a function that determines if a list contains all elements of another list.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3756, "level": 1, "question": "Create a function that determines if a list contains all elements of another list.", "split": "train" }
def largestRectangle(arr): n = len(arr) if n == 0: return 0 left = [-1] * n stack = [] for i in range(n): while stack and arr[stack[-1]] >= arr[i]: stack.pop() if stack: left[i] = stack[-1] else: left[i] = -1 stack.appe...
simplelr_Codeforces
[ { "content": "Question:\nYou are given an array of `n` non-negative integers representing the heights of pillars standing in a straight line. The width of each pillar is 1. You need to find the largest rectangle that can be formed between the pillars such that the rectangle's height is determined by the shortes...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3757, "level": 1, "question": "You are given an array of `n` non-negative integers representing the heights of pillars standing in a straight line. The width of each pillar is 1. You need to find the largest rectangle that can be formed between the pillars such that the rectangle's ...
def sum_list(numbers): return sum(numbers)
simplelr_Prefill
[ { "content": "Question:\nCreate a function that adds the numbers in an input list.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3758, "level": 1, "question": "Create a function that adds the numbers in an input list.", "split": "train" }
def sum_list(numbers): return sum(numbers)
simplelr_Filter
[ { "content": "Question:\nWrite a function in Python that takes a list of numbers as input and returns the sum of all the elements in the list. If the list is empty, the function should return 0. Can you provide a simple and efficient implementation of this function?\nAnswer:\nLet's think step by step.\n", "...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3759, "level": 1, "question": "Write a function in Python that takes a list of numbers as input and returns the sum of all the elements in the list. If the list is empty, the function should return 0. Can you provide a simple and efficient implementation of this function?", "split...
from collections import defaultdict def longest_substring_with_k_distinct(s: str, k: int) -> int: if k == 0 or not s: return 0 char_count = defaultdict(int) left = 0 max_length = 0 for right in range(len(s)): char = s[right] char_count[char] += 1 #...
simplelr_Prefill
[ { "content": "Question:\nWrite a function to return the length of the longest substring in the given string `s` that contains no more than `k` distinct characters.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3760, "level": 1, "question": "Write a function to return the length of the longest substring in the given string `s` that contains no more than `k` distinct characters.", "split": "train" }
def sort_by_second_item(tuple_list): return sorted(tuple_list, key=lambda x: x[1])
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to sort a list of tuples by the second item in each tuple using lambda function.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3761, "level": 1, "question": "Write a python function to sort a list of tuples by the second item in each tuple using lambda function.", "split": "train" }
def length_of_longest_substring_two_distinct(s): count = {} left = 0 max_len = 0 for right in range(len(s)): char = s[right] count[char] = count.get(char, 0) + 1 while len(count) > 2: left_char = s[left] count[left_char] -= 1 if count[left_char...
simplelr_Leetcode
[ { "content": "Question:\nYou are given a non-empty string containing only lowercase alphabetic characters. Write a function to return the length of the longest substring of the given string that contains at most two distinct characters. The substring must be contiguous and may involve any combination of the two...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3762, "level": 1, "question": "You are given a non-empty string containing only lowercase alphabetic characters. Write a function to return the length of the longest substring of the given string that contains at most two distinct characters. The substring must be contiguous and may...
def find_odd_numbers(numbers): return [num for num in numbers if num % 2 != 0] print(find_odd_numbers([1, 2, 3, 4, 5, 6]))
simplelr_Filter
[ { "content": "Question:\ndef find_odd_numbers(numbers):\n return [num for num in numbers if num % 2 != 0]\n\nprint(find_odd_numbers([1, 2, 3, 4, 5, 6]))\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3763, "level": 1, "question": "def find_odd_numbers(numbers):\n return [num for num in numbers if num % 2 != 0]\n\nprint(find_odd_numbers([1, 2, 3, 4, 5, 6]))", "split": "train" }
from collections import deque def min_subarray_length(nums, target): pre = [0] for num in nums: pre.append(pre[-1] + num) dq = deque() dq.append(0) min_len = float('inf') for j in range(1, len(pre)): # Check if current j can form a subarray with some i in dq while dq and...
simplelr_Leetcode
[ { "content": "Question:\nYou are given a list of integers `nums` representing a set of points on a number line. Your task is to find the shortest possible length of a subarray from `nums` such that its sum is at least `target`. If there is no such subarray, return `0` instead. A subarray is a contiguous part of...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3764, "level": 1, "question": "You are given a list of integers `nums` representing a set of points on a number line. Your task is to find the shortest possible length of a subarray from `nums` such that its sum is at least `target`. If there is no such subarray, return `0` instead....
def decode_string(s: str) -> str: stack = [] current_str = '' current_num = 0 for char in s: if char.isdigit(): current_num = current_num * 10 + int(char) elif char == '[': stack.append((current_str, current_num)) current_str = '' current_n...
simplelr_Data_Structure
[ { "content": "Question:\nYour task is to implement a function to decode a given encoded string according to the specific encoding rule provided. The encoding rule is: `k[encoded_string]`, where the `encoded_string` inside the square brackets is repeated exactly `k` times. You are guaranteed that `k` is a positi...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3765, "level": 1, "question": "Your task is to implement a function to decode a given encoded string according to the specific encoding rule provided. The encoding rule is: `k[encoded_string]`, where the `encoded_string` inside the square brackets is repeated exactly `k` times. You ...
def most_frequent_ip(logs: list[str]) -> str: if not logs: return '' counts = {} for log in logs: parts = log.split(' - ') ip = parts[1] counts[ip] = counts.get(ip, 0) + 1 max_count = max(counts.values()) for ip, count in counts.items(): if count == ...
simplelr_Algorithm
[ { "content": "Question:\n#### Scenario:\nYou are a developer at a tech startup tasked with developing a simple log analysis tool. Your job is to write a function that reads a list of log entries and extracts the most frequent IP address from these logs. Each log entry is in the format \"timestamp - IP Address -...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3766, "level": 1, "question": "#### Scenario:\nYou are a developer at a tech startup tasked with developing a simple log analysis tool. Your job is to write a function that reads a list of log entries and extracts the most frequent IP address from these logs. Each log entry is in th...
def is_circular_permutation(s1, s2): if len(s1) != len(s2): return False return s2 in s1 + s1
simplelr_Taco
[ { "content": "Question:\nImplement a function `is_circular_permutation(s1, s2)` that checks if string `s2` is a circular permutation of string `s1`.\n\nA string `s2` is a circular permutation of string `s1` if it can be obtained by shifting the characters of `s1` any number of times.\n\nFor example, for strings...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3767, "level": 1, "question": "Implement a function `is_circular_permutation(s1, s2)` that checks if string `s2` is a circular permutation of string `s1`.\n\nA string `s2` is a circular permutation of string `s1` if it can be obtained by shifting the characters of `s1` any number of...
def length_of_longest_substring_two_distinct(s): if not s: return 0 max_len = 0 freq = {} left = 0 for right in range(len(s)): char = s[right] if char in freq: freq[char] += 1 else: freq[char] = 1 # If the number of distinct characters ...
simplelr_Leetcode
[ { "content": "Question:\nYou are given a **0-indexed** string `s` consisting of lowercase English letters. You need to find the longest substring of `s` that contains no more than two distinct characters. Return the length of such a substring. If there are multiple such substrings with the maximum length, retur...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3768, "level": 1, "question": "You are given a **0-indexed** string `s` consisting of lowercase English letters. You need to find the longest substring of `s` that contains no more than two distinct characters. Return the length of such a substring. If there are multiple such substr...
import seaborn as sns import matplotlib.pyplot as plt def custom_barplot(x, y, style, custom_params): sns.set_style(style, custom_params) sns.barplot(x=x, y=y) plt.show()
simplelr_Docs
[ { "content": "Question:\n#### Objective\nDesign a function that creates a Seaborn visualization with a specific style and customized parameters.\n\n#### Problem Statement\n\nCreate a function called `custom_barplot` that takes the following parameters:\n- `x`: a list of labels for the x-axis.\n- `y`: a list of ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3769, "level": 1, "question": "#### Objective\nDesign a function that creates a Seaborn visualization with a specific style and customized parameters.\n\n#### Problem Statement\n\nCreate a function called `custom_barplot` that takes the following parameters:\n- `x`: a list of labels...
from typing import List, Tuple def max_sum_subarray(arr: List[int]) -> Tuple[int, int]: if not arr: return (0, 0) # Though the problem states 1 ≤ n, this handles empty lists gracefully current_sum = 0 current_start = 0 max_sum = -float('inf') best_start = 0 best_length = 0 fo...
simplelr_Code_Contests
[ { "content": "Question:\nGiven an array of integers, you are required to find a contiguous subarray with the largest sum, but with a twist: if there are multiple subarrays with the same largest sum, then find the one with the smallest length. If there's still a tie, return the earliest subarray (i.e., the one w...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3770, "level": 1, "question": "Given an array of integers, you are required to find a contiguous subarray with the largest sum, but with a twist: if there are multiple subarrays with the same largest sum, then find the one with the smallest length. If there's still a tie, return the...
def is_palindrome(s): # Clean the string by keeping only alphanumeric characters and converting to lowercase cleaned = ''.join([c.lower() for c in s if c.isalnum()]) # Check if the cleaned string is equal to its reverse return cleaned == cleaned[::-1]
simplelr_Prefill
[ { "content": "Question:\nWrite a function to check if a given string is a palindrome. A palindrome is a string that reads the same backward as forward, e.g., \"madam\". Ensure your function handles both uppercase and lowercase letters, and ignore spaces and punctuation. For example, \"A man, a plan, a canal, Pa...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3771, "level": 1, "question": "Write a function to check if a given string is a palindrome. A palindrome is a string that reads the same backward as forward, e.g., \"madam\". Ensure your function handles both uppercase and lowercase letters, and ignore spaces and punctuation. For ex...
def majority_element(nums): count = 0 candidate = None for num in nums: if count == 0: candidate = num count = 1 elif num == candidate: count += 1 else: count -= 1 # Verify if the candidate is a majority element occurrences...
simplelr_Taco
[ { "content": "Question:\nGiven a list of integers, write a function `majority_element(nums)` that finds the majority element in the list. The majority element is the element that appears more than `n // 2` times, where `n` is the size of the list. If no majority element exists, the function should return `None`...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3772, "level": 1, "question": "Given a list of integers, write a function `majority_element(nums)` that finds the majority element in the list. The majority element is the element that appears more than `n // 2` times, where `n` is the size of the list. If no majority element exists...
from collections import Counter def can_form_string(a: str, b: str, c: str) -> bool: if len(c) != len(a) + len(b): return False return Counter(a) + Counter(b) == Counter(c)
simplelr_Taco
[ { "content": "Question:\nGrace loves playing with strings and recently she came up with a new game. In this game, she takes any two strings, `a` and `b`, and checks whether the concatenation of some permutation of `a` and some permutation of `b` gives her another string `c`. Grace, being a curious person, now w...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3773, "level": 1, "question": "Grace loves playing with strings and recently she came up with a new game. In this game, she takes any two strings, `a` and `b`, and checks whether the concatenation of some permutation of `a` and some permutation of `b` gives her another string `c`. G...
def celsius_to_fahrenheit(celsius_temps): if not isinstance(celsius_temps, list): return "Error: Input is not a list." fahrenheit_temps = [] for temp in celsius_temps: if type(temp) in (int, float): fahrenheit = temp * 9/5 + 32 fahrenheit_temps.append(fahrenheit) ...
simplelr_Filter
[ { "content": "Question:\nComplete the function to properly convert a list of temperatures from Celsius to Fahrenheit and handle exceptional cases where the input might not be a list or contain elements that are not numerical values.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3774, "level": 1, "question": "Complete the function to properly convert a list of temperatures from Celsius to Fahrenheit and handle exceptional cases where the input might not be a list or contain elements that are not numerical values.", "split": "train" }
def can_sum_target(arr, target): if target == 0: return True n = len(arr) for mask in range(1, 1 << n): current_sum = 0 for i in range(n): if mask & (1 << i): current_sum += arr[i] if current_sum == target: return True return False
simplelr_Taco
[ { "content": "Question:\nYou are provided with a sequence of integers and a target value. Your task is to determine whether there is a subset of these integers that can sum up to the given target value. Implement a function `can_sum_target(arr, target)` that returns `True` if such a subset exists, and `False` o...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3775, "level": 1, "question": "You are provided with a sequence of integers and a target value. Your task is to determine whether there is a subset of these integers that can sum up to the given target value. Implement a function `can_sum_target(arr, target)` that returns `True` if ...
def find_string_in_list(lst, target): """ This function checks if a target string exists in a given list. If found, it returns the index of the string; otherwise, it returns -1. Args: lst (list): The list to search in. target (str): The string to search for. Returns: ...
simplelr_Filter
[ { "content": "Question:\nCan you provide a python code to check if a given list contains a specific string and if it does, return the index of the string in the list? If the string is not found in the list, I would like the function to return -1.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3776, "level": 1, "question": "Can you provide a python code to check if a given list contains a specific string and if it does, return the index of the string in the list? If the string is not found in the list, I would like the function to return -1.", "split": "train" }
def compare_containers(cont1, cont2): return set(cont1).issubset(set(cont2))
simplelr_Filter
[ { "content": "Question:\nI'm trying to write a function to compare two iterable containers `cont1` and `cont2`. This function should return `True` if all elements in `cont1` can be found in `cont2`, but in any order and not considering repeated elements. What can I do?\nAnswer:\nLet's think step by step.\n", ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3777, "level": 1, "question": "I'm trying to write a function to compare two iterable containers `cont1` and `cont2`. This function should return `True` if all elements in `cont1` can be found in `cont2`, but in any order and not considering repeated elements. What can I do?", "sp...
def count_negative_columns(matrix): if not matrix: return [] return [sum(1 for x in col if x < 0) for col in zip(*matrix)]
simplelr_Filter
[ { "content": "Question:\nGiven a 2D array representing a matrix, write a function to count the number of negative numbers in each column.\n\nExample:\n```\nInput: \n[\n [ 1, 5, 9],\n [ 2, 7, 4],\n [ 3, 8, 11],\n [ 4, 6, 12],\n [-1, -3, 13],\n [-2, -4, 14]\n]\n\nOutput: \n[0, 2, 0]\n```\nIn the above...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3778, "level": 1, "question": "Given a 2D array representing a matrix, write a function to count the number of negative numbers in each column.\n\nExample:\n```\nInput: \n[\n [ 1, 5, 9],\n [ 2, 7, 4],\n [ 3, 8, 11],\n [ 4, 6, 12],\n [-1, -3, 13],\n [-2, -4, 14]\n]\n\nOut...
from typing import List def custom_exchange_sort(arr: List[int]) -> List[int]: n = len(arr) for i in range(n): swapped = False for j in range(n - i - 1): if arr[j] > arr[j + 1]: arr[j], arr[j + 1] = arr[j + 1], arr[j] swapped = True if not swa...
simplelr_Data_Structure
[ { "content": "Question:\nImplement a Custom Sorting Function\n\nYou are required to implement a custom sorting function that sorts an array of integers using the Exchange Sort algorithm. Your function should handle various edge cases and ensure it operates within the constraints provided.\n\n#### Function Signa...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3779, "level": 1, "question": "Implement a Custom Sorting Function\n\nYou are required to implement a custom sorting function that sorts an array of integers using the Exchange Sort algorithm. Your function should handle various edge cases and ensure it operates within the constrain...
def trap_rain_water(arr, threshold): n = len(arr) if n == 0: return 0 if 0 <= threshold else -1 left_max = [0] * n for i in range(1, n): left_max[i] = max(left_max[i-1], arr[i-1]) right_max = [0] * n for i in range(n-2, -1, -1): right_max[i] = max(right_max[i+1], ar...
simplelr_Leetcode
[ { "content": "Question:\nYou are given a list of integers `arr` representing the heights of buildings in a line. The rainwater that can be trapped between the buildings is determined by the relative height differences among the buildings. Write a function to find the total amount of rainwater that can be trappe...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3780, "level": 1, "question": "You are given a list of integers `arr` representing the heights of buildings in a line. The rainwater that can be trapped between the buildings is determined by the relative height differences among the buildings. Write a function to find the total amo...
def first_occurrence_binary_search(arr, target): low = 0 high = len(arr) - 1 result = -1 while low <= high: mid = (low + high) // 2 if arr[mid] < target: low = mid + 1 elif arr[mid] > target: high = mid - 1 else: result = mid ...
simplelr_Filter
[ { "content": "Question:\nI want to implement a binary search algorithm that finds the first occurrence of the target in the array. I have an array of integers and the target value. \n\nI can use the basic binary search algorithm but the problem is that once I find the target, I have to find the first occurrence...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3781, "level": 1, "question": "I want to implement a binary search algorithm that finds the first occurrence of the target in the array. I have an array of integers and the target value. \n\nI can use the basic binary search algorithm but the problem is that once I find the target, ...
def generate_concordance(document: str) -> dict: concordance = {} lines = document.split('\n') for line_number, line in enumerate(lines, 1): tokens = line.split() line_words = [] for token in tokens: word = ''.join([c.lower() for c in token if c.isalpha()]) if...
simplelr_Algorithm
[ { "content": "Question:\n### Question: Document Concordance Generator\n\n#### Context\nYou are developing a text analysis tool that generates a concordance for a given document. A concordance is an alphabetical list of the principal words used in a text, typically with citations of the passages concerned.\n\n##...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3782, "level": 1, "question": "### Question: Document Concordance Generator\n\n#### Context\nYou are developing a text analysis tool that generates a concordance for a given document. A concordance is an alphabetical list of the principal words used in a text, typically with citatio...
import numpy as np def normalize_vector(v): v_min = np.min(v) v_max = np.max(v) if v_max == v_min: return np.zeros_like(v) else: return (v - v_min) / (v_max - v_min)
simplelr_Package
[ { "content": "Question:\n### Normalizing a Vector\n\nNormalization is a process that adjusts the values in a vector to a common scale, often between 0 and 1, without distorting the differences in the ranges of values. A common formula used for normalization of a vector `v` is:\n\n\\[ v_i' = \\frac{v_i - \\min(v...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3783, "level": 1, "question": "### Normalizing a Vector\n\nNormalization is a process that adjusts the values in a vector to a common scale, often between 0 and 1, without distorting the differences in the ranges of values. A common formula used for normalization of a vector `v` is:...
def find_median(numbers): if not numbers: return None sorted_numbers = sorted(numbers) n = len(sorted_numbers) if n % 2 == 1: return sorted_numbers[n // 2] else: return (sorted_numbers[(n // 2) - 1] + sorted_numbers[n // 2]) / 2
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to calculate and return the median of a set of values. The function should take a list of integers as input. If the list is empty, the function should return None.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3784, "level": 1, "question": "Write a python function to calculate and return the median of a set of values. The function should take a list of integers as input. If the list is empty, the function should return None.", "split": "train" }
def findKthSmallest(arr, k): """ Returns the k-th smallest element in the list. """ if not arr: raise IndexError("Array is empty") n = len(arr) if k < 1 or k > n: raise IndexError("k is out of bounds") sorted_arr = sorted(arr) return sorted_arr[k-1]
simplelr_Package
[ { "content": "Question:\nIn this problem, you need to implement a function that finds the k-th smallest element in an unsorted list. The function should handle edge cases such as when k is greater than the length of the list or when the list is empty.\n\nSpecifically, complete the function `findKthSmallest(arr,...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3785, "level": 1, "question": "In this problem, you need to implement a function that finds the k-th smallest element in an unsorted list. The function should handle edge cases such as when k is greater than the length of the list or when the list is empty.\n\nSpecifically, complete...
def are_anagrams(s1, s2): if len(s1) != len(s2): return False # Create dictionaries to store character counts count_s1 = {} for char in s1: count_s1[char] = count_s1.get(char, 0) + 1 count_s2 = {} for char in s2: count_s2[char] = count_s2.get(char, 0) + 1 ...
simplelr_Filter
[ { "content": "Question:\nGiven two strings s1 and s2, write a Python program to find whether s1 is an anagram of s2, considering case sensitivity and whitespace. Additionally, implement the program without using the built-in sort function.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3786, "level": 1, "question": "Given two strings s1 and s2, write a Python program to find whether s1 is an anagram of s2, considering case sensitivity and whitespace. Additionally, implement the program without using the built-in sort function.", "split": "train" }
def substring(s, start, end): n = len(s) if n == 0: return "" # Adjust for negative indices if start < 0: start += n if end < 0: end += n # Check if after adjustment, start is beyond end if start > end: return "" # Clamp start and end to be ...
simplelr_Filter
[ { "content": "Question:\nWrite a Python function that takes a string and a start index and an end index as input and returns the substring of the given string from the start index to the end index, inclusive. The function should handle edge cases such as negative indices, indices that are out of bounds, and ove...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3787, "level": 1, "question": "Write a Python function that takes a string and a start index and an end index as input and returns the substring of the given string from the start index to the end index, inclusive. The function should handle edge cases such as negative indices, indi...
def string_to_ascii_list(s): return [ord(c) for c in s]
simplelr_Prefill
[ { "content": "Question:\nCreate a function that converts a given string into a list containing the ASCII values of its characters.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3788, "level": 1, "question": "Create a function that converts a given string into a list containing the ASCII values of its characters.", "split": "train" }
def fibonacci_nth(n): if not isinstance(n, int): raise TypeError("n must be an integer") if n < 0: raise ValueError("n must be a non-negative integer") if n == 0: return 0 elif n == 1: return 1 else: fib_list = [0, 1] for i in range(2, n + 1): ...
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to create a list of Fibonacci sequence and return the nth number in the sequence.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3789, "level": 1, "question": "Write a python function to create a list of Fibonacci sequence and return the nth number in the sequence.", "split": "train" }
from collections import deque def max_sliding_window(nums, k): if not nums or k == 0: return [] n = len(nums) dq = deque() result = [] for i in range(n): # Remove indices from the back which are smaller than current while dq and nums[i] >= nums[dq[-1]]: dq.pop() ...
simplelr_Data_Structure
[ { "content": "Question:\n### Sliding Window Maximum - Optimal Implementation\n\nYou are given an array `nums` and an integer `k`, representing a sliding window size. The window moves from the left to the right end of the array, and you need to return a list of the maximum values in each window position.\n\n**Co...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3790, "level": 1, "question": "### Sliding Window Maximum - Optimal Implementation\n\nYou are given an array `nums` and an integer `k`, representing a sliding window size. The window moves from the left to the right end of the array, and you need to return a list of the maximum valu...
def find_matching_habitat(animal_habitats: dict) -> dict: habitat_animals = {} for animal, habitats in animal_habitats.items(): for habitat in habitats: if habitat not in habitat_animals: habitat_animals[habitat] = set() habitat_animals[habitat].add(animal) # ...
simplelr_Algorithm
[ { "content": "Question:\n### Question: Determine the Matching Habitat\n\nYou need to write a function `find_matching_habitat(animal_habitats)` that receives a dictionary where the keys are strings representing animal names and the values are lists of strings representing their respective habitats. The function ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3791, "level": 1, "question": "### Question: Determine the Matching Habitat\n\nYou need to write a function `find_matching_habitat(animal_habitats)` that receives a dictionary where the keys are strings representing animal names and the values are lists of strings representing their...
from typing import List, Tuple from collections import defaultdict def can_form_rectangle(points: List[Tuple[int, int]]) -> bool: if len(points) < 4: return False midpoint_dict = defaultdict(lambda: defaultdict(int)) for i in range(len(points)): x1, y1 = points[i] for j in...
simplelr_Algorithm
[ { "content": "Question:\n### Problem Statement\nYou are given a collection of points in a 2D plane. Your task is to find if there is any rectangle that can be formed such that all four of its vertices are present in the collection of points.\n\n### Function to Implement\nImplement the function `can_form_rectang...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3792, "level": 1, "question": "### Problem Statement\nYou are given a collection of points in a 2D plane. Your task is to find if there is any rectangle that can be formed such that all four of its vertices are present in the collection of points.\n\n### Function to Implement\nImple...
def running_sum(nums): result = [] current_sum = 0 for num in nums: current_sum += num result.append(current_sum) return result
simplelr_Leetcode
[ { "content": "Question:\nYou are given an integer array `nums`. We define a running sum of an array as `runningSum[i]` = `sum(nums[0]…nums[i])`. Return _the running sum of `nums`_. This means you need to construct a new array where each element at position `i` is the sum of all elements from the start of the ar...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3793, "level": 1, "question": "You are given an integer array `nums`. We define a running sum of an array as `runningSum[i]` = `sum(nums[0]…nums[i])`. Return _the running sum of `nums`_. This means you need to construct a new array where each element at position `i` is the sum of al...
def tuples_to_dict(tuple_list): result = {} for tup in tuple_list: result[tup[0]] = tup[1] return result
simplelr_Filter
[ { "content": "Question:\nWrite a Python function that takes a list of tuples as input and returns a dictionary where the first element of each tuple is the key and the second element is the value.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3794, "level": 1, "question": "Write a Python function that takes a list of tuples as input and returns a dictionary where the first element of each tuple is the key and the second element is the value.", "split": "train" }
from collections import defaultdict def subarray_sum(arr, target): prefix_counts = defaultdict(int) prefix_counts[0] = 1 current_sum = 0 count = 0 for num in arr: current_sum += num count += prefix_counts.get(current_sum - target, 0) prefix_counts[current_sum] += 1 retur...
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to find the number of contiguous subarrays within a given array that have a sum exactly equal to a given target sum.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3795, "level": 1, "question": "Write a python function to find the number of contiguous subarrays within a given array that have a sum exactly equal to a given target sum.", "split": "train" }
def sort_strings_lexicographically(strings): return sorted(strings, key=str.lower)
simplelr_Prefill
[ { "content": "Question:\nWrite a function to sort a list of strings lexicographically and ignore case sensitivity.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3796, "level": 1, "question": "Write a function to sort a list of strings lexicographically and ignore case sensitivity.", "split": "train" }
def sum_array(arr): return sum(arr) # Example usage: numbers = [1, 2, 3, 4, 5] result = sum_array(numbers) print("Sum of the array elements:", result)
simplelr_Filter
[ { "content": "Question:\n### Python Program to Find the Sum of All the Elements in an Array\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3797, "level": 1, "question": "### Python Program to Find the Sum of All the Elements in an Array", "split": "train" }
def sum_of_squares(a: int, b: int, c: int) -> int: """ Calculate the sum of the squares of three integers. Args: a (int): The first integer. b (int): The second integer. c (int): The third integer. Returns: int: The sum of the squares of a, b, and c. """ return ...
simplelr_Prefill
[ { "content": "Question:\nCreate a function that accepts three integers as input. It should return the sum of the squares of these integers. Make sure your function is well-documented and includes type annotations for better clarity.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3798, "level": 1, "question": "Create a function that accepts three integers as input. It should return the sum of the squares of these integers. Make sure your function is well-documented and includes type annotations for better clarity.", "split": "train" }
def count_even_numbers(numbers): """ This function takes a list of numbers as input and returns the count of even numbers in the list. Args: numbers: A list of integers. Returns: An integer representing the count of even numbers in the list. """ return sum(1 for number in numbe...
simplelr_Filter
[ { "content": "Question:\nI have a list of items and want to create a Python function that returns the count of items in the list which are even numbers.\n\nHere's what I have so far:\n\n```python\ndef count_even_numbers(numbers):\n \"\"\"\n This function takes a list of numbers as input and returns the count ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 3799, "level": 1, "question": "I have a list of items and want to create a Python function that returns the count of items in the list which are even numbers.\n\nHere's what I have so far:\n\n```python\ndef count_even_numbers(numbers):\n \"\"\"\n This function takes a list of numb...