Skip to content

Instantly share code, notes, and snippets.

@neonbadger
Created March 20, 2016 23:47
Show Gist options
  • Save neonbadger/c39d6828b4abff79342f to your computer and use it in GitHub Desktop.
Save neonbadger/c39d6828b4abff79342f to your computer and use it in GitHub Desktop.
"""
Hackerrank 2D Array solution.
Improvement: instead of start, find center
x x x
x
x x x
"""
import sys
def get_hour_glass_total(arr, x,y):
total = arr[y][x] + arr[y][x+1] + arr[y][x+2] + arr[y+1][x+1] + arr[y+2][x] + arr[y+2][x+1] + arr[y+2][x+2]
return total
arr = []
for arr_i in xrange(6):
arr_temp = map(int,raw_input().strip().split(' '))
arr.append(arr_temp)
total_list = []
for x in range(4):
for y in range(4):
total_list.append(get_hour_glass_total(arr, x, y))
print max(total_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment