Ad
  • Custom User Avatar
  • Custom User Avatar

    What unexpected behaviour are you talking about here? The ECMA specification says that the radix will default to 10 unless the string starts with "0x", which can't happen here as all non-numeric characters are removed.

    If radix is undefined or 0, it is assumed to be 10 except when the number begins with the code unit pairs 0x or 0X, in which case a radix of 16 is assumed. If radix is 16, the number may also optionally begin with the code unit pairs 0x or 0X.

    https://262.ecma-international.org/12.0/#sec-parseint-string-radix

  • Custom User Avatar

    I am, I look for it!

  • Custom User Avatar

    Of course, as long as you are ok with your code having unexpected behavior :D

  • Custom User Avatar

    I should do what I fancy to.

  • Custom User Avatar

    You should always provide radix (10 in this case) as the second argument to parseInt.

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt

  • Default User Avatar

    I don't understand also to anOver(n) and anOverAverage(n).

  • Custom User Avatar

    I agree, it is hard to understand what author actually expects from us for each function.

  • Default User Avatar

    Agreed. Description is unintelligable to me. Will have to skip this one.

  • Default User Avatar

    I must totally agree. Either I'm too stupid to understand this instruction or it's written too poorly. I wrote the code. I think it's correct. I think the result it gives back is correct (double checked it manually), but it's not (according to tests). I have no clue why and instruction does not clarifies this for me.

  • Default User Avatar

    Sorry, this kata's description is just written too poorly. Additionally, I don't think the test cases are all correct (for JavaScript at least).

    Consider this:

    Looking at the primes in gn(104) give:

    [5, 3, 11, 3, 23, 3, 47, 3, 5, 3, 101, 3]
    

    Sorting and removing duplicates yields

    [3, 5, 11, 23, 47, 101]
    

    So, if you want us to define a function p(n) that returns n unique primes, it might make sense where

    p(6) = [3, 5, 11, 23, 47, 101];
    

    However, if you look at the primes in gn(105), you get

    [5, 3, 11, 3, 23, 3, 47, 3, 5, 3, 101, 3, 7]
    

    Removing duplicates and sorting yields

    [3, 5, 7, 11, 23, 47, 101];
    

    So in this case, using a larger n in our gn(n) function gave us more primes (in this case, it added 7). So who's to say that p(6) shouldn't be

    p(6) = [3, 5, 7, 11, 23, 47];
    

    That satifies the definition of "return n unique prime numbers."

    Not knowing how to seed the gn(n) function gives us a non-deterministic p(n), which makes maxp(n) just trying to guess what you want.

    Not to mention, I have no idea what anOver(n) is supposed to do, as well as anOverAverage(n)

  • Default User Avatar

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

  • Default User Avatar

    I like this one the best, this kata screams for recursion, and you hit the nail on the head.

    Here is how it "snakes" through this sample city each step of the way (notice how the 8's on the right side don't get infected):

    var city = [
     [8, 8, 8, 8, 8, 7, 8],
     [1, 1, 1, 1, 8, 7, 8],
     [8, 8, 8, 1, 8, 7, 8],
     [8, 1, 1, 1, 8, 7, 8],
     [8, 8, 8, 8, 8, 7, 8]];
    
    [[1,0,0,0,0,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0]]
    
    [[1,1,0,0,0,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0]]
    
    [[1,1,1,0,0,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0]]
    
    [[1,1,1,1,0,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0]]
    
    [[1,1,1,1,1,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0]]
    
    [[1,1,1,1,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0]]
    
    [[1,1,1,1,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,0,0,0],
     [0,0,0,0,0,0,0]]
    
    [[1,1,1,1,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,0,0,0]]
    
    [[1,1,1,1,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,1,0,0]]
    
    [[1,1,1,1,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,1,1,0,0]]
    
    [[1,1,1,1,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,1,1,1,0,0]]
    
    [[1,1,1,1,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,1,0,0],
     [0,1,1,1,1,0,0]]
    
    [[1,1,1,1,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,1,0,0],
     [1,1,1,1,1,0,0]]
    
    [[1,1,1,1,1,0,0],
     [0,0,0,0,1,0,0],
     [0,0,0,0,1,0,0],
     [1,0,0,0,1,0,0],
     [1,1,1,1,1,0,0]]
    
    [[1,1,1,1,1,0,0],
     [0,0,0,0,1,0,0],
     [1,0,0,0,1,0,0],
     [1,0,0,0,1,0,0],
     [1,1,1,1,1,0,0]]
    
    [[1,1,1,1,1,0,0],
     [0,0,0,0,1,0,0],
     [1,1,0,0,1,0,0],
     [1,0,0,0,1,0,0],
     [1,1,1,1,1,0,0]]
    
    [[1,1,1,1,1,0,0],
     [0,0,0,0,1,0,0],
     [1,1,1,0,1,0,0],
     [1,0,0,0,1,0,0],
     [1,1,1,1,1,0,0]]
    
  • Default User Avatar

    Seriously, this part is really dumb. Why would [2,4] return [2,null]? Why should it return [2,2]?

    Probably because their internal test uses some dumb recursive method that doesn't take this in consideration.

  • Default User Avatar

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

  • Loading more items...