Hackerrank “30 Days of Code” Çözümleri – Day 11: 2D Arrays

Hackerrank‘in 30 Days of Code içerisinde bulunan “Day 11: 2D Arrays” sorusunun açıklaması ve çözümü. Bu soruda verilen bir list of list şeklindeki yapıda, kum saati şeklindeki elemanlarının toplamının maksimum değerini bulmanız isteniyor.

► Hackerrank 30 Days of Code Çözümleri – Day 11: 2D Arrays: https://www.hackerrank.com/challenges/30-2d-arrays/problem

► Problem açıklaması:

Objective

Today, we are building on our knowledge of arrays by adding another dimension. Check out the Tutorial tab for learning materials and an instructional video.

Context

Given a 6×6 2D Array, A:

1 1 1 0 0 0

0 1 0 0 0 0

1 1 1 0 0 0

0 0 0 0 0 0

0 0 0 0 0 0

0 0 0 0 0 0

We define an hourglass in to be a subset of values with indices falling in this pattern in A’s graphical representation:

a b c

d

e f g

There are 16 hourglasses in A, and an hourglass sum is the sum of an hourglass’ values.

Task

Calculate the hourglass sum for every hourglass in A, then print the maximum hourglass sum.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.