Ad
  • Custom User Avatar
  • Custom User Avatar

    approved by someone?

  • Custom User Avatar

    The module blocker is a fix to be applied to old kata, not something to include in new ones.

  • Custom User Avatar

    I've just enabled all modules. Now they can be feel free to use.

  • Custom User Avatar

    I'll have to bite: this kata is effectively just asking to calculate determinants without Laplace expansion.

    Besides the fact that it's not very novel, the fact that you have to ban all modules (besides things like math. Yes, fractions is banned too for some reasons) means that Python is not the language you want to write this kata in.

    Write the kata in a language more suitable for what you want, like JS or C++. Don't cripple the runtime with ridiculous hacks instead just to barely achieve the same thing. Module blockers are only used because certain Python users aren't willing to learn another language to write their katas in; they aren't supposed to be supported, and when it breaks in the future, someone will have to maintain it (which clearly won't be you, as you don't appear to know how it works, or that it has a glaring flaw as it currently stands).

  • Custom User Avatar

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

  • Custom User Avatar

    Resolved.

  • Custom User Avatar

    Alright my thought process was incorrect. Thanks for the fast response you are 100 % correct. I did not realise i and j can be the same to solve this. That was my problem. Resolved.

  • Custom User Avatar

    I just solved the kata in JS with my solution from other languages and I have no good idea what this issue is about. Everything seems to work as expected? Broken formatting in the original post is not helpful either.

  • Custom User Avatar

    I'm not really sure I understand your issue, but it seems like a code issue to me. You can represent 4 as 2 + 1 + 1, just like you can represent 16 as 8 + 4 + 4, and 256 as 128 + 64 + 64. I guess your assumption is wrong..?

  • Custom User Avatar

    According to instructions tests are invalid for 2 to the power of any number in JavaScript:

    Write a function that accepts a number, and checks it can be represented as a sum of exactly 3 powers of 2. (n == 2i + 2j + 2**k, i, j, k >= 0)

    --> Since 2 ** 0 = 1, then as far as I can tell you cannot have a value as true which is 2 ** i where i is the value that obtains the number in the test since then you still have + 1 and + 1 for + 2 extra. This needs to be dealt with since: "n = 4: expected false to equal true " is not correct nor 256 or 1024, etc <--

    For example:

    three_powers(2) # False
    three_powers(3) # True, 3 = 20 + 20 + 20
    three_powers(5) # True, 5 = 2
    0 + 21 + 21
    three_powers(15) # False
    Input
    1 <= n <= 2 ** 512 - 1
    There are 100 performance tests in languages with arbitrary precision integers, and a huge amount in C/Lua.

    Note to translators: this kata should NOT be translated into any languages without arbitrary precision integers, as the performance requirements are not guaranteed to be properly enforceable.

    If you need I can provide my code for testing purposes since the only ones it fails are the ones which are incorrectly labeled as true for 2 to the power of a single value. Just tell me how.

  • Custom User Avatar

    There is a trick to do it, which doesnt require searching for every possible combination. Hint: think about why its specifically powers of 2?

  • Custom User Avatar

    I can understand how to do it. My function work with small number, but when the input number = 2**69 and higher, than it always return false and note "Exiting potential infinite loop". Who know what to do? I'm coding in JavaScript

  • Custom User Avatar

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

  • Custom User Avatar

    It's written in maths, not C#, so it expands to 1 <= n AND n <= 2^64-1. ( Python understands the a <= b <= c syntax like that, but lots of other languages require the AND. )

  • Loading more items...