It's a somewhat interesting question to ponder, but I don't think it involves much in the way of fractions.
To clarify, I would guess the intent is that the barn and garden are both rectangular, and that the shared wall is an entire side of the barn and an entire side of the garden. And I suppose "the greatest length" means "the greatest possible length, considering all possible barns and gardens fitting this description", since there is only one shared wall, not several to be compared.
Then, my first question would be, how wide does a garden have to be, to be still considered a garden?