Created
March 20, 2016 23:47
-
-
Save neonbadger/c39d6828b4abff79342f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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