Tier 1 — floor
5/5
seed 1 (passed): all cases passed
296 tokens · 14.885s
extracted code
import re
def is_palindrome(s):
cleaned_s = re.sub('[^a-zA-Z0-9]', '', s).lower()
return cleaned_s == cleaned_s[::-1]
Tier 2 — edge-case handling
5/5
seed 1 (passed): all cases passed
411 tokens · 7.294s
extracted code
def second_largest_unique(numbers):
"""
Returns the second largest unique value in a list of integers.
Args:
numbers: List of integers
Returns:
The second largest unique integer or None if there are less than 2 unique values
"""
if not numbers:
return None
unique_numbers = sorted(list(set(numbers)))
if len(unique_numbers) < 2:
return None
return unique_numbers[-2]
Tier 3 — multi-class interface
5/5
seed 1 (passed): all cases passed
860 tokens · 15.149s
extracted code
class Book:
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 __repr__(self):
return f"Book(title='{self.title}', author='{self.author}', isbn='{self.isbn}', available={self.available})"
class Library:
def __init__(self):
self.books = []
def add_book(self, book: Book) -> None:
"""Add a book to the library."""
if not isinstance(book, Book):
raise ValueError('Only Book objects can be added to the library')
self.books.append(book)
def checkout_book(self, isbn: str) -> bool:
"""Check out a book by ISBN.
Args:
isbn: The ISBN of the book to check out.
Returns:
True if the book was successfully checked out, False otherwise.
"""
for book in self.books:
if book.isbn == isbn and book.available:
book.available = False
return True
return False
def return_book(self, isbn: str) -> bool:
"""Return a book by ISBN.
Args:
isbn:
... [truncated, 990 more chars]
Tier 4 — bug-fix
5/5
seed 1 (passed): all cases passed
260 tokens · 4.735s
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 discount_percent < 0 or discount_percent > 100:
raise ValueError('Discount percent must be between 0 and 100')
discount = price * (discount_percent / 100)
new_price = price - discount
return round(new_price, 2)
Tier 5 — schema cross-reference
5/5
seed 1 (passed): all cases passed
669 tokens · 11.783s
extracted code
def top_customers(orders, customers, n):
customer_map = {customer['customer_id']: customer['name'] for customer in customers}
customer_totals = {}
for order in orders:
customer_id = order['customer_id']
amount = order['amount']
if customer_id in customer_map:
if customer_id in customer_totals:
customer_totals[customer_id]['total_spent'] += amount
customer_totals[customer_id]['order_count'] += 1
else:
customer_totals[customer_id] = {'name': customer_map[customer_id], 'total_spent': amount, 'order_count': 1}
sorted_customers = sorted(customer_totals.values(), key=lambda x: x['total_spent'], reverse=True)
return sorted_customers[:n]
orders = [{'order_id': 1, 'customer_id': 101, 'amount': 50}, {'order_id': 2, 'customer_id': 102, 'amount': 30}, {'order_id': 3, 'customer_id': 101, 'amount': 20}, {'order_id': 4, 'customer_id': 103, 'amount': 70}]
customers = [{'customer_id': 101, 'name': 'Alice'}, {'customer_id': 102, 'name': 'Bob'}, {'customer_id': 103, 'name': 'Charlie'}]
top_n = top_customers(orders, customers, 2)
Tier 6 — strict JSON format
0/5
seed 1 (FAILED): total_value = 267.25, expected 289.85
46 tokens · 1.052s
raw response
```json
{
"low_stock_items": ["Widget", "Gizmo"],
"total_value": 267.25,
"most_expensive_item": "Gizmo"
}
```