def string_to_score_generic(string, mapping):
    length = int(math.log(len(mapping), 2) / 52)    #A

    pieces = map(ord, string[:length])              #B
    while len(pieces) < length:                     #C
        pieces.append(-1)                           #C

    score = 0
    for piece in pieces:                            #D
        value = mapping[piece]                      #D
        score = score * len(mapping) + value + 1    #D

    return score * 2 + (len(string) > length)       #E



# <start id="zadd-string"/>
dataset/ETHPy150Open huangz1990/riacn-code/ch07_listing_source.py/string_to_score_generic/swapped operands of `/`