Objective Today, we're 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 2D Array , : 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 's graphical representation: a b c d e f g There are hourglasses in , and an hourglass sum is the sum of an hourglass' values. Task Calculate the hourglass sum for every hourglass in , then print the maximum hourglass sum. Input Format There are lines of input, where each line contains space-separated integers describing 2D Array ; every value in will be in the inclusive range of to . Constraints Output Format ...
Objective In this challenge, we're going to learn about the difference between a class and an instance ; because this is an Object Oriented concept, it's only enabled in certain languages. Check out the Tutorial tab for learning materials and an instructional video! Task Write a Person class with an instance variable, , and a constructor that takes an integer, , as a parameter. The constructor must assign to after confirming the argument passed as is not negative; if a negative argument is passed as , the constructor should set to and print Age is not valid, setting age to 0. . In addition, you must write the following instance methods: yearPasses() should increase the instance variable by . amIOld() should perform the following conditional actions: If , print You are young. . If and , ...
Objective Today we're discussing Generics; be aware that not all languages support this construct , so fewer languages are enabled for this challenge. Task Write a single generic function named printArray ; this function must take an array of generic elements as a parameter (the exception to this is C++, which takes a vector ). The locked Solution class in your editor tests your function. Note: You must use generics to solve this challenge. Do not write overloaded functions. Input Format The locked Solution class in your editor will pass different types of arrays to your printArray function. Constraints You must have exactly function named printArray . Output Format Your printArray function should print each element of its generic array parameter on a new line. Solution : import java.util.*; class Printer <T> { ...
Comments
Post a Comment