Ad
  • Custom User Avatar

    Precompute the length of the final string, generate it, then go and replace the chunks as needed. a "".join() is still somehow better, but if you keep increasing a string at each step, you will do a lot of reallocation every few steps.

  • Custom User Avatar

    I'm still learning the basics of python (and programming in general). After comparing the solutions I have for various katas to the "best" and "clever" solutions others have devised, I have no doubt that most of the code I've written is subpar. If you don't mind me asking, what would be a more performant way of approaching this problem?

  • Custom User Avatar

    Glad you appreciate; doing concatenation is not necessarily the most performing way to achieve what you need to achieve, but it can work pretty fine :)

  • Custom User Avatar

    I loved this kata. It's a really clever way of making sure you understand the fundamentals. I first figured out the logic needed to get the results using print on an IDE and then realized I needed actually return an output since this was a function. Luckily strings are easy to manipulate with a simple += so I didn't have to change the structure of the code.