Ad
  • Custom User Avatar
  • Default User Avatar

    You are trying to declare an int variable with a double value, which obviously won't work.
    However, in this case it works, because compilator knows that the type of sum variable is int and it just casts it to int. Since the result of pow is an integer (double), nothing special happens, but if the result were a non-integer, then the decimal part of the method's result would be truncated (100.18 would be 100, 11.254 would be 11, 1.0 would be 1, and so on, and so on...).

    I know this comment is 7 months old, but I wanted to clear it up.

  • Custom User Avatar

    That is correct, why does this code work. It shouldn't at all.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Tests "TestAdvanced" and "TestRandom" takes function output as expected value. This introduces confusion as it is unclear what test is actually expecting without knowing this fact.

    if (stream.Length == 444){
      return new byte[444] {77,110,114,100,108,32,105,112,114,117,108,32,100,110,109,110,115,33,114,104,116,32,97,108,100,116,45,32,98,110,111,114,101,98,117,100,116,116,115,32,97,100, 255 ,112,104,114,99,104,110,103,32,100,108,104,117,44,33,115,100,100,32,100,111,32,100,104,117,114,108,110,101,32,117,100,109,112,110,114,33,104,111,98,104,100,104,100,117,110,116,33,116,116,32,108,97,98,111,115,100,32,100,116,33,100,110,108,111,114,100,32,109,96,103,110,97,32,96,108,105,112,117,96,46,32,84,116,33,100,110,105,108,32,96,100,33,108,105,111,104,108,32,118,101,110,104,96,109,44,32,112,117,104,115,32,111,110,114,116,115,116,101,32,100,120,100,114,99,104,116,97,116,104,110,110,33,116,109,109,96,108,98,110,33,108,96,98,111,114,104,114,33,110,105,114,105,32,116,116,33,96,109,104,112,116,104,112,33,100,120,33,100,96,32,98,111,108,109,111,100,110,32,98,111,110,114,100,113,116,96,116,47,32,69,116,105,114,32,96,117,116,101,32,104,114,116,114,101,32,100,111,108,110,114,32,105,110,33,115,100,112,114,100,105,100,110,100,101,114,104,116,33,104,111,32,119,110,108,116,113,116,97,116,100,32,118,100,109,104,116,33,100,114,114,100,33,98,105,109,108,116,108,32,101,110,108,110,115,100,32,100,117,32,103,116,103,104,96,116,33,110,117,108,108,96,32,112,97,114,104,97,116,116,114,46,33,68,121,99,100,112,116,100,117,114,32,114,105,110,116,32,111,98,99,96,101,98,96,116,33,98,117,112,104,100,96,116,97,116,32,111,110,110,32,112,115,110,105,101,100,110,116,44,33,114,116,110,117,32,104,110,33,98,117,108,113,96,32,112,117,104,33,110,102,102,104,98,105,96,32,101,100,114,100,114,117,110,117,33,108,110,108,108,105,116,32,96,111,104,108,32,105,100,33,100,115,116,32,108,97,98,111,114,116,108};
    }
    
    // Expected and actual are both <System.Byte[444]>
    //   Values differ at index [42]
    //   Expected: 255   <- returned by function
    //   But was:  105   <- actually expected value