Box It!

Sort by

recency

|

453 Discussions

|

  • + 0 comments

    What is the input format?? The problem is incomplete

  • + 0 comments

    Here is Box It! problem solution in C++ - https://programmingoneonone.com/hackerrank-box-it-solution-in-cpp.html

  • + 1 comment

    what needs to be called in the main function? There is no definition of it in the problem, thta is causing the test cases to fail.

  • + 0 comments

    C++20 is "broken". One can define the default constructor as

    Box() = default;

    All members will then be initialized to default value, i.e.: int => 0

    But if you do that instead of: Box(): l{0}, b{0}, h{0} {}, several testcases will fail.

    And the same applies to the default copy constructor. Given that is "clang", the compiler switches are not porperly applied.

  • + 0 comments

    Python main learning C++ 🤪

    class Box{
        private:
            int l;
            int b;
            int h;
        public:
            Box(){
                l = 0;
                b = 0;
                h = 0;
            }
            
            Box(int length, int breadth, int height){
                l = length;
                b = breadth;
                h = height;
            }
            int getLength(){
                return l;
            } 
            int getBreadth(){
                return b;
            }
            int getHeight(){
                return h;
            }
            long long CalculateVolume(){
                return static_cast<long long>(l)*b*h;
            }
            
            bool operator<(Box& other) const{
                if(l < other.l){
                    return true;
                }
                else if(b < other.b && l == other.l){
                    return true;
                }
                else if(h < other.h && b == other.b && l == other.l){
                    return true;
                }
                
                return false;
            }
            
            friend ostream& operator<<(ostream& os, const Box& other) {
                os << other.l << " " << other.b << " " << other.h;
                return os;
            }
            
    };