CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-xxhash

Python binding for xxHash library providing fast non-cryptographic hash algorithms

Overall
score

80%

Evaluation80%

1.03x

Agent success when using this tile

Overview
Eval results
Files

task.mdevals/scenario-7/

Hash Seed Validator

Overview

You need to build a hash seed validator tool that verifies whether two seed values will produce identical hash outputs for the same input data. This tool should handle seeds of any size and determine if they are equivalent after normalization.

Requirements

Your implementation should include:

  1. A function are_seeds_equivalent_32(seed1: int, seed2: int) -> bool that:

    • Takes two integer seed values
    • Returns True if both seeds would produce identical hash outputs when used with a 32-bit hash algorithm
    • Returns False otherwise
    • Should handle seeds that are negative, zero, or extremely large
  2. A function are_seeds_equivalent_64(seed1: int, seed2: int) -> bool that:

    • Takes two integer seed values
    • Returns True if both seeds would produce identical hash outputs when used with a 64-bit hash algorithm
    • Returns False otherwise
    • Should handle seeds that are negative, zero, or extremely large
  3. A function normalize_seed(seed: int, bit_size: int) -> int that:

    • Takes an arbitrary integer seed and a target bit size (32 or 64)
    • Returns the normalized seed value that would actually be used by the hash algorithm
    • Should handle negative seeds appropriately

Dependencies { .dependencies }

xxhash { .dependency }

Provides fast non-cryptographic hash functions with seed support.

Test Cases

Test 1: Basic 32-bit seed equivalence @test

# File: test_validator.py
from validator import are_seeds_equivalent_32

def test_basic_32bit_equivalence():
    # Seeds that overflow to the same value
    assert are_seeds_equivalent_32(0, 2**32)
    assert are_seeds_equivalent_32(5, 2**32 + 5)
    assert are_seeds_equivalent_32(100, 2**64 + 100)

    # Seeds that are different
    assert not are_seeds_equivalent_32(0, 1)
    assert not are_seeds_equivalent_32(100, 200)

Test 2: Basic 64-bit seed equivalence @test

# File: test_validator.py
from validator import are_seeds_equivalent_64

def test_basic_64bit_equivalence():
    # Seeds that overflow to the same value
    assert are_seeds_equivalent_64(0, 2**64)
    assert are_seeds_equivalent_64(42, 2**64 + 42)

    # Seeds that are different
    assert not are_seeds_equivalent_64(0, 1)
    assert not are_seeds_equivalent_64(1000, 2000)

Test 3: Seed normalization @test

# File: test_validator.py
from validator import normalize_seed

def test_seed_normalization():
    # 32-bit normalization
    assert normalize_seed(2**32, 32) == 0
    assert normalize_seed(2**32 + 10, 32) == 10

    # 64-bit normalization
    assert normalize_seed(2**64, 64) == 0
    assert normalize_seed(2**64 + 100, 64) == 100

Implementation Notes

  • Your solution should be in a file named validator.py
  • Test file should be named test_validator.py
  • Focus on correctness and handling edge cases properly
  • Consider how seeds larger than the native bit size behave

Install with Tessl CLI

npx tessl i tessl/pypi-xxhash

tile.json