Question 4: Determine extents 

r, c, min_r, max_r, min_c, max_c = 0, 0, 0, 0, 0, 0

for line in open('path.txt'):
    for cmd in line:
        if cmd == 'N': r -= 1
        if cmd == 'S': r += 1
        if cmd == 'W': c -= 1
        if cmd == 'E': c += 1
        if r < min_r: min_r = r
        if r > max_r: max_r = r
        if c < min_c: min_c = c
        if c > max_c: max_c = c

print("min_r: {} max_r: {} min_c: {} max_c: {}".format(
    min_r, max_r, min_c, max_c
))

# Ouput: min_r: 0 max_r: 511 min_c: 0 max_c: 1023