Skip to content

Comment on Programming Idiomsparent

Comments

On a related note, the problem is underspecified.

> Create string t containing the same characters as string s, in reverse order. Original string s must remain unaltered. Each character must be handled correctly regardless its number of bytes in memory.

What encoding? Assuming UTF-8, what is a "character"? A code point? A grapheme? The result of the lack of specification is that the different approaches really solve different problems. Some, like the C implementation, have a naive approach that only solves the problem in fixed size encodings where the width is equal to CHAR_BIT. Others I'm sure run into problems with combining characters

Submit a task/"idiom" with an improved/stricter spec and link back to the original one.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.