id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

james.shockey@austinisd.org lasa_drills_01 > LASA_crossbarCalc
prev  |  next  |  chance

LASA_crossbarCalc The first line of your solution should be:
    int[][] arr = {row1, row2, row3, row4, row5, row6};

A method takes a 2D array as input. A crossbar is in an array is a portion shaped like this:

a b c
  d
e f g

For example, if we create a crossbar with the number 1 within an array full of zeros, it may look like this:

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

Actually, there are many crossbars in the array above. The three leftmost crossbars are the following:
1 1 1  1 1 0   1 0 0
  1        0        0
1 1 1   1 1 0  1 0 0

The sum of a crossbar is the sum of all the numbers within it. The sum for the crossbar above is 7, 4, and 2, respectively.

In this problem, you have to calculate the largest sum among all the crossbars in the array.


LASA_crossbarCalc([0, 1, 1, 1, 0, 0], [0, 0, 6, 0, 0, 0], [0, 1, 1, 1, 0, 0], [0, 9, 2, -4, -4, 0], [8, 0, 0, -2, 0, 0], [0, 0, -1, -2, -4, 0]) → 19
LASA_crossbarCalc([1, 1, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0], [0, 0, 2, 4, 4, 0], [0, 0, 0, 2, 0, 0], [0, 0, 6, 2, 4, 0]) → 24
LASA_crossbarCalc([1, 1, 1, 0, 0, 1], [0, 1, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0], [0, 0, 2, 4, 4, 0], [0, 0, 0, 2, 0, 0], [0, 0, 1, 2, 4, 0]) → 19

...Save, Compile, Run (ctrl-enter)

int LASA_crossbarCalc(int[] row1, int[] row2, int[] row3, int[] row4, int[] row5, int[] row6) }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Copyright Nick Parlante 2017 - privacy