Ad
  • Custom User Avatar

    thx, for good explenation. Description isn't so good for understanding.

  • Custom User Avatar

    There is a typo in the instructions.. instead of saying 'such as' it should read 'such that'.

  • Default User Avatar

    Every coding people should or could know that modulo 2 sum of numbers or sum of these same numbers cubed both give the same result:-) So it's up to the coder to choose... unless he/she did it because he/she did not correctly read the description (unfotunately this often happens).

  • Custom User Avatar

    I think you're right there, parity won't change with pow (unless the power is 0)

  • Default User Avatar

    Done. Though I'm not sure if you can test for this actually. Like if you cube an even number, wouldn't you always get an even number, and vice versa?

  • Default User Avatar

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

  • Custom User Avatar

    Do you mean your solution used the sum of the digits instead of the sum of the cubes of the digits and it passed the tests in Swift? If that's true, open an issue saying that.

  • Custom User Avatar

    Hm, I might've misinterpreted the rules then, in which case - my bad. The only reason that was my assumption is that my solution didn't involve the cube part. But now that you point this out, it does seems a lot more plausible that that part of the rule just isn't covered in tests, and that I should've followed the instructions better :P

  • Custom User Avatar

    why is "chunk" used interchengably with "cube"?

    Where? They're not. Cube is only used once, and it is used as the mathematical term.

    Your instructions are wrong:

    sum of the cubes of its digits is divisible by 2

    That means, for instance, if you get a chunk of size 3 with the digits 123 as input, the sum of the cubes of its digits is 1 + 8 + 27 = 36 that's divisible by 2 and you should reverse it.

  • Default User Avatar

    The description of this is incomprehensible, far more difficult than the challenge itself (not saying it's easy, just that the description is unreasonably hard). Like why is "chunk" used interchengably with "cube"? Especially since cube is an established mathematical term, which made this even more confusing. Very frustrating.

    Here's my attempt of rewriting this:

    The input is a string of integers and a size integer. Split the string into substrings of the specified size, discarding the remaining characters fewer than the size.

    If the size is 0 or less, or is greater than the length of the string, return "".

    Implement an algorithm transforming each substring as follows:

    • If the sum of the substring's digits is a multiple of 2, reverse that substring ("123" > "321").
    • Otherwise, rotate the substring to the left by one position ("135" > "351")

    Combine the resulting substrings and return the result.

  • Custom User Avatar

    The goal is to basically implement the Brainfuck compiler. Took me a while to understand the problem myself, but I think understanding how the language itself works (rather than just the various commands it has) really helps, I found this video to be a good overview: https://www.youtube.com/watch?v=-3C200nCwpk