4 kyu

ASCII art codec

Description
Loading description...
ASCII Art
Image Processing
Recursion
Performance
  • Please sign in or sign up to leave a comment.
  • Blind4Basics Avatar

    Preventing a near possible approval until the suggestion below is sorted out.

  • Blind4Basics Avatar

    Both functions could be made linear in number of characters of the initial string (actually linearithmic, I believe. I'm specifically thinking about the encoding function, but I also see suboptimal decoding implementation in the current solutions). Are you sure you don't want to inforce that? Because this would make a nice 4kyu, imo.

    • Paul Robertson Avatar

      I like it the way it is to be honest.

      I could increase the size of the images in the random tests up to, say, 1000 x 1000 to disallow very slow solutions, but I don't really want to rewrite my own implementation, even if I had an idea how to optimise it ;)

    • Blind4Basics Avatar

      You could use mine? (the fork / I even can write the perf tests, if you want... x) )

      Frankly, the current suggested ranking is somewhat of a boomer (I've not been around for some time, and I see the beta process isn't going any better, considering the rank creep). With the additional requirement, I'd have no problem approving it in the blue level anyway.

    • dfhwze Avatar

      current rank creep is really sickening imo

    • Paul Robertson Avatar

      Ok. I will look into it a little more deeply. And I'll take you up on your offer.

      It's gonna need a "performance" tag now, right?

    • Blind4Basics Avatar

      tag: yes, and a note in the description saying that anything equal or worse than O(N²) with N the number of chars in the input won't work.

      Tell me when you want me to sneak myself in the process. The general idea about the tests, if you want to give it a shot, is the following:

      • testing long linear input of alternatig characters will make the recursive string concatenation explode: .x.x.x.x.x.x[...].x\n (doable with longer subsequeneces, to "add some variety" x) )

      • testing vertical input as well, just to avoid users avoidign the previous constraint with weird ideas: .\n.\n.\n.\n.\n.[...]\n

      • some kinda sqaure inputs also, like:

        .x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x\n
        x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.\n
        .x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x\n
        x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.\n
        .x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x\n
        x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.\n
        .x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x\n
        x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.\n
        .x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x\n
        x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.\n
        .x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x\n
        x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.\n
        .x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x\n
        x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.\n
        .x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x\n
        x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.\n
        .x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x\n
        x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.x.\n
        

      Then it's about tweaking the input generation to reach big enough inputs and adding some variations so that the user cannot kinda "hardcode" some parts of the logic in the perf tests.

      Note: buidling random huge maps with big homogeneous areas might not be a good idea. Or just a tiny number of them, because their generation will cost a lot

    • Paul Robertson Avatar

      I have republished the kata with the additional tests suggested above.

      I also took your decode function, although I kept my original encode

      Seems to have invalidated all but one of the submitted solutions.

    • Blind4Basics Avatar

      But that would make the requirements inconsistent: now, both fonctions do not require the same time complexity. Do you want me to try if I can differentiate both kinds of encoding solutions?

    • Blind4Basics Avatar

      OK, in fact, the current tests setup is not good : your code barely passes the tests, in 12s. that's not the good way to enforce performances. I’ll take a shot at it in the next few days.

    • Paul Robertson Avatar

      Yes, go for it.

    • Blind4Basics Avatar

      fork published here

    • Paul Robertson Avatar

      Approved

      Suggestion marked resolved by Paul Robertson 19 days ago
    • Blind4Basics Avatar

      do you want me to approve it right now at 4, or do we wait a bit for new feedback? (I wonder if it's 4 or 3 in the current state...)

    • Blind4Basics Avatar

      wait, it seems there is a problem. My previous solution shouldn't pass...

    • Blind4Basics Avatar

      well, according to my last measurments, they both behave almost the same anywy, so... I cannot really differentiate them. So I guess 4 kyu is enough... Approving?

    • Paul Robertson Avatar

      Yeah, do it. It's been long enough

  • dfhwze Avatar

    Very minor one:

    starts with the width and height, comma-separated, and followed by

    Comma-separated would mean 2,3\n..., but there is also a trailing comma 2,3,\n...

    You formulated it better here:

    with a line-feed \n marking the end of each row.

  • dfhwze Avatar

    How do I decode stuff without width and height encoded?

    M"{oLi~~1~+5JY~
    ;hgGY0A2pAR3e~
    R`tC+~7?^33~igl
    Q)^(/fiS],tLY{
    NY"XhODLpCO&u^c
    *_<~>//$[gZN4S+
    $-z:;O-5$&W[G(:
    b;e~$a%3m~YF)M<
    %PHxcw~toQSkAk|
    gQc)xp$|vb& xc$
    Z7E<t~Ng\G~~z@n
    6`F4N9b-Vlgz)4^
    
    • Paul Robertson Avatar

      At the outermost level the encoded string must start with image_width,image_height, to be valid.

      The dimensions of any subdivisions are not required as they can be calculated (as described in the kata description).

    • Mercy Madmask Avatar

      I see you already solved it but in case someone has the same problem, the tests are fine.
      I had that problem and it was an error in parsing specifics inputs like the one above. ;)

  • dfhwze Avatar

    What are the constraints on width and height for test cases?

  • dfhwze Avatar

    Bottom-left quarter requires further subdivision

    should be Bottom-right, unless I'm mistaken