two tiny puzzles with tiny solutions

I just can't leave these alone. Today I saw a small puzzler someone out there is using in interviews. "Rose trees" from Haskell came to mind:

gist

There was also some reddit discussion of asking interview candidates to determine if one string was a substring of another. Once again, Haskell's pattern matching seemed to come in handy:

gist

After a while I wondered what the solution would look like in a simpler language. Here is a C solution that is very straightforward and makes good use of pointers.

gist

last update 2014-03-18