Ad
  • Default User Avatar

    I think You could make while factor <= n/2, since math.floor(500/(250*5)) for example will be 0 anyway

  • Default User Avatar

    Lua:

    You can cheat with the last booleans test by just returning a separate prewritten answer for this case.

    (add more boolean tests or make random boolean tests?)

  • Default User Avatar

    Now that I see everyone else's solutions, I realize I'm so beyond repair...

  • Default User Avatar

    Lua

    my answer lies in the lastdigits[i]

    this passes the time limit:

    print(i, lastdigits[i])
    return 0 
    

    this does not:

    print(i, lastdigits[i])
    return lastdigits[i]
    

    It doesnt seem to be an optimization problem, because the code doesnt pass the time limit only when i return the table element, but I can call it anywhere else in the code for however many times and there will be no problem

  • Default User Avatar

    Lua.

    My answer is lies in an array b, so the return value is table.concat(b)

    Last two lines of the code:

     print("answer = " .. table.concat(b))
      return(table.concat(b))
    
    

    what I get:

    Log:

    answer = dmkyeCSddyGacrHsmufzNtbxrWihibkCxgdzyqpgAqdnk

    and

    Expected objects to be equal.
    Passed in:
    (string) 'dmkyeCSddyGacrHsmufzNtbxrWihibkCxgdzyqpgAqdnk'
    Expected:
    (string) 'dmkyeCSddyGacrHsmufzNtbxrWihibkCxgdzyqpg-aqdnk'
    
    

    The answer seems to be correct, but the random test tests my answer against an incoorect value - the result string can't have dashes

  • Default User Avatar

    same thing. all the tests work, but random test fails for some reason, as if it expects the output to be the original string

    Passed in:
    (string) 'jXhvjapjGxLambXinoLrbvevsmLiFtcrtoBqtoLqpmmtifg'  
    Expected:
    (string) 'jXhvjapjGxLambXinoLrbvevsm_liFtcrtoBqtoLqpmmtifg'
    
    
  • Default User Avatar

    ** including the SET itself, so i remove it