CSA Unit 4, Lesson 2, Level 8 example is wrong

If you select the Rubik’s Cube solver exercise, it says you’re finding the fastest solver, but then requires the following:
/* ----------------------------------- TO DO -----------------------------------
* :white_check_mark: Check if the parameter time is greater than fastestTime. If this is true,
* update fastestTime to the value passed to the parameter time.
* -----------------------------------------------------------------------------
*/

This will result in fastestTime taking on the largest time, which for any regular definition of time means it’s the slowest. I used the example solver list and, sure enough, it picks the slowest, Tanzer, as the person with the “fastest time”.

The lesson lets me complete with this idea. Switching the initial value of fastestTime to 65535 and the comparison to the following:

if(fastestTime > time){
  fastestTime = time;
  System.out.println(Integer.toString(time));
}

results in the fastest time being selected (363 centiseconds), but the code fails the built-in tests because they expect the incorrect comparison to have been used.

Hi Travis,
Thank you for alerting the community to this issue! I agree that the wording is confusing, and that it is actually finding the slowest solver, since that is the longest time. Posting here will help other teachers to be aware of this issue as they plan. To alert the curriculum team with typos or similar errors, emailing support@code.org, or clicking on the rate the lesson button on the unit overview page will get the message to them.

Thank you,
Lindsay

1 Like