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 sum_of_numbers(text): numbers = re.findall(r'\d+', text) return sum(int(num) for num in numbers) if numbers else 0
simplelr_Taco
[ { "content": "Question:\n# Task\nYou are writing a file processing tool to extract and process numbers from text files. In particular, you need a function that reads through a given text and extracts all the numerical values present. The function should then return the sum of these numbers.\n\n# Example\n\nFor ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6300, "level": 1, "question": "# Task\nYou are writing a file processing tool to extract and process numbers from text files. In particular, you need a function that reads through a given text and extracts all the numerical values present. The function should then return the sum of ...
import seaborn as sns import matplotlib.pyplot as plt import numpy as np def custom_barplot(): # Load the dataset tips = sns.load_dataset("tips") # Set the theme with custom parameters custom_params = { "axes.spines.right": False, "axes.spines.top": False, "grid.linewidth":...
simplelr_Docs
[ { "content": "Question:\n### Advanced Coding Assessment: Customizing Plots with Seaborn\n\n**Objective:**\nDemonstrate your understanding of Seaborn's theming capabilities and customization by creating a specialized plot.\n\n**Task:**\n\n1. Load the built-in Seaborn dataset 'tips'.\n2. Create a bar plot showing...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6301, "level": 1, "question": "### Advanced Coding Assessment: Customizing Plots with Seaborn\n\n**Objective:**\nDemonstrate your understanding of Seaborn's theming capabilities and customization by creating a specialized plot.\n\n**Task:**\n\n1. Load the built-in Seaborn dataset 't...
import hashlib def calculate_sha256(input_string): sha_signature = hashlib.sha256(input_string.encode()).hexdigest() return sha_signature # Example usage: # print(calculate_sha256_hash("Hello, World!"))
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to calculate the SHA-256 hash of a given string.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6302, "level": 1, "question": "Write a python function to calculate the SHA-256 hash of a given string.", "split": "train" }
def bucket_sort(arr): if not arr: return arr # Determine the number of buckets num_buckets = 10 buckets = [[] for _ in range(num_buckets)] # Find min and max values in the array min_value = min(arr) max_value = max(arr) # Calculate the range range_value = max_value - min_v...
simplelr_Filter
[ { "content": "Question:\nWrite sample code for the bucket sort algorithm to sort a list of floating point numbers in ascending order. Additionally, implement it in such a way that it can handle negative numbers as well. Finally, compare its efficiency with the built-in sort function in Python using time complex...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6303, "level": 1, "question": "Write sample code for the bucket sort algorithm to sort a list of floating point numbers in ascending order. Additionally, implement it in such a way that it can handle negative numbers as well. Finally, compare its efficiency with the built-in sort fu...
import pandas as pd def calculate_mean_temperature(file_path, date_range): try: df = pd.read_csv(file_path) except FileNotFoundError: print("The CSV file does not exist.") return None required_columns = ['Date', 'Location', 'Temperature'] if not all(col in df.columns for col in...
simplelr_Package
[ { "content": "Question:\n**\n\nWrite a function called `calculate_mean_temperature` that takes a `file_path` pointing to a CSV file with weather data and a dictionary called `date_range` with keys `start_date` and `end_date`. The function will calculate the mean temperature over the given date range and for a s...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6304, "level": 1, "question": "**\n\nWrite a function called `calculate_mean_temperature` that takes a `file_path` pointing to a CSV file with weather data and a dictionary called `date_range` with keys `start_date` and `end_date`. The function will calculate the mean temperature ov...
from typing import List def has_pythagorean_triplet(numbers: List[int]) -> bool: # Input validation if not isinstance(numbers, list): raise TypeError("Input must be a list.") for num in numbers: if not isinstance(num, int): raise ValueError("All elements must be integers.") ...
simplelr_Algorithm
[ { "content": "Question:\n### Problem Statement:\nWrite a function that determines if a given list of integers contains any Pythagorean Triplets. A Pythagorean Triplet is a set of three integers a, b, c (where a ≤ b ≤ c) that satisfy the equation a² + b² = c².\n\n### Input:\n- A list of integers `numbers` contai...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6305, "level": 1, "question": "### Problem Statement:\nWrite a function that determines if a given list of integers contains any Pythagorean Triplets. A Pythagorean Triplet is a set of three integers a, b, c (where a ≤ b ≤ c) that satisfy the equation a² + b² = c².\n\n### Input:\n- ...
def find_largest(nums): if not nums: return None largest_value = nums[0] largest_index = 0 for i in range(1, len(nums)): if nums[i] > largest_value: largest_value = nums[i] largest_index = i return (largest_index, largest_value)
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to find the largest element in a list `nums` and return its index and value. If there are multiple occurrences of the same largest value, return the index of the first occurrence.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6306, "level": 1, "question": "Write a python function to find the largest element in a list `nums` and return its index and value. If there are multiple occurrences of the same largest value, return the index of the first occurrence.", "split": "train" }
def sum_numbers(*args): total = 0 for arg in args: if isinstance(arg, list): total += sum(arg) else: total += arg return total
simplelr_Filter
[ { "content": "Question:\nWrite a function in Python to calculate the sum of two numbers. Then, modify the function to also accept a list of numbers and return the sum of all the numbers in the list. Ensure the function can handle both scenarios gracefully.\nAnswer:\nLet's think step by step.\n", "role": "us...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6307, "level": 1, "question": "Write a function in Python to calculate the sum of two numbers. Then, modify the function to also accept a list of numbers and return the sum of all the numbers in the list. Ensure the function can handle both scenarios gracefully.", "split": "train"...
def sieve_of_eratosthenes(n): if n < 2: return [] sieve = [True] * (n + 1) sieve[0], sieve[1] = False, False for i in range(2, int(n ** 0.5) + 1): if sieve[i]: sieve[i*i : n+1 : i] = [False] * len(sieve[i*i : n+1 : i]) return [i for i, is_prime in enumerate(sieve) if is_p...
simplelr_Leetcode
[ { "content": "Question:\nGiven an integer `n`, find all prime numbers less than or equal to `n` and return them as a list. Each returned prime number should be in the sorted order of ascending integers. Note that `n` is guaranteed to be a non-negative integer. \n\nReturn _a list of all prime numbers less than o...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6308, "level": 1, "question": "Given an integer `n`, find all prime numbers less than or equal to `n` and return them as a list. Each returned prime number should be in the sorted order of ascending integers. Note that `n` is guaranteed to be a non-negative integer. \n\nReturn _a li...
from typing import List def minimal_write_sort(arr: List[int]) -> List[int]: n = len(arr) for i in range(n): min_idx = i for j in range(i + 1, n): if arr[j] < arr[min_idx]: min_idx = j if min_idx != i: arr[i], arr[min_idx] = arr[min_idx], arr[i] ...
simplelr_Data_Structure
[ { "content": "Question:\n### Scenario\nYou are tasked with implementing a sorting algorithm for a specialized piece of flash memory where write operations are significantly more expensive than read operations. Therefore, minimizing the number of writes is crucial. In this scenario, Cycle Sort is an optimal solu...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6309, "level": 1, "question": "### Scenario\nYou are tasked with implementing a sorting algorithm for a specialized piece of flash memory where write operations are significantly more expensive than read operations. Therefore, minimizing the number of writes is crucial. In this scen...
def find_longest_string_of_duplicates(s: str) -> str: if not s: return "" current_char = s[0] current_length = 1 max_length = 1 max_char = current_char n = len(s) for i in range(1, n): if s[i] == current_char: current_length += 1 else: ...
simplelr_Package
[ { "content": "Question:\nYou are asked to implement a function `find_longest_string_of_duplicates(s)`, which will find and return the longest contiguous substring in a given string `s` where all characters are identical. If there are multiple substrings of the same maximum length, return the first one that appe...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6310, "level": 1, "question": "You are asked to implement a function `find_longest_string_of_duplicates(s)`, which will find and return the longest contiguous substring in a given string `s` where all characters are identical. If there are multiple substrings of the same maximum len...
def sum_k_greatest(arr, k): if len(arr) < k: return sum(arr) else: sorted_arr = sorted(arr, reverse=True) return sum(sorted_arr[:k])
simplelr_Prefill
[ { "content": "Question:\nWrite a function to compute the sum of the `k` greatest elements in an array. The array can contain either positive or negative integers, and `k` is a non-negative integer less than or equal to the length of the array. If the length of the array is less than `k`, return the sum of all e...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6311, "level": 1, "question": "Write a function to compute the sum of the `k` greatest elements in an array. The array can contain either positive or negative integers, and `k` is a non-negative integer less than or equal to the length of the array. If the length of the array is les...
def cumulative_sum(lst): cumulative = 0 result = [] for num in lst: cumulative += num result.append(cumulative) return result
simplelr_Filter
[ { "content": "Question:\nYou have been tasked with writing a function that calculates the cumulative sum of an input list of integers and returns the cumulative sum at each step. \n\nThe cumulative sum is calculated by adding the current number to the sum of all previous numbers. For example, given the input `[...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6312, "level": 1, "question": "You have been tasked with writing a function that calculates the cumulative sum of an input list of integers and returns the cumulative sum at each step. \n\nThe cumulative sum is calculated by adding the current number to the sum of all previous numbe...
def is_leap_year(year): return year % 400 == 0 or (year % 4 == 0 and year % 100 != 0)
simplelr_Apps
[ { "content": "Question:\nWrite a function that determines whether or not the given year is a leap year - `isLeapYear()` (`is_leap_year()` for Python).\n\nA few examples:\n\n```\nisLeapYear(2020) == True\n\nisLeapYear(2019) == False\n\nisLeapYear(2000) == True\n\nisLeapYear(1900) == False\n```\n\nA leap year is ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6313, "level": 1, "question": "Write a function that determines whether or not the given year is a leap year - `isLeapYear()` (`is_leap_year()` for Python).\n\nA few examples:\n\n```\nisLeapYear(2020) == True\n\nisLeapYear(2019) == False\n\nisLeapYear(2000) == True\n\nisLeapYear(190...
def count_ones_in_binary(n): return bin(n).count('1')
simplelr_Prefill
[ { "content": "Question:\nCreate a function that counts the number of 1s in a binary number. The function should take an integer as input and return the count of 1s in its binary representation.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6314, "level": 1, "question": "Create a function that counts the number of 1s in a binary number. The function should take an integer as input and return the count of 1s in its binary representation.", "split": "train" }
from typing import List def find_unique(nums: List[int]) -> int: res = 0 for num in nums: res ^= num return res
simplelr_Data_Structure
[ { "content": "Question:\n**Problem Statement**\n\nYou are given an array of integers `nums` where every element appears exactly twice, except for one element which appears only once. Write a function to find that single one.\n\n**Function Signature**\n```python\ndef find_unique(nums: List[int]) -> int:\n \"\...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6315, "level": 1, "question": "**Problem Statement**\n\nYou are given an array of integers `nums` where every element appears exactly twice, except for one element which appears only once. Write a function to find that single one.\n\n**Function Signature**\n```python\ndef find_uniqu...
def maxNonAdjacentSum(arr): if not arr: return 0 prev_incl = arr[0] prev_excl = 0 for i in range(1, len(arr)): current_incl = prev_excl + arr[i] current_excl = max(prev_incl, prev_excl) prev_incl, prev_excl = current_incl, current_excl max_sum = max(prev_incl, prev_ex...
simplelr_Taco
[ { "content": "Question:\nGiven a list of integers, find the maximum possible sum of a subsequence such that no two numbers in the sequence are adjacent in the array. If all numbers are negative, your function should return 0.\n\nExample 1:\nInput: arr = [3, 2, 5, 10, 7]\nOutput: 15\nExplanation: The subsequence...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6316, "level": 1, "question": "Given a list of integers, find the maximum possible sum of a subsequence such that no two numbers in the sequence are adjacent in the array. If all numbers are negative, your function should return 0.\n\nExample 1:\nInput: arr = [3, 2, 5, 10, 7]\nOutpu...
def shortest_string(arr): return min(arr, key=len)
simplelr_Filter
[ { "content": "Question:\nHere is a problem for you to solve:\n\nGiven an array of strings, return the shortest string in the array.\n\nHere's an example input:\n[\"apple\", \"banana\", \"cat\"]\n\nThe expected output is:\n\"cat\"\n\nCan you solve it? \n\nThe solution should be:\ndef shortest_string(arr):\n r...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6317, "level": 1, "question": "Here is a problem for you to solve:\n\nGiven an array of strings, return the shortest string in the array.\n\nHere's an example input:\n[\"apple\", \"banana\", \"cat\"]\n\nThe expected output is:\n\"cat\"\n\nCan you solve it? \n\nThe solution should be...
def most_frequent_number(lst): counts = {} for num in lst: if num in counts: counts[num] += 1 else: counts[num] = 1 most_frequent = None highest_count = 0 for num, count in counts.items(): if count > highest_count: highest_count = count ...
simplelr_Filter
[ { "content": "Question:\nHow can I find the most frequent number in a list of numbers using Python?\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6318, "level": 1, "question": "How can I find the most frequent number in a list of numbers using Python?", "split": "train" }
from typing import List def modify_array(arr: List[int], k: int) -> List[int]: result = [] for num in arr: if num % 10 == 0: result.append(num + k) else: result.append(num) return result
simplelr_Code_Contests
[ { "content": "Question:\nYou are given an array consisting of n integers. You need to modify the array in such a way that for every i-th element of the array which is a multiple of 10, increase it by a value of k to make the i-th element no longer a multiple of 10. If an element is not a multiple of 10, leave i...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6319, "level": 1, "question": "You are given an array consisting of n integers. You need to modify the array in such a way that for every i-th element of the array which is a multiple of 10, increase it by a value of k to make the i-th element no longer a multiple of 10. If an eleme...
def remove_duplicates(arr): seen = set() result = [] for element in arr: if element not in seen: seen.add(element) result.append(element) return result
simplelr_Filter
[ { "content": "Question:\nGiven the following array, write a Python code snippet to remove all duplicates while preserving the order of the first occurrence of each element.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6320, "level": 1, "question": "Given the following array, write a Python code snippet to remove all duplicates while preserving the order of the first occurrence of each element.", "split": "train" }
def next_bigger(num: int) -> int: digits = list(str(num)) n = len(digits) # Step 1: Find the first digit from the right that is smaller than its next digit i = n - 2 while i >= 0 and digits[i] >= digits[i + 1]: i -= 1 # If no such digit is found, return -1 (all digits are in de...
simplelr_Data_Structure
[ { "content": "Question:\n### Coding Problem: Next Higher Number with Same Digits\n\nGiven a number, you need to find the next higher number that has the exact same set of digits as the original number. This problem challenges your understanding of permutations and efficient in-place manipulations.\n\n#### Funct...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6321, "level": 1, "question": "### Coding Problem: Next Higher Number with Same Digits\n\nGiven a number, you need to find the next higher number that has the exact same set of digits as the original number. This problem challenges your understanding of permutations and efficient in...
def product_of_powers(base, exponents): result = 1 for exponent in exponents: result *= (base ** exponent) return result
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to determine the \"product of powers\" of a number given a list of exponents. The \"product of powers\" is defined as the product of all the base raised to its corresponding exponent in the list. For example, if the base is 2 and the list of exponents is [1, 2, 3...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6322, "level": 1, "question": "Write a python function to determine the \"product of powers\" of a number given a list of exponents. The \"product of powers\" is defined as the product of all the base raised to its corresponding exponent in the list. For example, if the base is 2 an...
def binary_to_decimal(binary_str): result = 0 for bit in binary_str: result = result * 2 + int(bit) return result # Example usage: binary_number = "1010" # Example binary number decimal_number = binary_to_decimal(binary_number) print(f"The decimal equivalent of {binary_number} is {decimal_number}"...
simplelr_Prefill
[ { "content": "Question:\nCreate a function that converts a Binary to a Decimal\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6323, "level": 1, "question": "Create a function that converts a Binary to a Decimal", "split": "train" }
from typing import List def gnome_sort(arr: List[int]) -> List[int]: i = 1 while i < len(arr): if arr[i] >= arr[i-1]: i += 1 else: arr[i], arr[i-1] = arr[i-1], arr[i] if i > 1: i -= 1 return arr
simplelr_Data_Structure
[ { "content": "Question:\n#### Context\nYou have been tasked to sort a list of integers by implementing a Gnome Sort algorithm. Gnome Sort, while not the most efficient, is notable for its simplicity and educational value in understanding how sorting algorithms work.\n\n#### Problem Statement\nImplement the `gno...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6324, "level": 1, "question": "#### Context\nYou have been tasked to sort a list of integers by implementing a Gnome Sort algorithm. Gnome Sort, while not the most efficient, is notable for its simplicity and educational value in understanding how sorting algorithms work.\n\n#### Pr...
def unique_paths(grid): m = len(grid) if m == 0: return 0 n = len(grid[0]) if grid[0][0] == 1 or grid[m-1][n-1] == 1: return 0 dp = [[0 for _ in range(n)] for _ in range(m)] dp[0][0] = 1 for i in range(m): for j in range(n): if i == 0 and j == 0: ...
simplelr_Leetcode
[ { "content": "Question:\nYou are given a 2D integer matrix `grid` representing the state of a minefield, where `grid[i][j]` can either be `0` (an empty cell) or `1` (a mine). A robot starts from the top-left corner of the grid and can only move right or down. You need to determine the number of distinct paths t...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6325, "level": 1, "question": "You are given a 2D integer matrix `grid` representing the state of a minefield, where `grid[i][j]` can either be `0` (an empty cell) or `1` (a mine). A robot starts from the top-left corner of the grid and can only move right or down. You need to deter...
from PIL import Image def combine_images(image_paths, width, height, combined_image_path): # Open all the images images = [Image.open(path) for path in image_paths] # Resize each image to the specified dimensions and convert to RGB mode resized_images = [] for img in images: resized = ...
simplelr_Filter
[ { "content": "Question:\nYou've been tasked with creating a function `combine_images` that takes in a list of image paths, a user-specified width, and a user-specified height. \nThe function should create a new image where all the input images are combined horizontally. \nThe function should also make sure that...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6326, "level": 1, "question": "You've been tasked with creating a function `combine_images` that takes in a list of image paths, a user-specified width, and a user-specified height. \nThe function should create a new image where all the input images are combined horizontally. \nThe ...
def longestConsecutiveSequence(nums): s = set(nums) max_length = 0 for num in s: if (num - 1) not in s: current_length = 1 current = num while current + 1 in s: current += 1 current_length += 1 if current_length > max_le...
simplelr_Taco
[ { "content": "Question:\nGiven an array of integers, find the length of the longest sequence of consecutive integers that can be formed using the elements of the array. The consecutive numbers can appear in any order in the array.\n\nExample\n\n$nums = [100, 4, 200, 1, 3, 2]$\n\nThe array contains the consecuti...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6327, "level": 1, "question": "Given an array of integers, find the length of the longest sequence of consecutive integers that can be formed using the elements of the array. The consecutive numbers can appear in any order in the array.\n\nExample\n\n$nums = [100, 4, 200, 1, 3, 2]$\...
from typing import List def find_common_elements(list1: List[int], list2: List[int]) -> List[int]: set1 = set(list1) set2 = set(list2) common_elements = set1.intersection(set2) return sorted(common_elements)
simplelr_Algorithm
[ { "content": "Question:\n### Coding Question\n\nImplement a function `find_common_elements` that takes two lists of integers and returns a new list containing the integers that appear in both input lists. The resulting list should have no duplicates and should be sorted in ascending order. Also, handle the case...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6328, "level": 1, "question": "### Coding Question\n\nImplement a function `find_common_elements` that takes two lists of integers and returns a new list containing the integers that appear in both input lists. The resulting list should have no duplicates and should be sorted in asc...
def count_high_temperature_days(temperatures, k): count = 0 n = len(temperatures) for i in range(k, n): prev_days = temperatures[i - k : i] if all(temp < temperatures[i] for temp in prev_days): count += 1 return count
simplelr_Leetcode
[ { "content": "Question:\nYou are given a list of `n` integers representing the temperatures recorded over a period of `n` days. Your task is to implement a function that processes this list and returns the number of days \\(i\\) such that the temperature on day \\(i\\) is strictly higher than the temperature on...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6329, "level": 1, "question": "You are given a list of `n` integers representing the temperatures recorded over a period of `n` days. Your task is to implement a function that processes this list and returns the number of days \\(i\\) such that the temperature on day \\(i\\) is stri...
def caesar_decipher(s: str, k: int) -> str: effective_shift = k % 26 result = [] for c in s: if c.isupper(): base = ord('A') current = ord(c) - base new_char = chr(base + (current - effective_shift) % 26) result.append(new_char) elif c.islower(...
simplelr_Data_Structure
[ { "content": "Question:\n### Caesar Cipher Decryption\n\nIn a Caesar Cipher, each letter in the plaintext is shifted a certain number of places down the alphabet. To decrypt a message encoded with a Caesar Cipher, you need to shift each letter in the ciphertext back the same number of places up the alphabet.\n\...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6330, "level": 1, "question": "### Caesar Cipher Decryption\n\nIn a Caesar Cipher, each letter in the plaintext is shifted a certain number of places down the alphabet. To decrypt a message encoded with a Caesar Cipher, you need to shift each letter in the ciphertext back the same n...
def find_missing_number(nums): missing = 0 for i in range(len(nums) + 1): missing ^= i for num in nums: missing ^= num return missing
simplelr_Leetcode
[ { "content": "Question:\nYou are given a **0-indexed** integer array `nums` of length `n` containing unique integers, where each integer in `nums` is a value within the range `[0, n-1]`. However, one integer within this range is missing from the array. Write a function that finds the missing integer from the ar...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6331, "level": 1, "question": "You are given a **0-indexed** integer array `nums` of length `n` containing unique integers, where each integer in `nums` is a value within the range `[0, n-1]`. However, one integer within this range is missing from the array. Write a function that fi...
from collections import defaultdict def longest_sublist_with_two_distinct(nums): count = defaultdict(int) left = 0 max_length = 0 for right in range(len(nums)): current = nums[right] count[current] += 1 # While there are more than two distinct elements, move the left pointer ...
simplelr_Evol
[ { "content": "Question:\nWrite a function that takes a list of integers as input and processes it to find and return the length of the longest contiguous sub-list that contains exactly two distinct integers. The function should satisfy the following conditions:\n\n- The input list will contain only integers.\n\...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6332, "level": 1, "question": "Write a function that takes a list of integers as input and processes it to find and return the length of the longest contiguous sub-list that contains exactly two distinct integers. The function should satisfy the following conditions:\n\n- The input ...
def atm_machine(transactions): balance = 0 for transaction in transactions: action, amount = transaction if action == 'deposit': balance += amount elif action == 'withdraw': if amount > balance: print(f"Withdrawal of {amount} exceeds current balanc...
simplelr_Filter
[ { "content": "Question:\nWrite a Python function that simulates a simple ATM machine that can handle deposits and withdrawals. The ATM has an initial balance of zero. The function should take a list of transactions, where each transaction is a tuple containing the type ('deposit' or 'withdraw') and the amount. ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6333, "level": 1, "question": "Write a Python function that simulates a simple ATM machine that can handle deposits and withdrawals. The ATM has an initial balance of zero. The function should take a list of transactions, where each transaction is a tuple containing the type ('depos...
def remove_every_other(lst): return lst[::2]
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes a list of integers and returns a new list with every other element removed.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6334, "level": 1, "question": "Create a function that takes a list of integers and returns a new list with every other element removed.", "split": "train" }
def can_form_target(words, target): sum_length = sum(len(word) for word in words) if sum_length != len(target): return False n = len(words) if n == 0: return target == "" full_mask = (1 << n) - 1 from collections import deque visited = set() queue = deque() queue...
simplelr_Leetcode
[ { "content": "Question:\nYou are given a list of strings `words` and a string `target`. You need to check if the `target` can be constructed by concatenating strings from the `words` list exactly once, regardless of the order. Return `true` if it is possible, otherwise return `false`. Note that each string in `...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6335, "level": 1, "question": "You are given a list of strings `words` and a string `target`. You need to check if the `target` can be constructed by concatenating strings from the `words` list exactly once, regardless of the order. Return `true` if it is possible, otherwise return ...
def reverse_list(lst): new_list = lst.copy() left = 0 right = len(new_list) - 1 while left < right: new_list[left], new_list[right] = new_list[right], new_list[left] left += 1 right -= 1 return new_list
simplelr_Filter
[ { "content": "Question:\nWrite a function that takes in a list and returns the elements in reverse order, but without using any built-in functions or methods for reversing the list. You may only use basic data structures and control flow statements. Additionally, the function should have a time complexity of O(...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6336, "level": 1, "question": "Write a function that takes in a list and returns the elements in reverse order, but without using any built-in functions or methods for reversing the list. You may only use basic data structures and control flow statements. Additionally, the function ...
import re def is_valid_email(email): pattern = r"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$" return bool(re.fullmatch(pattern, email))
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to check if a given string contains only valid email addresses. If the string is a valid email address, then return True, otherwise, return False. It should consider @ character and any valid domain names only. A valid email address has the format [username]@[dom...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6337, "level": 1, "question": "Write a python function to check if a given string contains only valid email addresses. If the string is a valid email address, then return True, otherwise, return False. It should consider @ character and any valid domain names only. A valid email add...
import ast def is_valid(s): try: ast.parse(s) return "Valid" except SyntaxError: return "Invalid"
simplelr_Taco
[ { "content": "Question:\nA software engineer is working on a chatbot that can answer programming-related questions. To ensure the chatbot doesn’t give out wrong or misleading information, the engineer must verify the correctness of its responses. One particular area of interest is whether the chatbot correctly ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6338, "level": 1, "question": "A software engineer is working on a chatbot that can answer programming-related questions. To ensure the chatbot doesn’t give out wrong or misleading information, the engineer must verify the correctness of its responses. One particular area of interes...
def count_paths(m, n): a = m + n - 2 b = min(m - 1, n - 1) if b == 0: return 1 result = 1 for i in range(1, b + 1): term = (a - b + i) result *= term result //= i return result
simplelr_Data_Structure
[ { "content": "Question:\nYou are developing a navigation algorithm for a robot within a factory's grid-like layout. The robot needs to find the total number of unique paths from its starting position at the top-left corner of the grid `(0, 0)` to the finishing position at the bottom-right corner `(m-1, n-1)`. Y...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6339, "level": 1, "question": "You are developing a navigation algorithm for a robot within a factory's grid-like layout. The robot needs to find the total number of unique paths from its starting position at the top-left corner of the grid `(0, 0)` to the finishing position at the ...
from typing import List, Tuple def highest_transaction_id(transactions: List[Tuple[int, float]]) -> int: max_id = None max_amount = None for txn in transactions: current_id, current_amount = txn if max_id is None: max_id = current_id max_amount = current_amount ...
simplelr_Algorithm
[ { "content": "Question:\nYou are given a list of transactions where each transaction is represented by a tuple (id, amount). Your task is to determine the transaction ID that has the highest amount. If there are multiple transactions with the highest amount, return the one that appears first in the list.\n\n###...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6340, "level": 1, "question": "You are given a list of transactions where each transaction is represented by a tuple (id, amount). Your task is to determine the transaction ID that has the highest amount. If there are multiple transactions with the highest amount, return the one tha...
def maxProfit(time, profit, totalHours): dp = [0] * (totalHours + 1) for i in range(len(time)): t = time[i] p = profit[i] for j in range(totalHours, t - 1, -1): dp[j] = max(dp[j], dp[j - t] + p) return max(dp)
simplelr_Taco
[ { "content": "Question:\nA company has multiple projects that need to be completed. Each project takes a certain amount of time to be completed and yields a certain profit. You're given two integer arrays, `time` and `profit`, where `time[i]` is the time required to complete the ith project and `profit[i]` is t...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6341, "level": 1, "question": "A company has multiple projects that need to be completed. Each project takes a certain amount of time to be completed and yields a certain profit. You're given two integer arrays, `time` and `profit`, where `time[i]` is the time required to complete t...
def concatenate_reversed(lst): concatenated = ''.join(lst) return concatenated[::-1]
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes a list of strings as input and returns a new string that is the concatenation of all the strings in the list, but reversed. For example, if the input is [\"Hello\", \"World\"], the output should be \"dlroWolleH\".\nAnswer:\nLet's think step by step.\n", ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6342, "level": 1, "question": "Create a function that takes a list of strings as input and returns a new string that is the concatenation of all the strings in the list, but reversed. For example, if the input is [\"Hello\", \"World\"], the output should be \"dlroWolleH\".", "spli...
import collections def most_frequent_word(document: str) -> str: word_counts = collections.defaultdict(int) tokens = document.split() for token in tokens: word = ''.join([c for c in token if c.isalpha()]) if word: word_counts[word] += 1 if not word_counts: return '' ...
simplelr_Code_Contests
[ { "content": "Question:\nYou are a software engineer working on improving the company's document management system. One of the features is to generate a summary of the statistics of words in a given document. Specifically, you need to identify the most frequently occurring word in the document.\n\n### Problem S...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6343, "level": 1, "question": "You are a software engineer working on improving the company's document management system. One of the features is to generate a summary of the statistics of words in a given document. Specifically, you need to identify the most frequently occurring wor...
def two_sum_indices(nums, target): index_map = {} for i in range(len(nums)): complement = target - nums[i] if complement in index_map: return [i, index_map[complement]] index_map[nums[i]] = i return []
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes in two parameters, a list of integers and a target number. The function should return the indices of the two numbers in the list that add up to the target number, with the condition that the first index is greater than the second index. If no valid pair of i...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6344, "level": 1, "question": "Create a function that takes in two parameters, a list of integers and a target number. The function should return the indices of the two numbers in the list that add up to the target number, with the condition that the first index is greater than the ...
def find_target_index(lst, target): for index, value in enumerate(lst): if value == target: return index return -1
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes in a list of integers and a target number, and returns the index of the target number in the list if it exists, or -1 if it does not.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6345, "level": 1, "question": "Create a function that takes in a list of integers and a target number, and returns the index of the target number in the list if it exists, or -1 if it does not.", "split": "train" }
def find_pairs(nums, target): nums.sort() result = [] n = len(nums) for i in range(n): if i > 0 and nums[i] == nums[i-1]: continue t = target - nums[i] low, high = i + 1, n - 1 found = False while low <= high: mid = (low + high) // 2 ...
simplelr_Leetcode
[ { "content": "Question:\nYou are given an array of integers `nums` and an integer `target`. Write a function that finds all unique pairs of integers in the array whose sum equals the given `target`. Each pair should be represented as an array `[num1, num2]`, where `num1` <= `num2`. The result array should be so...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6346, "level": 1, "question": "You are given an array of integers `nums` and an integer `target`. Write a function that finds all unique pairs of integers in the array whose sum equals the given `target`. Each pair should be represented as an array `[num1, num2]`, where `num1` <= `n...
def combine_lists(list1, list2): return [list(pair) for pair in zip(list1, list2)]
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes two lists as input and returns a list of lists, where each sublist contains elements from the two lists that share the same index.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6347, "level": 1, "question": "Create a function that takes two lists as input and returns a list of lists, where each sublist contains elements from the two lists that share the same index.", "split": "train" }
import os import gzip def compress_txt_files(input_dir: str, output_dir: str, compresslevel: int = 9) -> None: for root, dirs, files in os.walk(input_dir): for filename in files: if filename.endswith('.txt'): relative_path = os.path.relpath(root, input_dir) if re...
simplelr_Docs
[ { "content": "Question:\n**Coding Assessment Question**\n\n### Problem Statement:\n\nYou are tasked with creating a Python function that takes a directory path as input, compresses all `.txt` files in that directory using the `gzip` format, and saves the compressed files in a specified output directory. The com...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6348, "level": 1, "question": "**Coding Assessment Question**\n\n### Problem Statement:\n\nYou are tasked with creating a Python function that takes a directory path as input, compresses all `.txt` files in that directory using the `gzip` format, and saves the compressed files in a ...
from typing import List, Union, Tuple def find_pair_with_sum(arr: List[int], target: int) -> Union[Tuple[int, int], None]: seen = {} for i, num in enumerate(arr): complement = target - num if complement in seen: return (seen[complement], i) seen[num] = i return None
simplelr_Taco
[ { "content": "Question:\nGiven an integer array `arr` and an integer `target`, determine if there are two distinct indices `i` and `j` in the array such that `arr[i] + arr[j] == target`. If such indices exist, return a tuple of the indices `(i, j)` in any order. If no such indices exist, return `null`.\n\nFunct...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6349, "level": 1, "question": "Given an integer array `arr` and an integer `target`, determine if there are two distinct indices `i` and `j` in the array such that `arr[i] + arr[j] == target`. If such indices exist, return a tuple of the indices `(i, j)` in any order. If no such ind...
from typing import List def can_partition(nums: List[int]) -> str: total = sum(nums) if total % 2 != 0: return "NO" target = total // 2 dp = [False] * (target + 1) dp[0] = True for num in nums: for j in range(target, num - 1, -1): if dp[j - num]: dp[j...
simplelr_Code_Contests
[ { "content": "Question:\nGiven a list of positive integers, determine if the list can be split into two sublists such that the sums of the two sublists are equal. If it is possible, print \"YES\", otherwise print \"NO\".\n\nFor example, the list \"1, 5, 11, 5\" can be split into the two sublists \"1, 5, 5\" and...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6350, "level": 1, "question": "Given a list of positive integers, determine if the list can be split into two sublists such that the sums of the two sublists are equal. If it is possible, print \"YES\", otherwise print \"NO\".\n\nFor example, the list \"1, 5, 11, 5\" can be split in...
def maxProfit(prices): min_price = prices[0] max_profit = 0 for price in prices[1:]: potential_profit = price - min_price if potential_profit > max_profit: max_profit = potential_profit if price < min_price: min_price = price return max_profit
simplelr_Taco
[ { "content": "Question:\nYou are given a list of integers representing the stock price of a company in chronological order of days. Your task is to determine the maximum profit that can be achieved by buying and then later selling one share of the stock within the specified range of days. Note that you must buy...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6351, "level": 1, "question": "You are given a list of integers representing the stock price of a company in chronological order of days. Your task is to determine the maximum profit that can be achieved by buying and then later selling one share of the stock within the specified ra...
def calculate_average(numbers): """ Calculate the average of a list of numbers. Args: numbers (list): A list containing numerical values. Returns: float: The average of the numbers. Returns 0 if the list is empty. """ if not numbers: return 0 return sum(numb...
simplelr_Filter
[ { "content": "Question:\nCan you show me how to write a Python function that takes a list of numbers and returns the average of those numbers?\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6352, "level": 1, "question": "Can you show me how to write a Python function that takes a list of numbers and returns the average of those numbers?", "split": "train" }
def groupRanges(matrix: list[list[int]]) -> list[int]: group_data = [] for i, row in enumerate(matrix): mn = min(row) mx = max(row) rng = mx - mn group_data.append((rng, i)) group_data.sort(key=lambda x: (x[0], x[1])) result = [x[1] for x in group_data] return result
simplelr_Apps
[ { "content": "Question:\n## Problem Statement\n\nYou are given a matrix of integers where each column represents the values of a group. Your task is to calculate the range of values for each group and return the groups sorted by their ranges in ascending order.\n\nThe range of a group is defined as the differen...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6353, "level": 1, "question": "## Problem Statement\n\nYou are given a matrix of integers where each column represents the values of a group. Your task is to calculate the range of values for each group and return the groups sorted by their ranges in ascending order.\n\nThe range of...
def min_operations(s, t): m = len(s) n = len(t) # Create a DP table of (m+1) rows and (n+1) columns dp = [[0] * (n + 1) for _ in range(m + 1)] # Initialize the base cases for i in range(m + 1): dp[i][0] = i for j in range(n + 1): dp[0][j] = j # Fill the DP table...
simplelr_Taco
[ { "content": "Question:\nYou're given a function that takes two arguments, both of which are strings containing only lowercase letters. The function needs to determine the minimum number of operations required to convert the first string into the second string. The allowed operations are:\n1. Insert a character...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6354, "level": 1, "question": "You're given a function that takes two arguments, both of which are strings containing only lowercase letters. The function needs to determine the minimum number of operations required to convert the first string into the second string. The allowed ope...
def exponent(base, power): if power == 0: return 1 elif power < 0: return 1.0 / exponent(base, -power) else: result = 1 for _ in range(power): result *= base return result
simplelr_Filter
[ { "content": "Question:\nWrite a python function to calculate the exponent of a given number with a given power, without using the built-in exponentiation operator (**) or any other mathematical library functions that calculate powers. Additionally, the function should handle negative powers correctly.\nAnswer:...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6355, "level": 1, "question": "Write a python function to calculate the exponent of a given number with a given power, without using the built-in exponentiation operator (**) or any other mathematical library functions that calculate powers. Additionally, the function should handle ...
def sum_of_primes_within_range(n): """ Calculate the sum of all prime numbers in the range from 2 to n, inclusive. Args: n (int): The upper limit of the range. Returns: int: The sum of primes in the range. If n is less than 2, returns 0. Example: >>> sum_of_primes(10) ...
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to calculate the sum of all prime numbers in a given range, using a boolean array approach. I want this function to handle the range from 2 to n, inclusive. Also, please include a docstring explaining the function and its parameters.\nAnswer:\nLet's think step by...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6356, "level": 1, "question": "Write a python function to calculate the sum of all prime numbers in a given range, using a boolean array approach. I want this function to handle the range from 2 to n, inclusive. Also, please include a docstring explaining the function and its parame...
def matrix_multiply(matrix1, matrix2): # Check if either matrix is empty if not matrix1 or not matrix2: return [] # Get the dimensions of the matrices rows1 = len(matrix1) cols1 = len(matrix1[0]) if rows1 > 0 else 0 rows2 = len(matrix2) cols2 = len(matrix2[0]) if rows2 > 0 else ...
simplelr_Algorithm
[ { "content": "Question:\n### Matrix Multiplication Coding Assessment\n\nGiven two matrices, your task is to implement a function that performs matrix multiplication. Matrix multiplication is defined as the dot product of rows from the first matrix with columns of the second matrix. Ensure you verify the compati...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6357, "level": 1, "question": "### Matrix Multiplication Coding Assessment\n\nGiven two matrices, your task is to implement a function that performs matrix multiplication. Matrix multiplication is defined as the dot product of rows from the first matrix with columns of the second ma...
def find_pair_with_sum(nums, target): seen = set() for num in nums: complement = target - num if complement in seen: return True seen.add(num) return False
simplelr_Apps
[ { "content": "Question:\nGiven a list of integers, determine whether there is a pair of distinct elements (not necessarily adjacent) that sum up to a specific target. If such a pair exists, return True; otherwise, return False.\n\n## Task\n\nWrite a function `find_pair_with_sum(nums, target)` that takes a list ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6358, "level": 1, "question": "Given a list of integers, determine whether there is a pair of distinct elements (not necessarily adjacent) that sum up to a specific target. If such a pair exists, return True; otherwise, return False.\n\n## Task\n\nWrite a function `find_pair_with_su...
import requests from datetime import datetime def calculate_product_revenue(product_id: int, start_date: str, end_date: str) -> float: total = 0.0 try: response = requests.get('https://example.com/api/sales', timeout=10) response.raise_for_status() except requests.exceptions.RequestExcepti...
simplelr_Algorithm
[ { "content": "Question:\n### Problem Statement\nYou are developing a function that processes sales data from a JSON API and computes the total sales revenue for a specific product within a given date range. This task will involve making network requests, parsing JSON data, and filtering based on dates.\n\n### F...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6359, "level": 1, "question": "### Problem Statement\nYou are developing a function that processes sales data from a JSON API and computes the total sales revenue for a specific product within a given date range. This task will involve making network requests, parsing JSON data, and...
def is_palindrome_with_vowels(s): # Check if the string is a palindrome if s != s[::-1]: return False # Check if the string contains all vowels in alphabetical order vowels_order = ['a', 'e', 'i', 'o', 'u'] s_vowels = [c for c in s if c in vowels_order] expected = 0 for c in s_...
simplelr_Filter
[ { "content": "Question:\nCreate a function to check if a given string is a palindrome and contains all the vowels (a, e, i, o, u) in it in alphabetical order.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6360, "level": 1, "question": "Create a function to check if a given string is a palindrome and contains all the vowels (a, e, i, o, u) in it in alphabetical order.", "split": "train" }
def odd_length_strings(strings): return [s for s in strings if len(s) % 2 != 0]
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes a list of strings and returns a new list containing only the strings that have an odd number of characters. Ensure that the returned list maintains the original order of the input list.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6361, "level": 1, "question": "Create a function that takes a list of strings and returns a new list containing only the strings that have an odd number of characters. Ensure that the returned list maintains the original order of the input list.", "split": "train" }
def calculate_midpoints(start, end): return (start + end) // 2
simplelr_Filter
[ { "content": "Question:\nWrite a Python function named `calculate_midpoints` that calculates the midpoint of a range from `start` to `end` (inclusive). If the range does not contain an exact midpoint (i.e., the range has an even number of elements), the function should return the lower of the two middle numbers...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6362, "level": 1, "question": "Write a Python function named `calculate_midpoints` that calculates the midpoint of a range from `start` to `end` (inclusive). If the range does not contain an exact midpoint (i.e., the range has an even number of elements), the function should return ...
def countPaths(n, traps): traps_set = set(traps) if (0, 0) in traps_set or (n-1, n-1) in traps_set: return 0 dp = [[0 for _ in range(n)] for _ in range(n)] dp[0][0] = 1 # Starting point for i in range(n): for j in range(n): if i == 0 and j == 0: ...
simplelr_Code_Contests
[ { "content": "Question:\nIn a popular board game, there is a rectangular grid consisting of cells. Each cell in the grid can either be empty or contain a trap. The goal of the game is to move a player from the top-left corner of the grid to the bottom-right corner while avoiding traps. The player can move one c...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6363, "level": 1, "question": "In a popular board game, there is a rectangular grid consisting of cells. Each cell in the grid can either be empty or contain a trap. The goal of the game is to move a player from the top-left corner of the grid to the bottom-right corner while avoidi...
def can_split_into_reverse_parts(s): n = len(s) if n % 2 != 0: return False mid = n // 2 return s[:mid] == s[mid:][::-1]
simplelr_Prefill
[ { "content": "Question:\nWrite a function to check if a given string can be split into two parts where the first part is the reverse of the second part.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6364, "level": 1, "question": "Write a function to check if a given string can be split into two parts where the first part is the reverse of the second part.", "split": "train" }
def sum_of_digits(n): total = 0 for digit in str(abs(n)): total += int(digit) return total
simplelr_Filter
[ { "content": "Question:\nI am a computer science student and I need to write a program to calculate the sum of all the digits of a given number. Can you help me with the algorithm and provide some tips on how to implement it in Python?\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6365, "level": 1, "question": "I am a computer science student and I need to write a program to calculate the sum of all the digits of a given number. Can you help me with the algorithm and provide some tips on how to implement it in Python?", "split": "train" }
from collections import Counter def count_characters(words, characters): chars_count = Counter(characters) total = 0 chars_len = len(characters) for word in words: if len(word) > chars_len: continue word_count = Counter(word) valid = True for char, cnt in wor...
simplelr_Leetcode
[ { "content": "Question:\nYou are given a list of strings `words` and another string `characters`. Write a function that returns the sum of lengths of all `words[i]` that can be formed by characters from `characters`. You can only use each character from `characters` once. Ensure that each word in `words` must b...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6366, "level": 1, "question": "You are given a list of strings `words` and another string `characters`. Write a function that returns the sum of lengths of all `words[i]` that can be formed by characters from `characters`. You can only use each character from `characters` once. Ensu...
from typing import List, Dict def has_overlapping_events(events: List[Dict[str, int]]) -> bool: for i in range(len(events)): for j in range(i + 1, len(events)): a = events[i] b = events[j] if a['end'] >= b['start'] and a['start'] <= b['end']: return True ...
simplelr_Taco
[ { "content": "Question:\nDescription\n\nYou have been tasked with creating a function that processes a list of events. Each event has a start time and an end time. Your function should determine whether any events overlap. Two events overlap if they both occupy at least one common time unit.\n\nThe function sho...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6367, "level": 1, "question": "Description\n\nYou have been tasked with creating a function that processes a list of events. Each event has a start time and an end time. Your function should determine whether any events overlap. Two events overlap if they both occupy at least one co...
def max_at_each_index(list1, list2): result = [] # Append the maximum of each pair from list1 and list2 up to the shorter length for a, b in zip(list1, list2): result.append(max(a, b)) # Append the remaining elements from the longer list len1, len2 = len(list1), len(list2) if len1 > len2...
simplelr_Filter
[ { "content": "Question:\nWrite a function in Python that takes two lists of numbers and returns a new list containing the maximum value at each index. If the lists are of unequal length, the function should continue to append the remaining elements from the longer list to the result. Ensure the function handles...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6368, "level": 1, "question": "Write a function in Python that takes two lists of numbers and returns a new list containing the maximum value at each index. If the lists are of unequal length, the function should continue to append the remaining elements from the longer list to the ...
def longest_common_prefix(strings): """ This function takes a list of strings as input and returns the longest common prefix. Args: strings (list): A list of strings, each string consisting of only digits. Returns: str: The longest common prefix as a string. """ if not ...
simplelr_Filter
[ { "content": "Question:\nIn this problem, you will be presented with a sequence of strings, each string consisting of only digits (0-9). You need to write a function that takes this sequence as input and returns the longest prefix that is common to all strings in the sequence. \n\nFor example, if the input sequ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6369, "level": 1, "question": "In this problem, you will be presented with a sequence of strings, each string consisting of only digits (0-9). You need to write a function that takes this sequence as input and returns the longest prefix that is common to all strings in the sequence....
def symmetric_difference(*sets): count = {} order = [] for s in sets: seen_in_s = set() for elem in s: if elem not in seen_in_s: if elem not in count: order.append(elem) count[elem] = count.get(elem, 0) + 1 seen_...
simplelr_Filter
[ { "content": "Question:\nConstruct a function that will calculate the symmetric difference (elements that are in one set but not in the other and vice versa) of multiple provided sets. Your solution should be robust enough to handle an arbitrary number of sets, and also consider the repetition of elements, if a...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6370, "level": 1, "question": "Construct a function that will calculate the symmetric difference (elements that are in one set but not in the other and vice versa) of multiple provided sets. Your solution should be robust enough to handle an arbitrary number of sets, and also consid...
import os def resolve_paths(paths: list) -> dict: result = {} for path in paths: expanded_path = os.path.expanduser(path) absolute_path = os.path.abspath(expanded_path) result[path] = absolute_path return result
simplelr_Data_Structure
[ { "content": "Question:\n#### Scenario\nYou are tasked with creating a utility function that can resolutely transform a list of potentially relative file paths into their full, absolute paths. This is a part of building a file indexing tool that must standardize paths to ensure uniformity in handling files.\n\n...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6371, "level": 1, "question": "#### Scenario\nYou are tasked with creating a utility function that can resolutely transform a list of potentially relative file paths into their full, absolute paths. This is a part of building a file indexing tool that must standardize paths to ensur...
import re def find_numbers(text): """Finds all numbers in a string, including decimals. Args: text: The string to search. Returns: A list of numbers found in the string. """ return re.findall(r'\d+\.?\d*|\.\d+', text) # Example usage text = "This string has 123 numbers, 456.78 mo...
simplelr_Filter
[ { "content": "Question:\nI am writing code in Python to identify numbers in a string.\n\n```python\nimport re\n\ndef find_numbers(text):\n \"\"\"Finds all numbers in a string.\n\n Args:\n text: The string to search.\n\n Returns:\n A list of numbers found in the string.\n \"\"\"\n return re.findall(r'...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6372, "level": 1, "question": "I am writing code in Python to identify numbers in a string.\n\n```python\nimport re\n\ndef find_numbers(text):\n \"\"\"Finds all numbers in a string.\n\n Args:\n text: The string to search.\n\n Returns:\n A list of numbers found in the string...
def enhanced_prime_check(n: int) -> bool: if n <= 1: return False if n <= 3: return True if n % 2 == 0: return False # Write n-1 as d * 2^s d = n - 1 s = 0 while d % 2 == 0: d //= 2 s += 1 # Test bases that are sufficient for n < 2^32 bases =...
simplelr_Data_Structure
[ { "content": "Question:\n### Prime Number Detector for Large Inputs\n\n**Context**:\nA large-scale finance application needs to identify prime numbers rapidly to support encryption algorithms that rely on large prime numbers. Your task is to implement a function that efficiently determines if a number is prime....
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6373, "level": 1, "question": "### Prime Number Detector for Large Inputs\n\n**Context**:\nA large-scale finance application needs to identify prime numbers rapidly to support encryption algorithms that rely on large prime numbers. Your task is to implement a function that efficient...
import matplotlib.pyplot as plt import seaborn as sns def create_seaborn_plots() -> None: tips = sns.load_dataset('tips') # Bar plot showing the count of observations for each day of the week plt.figure(figsize=(10, 6)) sns.countplot(data=tips, x='day') plt.title('Count of Tips by Day of the W...
simplelr_Docs
[ { "content": "Question:\n### Seaborn Bar Plot Visualization and Grouping\n\nYou are provided with the \"tips\" dataset from the Seaborn library, which contains information about tips given in a restaurant, including variables such as the day of the week, the sex of the person, and the size of the party.\n\nYour...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6374, "level": 1, "question": "### Seaborn Bar Plot Visualization and Grouping\n\nYou are provided with the \"tips\" dataset from the Seaborn library, which contains information about tips given in a restaurant, including variables such as the day of the week, the sex of the person,...
def create_pairs(numbers): return [(numbers[i], numbers[i+1] if (i+1) < len(numbers) else None) for i in range(0, len(numbers), 2)]
simplelr_Filter
[ { "content": "Question:\nI have list of numbers in python, for example, `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]`, and I want to create pairs of numbers from this list, for example: `(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)`.\n\nI can achieve this by using the following approach:\n```python\nnumbers = [1, 2, 3, 4, 5, 6,...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6375, "level": 1, "question": "I have list of numbers in python, for example, `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]`, and I want to create pairs of numbers from this list, for example: `(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)`.\n\nI can achieve this by using the following approach:\n```p...
from typing import List def pigeonhole_sort(arr: List[int]) -> List[int]: if not arr: return [] min_val = min(arr) max_val = max(arr) range_size = max_val - min_val + 1 # Initialize the pigeonhole array with zeros pigeonhole = [0] * range_size # Populate the pigeonhol...
simplelr_Data_Structure
[ { "content": "Question:\n**Problem Statement**:\nYou are provided with a list of integers. Your task is to sort the list using the pigeonhole sort algorithm. However, to demonstrate your understanding, you need to modify the traditional pigeonhole sort algorithm such that it can handle arrays containing negativ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6376, "level": 1, "question": "**Problem Statement**:\nYou are provided with a list of integers. Your task is to sort the list using the pigeonhole sort algorithm. However, to demonstrate your understanding, you need to modify the traditional pigeonhole sort algorithm such that it c...
def dfs_traversal(graph, start_node): visited = set() stack = [start_node] result = [] while stack: node = stack.pop() if node not in visited: visited.add(node) result.append(node) # Add neighbors in reverse order to maintain the correct order ...
simplelr_Package
[ { "content": "Question:\nIn this task, you are asked to implement a depth-first search (DFS) algorithm to traverse a graph represented using an adjacency list. You need to write a function called `dfs_traversal(graph, start_node)` that returns a list of nodes in the order they are visited by the DFS algorithm. ...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6377, "level": 1, "question": "In this task, you are asked to implement a depth-first search (DFS) algorithm to traverse a graph represented using an adjacency list. You need to write a function called `dfs_traversal(graph, start_node)` that returns a list of nodes in the order they...
def greet(user_input): """This function takes user input and returns a greeting response. Args: user_input: The user's input string. Returns: A string containing the chatbot's greeting response. """ greetings = ["hello", "hi", "hey", "good morning", "good afternoon", "good evenin...
simplelr_Filter
[ { "content": "Question:\nThis is the problem:\n\nYou are building a simple chatbot that can recognize and respond to basic greetings. Your chatbot should be able to recognize greetings like \"hello\", \"hi\", \"hey\", \"good morning\", \"good afternoon\", \"good evening\", and should respond with a friendly mes...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6378, "level": 1, "question": "This is the problem:\n\nYou are building a simple chatbot that can recognize and respond to basic greetings. Your chatbot should be able to recognize greetings like \"hello\", \"hi\", \"hey\", \"good morning\", \"good afternoon\", \"good evening\", and...
def list_with_max_sum(list1, list2): sum1 = sum(list1) sum2 = sum(list2) return list1 if sum1 >= sum2 else list2
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes two lists as input and returns the list that has the maximum sum of elements. If both lists have the same sum, return the first list.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6379, "level": 1, "question": "Create a function that takes two lists as input and returns the list that has the maximum sum of elements. If both lists have the same sum, return the first list.", "split": "train" }
def find_treasure(grid): """ Finds the coordinates of the cell with the lowest terrain level in the grid. Args: grid (List[List[int]]): The n x n grid of integers. Returns: Tuple[int, int]: The coordinates (i, j) of the cell with the lowest terrain level. """ n = len(grid) ...
simplelr_Code_Contests
[ { "content": "Question:\nYou're assisting a treasure hunter who is trying to find the location of a hidden treasure on a grid map. The map is represented as an `n x n` matrix where each cell contains an integer representing the terrain level. The treasure is located in the lowest terrain level cell in the matri...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6380, "level": 1, "question": "You're assisting a treasure hunter who is trying to find the location of a hidden treasure on a grid map. The map is represented as an `n x n` matrix where each cell contains an integer representing the terrain level. The treasure is located in the low...
def longest_unique_substring(s: str) -> int: last_seen = {} max_length = 0 left = 0 for right in range(len(s)): char = s[right] if char in last_seen: left = max(left, last_seen[char] + 1) last_seen[char] = right current_length = right - left + 1 if cur...
simplelr_Codeforces
[ { "content": "Question:\nWrite a Python function that takes a string as input and returns the length of the longest substring without repeating characters.\n\nFunction signature: `def longest_unique_substring(s: str) -> int:`\n\n**Input:**\n- A string `s` (1 <= length of s <= 10^4) containing only printable ASC...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6381, "level": 1, "question": "Write a Python function that takes a string as input and returns the length of the longest substring without repeating characters.\n\nFunction signature: `def longest_unique_substring(s: str) -> int:`\n\n**Input:**\n- A string `s` (1 <= length of s <= ...
import os def get_file_names(file_paths): return [os.path.splitext(os.path.basename(path))[0] for path in file_paths]
simplelr_Filter
[ { "content": "Question:\nWrite a Python function that takes a list of file paths and returns a list of file names without their extensions. The function should be able to handle any type of file extension and should work regardless of whether the file path includes directories or not.\nAnswer:\nLet's think step...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6382, "level": 1, "question": "Write a Python function that takes a list of file paths and returns a list of file names without their extensions. The function should be able to handle any type of file extension and should work regardless of whether the file path includes directories...
def generate_permutation(seq1, seq2): """ Generate the permutation of seq2 based on the permutation of seq1. Args: seq1 (list): The sequence of integers to base the permutation on. seq2 (list): The sequence of integers to generate the permutation for. Returns: list: The permuta...
simplelr_Filter
[ { "content": "Question:\n### Generating Permutation\n\nGiven two sequences of integers, we want to generate the permutation of one sequence based on the permutation of the other sequence.\n\n**Problem**\n\nGiven two sequences of integers `seq1` and `seq2` both of length `n`, generate the permutation of `seq2` b...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6383, "level": 1, "question": "### Generating Permutation\n\nGiven two sequences of integers, we want to generate the permutation of one sequence based on the permutation of the other sequence.\n\n**Problem**\n\nGiven two sequences of integers `seq1` and `seq2` both of length `n`, g...
def common_elements(list1, list2): set1 = set(list1) set2 = set(list2) common = set1 & set2 return list(common)
simplelr_Filter
[ { "content": "Question:\nCreate a Python function that takes two lists of integers and returns a list of their common elements.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6384, "level": 1, "question": "Create a Python function that takes two lists of integers and returns a list of their common elements.", "split": "train" }
def merge_strings(word1, word2): i = j = 0 merged = [] while i < len(word1) and j < len(word2): if word1[i:] < word2[j:]: merged.append(word1[i]) i += 1 else: merged.append(word2[j]) j += 1 # Append the remaining characters from either word...
simplelr_Leetcode
[ { "content": "Question:\nYou are given two strings `word1` and `word2`. You want to construct a string `merged` by merging the characters of `word1` and `word2` in such a way that maintains the character order of both strings. Return _the lexicographically smallest_ string `merged` _that can be formed by mergin...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6385, "level": 1, "question": "You are given two strings `word1` and `word2`. You want to construct a string `merged` by merging the characters of `word1` and `word2` in such a way that maintains the character order of both strings. Return _the lexicographically smallest_ string `me...
def remove_duplicate_characters(s): seen = set() result = [] for char in s: if char not in seen: seen.add(char) result.append(char) return ''.join(result)
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to remove duplicate characters from a string. The function should return the string with all duplicate characters removed.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6386, "level": 1, "question": "Write a python function to remove duplicate characters from a string. The function should return the string with all duplicate characters removed.", "split": "train" }
def decimal_to_binary_encased(n): binary = bin(n).replace('0b', '') return f'db{binary}db'
simplelr_Prefill
[ { "content": "Question:\nWrite a python function to convert a decimal number to its binary string representation encased in \"db\" at the beginning and the end. The function should handle both positive and negative integers.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6387, "level": 1, "question": "Write a python function to convert a decimal number to its binary string representation encased in \"db\" at the beginning and the end. The function should handle both positive and negative integers.", "split": "train" }
from ipaddress import ip_address, ip_network from typing import List, Dict, Union def configure_devices(devices: List[Dict[str, Union[str, List[str]]]]) -> Dict[str, bool]: # Count occurrences of each primary IP address ip_counts = {} for device in devices: primary_ip = device['primary_ip'] ...
simplelr_Docs
[ { "content": "Question:\n**Problem Statement:**\n\nYou are tasked with writing a Python function to configure and verify the IP addresses and networks for a list of devices. Each device has a primary IP address and a set of secondary networks it can connect to. Your function should determine if the primary IP a...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6388, "level": 1, "question": "**Problem Statement:**\n\nYou are tasked with writing a Python function to configure and verify the IP addresses and networks for a list of devices. Each device has a primary IP address and a set of secondary networks it can connect to. Your function s...
def find_numbers_in_string(s, n): parts = s.split(',') numbers = [] for part in parts: stripped = part.strip() if stripped: try: num = int(stripped) numbers.append(num) except ValueError: pass result = [num for num i...
simplelr_Prefill
[ { "content": "Question:\nWrite a function to find all the numbers from 1 to n in a given string s, where the numbers are separated by commas.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6389, "level": 1, "question": "Write a function to find all the numbers from 1 to n in a given string s, where the numbers are separated by commas.", "split": "train" }
def bitwise_xor(a, b): return a ^ b
simplelr_Prefill
[ { "content": "Question:\nCreate a function that takes two integers as input and returns their bitwise XOR result.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6390, "level": 1, "question": "Create a function that takes two integers as input and returns their bitwise XOR result.", "split": "train" }
from collections import Counter def find_modes(nums): if not nums: return [] count = Counter(nums) max_count = max(count.values()) modes = [num for num, cnt in count.items() if cnt == max_count] modes.sort() return modes
simplelr_Prefill
[ { "content": "Question:\nWrite a function to find the mode of a given list of integers, where the mode is the number that appears most frequently in the list. If there are multiple modes, return all of them in ascending order.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6391, "level": 1, "question": "Write a function to find the mode of a given list of integers, where the mode is the number that appears most frequently in the list. If there are multiple modes, return all of them in ascending order.", "split": "train" }
from typing import List, Tuple def top_seller(ratings: List[Tuple[str, int]]) -> str: seller_data = {} for name, rating in ratings: if name not in seller_data: seller_data[name] = {'total': 0, 'count': 0} seller_data[name]['total'] += rating seller_data[name]['count'] += 1 ...
simplelr_Algorithm
[ { "content": "Question:\n### Scenario\n\nA popular online marketplace wants to evaluate the performance of its sellers based on the ratings provided by buyers. For this purpose, they require a function that calculates the average rating of each seller and identifies the top seller based on these ratings.\n\n###...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6392, "level": 1, "question": "### Scenario\n\nA popular online marketplace wants to evaluate the performance of its sellers based on the ratings provided by buyers. For this purpose, they require a function that calculates the average rating of each seller and identifies the top se...
import math def sieve_of_eratosthenes(n): if n < 2: return [] sieve = [True] * (n + 1) sieve[0], sieve[1] = False, False for p in range(2, int(math.sqrt(n)) + 1): if sieve[p]: for i in range(p * p, n + 1, p): sieve[i] = False return [i for i, is_prime in ...
simplelr_Filter
[ { "content": "Question:\nCan you explain how to implement a function in Python that finds all prime numbers within a given range, say from 1 to 100? To make it more efficient, I want to use the Sieve of Eratosthenes algorithm.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6393, "level": 1, "question": "Can you explain how to implement a function in Python that finds all prime numbers within a given range, say from 1 to 100? To make it more efficient, I want to use the Sieve of Eratosthenes algorithm.", "split": "train" }
def shorten_strings(input_list): return [s[:3] for s in input_list]
simplelr_Filter
[ { "content": "Question:\nThe problem is as follows:\n\nI need help with constructing a Python function that takes a list of strings as input and returns a new list where each string is shortened to its first three letters.\n\nFor instance:\n\n\n```python\ninput_list = [\"apple\", \"banana\", \"cherry\"]\nshorte...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6394, "level": 1, "question": "The problem is as follows:\n\nI need help with constructing a Python function that takes a list of strings as input and returns a new list where each string is shortened to its first three letters.\n\nFor instance:\n\n\n```python\ninput_list = [\"apple...
def common_elements(list1, list2): return list(set(list1) & set(list2))
simplelr_Filter
[ { "content": "Question:\nI need to write a Python function that takes two lists as input and returns a new list containing elements that are common to both input lists. How can I do this?\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6395, "level": 1, "question": "I need to write a Python function that takes two lists as input and returns a new list containing elements that are common to both input lists. How can I do this?", "split": "train" }
def rotate_matrix_90_clockwise(matrix): n = len(matrix) # Transpose the matrix for i in range(n): for j in range(i + 1, n): matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j] # Reverse each row for row in matrix: row.reverse() return matrix
simplelr_Evol
[ { "content": "Question:\nWrite a function to rotate a square matrix by 90 degrees clockwise. The function should ensure that the rotation is done in place without using any extra space. Return the modified matrix.\nmatrix = [\n [1, 2, 3],\n [4, 5, 6],\n [7, 8, 9]\n]\n\nExpected output after rotation:\n...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6396, "level": 1, "question": "Write a function to rotate a square matrix by 90 degrees clockwise. The function should ensure that the rotation is done in place without using any extra space. Return the modified matrix.\nmatrix = [\n [1, 2, 3],\n [4, 5, 6],\n [7, 8, 9]\n]\n...
def is_valid_triangle(a, b, c): if a <= 0 or b <= 0 or c <= 0: return False sides = sorted([a, b, c]) return sides[0] + sides[1] > sides[2]
simplelr_Taco
[ { "content": "Question:\nWrite a function that determines whether a given set of 3 sides can form a valid triangle. The function should take three integers as input and return a boolean value. A triangle is valid if the sum of any two sides is greater than the third side.\n\nFor example, `is_valid_triangle(3, 4...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6397, "level": 1, "question": "Write a function that determines whether a given set of 3 sides can form a valid triangle. The function should take three integers as input and return a boolean value. A triangle is valid if the sum of any two sides is greater than the third side.\n\nF...
def fibonacci_sequence(n): if n < 0: return [] sequence = [] a, b = 0, 1 while a <= n: sequence.append(a) a, b = b, a + b return sequence
simplelr_Prefill
[ { "content": "Question:\nWrite a function to get the Fibonacci sequence up to a given number 'n'. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1.\nAnswer:\nLet's think step by step.\n", "role": "user" } ]
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6398, "level": 1, "question": "Write a function to get the Fibonacci sequence up to a given number 'n'. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1.", "split": "train" }
def neighboring_elements(nums, target): if target not in nums: return [] index = nums.index(target) result = [] if index > 0: result.append(nums[index - 1]) result.append(target) if index < len(nums) - 1: result.append(nums[index + 1]) return result
simplelr_Filter
[ { "content": "Question:\nWrite the function `neighboring_elements` that takes in two parameters: a list of integers `nums` and an integer `target`. This function will iterate through the list to find the index of the target. If the target is found, the function will return a list that includes the elements to t...
code
{ "ground_truth": "pass", "style": "exec" }
{ "answer": "pass", "index": 6399, "level": 1, "question": "Write the function `neighboring_elements` that takes in two parameters: a list of integers `nums` and an integer `target`. This function will iterate through the list to find the index of the target. If the target is found, the function will return a l...