Ad
  • Default User Avatar

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

  • Custom User Avatar

    Sample test contains an incorrect test case that doesn't appear in the actual tests:

        it("should return two solutions in some situations", function()
      areSimilar({-1, 0}, {0, -1}, moveMaker(-2,-2,4,8)) end)
    
  • Default User Avatar

    all single digits are narcisitic because anything to the first power is equal to itself or
    x^1 = x

    7 is narcisitic because of the following.
    7 has one digit so I sum that one digit raised to the first power

    start = 7  
    sum = 7^1  
    print (start == sum)
    -- true
    

    for comparison

    start = 20
    sum = (2^2 + 0^2)
    print (start == sum)
    -- false
    
  • Default User Avatar

    IDK what language you are using, but are you taking a string and seperating the characters into an array of numbers?

    If so, then your numbers may be encoded as ascii numbers and are being turned into their integer equivalents, which would explain the constant shift.

    With so little information, and no code to read, that is all I can guess about.

  • Default User Avatar

    Sorry, I meant to point out that you can recompute the sqrt every time you find a divisor to further shrink the iteration count. See my solution.
    While figuring out how to format my critique, I think I forgot the reason I started writing it, and ended up spewing some nonsense.
    I'm not very good at giving advice or tips or knowing when to give any, and would love any input on how to improve.

    Sent from my IPhone

  • Default User Avatar

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

  • Default User Avatar

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

  • Default User Avatar

    Because what kind of language would have built in to hex functionality? ;p

  • Default User Avatar

    Your solution for median time is really cool. I simply halfed it and then floored one and ceiled the other, which isn't as cool as your solution. I also like the way you do format strings, putting parethesis around a string and then calling format with it. I think it looks nicer than string.format("")

    If there was one thing I would change it is that you don't store the size of times. You only need to calculate it once since you don't change its size after you fill it. You used #times in 5 different places without the size ever changing. You could have used it once and put it in a variable, and then used the variable.

    The other thing I really liked about your solution was how you added the sums together while retrieving them so that you could calculate the mean without a seperate for loop for adding all the sums together.

    One thing I didn't like so much was that you used times\[#times+1] = time instead of table.insert(times, time)

    The last thing that I thought you did better was put the format function outside of the main function, I put it inside, meaning I was recreating the format function with every call of the main function.