""" Delete middle node
Implement a algorithm to delete a node in the middle (not first nor last) of a single linked list given only access to that node
"""

def delete_middle_node(middle):
    middle.data = middle.next.data
    middle.next = middle.next.next

head = Node(5)
middle = Node(10)
head.append_array([1, 2, 3])
middle.append_array([3, 2, 1])
head.append_node(middle)
delete_middle_node(middle)
print head.to_list() == [5, 1, 2, 3, 3, 2, 1]

""" Partition
Write code to partition a linked list around a value x, such that all nodes less than x come before all nodes greater or equal to x.
If x is contained within the list, the value of x the value of x only need to be after the element less than x. The partition element x can appear anywhere in the right partition; it does not need to appear between the left and the right partitions.
Example:
[input] [3, 5, 8, 5, 10, 2, 1] partition 5
[output] [3, 1, 2, 10, 5, 5, 8]
"""

""" Sum Lists
You have two numbers represented by a libnked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1's digit is at the head of the list. Write a function that adds the two numbers and returns the sum as a linked list.
Example:
[7, 1, 6] + [5, 9, 2] => [2, 1, 9]

Suppose the digits are stored in forward order. Repeat the above problem