def differ_in_at_most_one(first, second):
    """Check if two strings differ in at most one position."""
    # Check if length differences make it possible
    if abs(len(first) - len(second)) > 1:
        return False

    if len(first) > len(second):
        longer, shorter = first, second
    else:
        longer, shorter = second, first

    one_found = False
    l, s = 0, 0
    long_length = len(longer)
    short_length = len(shorter)
    while l < long_length and s < short_length:
        if longer[l] != shorter[s]:
            if one_found: # found second difference
                return False
            else:
                one_found = True
                # skip one, if we have different lengths
                # position in shorter string should stay in place in that case
                if long_length != short_length:
                    l += 1
                else:
                    l += 1
                    s += 1
        else:
            l += 1
            s += 1
    return True