Tier 1 — floor
5/5
seed 1 (passed): all cases passed
1044 tokens · 15.304s
extracted code
import re
def is_palindrome(s: str) -> bool:
"""
Checks if a given string is a palindrome, ignoring case, spaces,
and punctuation.
Args:
s: The input string.
Returns:
True if the string is a palindrome, False otherwise.
"""
s_lower = s.lower()
cleaned_string = re.sub('[^a-z0-9]', '', s_lower)
return cleaned_string == cleaned_string[::-1]
Tier 2 — edge-case handling
5/5
seed 1 (passed): all cases passed
1798 tokens · 13.049s
extracted code
from typing import List, Optional
def find_second_largest_unique(nums: List[int]) -> Optional[int]:
"""
Finds the second largest unique value in a list of integers.
Args:
nums: A list of integers.
Returns:
The second largest unique integer, or None if fewer than two
unique elements exist (e.g., empty list, or all elements are the same).
"""
unique_nums = set(nums)
if len(unique_nums) < 2:
return None
sorted_unique = sorted(list(unique_nums), reverse=True)
return sorted_unique[1]
list1 = [10, 20, 30, 5]
result1 = find_second_largest_unique(list1)
list2 = [30, 20, 20, 10, 5]
result2 = find_second_largest_unique(list2)
list3 = [-10, -5, -20, -1]
result3 = find_second_largest_unique(list3)
list4 = [7, 7, 7]
result4 = find_second_largest_unique(list4)
list5 = []
result5 = find_second_largest_unique(list5)
list6 = [10, 2]
result6 = find_second_largest_unique(list6)
list7 = [5, 10, 5]
result7 = find_second_largest_unique(list7)
Tier 3 — multi-class interface
5/5
seed 1 (passed): all cases passed
1848 tokens · 13.713s
extracted code
class Book:
"""Represents a single book with metadata and availability status."""
def __init__(self, title: str, author: str, isbn: str, available: bool=True):
self.title = title
self.author = author
self.isbn = isbn
self.available = available
def __str__(self):
"""Provides a readable string representation of the Book."""
status = 'Available' if self.available else 'Checked Out'
return f"'{self.title}' by {self.author} (ISBN: {self.isbn}) - Status: {status}"
def __repr__(self):
"""Formal representation for debugging."""
return f"Book(title='{self.title}', author='{self.author}', isbn='{self.isbn}', available={self.available})"
class Library:
"""Manages a collection of Book objects, handling checkouts and returns."""
def __init__(self):
self._books = {}
def add_book(self, book: Book):
"""Adds a Book object to the library inventory. Checks for duplicate ISBNs."""
if not isinstance(book, Book):
raise TypeError('Must add an instance of the Book class.')
if book.isbn in self._books:
print(f'⚠️ Warning: Book with ISBN {book.isbn
... [truncated, 2294 more chars]
Tier 4 — bug-fix
5/5
seed 1 (passed): all cases passed
824 tokens · 6.063s
extracted code
def apply_discount(price, discount_percent):
"""
Applies a percentage discount to a price.
discount_percent is 0-100 (e.g., 20 means 20% off).
Returns the discounted price, rounded to 2 decimal places.
Raises ValueError if discount_percent is negative or greater than 100.
Raises ValueError if price is negative.
"""
if price < 0:
raise ValueError('Price cannot be negative.')
if not 0 <= discount_percent <= 100:
raise ValueError('Discount percentage must be between 0 and 100.')
discount_factor = discount_percent / 100.0
multiplier = 1.0 - discount_factor
new_price = price * multiplier
return round(new_price, 2)
Tier 5 — schema cross-reference
5/5
seed 1 (passed): all cases passed
1357 tokens · 9.861s
extracted code
from typing import List, Dict, Any
def top_customers(orders: List[Dict[str, Any]], customers: List[Dict[str, Any]], n: int) -> List[Dict[str, Any]]:
"""
Returns the top n customers by total order amount.
Args:
orders: A list of dictionaries, each representing an order
(must contain 'customer_id' and 'amount').
customers: A list of dictionaries, each representing a customer
(must contain 'customer_id' and 'name').
n: The number of top customers to return.
Returns:
A list of dictionaries, sorted descending by total_spent,
containing only the keys: name, total_spent, order_count.
"""
customer_stats = {}
for order in orders:
c_id = order['customer_id']
amount = order['amount']
if c_id not in customer_stats:
customer_stats[c_id] = {'total_spent': 0.0, 'order_count': 0}
customer_stats[c_id]['total_spent'] += amount
customer_stats[c_id]['order_count'] += 1
customer_name_map = {c['customer_id']: c['name'] for c in customers}
results = []
for c_id, stats in customer_stats.items():
name = customer_name_map.get(c_i
... [truncated, 1011 more chars]
Tier 6 — strict JSON format
0/5
seed 1 (FAILED): total_value = 367.95, expected 289.85
39 tokens · 0.621s
raw response
{"low_stock_items": ["Widget", "Gizmo"], "total_value": 367.95, "most_expensive_item": "Gizmo"}