# Task
 You are given n rectangular boxes, the ith box has the length lengthi, the width widthi and the height heighti. 
 
 Your task is to check if it is possible to pack all boxes into one so that inside each box there is no more than one another box (which, in turn, can contain at most one another box, and so on). 
 
 More formally, your task is to check whether there is such sequence of n different numbers pi (1 ≤ pi ≤ n) that for each 1 ≤ i < n the box number pi can be put into the box number pi+1.

 A box can be put into another box if all sides of the first one are less than the respective ones of the second one. You can rotate each box as you wish, i.e. you can `swap` its length, width and height if necessary.

# Example

 For `length = [1, 3, 2], width = [1, 3, 2] and height = [1, 3, 2]`, the output should be `true`;
 
 For `length = [1, 1], width = [1, 1] and height = [1, 1],` the output should be `false`;
 
 For `length = [3, 1, 2], width = [3, 1, 2] and height = [3, 2, 1]`, the output should be `false`.
 
# Input/Output


 - `[input]` integer array `length`

    Array of positive integers.

    Constraints:

    `1 ≤ length.length ≤ 100,`

    `1 ≤ length[i] ≤ 2000.`


 - `[input]` integer array `width`

    Array of positive integers.

    Constraints:

    `width.length = length.length,`

    `1 ≤ width[i] ≤ 2000.`


 - `[input]` integer array `height`

    Array of positive integers.

    Constraints:

    `height.length = length.length,`

    `1 ≤ height[i] ≤ 2000.`


 - `[output]` a boolean value

    `true` if it is possible to put all boxes into one, `false` otherwise.

Difficulty: introductory

Starter code:

def boxes_packing(length, width, height):
	

Solutions:
def boxes_packing(l, w, h):
    boxes = sorted(sorted(t) for t in zip(l, w, h))
    return all( s < l for b1,b2 in zip(boxes[:-1], boxes[1:]) for s,l in zip(b1,b2))

def boxes_packing(length, width, height):
    boxes = sorted([sorted(b) for b in zip(length, width, height)])
    return all(all(x < y for x, y in zip(a, b)) for a, b in zip(boxes, boxes[1:]))

def boxes_packing(length, width, height):
    boxes = sorted(range(len(width)), key=lambda i: length[i]*width[i]*height[i])
    for i in range(len(boxes)-1):
        x = boxes[i]
        y = boxes[i+1]
        rotations_x = [[length[x], width[x], height[x]],
                      [length[x], height[x], width[x]],
                      [width[x], length[x], height[x]],
                      [width[x], height[x], length[x]],
                      [height[x], length[x], width[x]],
                      [height[x], width[x], length[x]]]
        for lx, wx, hx in rotations_x:
            if lx < length[y] and wx < width[y] and hx < height[y]:
                break
        else:
            return False
    return True

def boxes_packing(l,w,h):
    return all(len(i)==len(set(i))and list(i)==sorted(i)for i in list(zip(*sorted(sorted(i)for i in list(zip(l,w,h))))))

def boxes_packing(length, width, height):
    incr = lambda s: all(x < y for x, y in zip(s, s[1:]))
    return all(incr(s) for s in zip(*sorted(sorted(b) for b in zip(length, width, height))))

def boxes_packing(length, width, height):
    boxes=sorted([sorted(t,reverse=True) for t in zip(length,width,height)],reverse=True)
    for b1,b2 in zip(boxes[:-1],boxes[1:]):
        if b1[0]<=b2[0] or b1[1]<=b2[1] or b1[2]<=b2[2]:
            return False
    return True

def boxes_packing(*args):
    boxes = sorted(map(sorted, zip(*args)))
    return all(dimension_1 < dimension_2 
                for box_1, box_2 in zip(boxes, boxes[1:]) 
                for dimension_1, dimension_2 in zip(box_1, box_2))

def boxes_packing(length, width, height):
    boxes = sorted(map(sorted, zip(length, width, height)))
    return all(all(d1 < d2 for d1, d2 in zip(smaller, larger)) for smaller, larger in zip(boxes, boxes[1:]))

from itertools import tee, chain,starmap
from operator import lt

# found at https://docs.python.org/3.6/library/itertools.html
def pairwise(iterable):
    "s -> (s0,s1), (s1,s2), (s2, s3), ..."
    a, b = tee(iterable)
    next(b, None)
    return zip(a, b)

def boxes_packing(length, width, height):
    boxes = map(sorted, sorted(zip(length, width, height), key=lambda b: b[0] * b[1] * b[2]))
    return all(starmap(lt, chain.from_iterable(zip(*a) for a in pairwise(boxes))))

def boxes_packing(length, width, height):
    L = list(map(sorted, zip(length, width, height)))
    return all(all(x<y for x,y in zip(b1, b2)) or all(x>y for x,y in zip(b1, b2)) for i,b1 in enumerate(L) for b2 in L[i+1:])