Ad
  • Custom User Avatar

    Hi,

    I've tried multiple things and am unable to replicate the issue (in Python).

    1. Using print(n) will correctly output the input in the log.
    2. Incorrect outputs are displayed verbosely, i.e. n = 86: 86 should equal (1, 101)

    Please open another issue with more information if you believe it is still occurring.

  • Custom User Avatar

    I believe I have fixed this and added 'closeTo' assertions using expects' in-built methods.

    The only errors are logical errors when the gallery width is >= 700.

  • Custom User Avatar

    Hey, you said that this is the solution? But "setUpGallery" isn't named correctly, the values are rounded, and the Image objects aren't returned as rows.

    Can you please provide the updated code where you got the 'floating point error'.

    This will prevent me from wasting time trying to recreate your solution and getting it wrong.

  • Custom User Avatar

    Could you please send your solution over so I can look into it further? Post it in Discord at "help-author" if that is better.

    @theunbeatableant

  • Custom User Avatar

    Although... that might be quite complicated to do with a 2D array of Image objects. If I were to implement fuzzy assertion, then I would appreciate any guidance you could give.

  • Custom User Avatar

    I could implement a 0.001 tolerance on either side of the expected value, that will definitely fix the errors.

    However, is you solution supposed to give the correct answers? If so, I will implement that now and that should fix everything.

  • Custom User Avatar

    Hi Voile, massive thanks for the clear and detailed explanation.

    1. OOP structure changed to a JavaScript function.
    2. Used .to.deep.equal() instead of JSON.stringify()
    3. Added chai.config.truncateThreshold = 0
    4. Changed return output to 2D array of Image objects.

    Hope this fixes any issues you raised :)

  • Custom User Avatar

    I made sure to remove the Math.round() from the solution and it looks like the solution is no longer passing the tests!

    (The actual image dimensions are different even though the return output is now a 2D array)

  • Custom User Avatar

    Perhaps I should use truncation instead to avoid language inconsistencies?

  • Custom User Avatar

    Ahh I was unaware that rounding could be mistaken for truncating, but after searching online I really can't find any sources where truncating is mistaken for rounding. I believe that using the term 'rounding' is appropriate when talking about rounding up or down based on whether the decimal part is >= 0.5 or < 0.5. x.5 should be rounded up :)

    Since my kata is about web development, it should just be for JavaScript, but yes I will take your comment about different languages into consideration.

    With regards to the applicable order of operations I was thinking of 2 methods:

    • Rounding their returned answer, so they just return their float result
    • Telling them to round the width/height after all calculations

    Surely rounding after all calculations should be fine? If I have done the same anyways.

  • Custom User Avatar

    I've go with rounding! Hopefully I won't come across any other issues, but if I do I will head over to the Codewars Discord :)

    Reasons for choosing rounding:

    • More realistic than truncation (for values like 12.999999, truncation will result in 12 rather than 13).
    • In this context, if the row is greater than the gallery width, css overflow hidden or flexbox can be used to mitigate the issues presented by these few pixels.
  • Custom User Avatar

    Yeah I was very confused with what to do regarding the floating point values.

    Could you please elaborate further with what you mean by using rational numbers? Perhaps I could add a ± 0.5 error in the tests? I would prefer to use integers, but of course the integer divisions may result in recurring decimals???

  • Custom User Avatar

    I think I've fixed this... Please correct me if the tests can still be bypassed!

  • Custom User Avatar

    Sounds pretty confusing, thanks for both your responses 👍

  • Custom User Avatar

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

  • Loading more items...