The challenge explanation was really clear but I just want to know why does x have to be less than or equal to y?
-
Module 2 Week 4 Day 14 Challenge Part 3
The challenge explanation was really clear but I just want to know why does x have to be less than or equal to y?
-
@The-Darkin-Blade Good question! It's just for organizational purposes, actually. We want to sort the different ways that we are trying by setting \(x\) to be the shortest side.
If we didn't have this requirement of \(x \leq y,\) then we might have \(3, 5,\) and \(6,\) as side lengths on our list of things to check in addition to side lengths \(5, 3\) and \(6,\) which are really the same combination.
So, in a nutshell, this requirement ensures that we cover all the cases without doing any of the cases twice!