One of the first chain emails I ever received was about a supposed Cambridge  University study that suggests your brain can read words no matter what order the letters are in, as long as the first and last letters of each word are correct.

Your task is to **create a function that can take any string and randomly jumble the letters within each word while leaving the first and last letters of the word in place.**

For example,
    
    mixwords('Winter is coming') // returns 'Wntier is cminog' or 'Wtiner is conimg'
    mixwords('Hey, friends!') // returns 'Hey, fierdns!' or 'Hey, fernids!'

* All punctuation should remain in place
* Words smaller than 3 letters should not change
* Letters must be randomly moved (and so calling the function multiple times with the same string should return different values
* Parameters that are not strings should return undefined

The tests do the following things to ensure a valid string is returned:
    
1. Check that the string returned is not equal to the string passed (you may have to revalidate the solution if your function randomly returns the same string)
2. Check that first and last letters of words remain in place
3. Check that punctuation remains in place
4. Checks string length remains the same
5. Checks the function returns `undefined` for non-strings
6. Checks that word interiors (the letters between the first and last) maintain the same letters, albeit in a different order
7. Checks that letters are randomly assigned.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

def _disabled_input(*args, **kwargs):
    raise RuntimeError("input() is disabled in callable mode")
builtins.input = _disabled_input

ns = {"__name__": "__judge__"}  # prevent if __name__ == "__main__" blocks
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'import random\nimport re\nimport numpy as np\n\ndef mix_words(text):\n    words_list = text.split()\n    result_list = []\n\n    for word in words_list:\n        punctuation = \'\'.join(re.findall("\\W", word))\n        # punctuation = \'\'.join(re.findall("[^a-zA-Z]", word))  #equivalent to line above, get non-alphanumeric characters\n        \n        # create 2 lists, the 1st as the word split into a list, the 2nd an empty list of the same size that will\n        # be get filled in sequentially\n        text_list = [x for x in word]\n        blank_list = [\'\' for x in range(len(word))]\n\n        # need to isolate the middle part of the word (not 1st, last, punctuation)\n        # assumption that any punctuation is at the end of each word. e.g. hello!, not hel?lo\n        lst = [x for x in range(1, ( len(text_list) - (len(punctuation) + 1) ))]\n        lst2 = lst[:]\n\n        # if there is only 1 randmisable character its position can\'t be changed  \n        if len(lst) > 1:\n            # shuffle the order of the randomisable characters, shuffle could return the same order (by chance) so perform\n            # this operation inside a while loop\n            while (np.array_equal(lst,lst2)):\n                random.shuffle(lst2)\n\n            # j variable is a counter for which element to take from the randomised characters list\n            j = 0\n            for i in range(len(word)):\n                if i == 0: \n                    # Keep first character in position\n                    blank_list[i] = text_list[i]\n                elif (len(punctuation) > 0) and ((text_list[i] in punctuation) or (text_list[i+1] in punctuation)):\n                    # Keep punctuation and last character (if there\'s punctuation) in position\n                    blank_list[i] = text_list[i]\n                elif (len(punctuation) == 0) and (i == len(word)-1):\n                    # Keep last character in position, if no punctuation\n                    blank_list[i] = text_list[i]\n                else:\n                    # if the character is not punctuation or first/last character then take from the randomised list\n                    blank_list[i] = text_list[lst2[j]]\n                    j += 1\n\n            new_text = \'\'.join(blank_list)\n            # join the individual list elements for each word together to create the randomised word\n            result_list.append(new_text)\n            # append the \n        else:\n            # if the word is less than 3 characters return the original word\n            result_list.append(word)\n    result = \'\'.join([item + \' \' for item in result_list]).strip()\n    \n    if (len(lst) > 2) & (result == text):\n        result = mix_words(text)\n            \n    return result'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

_target = None
_fn_name = 'mix_words'
if _fn_name:
    if "Solution" in ns:
        try:
            _obj = ns["Solution"]()
            if hasattr(_obj, _fn_name):
                _target = getattr(_obj, _fn_name)
        except Exception:
            _target = None
    if _target is None and _fn_name in ns and callable(ns[_fn_name]):
        _target = ns[_fn_name]
# Fallback: if there's exactly one user-defined function, use it
if _target is None:
    _cands = [v for k, v in ns.items() if callable(v) and getattr(v, "__module__", "") in ("__judge__", "__main__")]
    _user_funcs = [c for c in _cands if getattr(c, "__name__", "").startswith("_") is False]
    if len(_user_funcs) == 1:
        _target = _user_funcs[0]
if _target is None:
    raise RuntimeError(f"Could not resolve callable '{_fn_name}'")

_raw = sys.stdin.read().strip()
if _raw:
    _parsed = json.loads(_raw)
    if isinstance(_parsed, dict):
        _kwargs = _parsed.get("kwargs", {})
        _args = _parsed.get("args", [])
    else:
        _args, _kwargs = _parsed, {}
else:
    _args, _kwargs = [], {}
if not isinstance(_args, (list, tuple)):
    _args = [_args]
_res = _target(*_args, **_kwargs)
try:
    sys.stdout.write(repr(_res) + "\n")
except Exception:
    pass

```

Measured memory_bytes: 35993