You are stacking some boxes containing gold weights on top of each other. If a box contains more weight than the box below it, it will crash downwards and combine their weights. e.g. If we stack [2] on top of [1], it will crash downwards and become a single box of weight [3]
```
[2]
[1] --> [3]
```
Given an array of arrays, return the bottom row (i.e. the last array) after all crashings are complete.
```
crashing_weights([[1, 2, 3],  --> [[1, 2,  ],      [[1,  ,  ]],
                  [2, 3, 1],  -->  [2, 3, 4],  -->  [2, 2,  ],
                  [3, 1, 2]])      [3, 1, 2]]  -->  [3, 4, 6]]

therefore return [3, 4, 6]
```

## More details

boxes can be stacked to any height, and the crashing effect can snowball:
```
[3]
[2]     [5]
[4] --> [4] --> [9]
```
Crashing should always start from as high up as possible -- this can alter the outcome! e.g.
```
[3]                      [3]
[2]     [5]              [2]     [3]
[1] --> [1] --> [6], not [1] --> [3] 
```
Weights will always be integers. The matrix (array of arrays) may have any height or width > 1, and may not be square, but it will always be "nice" (all rows will have the same number of columns, etc).

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def crashing_weights(weights):
	

Solutions:
from functools import reduce

def crashing_weights(weights):
	return reduce(lambda a, b: [a1 + b1 if a1 > b1 else b1 for (a1, b1) in zip(a, b)], weights)


def crashing_weights(weights):
	lst = [0] * len(weights[0])
	for line in weights:
		lst = [b if a <= b else a + b for (a, b) in zip(lst, line)]
	return lst


def crashing_weights(weights):
	if len(weights) < 2:
		return weights[0]
	result = []
	for row in zip(*weights):
		cur = row[0]
		for nxt in row[1:]:
			cur = cur + nxt if cur > nxt else nxt
		result.append(cur)
	return result


from itertools import *

def crashing_weights(arr):
	arr = list(zip(*arr))
	return [list(accumulate(i, lambda x, y: x + y if x > y else y))[-1] for i in arr]


from functools import reduce

def crashing_weights(weights):
	return [reduce(lambda x, y: x * (x > y) + y, pile) for pile in zip(*weights)]


def crashing_weights(a):
	li = [list(i) for i in zip(*a)]
	for i in range(len(li)):
		for j in range(len(li[i]) - 1):
			if li[i][j] > li[i][j + 1]:
				li[i][j + 1] += li[i][j]
				li[i][j] = 0
	return [list(i) for i in zip(*li)][-1]


from functools import reduce

def crashing_weights(weights):
	return reduce(crash_if_heavier, weights)

def crash_if_heavier(upper_row, lower_row):
	return [wl if wu <= wl else wu + wl for (wu, wl) in zip(upper_row, lower_row)]


def crashing_weights(weights):
	w = zip(*weights)
	ans = []
	for i in w:
		i = list(i)[::-1]
		while len(i) > 1 and i != sorted(i, reverse=True):
			for j in range(len(i) - 1, 0, -1):
				if i[j - 1] < i[j]:
					i[j - 1] += i[j]
					del i[j]
					break
		ans.append(i[0])
	return ans


def crashing_weights(weights):
	r = []
	for t in zip(*weights):
		l = list(t)
		for i in range(1, len(l)):
			if l[i - 1] > l[i]:
				l[i] += l[i - 1]
		r.append(l[-1])
	return r