2 kyu

Ludicrous Coloured Triangles

287 of 484rooflack
Description
Loading description...
Puzzles
Mathematics
Algorithms
  • Please sign in or sign up to leave a comment.
  • Mafir Avatar

    Great follow up kata of the Insane version. First i thought, i had to find a new better approach, but my recursive approach from Insane Colored Trinagles was good enough, it just needed some gradual optimizations. Final testing time of my Python solution was 10109 ms. Thanks for this kata, I learned even more!

  • 6t41m0ct5 Avatar

    This comment has been hidden.

  • k_sh_2011 Avatar

    Finally, I did it. Python. My time is at the eadge. 11300 ms. I think that for Python some tests should be excluded.

  • krylovdash Avatar

    Something does not work with Python, as reported by other users. Even just writing "return 'R'" in the function body, it takes 6-12 seconds to pass/fail all the tests; sometimes it even times out. Some administrator should consider removing the Python version entirely.

  • nomennescio Avatar

    The variation in inputs (for Python) causes this Kata to randomly pass or fail solutions due to timeout. Please fix such that the inputs are representative and can be finished in the time budget.

  • Madjosz Avatar

    This kata cannot be updated to Node v14 because of the reduced max string length limit which was reverted from 1GB to 256 MB in V8 version 8.2.6: https://github.com/v8/v8/commit/ea56bf5513d0cbd2a35a9035c5c2996272b8b728 Node v14 uses V8 8.4, before since Node v9 (V8: 6.2.100) the 1GB limit was in place.

  • FArekkusu Avatar

    Python 3.8 should be enabled.

  • Quaternions Avatar

    Here is my "Translation (attempt)" to Ruby. https://www.codewars.com/kumite/61575a190f76ac0021c0e336?sel=61575a190f76ac0021c0e336 It seems to work fine, although I had to use a "little trick" to "generate the Huge Random strings faster" ==> I hope it's not too much of an issue :/

    Note: the solution I coded always passed the tests taking between 5 and 10s, while I also made a test with the 3 "best rated" (Ruby) solutions from "Insane Coloured Triangles" ==> All 3 of them timed out ;) ...So I guess the "tests' level" seems quite appropriate...^^

  • Quaternions Avatar

    This comment has been hidden.

  • AntonTimofeev Avatar

    Whats wrong with yours server? My solution solve 100 million character string for 21 sec on my PC. But here 1 million char-string is longer then 12 sec. Upgrade your server!))

  • Blind4Basics Avatar

    languages version are inconsistent:

    • I passed in JS
    • the same approach in python doesn't pass...
  • Kacarott Avatar

    Finally solved, but honestly this feels like 50% optimisation and 50% luck from the server. But maybe my solution is just slow :D

  • TheRyuTeam Avatar

    this branch about who can complicate task more than other :)

  • Granpepinillo Avatar

    Este kata falla, sin haber puesto ningun algoritmo, solamente [return "B"] ya me da el error del tiempo.

  • lasydler Avatar

    This comment has been hidden.

  • MisfitToys Avatar

    Can anyone who has completed this before reach out to me, please? I'm pretty certain that I have the correct approach and my code gets through a Massive amount of the larger ones before timing out. I'm wondering if there's room for improvement, or I'm just trying at bad server times. If I can improve my algorithm, I don't see how, but I like this particular kata and would like to know.

  • LesterJones Avatar

    Well return("") took 8 - 12+ seconds. (Frequently timed out.)

    I did manage to get python to pass the test, but I had to submit like 20 times.

  • alfe Avatar

    I propose to change this kata so that we aren't given a pre-produced string but instead a string-ish object which counts how many accesses to its characters are made and makes up characters on the fly following a certain algorithm. And if the amount of the accesses is too large, it should throw an exception. This way it would not use the brittle timeout-mechanism to ensure the correctness of the algorithm.

  • alfe Avatar

    I'm pretty sure I have the optimal algorithm, and now I even optimized the code, although the description says that's not what it is about. And still I get timeouts in Python.

    It's frustrating to have it this way. Someone should reduce the limits of the test cases to make sense for Python.

  • fibonaccios Avatar

    Would anyone do anything about this kata and update the Python version to 3.x???? See the post below.

  • KYLAN Avatar

    I always get the following error:

    Traceback (most recent call last): File "main.py", line 114, in fixed = generate(1, size+1, size)[0] File "main.py", line 68, in generate generate._pool_cache.append(''.join(random.choices(combos, k=chunk_len//combo_len))) AttributeError: 'module' object has no attribute 'choices'

    10 basic tests are passed. In Python2 'choices' method not exist. Why Python 3.X interpreters are disabled?

  • thisisyuu Avatar

    Execution Timed Out (12000 ms) for even O(1) return functions in python.

  • morphism Avatar

    I have attempted the kata multiple times with a blank function to measure the test generation speed. Many times I time out, most times it takes at least 11 seconds, and I've never seen it go below 10.

    I doubt this kata is completable in its current form, given the time constraints.

  • MOPbKO_HA_BOCTOKE Avatar

    Execution Timed Out (12000 ms)

    My solution code:

    def triangle(row):
      return ''
    
  • sandalaphon Avatar

    This times out:

    def triangle(row):
        return 'B'
    

    Does the python test suite generate within 12s?

  • user7194757 Avatar

    Sorry, in my opinion this kata does not make any sense at all. The runtime highly depends on the exact length of the test patterns. If you know the general idea behind the algorithm you know that you can construct worst case scenarios for the input length that lead to a massive penalty regarding the runtime. So, in the end it's all a question of luck that you don't get any of those test patterns that represent such a worst-case scenario. I tried several of the committed solutions on my local machine and they all failed to solve inputs of specific lengths within several minutes. If you don’t believe me try some of the committed solutions with any arbitrary input string that has a length of exactly 387.420.489 characters.

  • rooflack Avatar

    Hi guys, I'm the original author of this kata. Sorry for the very long delay, I haven't been on CodeWars for almost a year. I recently got a few notifications from the site, and I thought it might be worth clarifying a few things here.

    First, note that I only wrote the initial JS code, not the Python version, which I haven't really looked at, so I'll only speak about the JS version.

    Now, let's talk about speed. Most of the time in this kata is spent generating the samples. It takes a LOT longer to generate the super long strings than to process them. So this is perfectly normal that submitting an empty function still takes several seconds to run. It is also true that the execution times varies significantly depending on the server load, and that you shouldn't expect 99% success rate. That being said, when I created this kata about one year ago, it typically took around 6 to 8 seconds to run. I've just run a few tests and it seems that it is now closer to 9-11 seconds, with great variability (I tried about ten times and got two timeouts, one run under 8 seconds, two between 8 and 9, and the rest between 9 and 11.9 s)... This is not great (I actually expected speed to increase over time, not decrease), but it still leaves room to complete the kata with a decent success rate (say at least 50%): if you're sure your solution should but it still hits the timeout, just submit it once again and it should be ok.

    I agree that it's not ideal, especially for people who are limited to using CodeWars at rush hour, but I'm afraid that, by removing some tests or making them less random, it will make it possible to complete the kata without getting the right algorithm and cutting down the complexity, thus defeating the kata's purpose. It was precisely written as a tougher version of Bubbler's "Insane Coloured Triangles", which is rather forgiving in that aspect, so the fact that it runs on the edge of the timeout is kind of a necessary pain.

    I'm sorry if this is not very helpful, I wish there were a differentiated, adjustable timeout system that would allow to time the input genration and the solution test separately, thus removing that server load dependency, but unfortunately this is not the way the system works. In the meantime, keep in mind that the solution should litterally be able to crunch gigabyte-sized inputs in fractions of a second. And if the sample input generation takes too long, just hit the 'retry' button until it passes :-/

    Cheers.

  • GeneralYouri Avatar

    The number of tests causes runtime to come pretty close to the time limit, sometimes leaving the ability to submit up to how busy the codewars server is. I've even had an empty function submission (ie submit the starting template) result in a timeout. Depending on the solution, the performance difference between different inputs can also be pretty big and decides between timeout or not (ie it can be much less consistent than '99%'). It might be useful to either make the timer a bit more lenient, or limit the variance between inputs more; specifically to use set input lengths even for the random tests if this isn't done yet.

  • knz1981 Avatar

    The program execution time with an empty instruction (pass) is 11.1-11.5 / 12 sec, which causes doubts in the ability to perform this task in the Python3. When I try to get the difference between the start of the program time and each return value time using the time.time () function of the time module, I get a time out error.

  • efghbj Avatar

    .

  • gdbaldw Avatar

    Does this Kata work in Python 3? Description says...

    Caution: This kata does not currently have any known supported versions for Python. It may not be completable due to dependencies on out-dated libraries/language versions.

  • MMMAAANNN Avatar

    This comment has been hidden.

  • dulaortizflores@gmail.com Avatar

    This comment has been hidden.

  • Blind4Basics Avatar

    python is lacking its sample tests.

  • rooflack Avatar

    Quick note about rank assessment. I believe this should be a 3kyu rather than a 2kyu, as it's a lot easier than other 2kyu I've seen. The problem is that it's based on Bubbler's Insane version, which is already ranked 2kyu, and this one is "harder", in the sense that any solution that beats it will also be valid for the other one. So I thought it wouldn't make sense to give it a lower rank, and chose 2kyu, even though I still think it's kind of overranking.

  • zapakh Avatar

    Did that test case just rickroll me?!

  • kontic Avatar

    Very nice!