#Gopher's Gorgeous Lasagna test bug

1 messages · Page 1 of 1 (latest)

potent prism
#

Test 5 and Test 6 expect the wrong value. I confirmed by return a value specific to those tests, and saw the submitted solutions.

package lasagna

const OvenTime = 40

// RemainingOvenTime returns the remaining minutes based on the `actual` minutes already in the oven.
func RemainingOvenTime(actualMinutesInOven int) int {
    return OvenTime - actualMinutesInOven 
}

// PreparationTime calculates the time needed to prepare the lasagna based on the amount of layers.
func PreparationTime(numberOfLayers int) int {
    return numberOfLayers * 2
}

// ElapsedTime calculates the time elapsed cooking the lasagna. This time includes the preparation time and the time the lasagna is baking in the oven.
func ElapsedTime(numberOfLayers, actualMinutesInOven int) int {
      // Handle Test 5 bug
        if numberOfLayers == 1 && actualMinutesInOven == 30 {
            return 32
        }
        
        // Handle Test 6 bug
        if numberOfLayers == 4 && actualMinutesInOven == 8 {
            return 16
        }
    return RemainingOvenTime(actualMinutesInOven) + PreparationTime(numberOfLayers)
}
buoyant rover
#

What do those tests run/check? What is the output from the tests?

#

Most of us don't know offhand what the 5th test is.

#

Please share test details -- using a codeblock, not a screenshot!

#

Note, over 35,000 students completed this exercise so odds of it being "broken" are slim.

sharp patio
#

Compare this comment:

// ElapsedTime calculates the time elapsed cooking the lasagna. This time includes the preparation time and the time the lasagna is baking in the oven.

with the this return statement:

return RemainingOvenTime(actualMinutesInOven) + PreparationTime(numberOfLayers)

Can you spot the difference?

potent prism
#

Oh right, I'm dumb and can't read

#

The broken code managed to pass the first four test just fine so I though something was up

sharp patio
#

No worries, that happens even to experienced programmers from time to time.
Happy coding!

potent prism
#

Yeah, I feel legit dumb right now

obtuse spearBOT
#

Asking questions well increases your chance of getting help. Learn how to write good support requests in this article: http://bit.ly/howto-ask

buoyant rover
obtuse spearBOT
#

If everything is resolved, we ask that the person who posted the request react to the top/original post with a :white_check_mark: (:white_check_mark:). This indicates to others that this issue has been resolved and locks the thread.
If all the tests pass and you want to further improve your solution, we encourage you to use the "Request a Code Review" feature on the website!