CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-python-levenshtein

Python compatibility wrapper for computing string edit distances and similarities using fast Levenshtein algorithms.

88

1.37x
Overview
Eval results
Files

task.mdevals/scenario-9/

String Transformation Reversal System

Build a bidirectional string transformation system that can transform strings and reverse those transformations.

Requirements

Implement a module that provides bidirectional string transformation capabilities:

  1. Transform a source string to a target string and compute the edit operations
  2. Reverse the transformation by applying inverse operations to go back to the original string
  3. Validate that applying forward and inverse operations results in the original string

Functionality

Your implementation should:

  • Accept two strings (source and target) and compute the transformation from source to target
  • Generate the reverse transformation that can convert target back to source
  • Apply both forward and inverse transformations and verify correctness
  • Return results showing both the transformed string and the result of applying the inverse transformation

Expected Behavior

The system should demonstrate bidirectional transformations:

  • When transforming "hello" to "hallo", it should compute operations to perform this change
  • The inverse operations should transform "hallo" back to "hello"
  • The system should verify that applying inverse operations correctly reverses the transformation

Test Cases

  • Transforming "kitten" to "sitting" and back should return "kitten" @test
  • Transforming "flaw" to "lawn" and applying inverse should return "flaw" @test
  • Empty string transformations should handle inverse operations correctly @test

Implementation

@generates

API

def transform_and_reverse(source: str, target: str) -> dict:
    """
    Transforms source to target, then applies inverse transformation.

    Args:
        source: The original string
        target: The string to transform into

    Returns:
        A dictionary containing:
        - 'forward_result': Result of transforming source to target
        - 'inverse_result': Result of applying inverse transformation to target
        - 'matches_source': Boolean indicating if inverse result matches source
    """
    pass

Dependencies { .dependencies }

Levenshtein { .dependency }

Provides string edit distance computation and transformation operations.

Install with Tessl CLI

npx tessl i tessl/pypi-python-levenshtein

tile.json