Skip to content

Instantly share code, notes, and snippets.

@popey456963
Created November 5, 2015 14:05
Show Gist options
  • Save popey456963/28378da7f44ac28be822 to your computer and use it in GitHub Desktop.
Save popey456963/28378da7f44ac28be822 to your computer and use it in GitHub Desktop.
Adding Squares
line = []
n = int(input())
for i in range(n):
line.append(input())
if len(line) != 1:
a = sum([int(i) for i in line[0].split()])
b = sum([int(i) for i in line[n-1].split()])
c = 0
for i in range(len(line)-2):
data = [int(i) for i in line[i+1].split()]
c+=data[0]
c+=data[n-1]
print(a+b+c)
else:
print(line[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment