Ad
  • Default User Avatar

    original solution with dictionnary !
    I think len(l[0]) would be faster (O(1) instead of O(n))

  • Default User Avatar

    Oh, I didn't know putting brackets would keep the sepators in list ! Thank you !

  • Default User Avatar

    This solution seems much better to be than the "best practice/clever" above ones. Lets vote for it ahah :)
    Question however : you chose to say it was false if arr[i]>=arr[i+1], I chose to accept it, it seems both pass the tests ?
    The instructions didn't say what to do if arr[i]==arr[i+1]

  • Default User Avatar

    this one is more efficient than the one using sorted !
    you could also compare arr[i] and arr[i+1] to avoid the use of a third variable.

  • Default User Avatar

    slower than necessery, and you kind of loose all the interest of the kata ?

  • Default User Avatar

    shouldn't it also return 0 if n is anything elses than 9 ? (juste trying to understand it correctly)

  • Default User Avatar

    Yes don't worry I don't take it wrong :) I don't know standard at all !
    I put the comment mostly for myself ahah :) to separate things (while I saw you put spaces).

    Same about the return : I know this is useless, but I sometimes find it clearer. I didn't know it was against standard : thank you for teaching me that.

    (Just to be sure : I didn't made the fork about refactoring/because of your presentation, my idea was "ah, he made the same than me (and you gave me the idea of generator, while I did a function) but mine is faster because of this check things, lets see if I can adapt his code to do so too.)
    My fork was not criticizing your presentation, sorry if there where a misunderstanding here :)

  • Default User Avatar

    good idea to stock previous node in a dictionnary instead of copying all path each time as I did !
    It seems a little faster (not sure it is because of that, but I think so ?) with about 650ms against 700-800ms.

  • Default User Avatar

    I needed some time to see why it was working : I was thinking "but you don't check that i is prime number", before I realize that if you start with 2 ans go up, then n can't be divided by non-prime numbers.

    also, I made a very complexe solution to optimize time, but surprisingly the gain is not that big (I use maybe 75% or your time, so... maybe not worth the complexity !)
    I assumed a so simple solution would be to slow and was wrong.

  • Default User Avatar
    • once you imported maths, you can use a function making it shorter
    • also you could replace this if/else thing by something else
  • Default User Avatar

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

  • Default User Avatar
    • do you really need to check each letter of the list to see if pos = i ? couldn't you just do v[i] and check v[i]==val ?
    • do you really need a dict per letter ?
    • if you look further, you may see the pattern and be able to directly reverse it
  • Default User Avatar

    test the encode function ot have an idea of what is going on
    the test already written give hug hints !
    you can also add some tests on your own.
    What do you observe with aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ?
    what about bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb ?

  • Default User Avatar

    really fun, but I think maybe too easy for 3 kyu (more 5 or 4 kyu)

  • Default User Avatar

    I like the "bird bird bird" effect induced by the choice of name ahah :)

  • Loading more items...