← Back to leaderboard

mistral:7b

5.6 GB measured VRAM · 4-8GB tier
Tier 1 — floor 5/5
seed 1 (passed): all cases passed
191 tokens · 1.454s
extracted code
import re

def is_palindrome(s):
    s = re.sub('\\W+', '', s).lower()
    if s == s[::-1]:
        return True
    else:
        return False
Tier 2 — edge-case handling 0/5
seed 1 (FAILED): f([5, 5, 5]) = -inf, expected None
321 tokens · 2.018s
extracted code
def find_second_largest(numbers):
    if not numbers:
        return None
    max1 = float('-inf')
    max2 = float('-inf')
    for num in set(numbers):
        if num > max1:
            max2, max1 = (max1, num)
        elif num > max2 and num != max1:
            max2 = num
    return max2
Tier 3 — multi-class interface 5/5
seed 1 (passed): all cases passed
744 tokens · 4.613s
extracted code
class Book:

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

    def __repr__(self):
        status = 'Available' if self.available else 'Checked out'
        return f'{self.title} by {self.author}, ISBN: {self.isbn}, Status: {status}'

class Library:

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

    def add_book(self, book):
        if book not in self.books:
            self.books.append(book)

    def checkout_book(self, isbn):
        for book in self.books:
            if book.isbn == isbn and book.available:
                book.available = False
                return True
        return False

    def return_book(self, isbn):
        for book in self.books:
            if book.isbn == isbn:
                book.available = True
                return True
        return False

    def find_by_author(self, author):
        results = [book for book in self.books if book.author == author]
        return results
library = Library()
book1 = Book('The Catcher in the Rye', 'J.D. Salinger', '978-0316769488', True)
book2 = Book('To Kill a Mockingbird'
... [truncated, 39 more chars]
Tier 4 — bug-fix 5/5
seed 1 (passed): all cases passed
307 tokens · 1.97s
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 percentage 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 0/5
seed 1 (FAILED): exception: 'bool' object is not subscriptable
356 tokens · 2.25s
extracted code
from collections import defaultdict, Counter

def top_customers(orders, customers, n):
    customer_orders = defaultdict(lambda: (0, 0))
    for order in orders:
        customer_id = order['customer_id']
        customer_orders[customer_id] = (customer_orders[customer_id][0] + order['amount'], customer_orders[customer_id][1] + 1)
    top_n_customers = sorted(customer_orders.items(), key=lambda x: (-x[1][0], -x[1][1]), reverse=True)[:n]
    result = []
    for customer in top_n_customers:
        name = next((c['customer_id'] == customer[0] for c in customers if c['customer_id'] == customer[0]), None)
        if name:
            result.append({'name': name['name'], 'total_spent': customer[1][0], 'order_count': customer[1][1]})
    return result
Tier 6 — strict JSON format 0/5
seed 1 (FAILED): total_value = 167.5, expected 289.85
42 tokens · 0.336s
raw response
 {"low_stock_items": ["Widget", "Gizmo"], "total_value": "167.50", "most_expensive_item": "Gizmo"}