Hacker News new | past | comments | ask | show | jobs | submit login

> knowledge about `isPrefixOf` or `startsWith` or whatever the equivalent function is called in your language of choice.

There's no guarantee the digits are the first or last, so it's more `find` and `rfind`, unless you try every subslice of the line by hand.

Although thinking about it assuming the lines are not too long I guess that also works.




I looked at the slices from each position to the end. Now for every name (“one”, “1”, “two”, …) check slice.startswith(name).

After I pulled out first and last from results array.

Two nested for loops, program all included was under twenty lines.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: