← Back to leaderboard

granite4:3b

2.9 GB measured VRAM · sub-4GB tier
Tier 1 — floor 5/5
seed 1 (passed): all cases passed
171 tokens · 1.992s
extracted code
import re

def is_palindrome(s):
    s = re.sub('\\W+', '', s).lower()
    return s == s[::-1]
Tier 2 — edge-case handling 0/5
seed 1 (FAILED): exception on [5, 5, 5]: There must be at least two unique numbers
410 tokens · 2.03s
extracted code
def find_second_largest(numbers):
    if not isinstance(numbers, list):
        raise ValueError('Input must be a list')
    for num in numbers:
        if not isinstance(num, int):
            raise ValueError('All elements in the list must be integers')
    unique_numbers = set(numbers)
    if len(unique_numbers) < 2:
        raise ValueError('There must be at least two unique numbers')
    sorted_unique_numbers = sorted(unique_numbers, reverse=True)
    return sorted_unique_numbers[1]
Tier 3 — multi-class interface 5/5
seed 1 (passed): all cases passed
537 tokens · 2.651s
extracted code
class Book:

    def __init__(self, title, author, isbn):
        self.title = title
        self.author = author
        self.isbn = isbn
        self.available = True

class Library:

    def __init__(self):
        self.books = []

    def add_book(self, book):
        if isinstance(book, Book):
            self.books.append(book)
            return True
        else:
            print('Invalid input. Please provide a Book object.')
            return False

    def checkout_book(self, isbn):
        for book in self.books:
            if book.isbn == isbn and book.available:
                book.available = False
                return True
        print('Book not found or already checked out.')
        return False

    def return_book(self, isbn):
        for book in self.books:
            if book.isbn == isbn and (not book.available):
                book.available = True
                return True
        print('Book not found or already available.')
        return False

    def find_by_author(self, author):
        books_by_author = [book for book in self.books if book.author == author]
        return books_by_author
library = Library()
books = [Book('Book1', 'Author1',
... [truncated, 147 more chars]
Tier 4 — bug-fix 5/5
seed 1 (passed): all cases passed
161 tokens · 0.857s
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 = round(price - discount, 2)
    return new_price
Tier 5 — schema cross-reference 5/5
seed 1 (passed): all cases passed
542 tokens · 2.654s
extracted code
def top_customers(orders, customers, n):
    customer_totals = {}
    for order in orders:
        customer_id = order['customer_id']
        if customer_id not in customer_totals:
            customer_name = next((customer['name'] for customer in customers if customer['customer_id'] == customer_id))
            customer_totals[customer_id] = {'name': customer_name, 'total_spent': 0, 'order_count': 0}
        customer_totals[customer_id]['total_spent'] += order['amount']
        customer_totals[customer_id]['order_count'] += 1
    result = [{'name': customer['name'], 'total_spent': customer['total_spent'], 'order_count': customer['order_count']} for customer in customer_totals.values()]
    result.sort(key=lambda x: x['total_spent'], reverse=True)
    return result[:n]
Tier 6 — strict JSON format 0/5
seed 1 (FAILED): low_stock_items = {'Gizmo'}, expected {'Widget', 'Gizmo'}
31 tokens · 0.255s
raw response
{"low_stock_items": ["Gizmo"], "total_value": 212.50, "most_expensive_item": "Gizmo"}