import random


def shuffle_word(word: str) -> str:
    """
    Function is encoding given word with the following conditions:
    - first and last character of a word stays the same
    - characters in between are being shuffled
    - final word must not be the same as the original word (if possible)
    :param word: a word that needs to be shuffled
    :return: shuffled_word: string
    """
    if len(word) < 4:
        # Word with 3 letters can not be shuffled with to given conditions
        return word

    # Convert letters to shuffle to list
    letters_to_shuffle = list(word[1:-1])
    sorted_letters = letters_to_shuffle.copy()
    sorted_letters.sort()

    # If all the letters are the same permutation is not possible
    if sorted_letters[0] == sorted_letters[-1]:
        return word

    # Shuffle the letters
    shuffled_letters = letters_to_shuffle.copy()

    while shuffled_letters == letters_to_shuffle:
        random.shuffle(shuffled_letters)

    # List to string
    shuffled_letters = "".join(shuffled_letters)

    # Create a shuffled word and return it
    shuffled_word = word[0] + shuffled_letters + word[-1]
    return shuffled_word