Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

An easier Ruby solution would be:

("letters in this sentence" + "and this one").chars.sort.reverse



Except you aren't using sets, so you get duplicate characters.

I can just as easily write ("letters in this sentence" + "and this one").toSeq.sorted.reverse in scala. You could tag the end of your ruby statement with .uniq and you would be fine. Alternatively, you could wrap the above scala statement in TreeSet(). These solutions process things in a significantly different way than was done by the OP, though.


("letters in this sentence".split(//) & "and this one".split(//)).sort.reverse.join

I'm just learning, but I think this performs it correctly with sets.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: