def compare(riddle, attempt):
    """
    compare function gets answer for "Bulls&Cows" game
    by comparison riddle to attempt
    :param riddle: the string consisted of 4 different numeric symbols to be recognised
    :param attempt: the string consisted of 4 different numeric symbols as an attempt to recognize the riddle
    :return result: the string of template 'B1 C2' ('B0 C0', 'B2 C2', etc.)
    """

    bulls = 0
    cows = 0

    # check every 4 symbols of the attempt against the riddle
    for i in range(4):
        if attempt[i] == riddle[i]:
            # if symbol is in the same position it contributes to bulls
            bulls += 1
        else:
            if attempt[i] in riddle:
                # if symbol is in the different position it contributes to cows
                cows += 1
    # the response of template 'B1 C2' ('B0 C0', 'B2 C2', etc.)
    return 'B' + str(bulls) + ' C' + str(cows)