library_for_python

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub Kazun1998/library_for_python

:warning: Hamming Distance
(Sequence/Hamming_Distance.py)

Outline

$\lvert S \rvert = \lvert T \rvert$ である列 $S,T$ に対して, $N:=\lvert S \rvert$ とする. このとき, $S_i \neq T_i$ を満たす $1$ 以上 $N$ 以下の整数 $i$ の個数を $S,T$ の Hamming 距離という.

Code

#ハミング距離
def Hamming_Distance(S, T):
    """ 列の長さが等しい S, T におけるハミング距離を求める.

    S,T: (|S|=|T| を満たしていなければならない)
    """

    assert len(S)==len(T)
    return sum(int(S[i]!=T[i]) for i in range(len(S)))
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.13.3/x64/lib/python3.13/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
                   ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.13.3/x64/lib/python3.13/site-packages/onlinejudge_verify/languages/python.py", line 96, in bundle
    raise NotImplementedError
NotImplementedError
Back to top page