6 kyu

N in a row

65 of 77Yushi.py
Description
Loading description...
Iterators
  • Please sign in or sign up to leave a comment.
  • goldenratio161 Avatar

    In my opinion, my solution is quite intuitive, which was also the approach displayed in the description. Had I not read about the warning of implementing O(n^2) time complexity, I would have still done the exact same solution. To make the description slightly more concise, may I suggest condensing that section or removing it entirely?

    Edit: nice kata btw :)

  • goldenratio161 Avatar

    completely unrelated to the kata, but to those who know, we want you back, jperm...

  • ahmet_popaj Avatar

    Quite nice and funny kata.

  • JohanWiltink Avatar

    JS translation

    the example solution is not the fastest, but the reference solution is actually a lot better ( example solution runs in ~9 seconds; reference solution in ~3 ), so I hope solvers have a reasonable amount of time for their solution to run.

    minor changes to the description, also because I did not bother to preload iterator.take.

  • JohanWiltink Avatar
    first = randrange(maximum - minimum - total)
    ...
    yield from randoms(1, total + 1, maximum - minimum - first) # Some random extra tests, may be infinite if maximum < 0
    

    this never goes to infinity. there's always at least total left. given the comment, this may not be intentional. also, maximum is never < 0.

    the random tests are heavily overengineered; they are a total pain in the neck to translate. can't that be done simpler?

  • Andrew-Potapchuk1998 Avatar

    Sorry, but its the worst description, that ive ever read

  • custom_concern Avatar

    man, this isn't your daddy's 6 kyu kata lol. good one tho.

  • Kees de Vreugd Avatar

    Surprised to see people here who seem to understand the description. Big pass.

  • dfhwze Avatar

    This is misleading information.

    You're expected to deliver an O(n) solution; further optimization should not be necessary as long as the time complexity constraint is followed.

    I think it's more correct to state O(n logn) or O(n log logn) is expected, and further optimization towards O(n) is not required.

  • Blind4Basics Avatar

    Are you sure the perf constraints are not too much tight? My solution seems to be one of the expected one, but it times out more than half the time.

  • scarecrw Avatar

    The implementation of first_n consumes one extra element from the iterator. You can swap the order of the zip arguments to avoid this.

  • Kacarott Avatar
    • Initial solution should explicitely import the types it needs
    • Should explicitely import preloaded in initial solution
    • (suggestion) I think ideally in preloaded, your imports should happen inside first_n to avoid leaking imports to solvers
  • KayleighWasTaken Avatar

    Could do with having fixed tests which expect None.

    Would ideally cover all three cases of len(placements) > n, len(placements) == n, and len(placements) < n.