Ad
  • Default User Avatar

    Is this mathematically correct ? I don't think it will work for all integers..

  • Default User Avatar

    For what purpose do you use dynamic memory allocation here?

  • Default User Avatar

    I think that one of them is clearly wrong, to pass it I hardcoded the specific test case.
    This killed the joy of seeing the K-Means algorithm decoding that last message.

  • Custom User Avatar

    If str_in is empty string then str_out[str_out_idx - 1] is unallocated memory

  • Custom User Avatar

    upd: OMFG I did it! I fucking did it!!

    So, after creating those posts I decided to take a break and went to read "The C Programming Language" by Kernighan & Ritchie and suddenly I got reminded that strlen() function reads through the whole string in order to find out it's length. That got me thinking: "Hmm... My program is actually using this function every time it has to translate a bit of BF code into C code... Hmm... AM I SURE, this is the right thing to do, concidering input size can reach up to a million characters? ABSOLUTELY FUCKING NOT!!" So I went back to my stack solution and refactored it to calculate C code idx using log10 for the character length of counts.

    After that, my timeouts were gone! But now it would fail on super_input 8, so I did some investigation by compiling and running a local version of this code — it gave me a Segmentation Fault, so I figured out the only way this could happen is if I didn't allocate enough space for resulting C code string. So I raised the size of the buffer and voilà! All green! Wo-hooooooow! I feel like such a hacker now... :)))

    (I'm only using static size array to avoid millions of realloc-s, but will see if I can make it dinamic since it only takes 3 seconds to run my code now.)

  • Custom User Avatar

    By the way, how many tests are there? Maybe there is a way to optimize one of my solutions to pass it? I tried to modify the stack to use a doubly linked list so I don't have to reverse it but that caused it to crash on (*root)->prev = stack_node; somehow. Weird...

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    Tried two different approaches — both of them pass 53 tests and then timeout (super_input 6 of 6).

    For anyone considering solving this kata: this is NOT A 4kyu KATA! It seems like the only way to solve it and not get a timeout is to somehow transpile the whole thing on the fly in one pass — something that should have been mentioned in the description. :|

    I'm gonna post both of my solutions in comments to this post just in case...

  • Default User Avatar
  • Custom User Avatar

    I've found two more:

    • You task should be Your task
    • langauge should be language
  • Default User Avatar
  • Custom User Avatar

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

  • Default User Avatar

    Fixed

  • Custom User Avatar

    Typo in description, equivilent should be equivalent.

  • Loading more items...