Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with this Java question. We are given a code to work with and please use Java 8 to answer the question. Here

Please help me with this Java question. We are given a code to work with and please use Java 8 to answer the question.

image text in transcribed

image text in transcribed

Here is a code we are given to work with.

import java.io.*;

import java.math.*;

import java.security.*;

import java.text.*;

import java.util.*;

import java.util.concurrent.*;

import java.util.function.*;

import java.util.regex.*;

import java.util.stream.*;

import static java.util.stream.Collectors.joining;

import static java.util.stream.Collectors.toList;

public class Solution {

public static void main(String[] args) throws IOException {

BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

List> arr = new ArrayList();

IntStream.range(0, 6).forEach(i -> {

try {

arr.add(

Stream.of(bufferedReader.readLine().replaceAll("\\s+$", "").split(" "))

.map(Integer::parseInt)

.collect(toList())

);

} catch (IOException ex) {

throw new RuntimeException(ex);

}

});

bufferedReader.close();

}

}

You are given a 66 2D array. An hourglass in an array is a portion shaped like this: dabcefg For example, if we create an hourglass using the number 1 within an array full of zeros, it may look like this: 101000111000101000000000000000000000 Actually, there are many hourglasses in the array above. The three leftmost hourglasses are the following: The sum of an hourglass is the sum of all the numbers within it. The sum for the hourglasses above are 7, 4, and 2, respectively. In this problem you have to print the largest sum among all the hourglasses in the array. Input Format There will be exactly 6 lines, each containing 6 integers seperated by spaces. Each integer will be between -9 and 9 inclusive. Output Format Print the answer to this problem on a single line

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

0619064625, 978-0619064624

More Books

Students also viewed these Databases questions