CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-qrcode

QR Code image generator with customizable image formats, error correction levels, and styling options

42%

Overall

Evaluation42%

0.86x

Agent success when using this tile

Overview
Eval results
Files

task.mdevals/scenario-10/

QR Code Version Manager

Build a utility that demonstrates control over QR code versions to generate codes of specific sizes.

Requirements

Your task is to create a Python module that:

  1. Generates QR codes with explicit version control: Create QR codes where you specify the exact version (size) of the QR code, ranging from version 1 (21x21 modules) to version 40 (177x177 modules).

  2. Calculates version dimensions: Given a version number, calculate and return the matrix dimensions (width and height in modules) for that QR code version. Each version number corresponds to a specific size: version N has dimensions of (17 + 4N) x (17 + 4N) modules.

  3. Finds minimum version for data: Given input data and an error correction level, determine the smallest QR code version that can accommodate that data.

Specifications

Create a module with the following functions:

create_qr_with_version(data: str, version: int, error_correction: str = "M") -> object

Creates a QR code with a specific version number.

  • data: The text/data to encode in the QR code
  • version: An integer from 1 to 40 specifying the QR code version
  • error_correction: Error correction level ("L", "M", "Q", or "H")
  • Returns: A QR code object that can be rendered to an image

get_version_dimensions(version: int) -> dict

Returns the dimensions of a QR code for a given version.

  • version: An integer from 1 to 40
  • Returns: A dictionary with keys "width" and "height" representing the number of modules in each dimension

find_minimum_version(data: str, error_correction: str = "M") -> int

Determines the smallest version that can fit the given data.

  • data: The text/data that needs to be encoded
  • error_correction: Error correction level ("L", "M", "Q", or "H")
  • Returns: The minimum version number (integer) that can accommodate the data

Test Cases

  • Creating a version 1 QR code with "Hello" returns a QR code object. Calling get_version_dimensions(1) returns {"width": 21, "height": 21} @test
  • Creating a version 10 QR code with "Test data" returns a QR code object. Calling get_version_dimensions(10) returns {"width": 57, "height": 57} @test
  • Finding the minimum version for "Hi" with error correction "L" returns a small version number (between 1-5) @test
  • Finding the minimum version for a 200-character string with error correction "H" returns a version number larger than 5 @test

Dependencies { .dependencies }

qrcode { .dependency }

Provides QR code generation capabilities with version control and error correction options.

@satisfied-by

Implementation

@generates

API

def create_qr_with_version(data: str, version: int, error_correction: str = "M") -> object:
    """
    Creates a QR code with a specific version number.

    Args:
        data: The text/data to encode in the QR code
        version: An integer from 1 to 40 specifying the QR code version
        error_correction: Error correction level ("L", "M", "Q", or "H")

    Returns:
        A QR code object that can be rendered to an image
    """
    pass

def get_version_dimensions(version: int) -> dict:
    """
    Returns the dimensions of a QR code for a given version.

    Args:
        version: An integer from 1 to 40

    Returns:
        A dictionary with keys "width" and "height" representing module dimensions
    """
    pass

def find_minimum_version(data: str, error_correction: str = "M") -> int:
    """
    Determines the smallest version that can fit the given data.

    Args:
        data: The text/data that needs to be encoded
        error_correction: Error correction level ("L", "M", "Q", or "H")

    Returns:
        The minimum version number that can accommodate the data
    """
    pass

Install with Tessl CLI

npx tessl i tessl/pypi-qrcode@7.4.0
What are skills?

tile.json