Hacker News new | ask | show | jobs
by masklinn 926 days ago
> 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.

1 comments

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.