---
# System prepended metadata

title: WDI zadanie 6 lista 9

---

---
title: WDI zadanie 6 lista 9
---

```python=

from wdi import Array

def traverse(n, a):
    tab = Array(n, n)
    tab[0][0] = a[0][0]

    for k in range(1, n):
        tab[0][k] = tab[0][k-1] + a[0][k]

    for w in range(1, n):
        tab[w][0] = tab[w-1][0] + a[w][0]

    for w in range(1, n):
        for k in range(1, n):
            gorny = tab[w-1][k]
            lewy = tab[w][k-1]
            if lewy > gorny:
                minimum = gorny
            else:
                minimum = lewy
            tab[w][k] = a[w][k] + minimum

    return tab[w][k]

m = [
    [10, 9, 31],
    [21, 7, 8],
    [13, 14, 10]
]

print(traverse(3, m))

```