Ad
  • Default User Avatar

    make sure your types can fit your values

    your rounding error probably comes from involving f64, python:

    >>> int(float(9**19))
    1350851717672992000
    

    likewise, make sure you use a large enough integer type - for example, 1350851717672992000 barely fits in a 64-bit int but not in a 32-bit int, and if you were to go a bit bigger than that you would overflow the 64-bit int as well

  • Default User Avatar

    Have you resolved it? I have the same problem

  • Default User Avatar

    Strange with Swift.
    Tests with very large numbers do not pass. In Xcode, for example, the number 35875699062250035 outputs as false. Moreover, if I do print, then the last received number, which is raised to a power, differs by 2 digits - 35875699062250037
    Does anyone know what the problem is?

  • Custom User Avatar

    You've already been told that code working in another version of Swift and not in the one available is not a kata issue. Please don't open more issues about that. Your code has a problem too, it won't work when called several times in a row.

  • Default User Avatar

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

  • Custom User Avatar
  • Custom User Avatar

    I tried your code in some REPLs and indeed it seems to compile fine on Swift 5.8, but not on Swift 5.3. However, it is not an issue with the kata itself, but rather with general setup of Swift on Codewars. I created this ticket as a follow-up: https://github.com/codewars/runner/issues/261, and I am going to close this discussion as not a kata issue.

  • Default User Avatar

    Thanks for reply!
    My Xcode version: Apple Swift version 5.8.1
    I think it must work on higner version of Swift

  • Custom User Avatar

    What version of Swift do you use in your XCode? Is it possible to configure your local XCode to use Swift 5.3? Does your solution work locally for you in Swift 5.3?

  • Default User Avatar

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

  • Custom User Avatar

    No answer after 5 months, closing.

  • Default User Avatar

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

  • Custom User Avatar

    What version of Swift are you using locally? Note that this kata uses Swift 5.3. The error seems to be correct, because you have the range "4"..."20" in your code, which is not valid, because "4" is greater than "20" so "4" cannot be a lower bound while "20" is an upper bound.

  • Default User Avatar

    Solution is working in Xcode, but it doesn't working here. Issue with tests

    Fatal error: Can't form Range with upperBound < lowerBound: file Swift/ClosedRange.swift, line 335

  • Custom User Avatar

    Your code is wrong:

    Any values that fall out of that range must be rounded to the closest valid value.

    Not a kata issue.

  • Loading more items...