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 , ...
This problem is all about unit testing. Your company needs a function that meets the following requirements: For a given array of integers, the function returns the index of the element with the minimum value in the array. If there is more than one element with the minimum value, the returned index should be the smallest one. If an empty array is passed to the function, it should raise an Exception. Note: The arrays are indexed from . A colleague has written that function, and your task is to design separated unit tests, testing if the function behaves correctly. The implementation in Python is listed below (Implementations in other languages can be found in the code template): def minimum_index ( seq ): if len ( seq ) == 0 : raise ValueError ( "Cannot get the minimum value index from an empty sequence" ) min_idx = 0 for i in range ( 1 , len ( seq )): if a [ i ] < a [ min_idx ]: mi...
Comments
Post a Comment