Writing awesome backtrack code in Ruby

Hello all,

Some algorithm expert showed a way to do approximate string matching
using backtracking over on stackoverflow:

So, how would that bit of code look in Ruby? Perhaps with Inline C?

Cheers,

Martin