publicboolFitIn(inta,intb,intm,intn){//both squares (added) must fit into the long side of the rectangle AND//the bigger single square must fit into the short side of the rectangleintlongSide=Math.Max(m,n);intshortSide=Math.Min(m,n);intaddedSquareLengths=a+b;intbiggerSingleSquareSize=Math.Max(a,b);//do they fit?boolfitsLong=addedSquareLengths<=longSide;boolfitsShort=biggerSingleSquareSize<=shortSide;returnfitsLong&&fitsShort;}
I know, it's a bit verbose, but very self explanatory. A short version will look like this:
The long side is the obvious case, but what if
=> FitIn(1,2,3,1)?
in C#
I know, it's a bit verbose, but very self explanatory. A short version will look like this: