Ad
  • Default User Avatar

    That's quite allright, no problem at all :) Yes, from a competitive standpoint, this definitely takes way too much time to write!

  • Custom User Avatar

    I'm sorry, I have no idea what I was thinking when I called this 'very bad'. But, when I claimed that this was inefficient, I wasn't talking about runtime. I'm a competitive programmer and that's all about speed - which means trying to make your code as short as possible. So it isn't inefficient in terms of runtime; but, in terms of length. It's good code though, I don't know when I claimed that it was bad.

  • Default User Avatar

    Can you articulate why? :)

    The fact that it is much longer than other solutions does not make it inefficient, and especially not bad code. Multi-layered ternary operators in a single line may be more clever, but not "better"(see note in the bottom). In fact I think my code is exceptionally readable, though others are free to disagree. As for efficiency, we could debate it, but the use case is a grid of 12 elements, so it is quite pointless.

    Note: I do not believe that there is a general definition of better. Sometimes time complexity is paramount, other times space complexity, yet other times developer time/maintainability/extendability are way more important.

  • Custom User Avatar
  • Custom User Avatar