logoalt Hacker News

integralidtoday at 7:19 AM2 repliesview on HN

If someone doesn't know how to reverse words in a sentence they are absolutely not qualified to be a programmer. Yes they probably won't do this exact task often, but this is like a doctor that can't distinguish heart from the liver. It tells you something has gone horribly wrong.


Replies

ThunderSizzletoday at 12:26 PM

In many languages, the basic version can be just one line of code, if you know the right libraries to leverage. C# leveraging Linq, for example:

    String.Join(" ",
      String.Split(" ", sentence).Reverse()))
chonglitoday at 2:28 PM

What if the sentence is in Japanese (which doesn’t use spaces)?