target
stringlengths
29
3.65k
data_source
stringclasses
12 values
prompt
listlengths
1
1
ability
stringclasses
1 value
reward_model
dict
extra_info
dict
def remove_vowels(s): vowels = {'a', 'e', 'i', 'o', 'u'} return ''.join(c for c in s if c.lower() not in vowels)
simplelr_Filter
[ { "content": "Question:\nCan you design a Python function that takes a string and returns the string with all vowels removed?\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6700, "level": 1, "question": "Can you design a Python function that takes a string and returns the string with all vowels removed?", "split": "train" }
def has_pair_with_sum(arr, target): seen = set() for num in arr: complement = target - num if complement in seen: return True seen.add(num) return False
simplelr_Evol
[ { "content": "Question:\nYou are given an array of integers and a target sum. Write a function to determine if there are two distinct integers in the array whose sum equals the target sum. Your function should return a boolean value indicating whether such a pair exists. \n\nYour solution should have a time com...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6701, "level": 1, "question": "You are given an array of integers and a target sum. Write a function to determine if there are two distinct integers in the array whose sum equals the target sum. Your function should return a boolean value indicating whether such a pair exists. \n\nY...
def celsius_to_fahrenheit(celsius): return celsius * 9/5 + 32
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes a temperature in Celsius and returns the temperature in Fahrenheit.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6702, "level": 1, "question": "Create a function that takes a temperature in Celsius and returns the temperature in Fahrenheit.", "split": "train" }
def find_max_product(arr): arr_sorted = sorted(arr) n = len(arr_sorted) product1 = arr_sorted[-1] * arr_sorted[-2] * arr_sorted[-3] product2 = arr_sorted[0] * arr_sorted[1] * arr_sorted[-1] return max(product1, product2)
simplelr_Taco
[ { "content": "Question:\n# Task\nGiven an array of integers, find the largest product that can be made by multiplying any three integers.\n\n# Example\n\nFor `arr = [1, 10, -5, 1, -100]`, the output should be `5000`.\n\nThe largest product can be achieved by multiplying `10`, `-5`, and `-100` (`10 * -5 * -100 =...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6703, "level": 1, "question": "# Task\nGiven an array of integers, find the largest product that can be made by multiplying any three integers.\n\n# Example\n\nFor `arr = [1, 10, -5, 1, -100]`, the output should be `5000`.\n\nThe largest product can be achieved by multiplying `10`, ...
def sum_neighbors(lst): if len(lst) < 3: return lst.copy() new_list = [] for i in range(len(lst)): if i == 0: total = lst[i] + lst[i+1] elif i == len(lst) - 1: total = lst[i-1] + lst[i] else: total = lst[i-1] + lst[i] + lst[i+1] new...
simplelr_Evol
[ { "content": "Question:\nWrite a function in Python that takes a list of integers and returns a new list with each element being the sum of its neighbors and itself. For example, if the input list is [1, 2, 3, 4], the output should be [3, 6, 9, 7]. If the list has fewer than 3 elements, the original list should...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6704, "level": 1, "question": "Write a function in Python that takes a list of integers and returns a new list with each element being the sum of its neighbors and itself. For example, if the input list is [1, 2, 3, 4], the output should be [3, 6, 9, 7]. If the list has fewer than 3...
import heapq def dijkstra(graph, start): """ Dijkstra's algorithm to find the shortest path. Args: graph: A dictionary representing the graph, where each key is a node and its corresponding value is another dictionary. The inner dictionary's keys are the node's neighbors and its values are ...
simplelr_Filter
[ { "content": "Question:\n### Introduction to Graph Algorithms\n#### 7.4. Dijkstra's Algorithm\nDijkstra's algorithm is a well-known algorithm in graph theory for finding the shortest path between nodes in a graph. It works by maintaining a list of unvisited nodes and iteratively selecting the node with the shor...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6705, "level": 1, "question": "### Introduction to Graph Algorithms\n#### 7.4. Dijkstra's Algorithm\nDijkstra's algorithm is a well-known algorithm in graph theory for finding the shortest path between nodes in a graph. It works by maintaining a list of unvisited nodes and iterative...
def calculate_fine(days_overdue, daily_fine, max_fine): if days_overdue < 0: raise ValueError("Days cannot be negative.") if days_overdue <= 0: return 0.0 calculated = days_overdue * daily_fine result = min(calculated, max_fine) return round(result, 2)
simplelr_Algorithm
[ { "content": "Question:\n### Scenario\n\nYou are developing a software module for a library management system. One of the features required is a function that calculates the overdue fine for a borrowed book based on the number of days it is overdue.\n\n### Function Details\n\nImplement a function `calculate_fin...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6706, "level": 1, "question": "### Scenario\n\nYou are developing a software module for a library management system. One of the features required is a function that calculates the overdue fine for a borrowed book based on the number of days it is overdue.\n\n### Function Details\n\n...
def get_account_ids(accounts, search_term): matching_ids = [] for account in accounts: if search_term in account['name'] or search_term in account['email']: matching_ids.append(account['id']) return matching_ids
simplelr_Filter
[ { "content": "Question:\nHere is a Python script to get an account ID from a list of accounts based on a search term. If the search term is found in the account's name, the ID is returned.\n```python\ndef get_account_id(accounts, search_term):\n for account in accounts:\n if search_term in account['na...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6707, "level": 1, "question": "Here is a Python script to get an account ID from a list of accounts based on a search term. If the search term is found in the account's name, the ID is returned.\n```python\ndef get_account_id(accounts, search_term):\n for account in accounts:\n ...
def has_repeated_characters(s): return len(set(s)) != len(s) # Example usage: s = "hello" print(has_repeated_characters(s)) # Output: True s = "world" print(has_repeated_characters(s)) # Output: False
simplelr_Filter
[ { "content": "Question:\nI have a string 's' and I want to check if it contains any repeated 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": 6708, "level": 1, "question": "I have a string 's' and I want to check if it contains any repeated characters. How can I do this in Python?", "split": "train" }
def maxMeetings(n, meetings): meetings.sort(key=lambda x: x[1]) last_end = 0 count = 0 for start, end in meetings: if start >= last_end: count += 1 last_end = end return count
simplelr_Taco
[ { "content": "Question:\nGiven a list of meetings with their start and end times, find the maximum number of meetings that can be attended without any overlap. Each meeting is represented by a tuple (start time, end time). A person can attend a meeting exactly when it starts, and they have to stay till it ends....
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6709, "level": 1, "question": "Given a list of meetings with their start and end times, find the maximum number of meetings that can be attended without any overlap. Each meeting is represented by a tuple (start time, end time). A person can attend a meeting exactly when it starts, ...
def longestPalindrome(s): freq = [0] * 26 for c in s: index = ord(c) - ord('a') freq[index] += 1 total = 0 has_odd = False for count in freq: total += (count // 2) * 2 if count % 2 != 0: has_odd = True if has_odd: total += 1 return total
simplelr_Taco
[ { "content": "Question:\nGiven a string s containing only lowercase alphabets, determine the longest palindrome that can be made by deleting or rearranging characters from the string. \n\nExample 1:\nInput:\ns = 'abccccdd'\nOutput: 7\nExplanation:\nOne of the longest palindromes that can be built is \"dccaccd\"...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6710, "level": 1, "question": "Given a string s containing only lowercase alphabets, determine the longest palindrome that can be made by deleting or rearranging characters from the string. \n\nExample 1:\nInput:\ns = 'abccccdd'\nOutput: 7\nExplanation:\nOne of the longest palindrom...
def broadcast_time(n: int, id: int) -> list[int]: return [abs(j - id) for j in range(1, n + 1)]
simplelr_Codeforces
[ { "content": "Question:\nYou are given a set of n electronic devices connected in a line, and each device has a unique integer identifier. Each device can transfer data to its directly connected neighboring devices. A data packet originates from a device with the identifier id and needs to be broadcasted to all...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6711, "level": 1, "question": "You are given a set of n electronic devices connected in a line, and each device has a unique integer identifier. Each device can transfer data to its directly connected neighboring devices. A data packet originates from a device with the identifier id...
from typing import List, Dict, Any def balance_bookkeeping(transactions: List[Dict[str, Any]]) -> Dict[str, float]: total_expenses = 0.0 total_revenues = 0.0 for transaction in transactions: if transaction['type'] == 'expense': total_expenses += transaction['amount'] else: ...
simplelr_Package
[ { "content": "Question:\nYou are asked to create a function named `balance_bookkeeping` to help balance the expenses and revenues in a company's bookkeeping system. This function should process a series of transactions given as a list of dictionaries and calculate the net balance, the total expenses, and the to...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6712, "level": 1, "question": "You are asked to create a function named `balance_bookkeeping` to help balance the expenses and revenues in a company's bookkeeping system. This function should process a series of transactions given as a list of dictionaries and calculate the net bala...
def minRemovals(nums, k): if not nums: return 0 nums.sort() n = len(nums) left = 0 max_size = 0 for right in range(n): # Move the left pointer to ensure the window condition is satisfied while nums[right] - nums[left] > k: left += 1 current_size = righ...
simplelr_Leetcode
[ { "content": "Question:\nGiven a list of non-negative integers `nums`, you are tasked with removing the minimum number of elements from the list so that the difference between the maximum and minimum values in the remaining list is at most `k`. Return the minimum number of elements to remove. Write a function `...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6713, "level": 1, "question": "Given a list of non-negative integers `nums`, you are tasked with removing the minimum number of elements from the list so that the difference between the maximum and minimum values in the remaining list is at most `k`. Return the minimum number of ele...
def product_except_self(nums): n = len(nums) prefix = [1] * n for i in range(1, n): prefix[i] = prefix[i-1] * nums[i-1] suffix = [1] * n for i in range(n-2, -1, -1): suffix[i] = suffix[i+1] * nums[i+1] return [prefix[i] * suffix[i] for i in range(n)]
simplelr_Algorithm
[ { "content": "Question:\n### Coding Question: Product of Array Except Self\n\nYou are given an array of integers `nums` where the length of the array is `n`. Your task is to write a function `product_except_self` that returns an array `answer` such that `answer[i]` is equal to the product of all the elements of...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6714, "level": 1, "question": "### Coding Question: Product of Array Except Self\n\nYou are given an array of integers `nums` where the length of the array is `n`. Your task is to write a function `product_except_self` that returns an array `answer` such that `answer[i]` is equal to...
import numpy as np def matrix_sine(angles): angles_array = np.asarray(angles) return np.sin(angles_array)
simplelr_Package
[ { "content": "Question:\nYou are required to write a function named `matrix_sine` which utilizes the `numpy.sin` function to compute the element-wise sine of an array of angles. Specifically, the function should take one argument: \n1. `angles` - a 2D array-like structure (list of lists, tuple of tuples, or a 2...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6715, "level": 1, "question": "You are required to write a function named `matrix_sine` which utilizes the `numpy.sin` function to compute the element-wise sine of an array of angles. Specifically, the function should take one argument: \n1. `angles` - a 2D array-like structure (lis...
from collections import Counter def can_form_palindrome(s): counts = Counter(s) odd_count = 0 for cnt in counts.values(): if cnt % 2 != 0: odd_count += 1 if odd_count > 1: return False return True
simplelr_Leetcode
[ { "content": "Question:\nYou are given a string `s` containing only lowercase English letters. Your task is to determine if `s` can be transformed into a palindrome by permuting its characters. In other words, you need to check if the frequency of each character allows for a reordering of the string such that i...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6716, "level": 1, "question": "You are given a string `s` containing only lowercase English letters. Your task is to determine if `s` can be transformed into a palindrome by permuting its characters. In other words, you need to check if the frequency of each character allows for a r...
def visible_trees(heights): max_height = float('-inf') result = [] for height in heights: if height > max_height: result.append(1) max_height = height else: result.append(0) return result
simplelr_Leetcode
[ { "content": "Question:\nYou have an array of integers `heights` representing the heights of trees in a row. An observer at the left end of the row can see a tree if it is taller than all the trees to its left. Given an integer array `heights`, return an array of integers where each element is `1` if the corres...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6717, "level": 1, "question": "You have an array of integers `heights` representing the heights of trees in a row. An observer at the left end of the row can see a tree if it is taller than all the trees to its left. Given an integer array `heights`, return an array of integers wher...
import re from collections import defaultdict def most_popular_hashtag(posts): hashtag_counts = defaultdict(int) for post in posts: hashtags = re.findall(r'#[a-zA-Z0-9]+', post) for tag in hashtags: hashtag_counts[tag] += 1 if not hashtag_counts: return '' max_count ...
simplelr_Algorithm
[ { "content": "Question:\n### Context\nYou are designing a social media platform, and one of the features is to identify the most popular hashtag within a given set of posts. Your task is to implement a function that finds the most frequently occurring hashtag in the provided list of posts.\n\n### Problem Statem...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6718, "level": 1, "question": "### Context\nYou are designing a social media platform, and one of the features is to identify the most popular hashtag within a given set of posts. Your task is to implement a function that finds the most frequently occurring hashtag in the provided l...
def sum_greater_than(list_of_integers, n): return sum(num for num in list_of_integers if num > n)
simplelr_Filter
[ { "content": "Question:\nWrite a Python function that takes two arguments: a list of integers and an integer n. The function should return the sum of the elements in the list that are greater than n. For example, given the list [1, 2, 3, 4, 5] and n=3, the function should return 9 (because 4+5=9).\nAnswer:\nLet...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6719, "level": 1, "question": "Write a Python function that takes two arguments: a list of integers and an integer n. The function should return the sum of the elements in the list that are greater than n. For example, given the list [1, 2, 3, 4, 5] and n=3, the function should retu...
def get_max_value(lst): if not lst: return -1 return max(lst)
simplelr_Prefill
[ { "content": "Question:\nCreate a function that returns the maximum value in a list of integers. If the list is empty, return -1. For example, given [3, 5, 1, 2, 4], the function should return 5.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6720, "level": 1, "question": "Create a function that returns the maximum value in a list of integers. If the list is empty, return -1. For example, given [3, 5, 1, 2, 4], the function should return 5.", "split": "train" }
def longest_consecutive_subarray(arr): if not arr: return 0 unique_sorted = sorted(set(arr)) max_len = 1 current = 1 for i in range(1, len(unique_sorted)): if unique_sorted[i] == unique_sorted[i-1] + 1: current += 1 if current > max_len: max_le...
simplelr_Taco
[ { "content": "Question:\nWrite a function `longest_consecutive_subarray` that takes a list of integers as its input and returns the length of the longest subarray that contains consecutive integers, although the integers need not be in order in the subarray.\n\nExample:\n\n```python\ndef longest_consecutive_sub...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6721, "level": 1, "question": "Write a function `longest_consecutive_subarray` that takes a list of integers as its input and returns the length of the longest subarray that contains consecutive integers, although the integers need not be in order in the subarray.\n\nExample:\n\n```...
def is_narcissistic(n): if n < 0: return False num_str = str(n) num_digits = len(num_str) digits = [int(d) for d in num_str] sum_of_powers = sum(d ** num_digits for d in digits) return sum_of_powers == n
simplelr_Prefill
[ { "content": "Question:\nCreate a function that checks if a number is narcissistic or not. A narcissistic number is a number that is the sum of its own digits each raised to the power of the number of digits. For example, 153 is a narcissistic number because \\(1^3 + 5^3 + 3^3 = 153\\).\nAnswer:\nLet's think st...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6722, "level": 1, "question": "Create a function that checks if a number is narcissistic or not. A narcissistic number is a number that is the sum of its own digits each raised to the power of the number of digits. For example, 153 is a narcissistic number because \\(1^3 + 5^3 + 3^3...
def limit(arr: list[int], min_lim: int = None, max_lim: int = None) -> list[int]: if not arr: return [] # Determine min_lim and max_lim if they are None if min_lim is None: min_lim = min(arr) if max_lim is None: max_lim = max(arr) # Filter the array based on the determined li...
simplelr_Data_Structure
[ { "content": "Question:\n### Problem Description:\n\nYou have been provided an array of integers, and you need to filter the array such that it only includes elements within a specified range. Implement the function `limit` that accomplishes this task. \n\n### Function Signature:\n```python\ndef limit(arr: list...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6723, "level": 1, "question": "### Problem Description:\n\nYou have been provided an array of integers, and you need to filter the array such that it only includes elements within a specified range. Implement the function `limit` that accomplishes this task. \n\n### Function Signatu...
def two_sum(nums, target): seen = {} for num in nums: complement = target - num if complement in seen: return [complement, num] seen[num] = True return None # or handle the case where no pair is found as needed
simplelr_Filter
[ { "content": "Question:\nIn this problem, you are given a list of integers and a target number. The task is to find the pair of numbers in the list that add up to the target number.\n\nExample:\n\nInput: nums = [2, 7, 11, 15], target = 9\nOutput: [2, 7]\n\nBecause 2 + 7 = 9\n\nHere is a simple solution to this ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6724, "level": 1, "question": "In this problem, you are given a list of integers and a target number. The task is to find the pair of numbers in the list that add up to the target number.\n\nExample:\n\nInput: nums = [2, 7, 11, 15], target = 9\nOutput: [2, 7]\n\nBecause 2 + 7 = 9\n\...
def distribute_books(shelves, books): possible_sums = {0} for capacity in shelves: new_sums = set() for s in possible_sums: new_sum = s + capacity new_sums.add(new_sum) possible_sums.update(new_sums) return books in possible_sums
simplelr_Taco
[ { "content": "Question:\nYou are organizing a library, and one of the tasks is to ensure all the shelves are neatly arranged. Each shelf has a different maximum capacity, and you need to distribute the books across shelves accordingly. You want to ensure that each shelf is either fully occupied or entirely empt...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6725, "level": 1, "question": "You are organizing a library, and one of the tasks is to ensure all the shelves are neatly arranged. Each shelf has a different maximum capacity, and you need to distribute the books across shelves accordingly. You want to ensure that each shelf is eit...
def can_make_symmetric(lights: str) -> bool: n = len(lights) cnt = 0 for i in range(n // 2): if lights[i] != lights[n - 1 - i]: cnt += 1 return cnt <= 1
simplelr_Leetcode
[ { "content": "Question:\nA company wants to send a message to its employees using a **light pattern** on a display board. The light pattern is represented as a binary string where '1' means the light is on and '0' means the light is off. The message should be symmetric, meaning it reads the same forwards and ba...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6726, "level": 1, "question": "A company wants to send a message to its employees using a **light pattern** on a display board. The light pattern is represented as a binary string where '1' means the light is on and '0' means the light is off. The message should be symmetric, meanin...
def multiply_lists(list1, list2): return [a * b for a, b in zip(list1, list2)]
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes two integer lists as inputs, multiplies the elements of the same positions together, and returns a new list with the results.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6727, "level": 1, "question": "Create a function that takes two integer lists as inputs, multiplies the elements of the same positions together, and returns a new list with the results.", "split": "train" }
from datetime import datetime, timedelta def get_next_day(date_str): date_obj = datetime.strptime(date_str, '%Y-%m-%d').date() next_day = date_obj + timedelta(days=1) return next_day.strftime('%Y-%m-%d')
simplelr_Filter
[ { "content": "Question:\nWrite a function to get the next day of a given date in Python.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6728, "level": 1, "question": "Write a function to get the next day of a given date in Python.", "split": "train" }
from datetime import datetime def days_between_dates(date1: str, date2: str) -> int: date1_obj = datetime.strptime(date1, "%Y-%m-%d").date() date2_obj = datetime.strptime(date2, "%Y-%m-%d").date() delta_days = (date2_obj - date1_obj).days return abs(delta_days)
simplelr_Algorithm
[ { "content": "Question:\n### Objective\nWrite a function to determine the number of days between two given dates.\n\n### Problem Statement\nGiven two dates as strings in the format \"YYYY-MM-DD\", write a function `days_between_dates` that calculates and returns the number of full days between them. Ensure your...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6729, "level": 1, "question": "### Objective\nWrite a function to determine the number of days between two given dates.\n\n### Problem Statement\nGiven two dates as strings in the format \"YYYY-MM-DD\", write a function `days_between_dates` that calculates and returns the number of ...
def shuffle_array(arr): result = [] for i in range(0, len(arr), 2): if i + 1 < len(arr): result.append(arr[i + 1]) result.append(arr[i]) else: result.append(arr[i]) return result
simplelr_Algorithm
[ { "content": "Question:\nArray Shuffling\n\nYou need to create a function that takes a list of integers and rearranges its elements in such a way that every consecutive pair of elements are swapped. If the list has an odd number of elements, the last element should remain in its original position.\n\n### Functi...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6730, "level": 1, "question": "Array Shuffling\n\nYou need to create a function that takes a list of integers and rearranges its elements in such a way that every consecutive pair of elements are swapped. If the list has an odd number of elements, the last element should remain in i...
def circular_shift(lst, shifts): n = len(lst) if n == 0: return [] effective_shift = shifts % n return lst[-effective_shift:] + lst[:-effective_shift]
simplelr_Apps
[ { "content": "Question:\nWrite a function called `circular_shift` which takes in two parameters: a list of integers `lst` and an integer `shifts`. The function should return a new list where each element of the input list `lst` is circularly shifted to the right by the number of positions specified by `shifts`....
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6731, "level": 1, "question": "Write a function called `circular_shift` which takes in two parameters: a list of integers `lst` and an integer `shifts`. The function should return a new list where each element of the input list `lst` is circularly shifted to the right by the number ...
def length_of_longest_substring(s): last_occurrence = {} max_length = 0 left = 0 for right in range(len(s)): char = s[right] if char in last_occurrence and last_occurrence[char] >= left: left = last_occurrence[char] + 1 last_occurrence[char] = right current...
simplelr_Leetcode
[ { "content": "Question:\nGiven a string `s`, return _the length of the longest substring of `s` without repeating characters_. You may assume that all characters in the string are ASCII characters. Solve this problem using the sliding window technique, ensuring that your solution's time complexity is linear in...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6732, "level": 1, "question": "Given a string `s`, return _the length of the longest substring of `s` without repeating characters_. You may assume that all characters in the string are ASCII characters. Solve this problem using the sliding window technique, ensuring that your solu...
import logging import os import string def word_count(input_string, log_dir): if not isinstance(input_string, str): raise ValueError("Input must be a string.") # Check if log directory exists, is a directory, and is writable if not os.path.exists(log_dir): raise FileNotFoundError(f"The...
simplelr_Package
[ { "content": "Question:\n```\nWrite a function that takes a string as an input and returns a dictionary with the word count of each unique word in the string. The function should ignore case, punctuation, and handle multiple spaces between words. It should log the process of counting to a file named 'word_count...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6733, "level": 1, "question": "```\nWrite a function that takes a string as an input and returns a dictionary with the word count of each unique word in the string. The function should ignore case, punctuation, and handle multiple spaces between words. It should log the process of c...
def climb_stairs_variation(steps: int) -> int: if steps == 1: return 1 elif steps == 2: return 2 elif steps == 3: return 4 else: a, b, c = 1, 2, 4 for i in range(4, steps + 1): current = a + b + c a, b, c = b, c, current return c
simplelr_Data_Structure
[ { "content": "Question:\n### Climbing Stairs Variation\n\nYou are given a staircase problem, but with a twist. This time, you can climb the stairs by taking 1, 2, or 3 steps at a time. Given a staircase with `n` steps, find out how many distinct ways you can climb to the top using these steps.\n\nWrite a functi...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6734, "level": 1, "question": "### Climbing Stairs Variation\n\nYou are given a staircase problem, but with a twist. This time, you can climb the stairs by taking 1, 2, or 3 steps at a time. Given a staircase with `n` steps, find out how many distinct ways you can climb to the top u...
def process_operations(s, operations): lst = list(s) for op in operations: if op[0] == "insert": index = op[1] char = op[2] lst.insert(index, char) else: # op[0] is "delete" index = op[1] if index < len(lst): lst.pop(in...
simplelr_Leetcode
[ { "content": "Question:\nYou are given a list of operations on a string where each operation is defined as `[operation_type, index, char]`. The `operation_type` can be `insert` or `delete`. If it is `insert`, insert `char` at the position `index` in the current string. If it is `delete`, remove the character at...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6735, "level": 1, "question": "You are given a list of operations on a string where each operation is defined as `[operation_type, index, char]`. The `operation_type` can be `insert` or `delete`. If it is `insert`, insert `char` at the position `index` in the current string. If it i...
from datetime import datetime import builtins def custom_print(*args, **kwargs): if len(args) == 0 and len(kwargs) == 0: builtins.print() return timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") new_args = (timestamp,) + args builtins.print(*new_args, **kwargs)
simplelr_Docs
[ { "content": "Question:\n### Question: Custom Wrapper for Built-in Functions\n\nIn this assessment, you are required to create a custom implementation of a built-in function while retaining the ability to use the original built-in function. You will demonstrate your understanding by enhancing the behavior of a ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6736, "level": 1, "question": "### Question: Custom Wrapper for Built-in Functions\n\nIn this assessment, you are required to create a custom implementation of a built-in function while retaining the ability to use the original built-in function. You will demonstrate your understand...
import keyword import re def is_valid_variable_name(variable_name: str) -> bool: if not variable_name: return False if keyword.iskeyword(variable_name): return False pattern = r'^[a-zA-Z_][a-zA-Z0-9_]*$' if not re.fullmatch(pattern, variable_name): return False return True
simplelr_Taco
[ { "content": "Question:\nCreate a function that takes a string as input and returns True if it is a valid variable name in Python, and False otherwise.\n\nA valid variable name in Python:\n- Can only contain letters (a-z, A-Z), digits (0-9), and underscores (_).\n- Must start with a letter (a-z, A-Z) or an unde...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6737, "level": 1, "question": "Create a function that takes a string as input and returns True if it is a valid variable name in Python, and False otherwise.\n\nA valid variable name in Python:\n- Can only contain letters (a-z, A-Z), digits (0-9), and underscores (_).\n- Must start ...
def custom_sum(numbers): total = 0 for number in numbers: total += number return total
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to calculate the sum of a list of numbers without using Python's built-in sum function.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6738, "level": 1, "question": "Write a python function to calculate the sum of a list of numbers without using Python's built-in sum function.", "split": "train" }
def day_of_week(date: str) -> str: days = ["Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"] y, m, d = map(int, date.split('-')) if m < 3: m += 12 y -= 1 q = d K = y % 100 J = y // 100 h = (q + (13 * (m + 1) // 5) + K + (K // 4) + (J // 4) - 2 * J)...
simplelr_Algorithm
[ { "content": "Question:\n### Coding Question\nYou are tasked to implement a function that simulates the calculation of the day of the week for a given date using Zeller's Congruence algorithm. Given a date in the format `YYYY-MM-DD`, your function should return the day of the week for that date.\n\n#### Functio...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6739, "level": 1, "question": "### Coding Question\nYou are tasked to implement a function that simulates the calculation of the day of the week for a given date using Zeller's Congruence algorithm. Given a date in the format `YYYY-MM-DD`, your function should return the day of the ...
def maximalSquare(grid): if not grid or not grid[0]: return 0 m = len(grid) n = len(grid[0]) dp = [[0] * n for _ in range(m)] max_side = 0 for i in range(m): for j in range(n): if grid[i][j] == 1: if i == 0 or j == 0: dp[i][j] = 1 ...
simplelr_Filter
[ { "content": "Question:\nGiven a grid of m x n binary values (0 or 1), write a Python function to find the maximum side length of a square with all 1s. The grid is represented as a 2D list where each element is either 0 or 1.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6740, "level": 1, "question": "Given a grid of m x n binary values (0 or 1), write a Python function to find the maximum side length of a square with all 1s. The grid is represented as a 2D list where each element is either 0 or 1.", "split": "train" }
def rotate_matrix(matrix): return [list(row[::-1]) for row in zip(*matrix)]
simplelr_Taco
[ { "content": "Question:\nWrite a function `rotateMatrix`, `rotate_matrix` or `RotateMatrix` that takes a 2D matrix (list of lists) and returns the matrix rotated by 90 degrees in the clockwise direction. The function should handle matrices of any size, including non-square matrices. \n\nExample:\n```\nInput: [[...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6741, "level": 1, "question": "Write a function `rotateMatrix`, `rotate_matrix` or `RotateMatrix` that takes a 2D matrix (list of lists) and returns the matrix rotated by 90 degrees in the clockwise direction. The function should handle matrices of any size, including non-square mat...
def max_benefit(B: int, C: list, V: list) -> int: n = len(C) dp = [0] * (B + 1) for i in range(n): cost = C[i] value = V[i] for j in range(B, cost - 1, -1): if dp[j - cost] + value > dp[j]: dp[j] = dp[j - cost] + value return max(dp)
simplelr_Codeforces
[ { "content": "Question:\nA hotel offers a special promotional package that provides guests with a combination of different types of rooms. Each type of room has a specific cost and amount of benefit it provides. Guests have a limited budget and aim to maximize the benefit they get within their budget constraint...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6742, "level": 1, "question": "A hotel offers a special promotional package that provides guests with a combination of different types of rooms. Each type of room has a specific cost and amount of benefit it provides. Guests have a limited budget and aim to maximize the benefit they...
def sparse_recovery(array): value_sums = {} for val, sign in array: delta = val if sign == '+' else -val if val in value_sums: value_sums[val] += delta else: value_sums[val] = delta non_zero = [k for k, v in value_sums.items() if v != 0] return non_zero[0]...
simplelr_Data_Structure
[ { "content": "Question:\nSparse Stream Recovery\n\n**Introduction**:\n\nYou are given a real-time sensor network where values are monitored and reported. Occasionally, some readings are positive (+) and some are negative (-). Your task is to check if a stream of sensor readings results in exactly one unique non...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6743, "level": 1, "question": "Sparse Stream Recovery\n\n**Introduction**:\n\nYou are given a real-time sensor network where values are monitored and reported. Occasionally, some readings are positive (+) and some are negative (-). Your task is to check if a stream of sensor reading...
def numDecodings(s: str) -> int: n = len(s) dp = [0] * (n + 1) dp[0] = 1 # Base case: one way to decode empty string for i in range(1, n + 1): # Check single digit case if s[i-1] != '0': dp[i] += dp[i-1] # Check two digits case if i >= 2: two...
simplelr_Apps
[ { "content": "Question:\nWrite a function that calculates the total number of ways to decode a given string containing only digits. Each digit or group of digits can be decoded as letters based on the mapping: '1' -> 'A', '2' -> 'B', ..., '26' -> 'Z'. The input to the function will be a non-empty string of digi...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6744, "level": 1, "question": "Write a function that calculates the total number of ways to decode a given string containing only digits. Each digit or group of digits can be decoded as letters based on the mapping: '1' -> 'A', '2' -> 'B', ..., '26' -> 'Z'. The input to the function...
def stooge_sort(arr: list, l: int, h: int) -> None: if l >= h: return if arr[l] > arr[h]: arr[l], arr[h] = arr[h], arr[l] n = h - l + 1 if n > 2: m = n // 3 stooge_sort(arr, l, h - m) stooge_sort(arr, l + m, h) stooge_sort(arr, l, h - m)
simplelr_Data_Structure
[ { "content": "Question:\n### Question\n\n#### Context:\nYou are given a list of unique numbers representing the order of participants in a marathon. The list needs to be sorted in ascending order based on their finish times. Since this is a theoretical study on sorting algorithms, you are required to implement ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6745, "level": 1, "question": "### Question\n\n#### Context:\nYou are given a list of unique numbers representing the order of participants in a marathon. The list needs to be sorted in ascending order based on their finish times. Since this is a theoretical study on sorting algorit...
def longest_consecutive_subsequence(nums): if not nums: return [] s = set(nums) max_length = 0 start = 0 for num in nums: if (num - 1) not in s: current_num = num current_length = 1 while (current_num + 1) in s: current_num += 1 ...
simplelr_Apps
[ { "content": "Question:\nDescription:\n\nWrite a function that takes a list of integers and returns the longest consecutive subsequence. A consecutive subsequence is a sequence in which the elements are consecutive integers. Structure your solution to work efficiently with large arrays.\n\nExamples:\n\nInput `[...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6746, "level": 1, "question": "Description:\n\nWrite a function that takes a list of integers and returns the longest consecutive subsequence. A consecutive subsequence is a sequence in which the elements are consecutive integers. Structure your solution to work efficiently with lar...
def allocate_faculty(m: int, capacity: list[int], n: int, course_sections: list[int]) -> list[list[int]]: total_sections = sum(course_sections) total_capacity = sum(capacity) if total_sections > total_capacity: return [] # Sort courses by the number of sections in descending order, kee...
simplelr_Algorithm
[ { "content": "Question:\n### Faculty Allocation for Course Schedule\n\nIn a university setting, proper allocation of faculty to courses while maintaining a balanced workload is essential for smooth operations. Each faculty member can teach a limited number of courses and every course has a certain number of sec...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6747, "level": 1, "question": "### Faculty Allocation for Course Schedule\n\nIn a university setting, proper allocation of faculty to courses while maintaining a balanced workload is essential for smooth operations. Each faculty member can teach a limited number of courses and every...
def are_all_characters_unique(s): char_count = {} for char in s: if char in char_count: return False char_count[char] = True return True
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to check if all the characters in a string are unique using a dictionary. How can this be done in an optimized way?\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6748, "level": 1, "question": "Write a python function to check if all the characters in a string are unique using a dictionary. How can this be done in an optimized way?", "split": "train" }
def coinChange(coins, amount): if amount == 0: return 0 dp = [float('inf')] * (amount + 1) dp[0] = 0 # Base case: 0 coins needed to make 0 amount for i in range(1, amount + 1): for coin in coins: if coin <= i: dp[i] = min(dp[i], dp[i - coin] + 1) ...
simplelr_Leetcode
[ { "content": "Question:\nYou are given a list of `coins` where each element represents a coin with a specific value, and a target amount `amount`. Your goal is to determine the **fewest number of coins** that you need to make up that amount. If that amount of money cannot be made up by any combination of the co...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6749, "level": 1, "question": "You are given a list of `coins` where each element represents a coin with a specific value, and a target amount `amount`. Your goal is to determine the **fewest number of coins** that you need to make up that amount. If that amount of money cannot be m...
import torch def manipulate_and_compute(input_matrix): """ This function takes a 2D input matrix, performs a series of tensor operations, and returns both the result of the computations and the gradient of a specific scalar output with respect to the input. Parameters: - input_matrix (list of ...
simplelr_Docs
[ { "content": "Question:\n### PyTorch Tensor Manipulation and Automatic Differentiation\n\nYou are tasked with implementing a function that leverages PyTorch tensors to perform a series of operations and computations. \n\n#### Function Signature\n```python\nimport torch\n\ndef manipulate_and_compute(input_matrix...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6750, "level": 1, "question": "### PyTorch Tensor Manipulation and Automatic Differentiation\n\nYou are tasked with implementing a function that leverages PyTorch tensors to perform a series of operations and computations. \n\n#### Function Signature\n```python\nimport torch\n\ndef ...
from collections import Counter def is_palindrome_permutation(s: str) -> bool: # Remove all whitespace and convert to lowercase s_clean = s.replace(" ", "").lower() if len(s_clean) == 0: return False # Count the frequency of each character counts = Counter(s_clean) # Count how many char...
simplelr_Algorithm
[ { "content": "Question:\n### Coding Question\n\n#### Problem Statement\nYou are tasked with creating a function `is_palindrome_permutation` that determines if a given string is a permutation of a palindrome. Your function should ignore whitespace and be case-insensitive.\n\n#### Function Signature\n```python\nd...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6751, "level": 1, "question": "### Coding Question\n\n#### Problem Statement\nYou are tasked with creating a function `is_palindrome_permutation` that determines if a given string is a permutation of a palindrome. Your function should ignore whitespace and be case-insensitive.\n\n##...
from collections import deque def max_reachable_nodes(n, edges, restricted): if 0 in restricted: return 0 # Build adjacency list adj = [[] for _ in range(n)] for u, v in edges: adj[u].append(v) adj[v].append(u) restricted_set = set(restricted) visited = [False]...
simplelr_Leetcode
[ { "content": "Question:\nYou are given an undirected graph with `n` nodes labeled from `0` to `n-1` represented as an edge list `edges` where `edges[i] = [u_i, v_i]` denotes an edge between nodes `u_i` and `v_i`. Additionally, you are provided with a 2D integer array `restricted` where `restricted[j]` denotes n...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6752, "level": 1, "question": "You are given an undirected graph with `n` nodes labeled from `0` to `n-1` represented as an edge list `edges` where `edges[i] = [u_i, v_i]` denotes an edge between nodes `u_i` and `v_i`. Additionally, you are provided with a 2D integer array `restrict...
def create_custom_scatterplots(): """ This function generates and displays the required scatter plots using the seaborn library. """ import seaborn as sns import matplotlib.pyplot as plt # Load the tips dataset tips = sns.load_dataset("tips") # Plot 1: Simple Scatter Plot of To...
simplelr_Docs
[ { "content": "Question:\n#### Objective\nYour task is to demonstrate your knowledge and understanding of the seaborn library to create and customize scatter plots. You will be provided with a dataset, and you are required to generate multiple scatter plots that clearly and effectively communicate the relationsh...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6753, "level": 1, "question": "#### Objective\nYour task is to demonstrate your knowledge and understanding of the seaborn library to create and customize scatter plots. You will be provided with a dataset, and you are required to generate multiple scatter plots that clearly and eff...
def sum_of_subarray_products(arr): current_sum = 0 total_sum = 0 for num in arr: current_sum = current_sum * num + num total_sum += current_sum return total_sum
simplelr_Leetcode
[ { "content": "Question:\nGiven an array of integers `arr`, consider all possible subarrays. For each subarray, compute the product of its elements. Return the sum of these products for all subarrays.\n\nA **subarray** is a contiguous part of the original array. For example, the subarrays of `[1, 2, 3]` are `[1]...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6754, "level": 1, "question": "Given an array of integers `arr`, consider all possible subarrays. For each subarray, compute the product of its elements. Return the sum of these products for all subarrays.\n\nA **subarray** is a contiguous part of the original array. For example, th...
def integer_decompositions(n: int) -> int: if n == 0: return 1 # Handle edge case if n=0 dp = [0] * (n + 1) dp[0] = 1 # Base case: one way to partition 0 (with no parts) for i in range(1, n + 1): for j in range(i, n + 1): dp[j] += dp[j - i] return dp[n]
simplelr_Data_Structure
[ { "content": "Question:\n### Question\nA historical mathematician has discovered an ancient tablet containing the decomposition of numbers using non-negative integers. You are required to design a function that returns the number of ways to decompose a given positive integer using smaller non-negative integers,...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6755, "level": 1, "question": "### Question\nA historical mathematician has discovered an ancient tablet containing the decomposition of numbers using non-negative integers. You are required to design a function that returns the number of ways to decompose a given positive integer u...
def fibonacci(n): if n == 1: return 0 elif n == 2: return 1 else: a, b = 0, 1 for i in range(3, n + 1): c = a + b a = b b = c return b
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to return the nth number in the Fibonacci sequence without using recursion.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6756, "level": 1, "question": "Write a python function to return the nth number in the Fibonacci sequence without using recursion.", "split": "train" }
def can_split_array(arr): if len(arr) < 2: return False total = sum(arr) if total % 2 != 0: return False target = total // 2 current = 0 for num in arr: current += num if current == target: return True return False
simplelr_Leetcode
[ { "content": "Question:\nGiven an integer array `arr`, you need to determine if it is possible to split the array into two non-empty subarrays such that the sum of the elements in both subarrays is the same. If it is possible, return `true`; otherwise, return `false`. For example, if `arr = [1, 2, 3, 4, 5, 5]`,...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6757, "level": 1, "question": "Given an integer array `arr`, you need to determine if it is possible to split the array into two non-empty subarrays such that the sum of the elements in both subarrays is the same. If it is possible, return `true`; otherwise, return `false`. For exam...
from typing import List, Dict, Any def sort_dict_list(dict_list: List[Dict[str, Any]], key_order: List[str]) -> List[Dict[str, Any]]: return sorted(dict_list, key=lambda x: tuple(x[k] for k in key_order))
simplelr_Algorithm
[ { "content": "Question:\n### Sorting a List of Dictionaries by Multiple Keys\n\nYou are required to implement a function that sorts a list of dictionaries based on multiple keys. The sequence of keys will determine the primary, secondary, tertiary, and so on, sorting order. The function you write should follow ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6758, "level": 1, "question": "### Sorting a List of Dictionaries by Multiple Keys\n\nYou are required to implement a function that sorts a list of dictionaries based on multiple keys. The sequence of keys will determine the primary, secondary, tertiary, and so on, sorting order. Th...
import re def tokenize_ingredients(text): text = text.strip() ingredients = [i.strip() for i in text.split(',')] ingredient_names = [] for ingredient in ingredients: match = re.search(r'of\s+(.+)$', ingredient) if match: ingredient_name = match.group(1).strip() i...
simplelr_Filter
[ { "content": "Question:\nI have a string of text that I'd like to tokenize. The text is a recipe, and I'd like to extract the ingredients from the text. The ingredients are listed at the top of the recipe and are separated by commas, and there are multiple ingredients on the same line. \n\nHere is an example of...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6759, "level": 1, "question": "I have a string of text that I'd like to tokenize. The text is a recipe, and I'd like to extract the ingredients from the text. The ingredients are listed at the top of the recipe and are separated by commas, and there are multiple ingredients on the s...
from typing import List def subarray_sum_zero(arr: List[int]) -> bool: seen = {0} current_sum = 0 for num in arr: current_sum += num if current_sum == 0 or current_sum in seen: return True seen.add(current_sum) return False
simplelr_Apps
[ { "content": "Question:\nGiven an array of integers, write a function to determine if a subarray exists such that the sum of the subarray is equal to zero. If such a subarray exists, return `True`, otherwise return `False`. A subarray is defined as a contiguous segment of the array. \n\n### Input\n- A list of i...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6760, "level": 1, "question": "Given an array of integers, write a function to determine if a subarray exists such that the sum of the subarray is equal to zero. If such a subarray exists, return `True`, otherwise return `False`. A subarray is defined as a contiguous segment of the ...
def max_profit(prices): if len(prices) < 2: return 0 min_price = prices[0] max_profit = 0 for i in range(1, len(prices)): current_price = prices[i] if current_price < min_price: min_price = current_price potential_profit = current_price - min_price if ...
simplelr_Prefill
[ { "content": "Question:\nWrite a function to calculate the maximum profit you can make from a single buy and sell transaction on a given list of daily stock prices. The list is provided as an array `[prices]`.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6761, "level": 1, "question": "Write a function to calculate the maximum profit you can make from a single buy and sell transaction on a given list of daily stock prices. The list is provided as an array `[prices]`.", "split": "train" }
def find_pair_with_sum(nums, target): for i in range(len(nums) - 1): for j in range(i + 1, len(nums)): if nums[i] + nums[j] == target: return [nums[i], nums[j]] return []
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes two parameters: a list of integers and an integer representing the sum. The function should return the first two integers in the list whose sum equals the given integer. If no such integers exist, return an empty list.\nAnswer:\nLet's think step by step.\n",...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6762, "level": 1, "question": "Create a function that takes two parameters: a list of integers and an integer representing the sum. The function should return the first two integers in the list whose sum equals the given integer. If no such integers exist, return an empty list.", ...
def find_min_in_rotated_sorted_array(nums): left = 0 right = len(nums) - 1 while left < right: mid = (left + right) // 2 if nums[mid] > nums[right]: left = mid + 1 elif nums[mid] < nums[right]: right = mid else: right -= 1 return nums[l...
simplelr_Prefill
[ { "content": "Question:\nWrite a function to find the minimum number in a rotated sorted array in constant logarithmic time. The array may contain duplicates. Explain the method used and how it handles duplicates.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6763, "level": 1, "question": "Write a function to find the minimum number in a rotated sorted array in constant logarithmic time. The array may contain duplicates. Explain the method used and how it handles duplicates.", "split": "train" }
def length_of_longest_substring(s): char_index = {} start = 0 max_length = 0 for i, char in enumerate(s): if char in char_index and char_index[char] >= start: start = char_index[char] + 1 char_index[char] = i current_length = i - start + 1 if current_length > ...
simplelr_Taco
[ { "content": "Question:\nWrite a function that finds the longest substring without repeating characters in a given string. The function should return the length of this substring. Ensure the algorithm runs efficiently so that it can handle larger input strings seamlessly.\nAnswer:\nLet's think step by step.\n",...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6764, "level": 1, "question": "Write a function that finds the longest substring without repeating characters in a given string. The function should return the length of this substring. Ensure the algorithm runs efficiently so that it can handle larger input strings seamlessly.", ...
from collections import deque def ladder_length(beginWord: str, endWord: str, wordList: list[str]) -> int: word_set = set(wordList) if endWord not in word_set: return 0 queue = deque() queue.append((beginWord, 1)) visited = set() visited.add(beginWord) while queue: ...
simplelr_Apps
[ { "content": "Question:\n### Word Ladder Path Finder\n\nGiven two words (beginWord and endWord), and a dictionary's word list, find the length of the shortest transformation sequence from beginWord to endWord, such that:\n\n1. Only one letter can be changed at a time.\n2. Each transformed word must exist in the...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6765, "level": 1, "question": "### Word Ladder Path Finder\n\nGiven two words (beginWord and endWord), and a dictionary's word list, find the length of the shortest transformation sequence from beginWord to endWord, such that:\n\n1. Only one letter can be changed at a time.\n2. Each...
def max_length_of_substring_with_2_distinct_chars(s): left = 0 max_len = 0 char_count = {} distinct = 0 for right in range(len(s)): char = s[right] if char in char_count: char_count[char] += 1 else: char_count[char] = 1 distinct += 1 ...
simplelr_Leetcode
[ { "content": "Question:\nGiven a string `s` containing only lowercase letters, you need to determine the maximum length of a substring that contains no more than 2 distinct characters. Return the length of such a substring.\n\nFor example, given `s = \"eceba\"`, the function should return `3` as the substring `...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6766, "level": 1, "question": "Given a string `s` containing only lowercase letters, you need to determine the maximum length of a substring that contains no more than 2 distinct characters. Return the length of such a substring.\n\nFor example, given `s = \"eceba\"`, the function s...
def sort_usernames(usernames: list) -> list: if not isinstance(usernames, list): raise TypeError("Input must be a list.") if any(not isinstance(x, str) for x in usernames): raise ValueError("All elements in the input list must be strings.") unique_usernames = list({x for x in usernames}) ...
simplelr_Algorithm
[ { "content": "Question:\n### Sorting Usernames by Length and Alphabetically\n\nYou are required to write a function that takes a list of usernames and returns the sorted list. The usernames should be sorted first by their length in ascending order, and then alphabetically for usernames of the same length. If th...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6767, "level": 1, "question": "### Sorting Usernames by Length and Alphabetically\n\nYou are required to write a function that takes a list of usernames and returns the sorted list. The usernames should be sorted first by their length in ascending order, and then alphabetically for ...
def decimal_to_binary(n): if n == 0: return '0' binary_str = '' while n > 0: remainder = n % 2 binary_str += str(remainder) n = n // 2 return binary_str[::-1]
simplelr_Filter
[ { "content": "Question:\nWrite a code that converts a decimal number to its binary representation, but you are not allowed to use any built-in functions or libraries for converting decimal to binary. You can only use basic arithmetic operations like addition, subtraction, multiplication, and division. The decim...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6768, "level": 1, "question": "Write a code that converts a decimal number to its binary representation, but you are not allowed to use any built-in functions or libraries for converting decimal to binary. You can only use basic arithmetic operations like addition, subtraction, mult...
def remove_all_occurrences(lst, char): return [x for x in lst if x != char]
simplelr_Filter
[ { "content": "Question:\nWrite a python function that removes all occurrences of a specific character from a list. The function should work even when the list contains a large volume of data (assuming length = 1e6). The erroneous reference code provided below doesn't achieve the desired functionality.\nAnswer:\...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6769, "level": 1, "question": "Write a python function that removes all occurrences of a specific character from a list. The function should work even when the list contains a large volume of data (assuming length = 1e6). The erroneous reference code provided below doesn't achieve t...
from typing import List def min_elements_to_sum(lst: List[int], target: int) -> int: sorted_lst = sorted(lst, reverse=True) current_sum = 0 count = 0 for num in sorted_lst: current_sum += num count += 1 if current_sum >= target: return count return -1
simplelr_Algorithm
[ { "content": "Question:\n### Problem Statement\n\nYou are given a list of positive integers. Write a Python function that determines the smallest number of elements needed from the list to sum up to at least a given target value. If it is not possible to reach the target sum with the provided integers, the func...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6770, "level": 1, "question": "### Problem Statement\n\nYou are given a list of positive integers. Write a Python function that determines the smallest number of elements needed from the list to sum up to at least a given target value. If it is not possible to reach the target sum w...
def invert_case(text: str) -> str: return text.swapcase()
simplelr_Package
[ { "content": "Question:\nYou are tasked with writing a function `invert_case` that takes in one parameter:\n- `text` (a string containing multiple words)\n\nThe function should return a new string where the case of each letter in the input string is inverted (uppercase letters become lowercase and vice versa). ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6771, "level": 1, "question": "You are tasked with writing a function `invert_case` that takes in one parameter:\n- `text` (a string containing multiple words)\n\nThe function should return a new string where the case of each letter in the input string is inverted (uppercase letters...
def edit_distance(str1: str, str2: str) -> int: m = len(str1) n = len(str2) dp = [[0] * (n + 1) for _ in range(m + 1)] # Initialize the first row and column for i in range(m + 1): dp[i][0] = i for j in range(n + 1): dp[0][j] = j for i in range(1, m + 1): for...
simplelr_Algorithm
[ { "content": "Question:\n### Objective:\nImplement a function in Python to calculate the edit distance (Levenshtein distance) between two strings.\n\n### Problem Statement:\nYou are tasked with implementing the edit distance algorithm to compute the minimum number of single-character edits (insertions, deletion...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6772, "level": 1, "question": "### Objective:\nImplement a function in Python to calculate the edit distance (Levenshtein distance) between two strings.\n\n### Problem Statement:\nYou are tasked with implementing the edit distance algorithm to compute the minimum number of single-ch...
def remove_consecutive_duplicates(nums): if not nums: return [] result = [nums[0]] for num in nums[1:]: if num != result[-1]: result.append(num) return result
simplelr_Evol
[ { "content": "Question:\nCreate a function that takes a list of integers and returns a new list containing only the integers that remain after removing all consecutive duplicate values. For example, given the input list [1, 2, 2, 3, 3, 1, 1, 4], the output should be [1, 2, 3, 1, 4].\nAnswer:\nLet's think step b...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6773, "level": 1, "question": "Create a function that takes a list of integers and returns a new list containing only the integers that remain after removing all consecutive duplicate values. For example, given the input list [1, 2, 2, 3, 3, 1, 1, 4], the output should be [1, 2, 3, ...
def restore_string(s, indices): pos = {v: i for i, v in enumerate(indices)} original = [] for j in range(len(s)): original.append(s[pos[j]]) return ''.join(original)
simplelr_Leetcode
[ { "content": "Question:\nYou are given a string `s` consisting of lowercase English letters, and an integer array `indices` of the same length. The string `s` was originally large enough, but a mechanism shifted its characters such that now each character moved to the position specified in `indices`. Your task ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6774, "level": 1, "question": "You are given a string `s` consisting of lowercase English letters, and an integer array `indices` of the same length. The string `s` was originally large enough, but a mechanism shifted its characters such that now each character moved to the position...
def filterStudentsByGrade(data, passingGrade): return [student['name'] for student in data if student['grade'] >= passingGrade]
simplelr_Package
[ { "content": "Question:\nYou are tasked with writing a function, `filterStudentsByGrade(data, passingGrade)`, that filters a list of student records based on their grades. Each student record is represented as a dictionary with the following keys: 'name', 'id', and 'grade'. The function should return a list of ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6775, "level": 1, "question": "You are tasked with writing a function, `filterStudentsByGrade(data, passingGrade)`, that filters a list of student records based on their grades. Each student record is represented as a dictionary with the following keys: 'name', 'id', and 'grade'. Th...
def fever_detector(input_temps): return [any(temp >= 100.4 for temp in participant) for participant in input_temps]
simplelr_Taco
[ { "content": "Question:\nA pharmaceutical company is conducting a study on the effectiveness of a new drug. Each participant in the study has his/her temperature recorded at various times during the day, and a decision has to be made on whether the participant has a fever at any time during the day.\n\nThe feve...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6776, "level": 1, "question": "A pharmaceutical company is conducting a study on the effectiveness of a new drug. Each participant in the study has his/her temperature recorded at various times during the day, and a decision has to be made on whether the participant has a fever at a...
def filter_strings(string_list): return [string for string in string_list if len(string) > 5 and 'e' in string]
simplelr_Filter
[ { "content": "Question:\nWrite a python function that takes a list of strings and returns a new list containing only the strings that have a length greater than 5 and contain the letter 'e'. If no such strings are found, the function should return an empty list.\nAnswer:\nLet's think step by step.\n", "role...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6777, "level": 1, "question": "Write a python function that takes a list of strings and returns a new list containing only the strings that have a length greater than 5 and contain the letter 'e'. If no such strings are found, the function should return an empty list.", "split": "...
def fibonacci(n): if n <= 0: return [] elif n == 1: return [0] elif n == 2: return [0, 1] else: fib_sequence = [0, 1] for i in range(2, n): next_term = fib_sequence[i-1] + fib_sequence[i-2] fib_sequence.append(next_term) return fib_...
simplelr_Filter
[ { "content": "Question:\nHow can I design a function in Python to calculate the Fibonacci sequence up to the n-th term?\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6778, "level": 1, "question": "How can I design a function in Python to calculate the Fibonacci sequence up to the n-th term?", "split": "train" }
import seaborn as sns import matplotlib.pyplot as plt from seaborn import load_dataset def plot_life_expectancy_vs_spending(): # Load the dataset healthexp = load_dataset("healthexp").sort_values(["Country", "Year"]) # Create a figure with appropriate size plt.figure(figsize=(12, 8)) ax = plt....
simplelr_Docs
[ { "content": "Question:\n### Seaborn Coding Assessment Question\n\n#### Objective:\nTo assess your understanding of seaborn's advanced plotting capabilities, dataset handling, and customization features.\n\n#### Question:\nUsing the seaborn library, write a function `plot_life_expectancy_vs_spending` that takes...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6779, "level": 1, "question": "### Seaborn Coding Assessment Question\n\n#### Objective:\nTo assess your understanding of seaborn's advanced plotting capabilities, dataset handling, and customization features.\n\n#### Question:\nUsing the seaborn library, write a function `plot_life...
def spiral_traversal(matrix): if not matrix or not matrix[0]: return [] result = [] top = 0 bottom = len(matrix) - 1 left = 0 right = len(matrix[0]) - 1 while top <= bottom and left <= right: # Traverse top row from left to right for i in range(left, right +...
simplelr_Data_Structure
[ { "content": "Question:\n### Spiral Matrix Traversal\n\n**Context**: You are tasked with developing a navigation system for a robot that is required to traverse a 2D plane in a specific spiral pattern starting from the top-left point.\n\n**Task**: Given a matrix of m x n elements (m rows and n columns), impleme...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6780, "level": 1, "question": "### Spiral Matrix Traversal\n\n**Context**: You are tasked with developing a navigation system for a robot that is required to traverse a 2D plane in a specific spiral pattern starting from the top-left point.\n\n**Task**: Given a matrix of m x n eleme...
from collections import deque def shortest_path(N, M, grid): # Check if the start or end is blocked if grid[0][0] == 1 or grid[N-1][M-1] == 1: return -1 # Define the four possible directions to move directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] # Initialize the visited matrix ...
simplelr_Taco
[ { "content": "Question:\nYou are given a grid where some cells are blocked and others are open. Your task is to find the shortest path from the top-left cell to the bottom-right cell, moving only up, down, left, or right. If no path exists, return -1.\n\n### Input\n- An integer `N` representing the number of ro...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6781, "level": 1, "question": "You are given a grid where some cells are blocked and others are open. Your task is to find the shortest path from the top-left cell to the bottom-right cell, moving only up, down, left, or right. If no path exists, return -1.\n\n### Input\n- An intege...
from collections import Counter def most_frequent_word(word_list): # Convert all words to lowercase lower_words = [word.lower() for word in word_list] # Count the occurrences of each word word_counts = Counter(lower_words) # Find the most common word if word_counts: most_common = word_c...
simplelr_Filter
[ { "content": "Question:\nThis prompt is a little more challenging:\n\nI'm working on a Python program that processes text data.\n\nI have a list of words, and I want to find the most frequent word in the list.\n\nHowever, I want to ignore case, so \"The\" and \"the\" should be counted as the same word.\n\n\n**C...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6782, "level": 1, "question": "This prompt is a little more challenging:\n\nI'm working on a Python program that processes text data.\n\nI have a list of words, and I want to find the most frequent word in the list.\n\nHowever, I want to ignore case, so \"The\" and \"the\" should be...
def convert_books(books): book_dict = {} for book in books: title = book['title'] author = book['author'] year = book['year'] book_dict[title] = (author, year) return book_dict
simplelr_Taco
[ { "content": "Question:\nYou are given a list of dictionaries, where each dictionary contains information about a book. Each book has a title, author, and year of publication. Write a function that will take this list of dictionaries and return a new dictionary. The new dictionary should have the titles of the ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6783, "level": 1, "question": "You are given a list of dictionaries, where each dictionary contains information about a book. Each book has a title, author, and year of publication. Write a function that will take this list of dictionaries and return a new dictionary. The new dictio...
def count_vowels(s): vowels = {'a', 'e', 'i', 'o', 'u'} count = 0 for char in s: if char.lower() in vowels: count += 1 return count
simplelr_Filter
[ { "content": "Question:\nPlease write a python function that takes a string and returns a count of all the vowels in the string.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6784, "level": 1, "question": "Please write a python function that takes a string and returns a count of all the vowels in the string.", "split": "train" }
def maxSlidingWindowSum(nums, k): current_sum = sum(nums[:k]) max_sum = current_sum for i in range(k, len(nums)): current_sum = current_sum - nums[i - k] + nums[i] if current_sum > max_sum: max_sum = current_sum return max_sum
simplelr_Taco
[ { "content": "Question:\nYou are given an array of integers and a sliding window of size `k`. Your task is to find the maximum sum of any subarray of size `k`.\n\nImplement a function `maxSlidingWindowSum(nums, k)` that takes in:\n- `nums`: a list of integers\n- `k`: an integer representing the size of the slid...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6785, "level": 1, "question": "You are given an array of integers and a sliding window of size `k`. Your task is to find the maximum sum of any subarray of size `k`.\n\nImplement a function `maxSlidingWindowSum(nums, k)` that takes in:\n- `nums`: a list of integers\n- `k`: an intege...
def isValidString(S): stack = [] for char in S: if char == '{': stack.append(char) elif char == '}': if not stack: return False stack.pop() return len(stack) == 0
simplelr_Taco
[ { "content": "Question:\nGiven a string S consisting of lowercase English letters and the characters '{', '}', the task is to determine if the string is valid. A string is considered valid if and only if for every closing bracket '}', there is a corresponding opening bracket '{' in the correct order.\n\nExample...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6786, "level": 1, "question": "Given a string S consisting of lowercase English letters and the characters '{', '}', the task is to determine if the string is valid. A string is considered valid if and only if for every closing bracket '}', there is a corresponding opening bracket '...
def move_second_to_last_to_front(lst): if len(lst) < 2: return lst val = lst[-2] new_list = [None] * len(lst) new_list[0] = val j = 0 for i in range(1, len(lst)): while j < len(lst): if j != len(lst) - 2: new_list[i] = lst[j] j += 1 ...
simplelr_Filter
[ { "content": "Question:\nWrite a function in Python to move the second-to-last element of a given list to the beginning of the list. However, you are not allowed to use any list manipulation methods or slicing operations. You can only use basic operations such as assignment, loops, and conditionals.\nAnswer:\nL...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6787, "level": 1, "question": "Write a function in Python to move the second-to-last element of a given list to the beginning of the list. However, you are not allowed to use any list manipulation methods or slicing operations. You can only use basic operations such as assignment, l...
def trap_water(nums): if not nums or len(nums) < 3: return 0 n = len(nums) left = [0] * n right = [0] * n # Compute left max array for i in range(1, n): left[i] = max(left[i-1], nums[i-1]) # Compute right max array for i in range(n-2, -1, -1): right[i] =...
simplelr_Leetcode
[ { "content": "Question:\nGiven a list of non-negative integers, `nums`, representing the amount of water trapped between non-negative bars. Each element in the list represents the height of the bar. Your task is to return the total amount of water trapped. \n\nExample:\n- Input: `nums = [0, 1, 0, 2, 1, 0, 1, 3,...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6788, "level": 1, "question": "Given a list of non-negative integers, `nums`, representing the amount of water trapped between non-negative bars. Each element in the list represents the height of the bar. Your task is to return the total amount of water trapped. \n\nExample:\n- Inpu...
def fizzbuzz(n): return ("fizz" * (n % 3 == 0) + "buzz" * (n % 5 == 0)) or str(n)
simplelr_Filter
[ { "content": "Question:\nGenerate a fizzbuzz function in Python that, given a number, will return \"fizz\" if the number is divisible by 3, \"buzz\" if it's divisible by 5, and \"fizzbuzz\" if it's divisible by both. However, you must implement this without using any if or else statements.\nAnswer:\nLet's think...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6789, "level": 1, "question": "Generate a fizzbuzz function in Python that, given a number, will return \"fizz\" if the number is divisible by 3, \"buzz\" if it's divisible by 5, and \"fizzbuzz\" if it's divisible by both. However, you must implement this without using any if or els...
def sum_of_primes(n): if n < 2: return 0 is_prime = [True] * (n + 1) is_prime[0], is_prime[1] = False, False for p in range(2, int(n ** 0.5) + 1): if is_prime[p]: for multiple in range(p * p, n + 1, p): is_prime[multiple] = False return sum(i for i, prime ...
simplelr_Filter
[ { "content": "Question:\nWrite a Python function to compute the sum of all the prime numbers from 1 to a given number n, inclusive. The function should efficiently handle large values of n. Optimize your solution for time complexity.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6790, "level": 1, "question": "Write a Python function to compute the sum of all the prime numbers from 1 to a given number n, inclusive. The function should efficiently handle large values of n. Optimize your solution for time complexity.", "split": "train" }
import re def find_all_occurrences(pattern, text): """ Finds all occurrences of a given regex pattern in the specified text. Args: pattern (str): The regular expression pattern to search for. text (str): The text to search within. Returns: list: A list of strings repre...
simplelr_Filter
[ { "content": "Question:\nI'm trying to implement a solution in Python for a problem involving regular expressions, but I'm having a bit of trouble with the implementation. The goal is to find all matching occurrences of a certain pattern within a given text. Can you provide a demonstration of how to use Python'...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6791, "level": 1, "question": "I'm trying to implement a solution in Python for a problem involving regular expressions, but I'm having a bit of trouble with the implementation. The goal is to find all matching occurrences of a certain pattern within a given text. Can you provide a ...
def analyze_memoryview(buffer: bytes) -> dict: info = {} mv = memoryview(buffer) info['length'] = len(mv) info['first_5_elements'] = mv[:5].tobytes() info['last_5_elements'] = mv[-5:].tobytes() info['is_contiguous'] = mv.contiguous read_only_mv = mv.toreadonly() try: re...
simplelr_Docs
[ { "content": "Question:\n#### Objective\n\nImplement a function `analyze_memoryview(buffer: bytes) -> dict` that demonstrates the usage and understanding of Python's `memoryview` object.\n\n#### Requirements\n\n1. The function should accept a `bytes` buffer as input.\n2. Create a `memoryview` from the input buf...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6792, "level": 1, "question": "#### Objective\n\nImplement a function `analyze_memoryview(buffer: bytes) -> dict` that demonstrates the usage and understanding of Python's `memoryview` object.\n\n#### Requirements\n\n1. The function should accept a `bytes` buffer as input.\n2. Creat...
def flatten_nested_list(nested_list): """ Flattens a nested list of integers into a single list of integers. >>> flatten_nested_list([1, [2, [3, 4], 5], 6]) [1, 2, 3, 4, 5, 6] >>> flatten_nested_list([1, [2, 3], 4]) [1, 2, 3, 4] >>> flatten_nested_list([[[1], 2], [3, 4], 5]) [1, 2, 3, 4,...
simplelr_Evol
[ { "content": "Question:\nCreate a function that flattens a nested list of integers into a single list of integers. The function should handle lists with varying depths of nesting, and should not use any built-in flattening utilities. Additionally, provide an erroneous section of the code as a reference.\n\ndef ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6793, "level": 1, "question": "Create a function that flattens a nested list of integers into a single list of integers. The function should handle lists with varying depths of nesting, and should not use any built-in flattening utilities. Additionally, provide an erroneous section ...
def concatenate_with_exclamation(str1, str2): return str1 + "!" + str2
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes two strings as input and returns a new string that is the result of concatenating the first string with an exclamation mark and then the second string.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6794, "level": 1, "question": "Create a function that takes two strings as input and returns a new string that is the result of concatenating the first string with an exclamation mark and then the second string.", "split": "train" }
def parse_string_to_float(s): try: return float(s) except ValueError: return None
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to parse a string to a float. If the string represents a valid float, return the float value. If the string does not represent a valid float, return None. Make sure to handle both integer and decimal representations.\nAnswer:\nLet's think step by step.\n", "r...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6795, "level": 1, "question": "Write a python function to parse a string to a float. If the string represents a valid float, return the float value. If the string does not represent a valid float, return None. Make sure to handle both integer and decimal representations.", "split"...
def word_chain(): """Simulates a game of Word Chain.""" words = [] last_letter = None while True: word = input("Enter a word (or 'pass' to stop): ").lower() if word == 'pass': break elif not word: print("Please enter a word or 'pass'.") conti...
simplelr_Filter
[ { "content": "Question:\nThe following information is about a game:\n\n* The game is called \"Word Chain\".\n\n* The game requires two or more players.\n\n* Players take turns saying words.\n\n* Each new word must begin with the last letter of the previous word.\n\n* For example:\n\n Player 1: Cat\n\n Playe...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6796, "level": 1, "question": "The following information is about a game:\n\n* The game is called \"Word Chain\".\n\n* The game requires two or more players.\n\n* Players take turns saying words.\n\n* Each new word must begin with the last letter of the previous word.\n\n* For examp...
def list_of_lists_to_dict(lst): result = {} for sub in lst: if len(sub) == 2: result[sub[0]] = sub[1] return result
simplelr_Filter
[ { "content": "Question:\nWrite a Python function that converts a list of lists to a dictionary. Each inner list contains two elements, the first being the key and the second the value. Additionally, handle cases where the inner lists might not have exactly two elements by skipping those lists.\nAnswer:\nLet's t...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6797, "level": 1, "question": "Write a Python function that converts a list of lists to a dictionary. Each inner list contains two elements, the first being the key and the second the value. Additionally, handle cases where the inner lists might not have exactly two elements by skip...
from datetime import datetime, timedelta, timezone def next_day_start_timestamp(): now = datetime.now(timezone.utc) today = now.replace(hour=0, minute=0, second=0, microsecond=0) tomorrow = today + timedelta(days=1) return int(tomorrow.timestamp())
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to generate the Unix timestamp for the next day at the start of the day (00:00:00).\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6798, "level": 1, "question": "Write a python function to generate the Unix timestamp for the next day at the start of the day (00:00:00).", "split": "train" }
def check_string_requirements(s): has_upper = False has_lower = False has_digit = False for c in s: if c.isupper(): has_upper = True if c.islower(): has_lower = True if c.isdigit(): has_digit = True return has_upper and has_lower and has_di...
simplelr_Filter
[ { "content": "Question:\nWrite a Python function that checks if a string contains at least one uppercase letter, one lowercase letter, and one digit. The function should return `True` if all conditions are met, otherwise `False`.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6799, "level": 1, "question": "Write a Python function that checks if a string contains at least one uppercase letter, one lowercase letter, and one digit. The function should return `True` if all conditions are met, otherwise `False`.", "split": "train" }