exercism / swift

Exercism exercises in Swift.
https://exercism.org/tracks/swift
MIT License
113 stars 158 forks source link

Solution in Layer's Of Lasagna [Swift] #576

Open kamarceneaux opened 2 years ago

kamarceneaux commented 2 years ago

The solution for Test #4 is expecting "25" as it's answers, however the correct answer should be 39. Could be a error with the way the test code was written.

ErikSchierboom commented 2 years ago

Could you indicate why you think it is incorrect? totalTimeInMinutes(layers: 6, elapsedMinutes: 13) has 6 layers, which means that 6 * 2 minutes per layer = 12 and then add 13 = 25.

quixoticraindrp commented 1 year ago

Because if you send remainingMinutesInOven a value for elapsedMinutes of 13, the output of remainingMinutesInOven is 27: expectedMinutesInOven starts at 40; 40 - 13 (elapsed time) = 27 ; 12 + 27 = 39.

quixoticraindrp commented 1 year ago

The test case for expectedMinutesInOven even explicitly expects "27" as the correct return value. The expected return value for totalTimeInMinutes can't be 25 for the values given, which are the same as the values given to test the other two functions, and those tests pass with those values while the final test does not, even with the same values.

quixoticraindrp commented 1 year ago

I think this is actually a bit of confusion, however. The third function seems to imply asking for the sum of the output of the first two functions, and that seems logical; however, what it is actually asking for is a sum of the output of the second function and the argument for "elapsedMinutes". I think at least part of this confusion is that the second parameter for totalTimeInMinutes is identical to the parameter for remainingMinutesInOven, implying that it is the output of the function remainingMinutesInOven that should be used, when in fact elapsedMinutes in the function totalTimeInMinutes is supposed to be a constant Int value instead.

IMO the right solution here is to change "elapsedMinutes" in the third function to be some other name. It invites confusion to use identical labels for two different concepts.