def naked_twins(values):
    "Eliminate values using the naked twins strategy.\n\n    The naked twins strategy says that if you have two or more unallocated boxes\n    in a unit and there are only two digits that can go in those two boxes, then\n    those two digits can be eliminated from the possible assignments of all other\n    boxes in the same unit.\n\n    Parameters\n    ----------\n    values(dict)\n        a dictionary of the form {'box_name': '123456789', ...}\n\n    Returns\n    -------\n    dict\n        The values dictionary with the naked twins eliminated from peers\n\n    Notes\n    -----\n    Your solution can either process all pairs of naked twins from the input once,\n    or it can continue processing pairs of naked twins until there are no such\n    pairs remaining -- the project assistant test suite will accept either\n    convention. However, it will not accept code that does not process all pairs\n    of naked twins from the original input. (For example, if you start processing\n    pairs of twins and eliminate another pair of twins before the second pair\n    is processed then your code will fail the PA test suite.)\n\n    The first convention is preferred for consistency with the other strategies,\n    and because it is simpler (since the reduce_puzzle function already calls this\n    strategy repeatedly).\n\n    See Also\n    --------\n    Pseudocode for this algorithm on github:\n    https://github.com/udacity/artificial-intelligence/blob/master/Projects/1_Sudoku/pseudocode.md\n    "
    "\n    out = values.copy()\n    len_2_boxes = [box for box in values if len(values[box]) == 2]\n    for boxA in len_2_boxes:\n        boxAPeers = peers[boxA]\n        for boxB in boxAPeers:\n            if values[boxA] == values[boxB]:\n                intersect = [val for val in boxAPeers if val in peers[boxB]]\n                for peer in intersect:\n                    out[peer] = out[peer].replace(values[boxA], '')\n    return out\n    "
    out = values.copy()
    for boxA in values:
        boxAPeers = peers[boxA]
        for boxB in boxAPeers:
            if ((values[boxA] == values[boxB]) and (len(values[boxA]) == 2)):
                intersect = [val for val in boxAPeers if (val in peers[boxB])]
                for peer in intersect:
                    for digit in values[boxA]:
                        out[peer] = out[peer].replace(digit, '')
    return out
Eliminate values using the naked twins strategy.

The naked twins strategy says that if you have two or more unallocated boxes
in a unit and there are only two digits that can go in those two boxes, then
those two digits can be eliminated from the possible assignments of all other
boxes in the same unit.

Parameters
----------
values(dict)
    a dictionary of the form {'box_name': '123456789', ...}

Returns
-------
dict
    The values dictionary with the naked twins eliminated from peers

Notes
-----
Your solution can either process all pairs of naked twins from the input once,
or it can continue processing pairs of naked twins until there are no such
pairs remaining -- the project assistant test suite will accept either
convention. However, it will not accept code that does not process all pairs
of naked twins from the original input. (For example, if you start processing
pairs of twins and eliminate another pair of twins before the second pair
is processed then your code will fail the PA test suite.)

The first convention is preferred for consistency with the other strategies,
and because it is simpler (since the reduce_puzzle function already calls this
strategy repeatedly).

See Also
--------
Pseudocode for this algorithm on github:
https://github.com/udacity/artificial-intelligence/blob/master/Projects/1_Sudoku/pseudocode.md
def naked_twins(values):
    "Eliminate values using the naked twins strategy.\n\n    The naked twins strategy says that if you have two or more unallocated boxes\n    in a unit and there are only two digits that can go in those two boxes, then\n    those two digits can be eliminated from the possible assignments of all other\n    boxes in the same unit.\n\n    Parameters\n    ----------\n    values(dict)\n        a dictionary of the form {'box_name': '123456789', ...}\n\n    Returns\n    -------\n    dict\n        The values dictionary with the naked twins eliminated from peers\n\n    Notes\n    -----\n    Your solution can either process all pairs of naked twins from the input once,\n    or it can continue processing pairs of naked twins until there are no such\n    pairs remaining -- the project assistant test suite will accept either\n    convention. However, it will not accept code that does not process all pairs\n    of naked twins from the original input. (For example, if you start processing\n    pairs of twins and eliminate another pair of twins before the second pair\n    is processed then your code will fail the PA test suite.)\n\n    The first convention is preferred for consistency with the other strategies,\n    and because it is simpler (since the reduce_puzzle function already calls this\n    strategy repeatedly).\n\n    See Also\n    --------\n    Pseudocode for this algorithm on github:\n    https://github.com/udacity/artificial-intelligence/blob/master/Projects/1_Sudoku/pseudocode.md\n    "
    "\n    out = values.copy()\n    len_2_boxes = [box for box in values if len(values[box]) == 2]\n    for boxA in len_2_boxes:\n        boxAPeers = peers[boxA]\n        for boxB in boxAPeers:\n            if values[boxA] == values[boxB]:\n                intersect = [val for val in boxAPeers if val in peers[boxB]]\n                for peer in intersect:\n                    out[peer] = out[peer].replace(values[boxA], )\n    return out\n    "
    out = values.copy()
    for boxA in values:
        boxAPeers = peers[boxA]
        for boxB in boxAPeers:
            if ((values[boxA] == values[boxB]) and (len(values[boxA]) == 2)):
                intersect = [val for val in boxAPeers if (val in peers[boxB])]
                for peer in intersect:
                    for digit in values[boxA]:
                        out[peer] = out[peer].replace(digit, )
    return out