Added lua solution. Memoized the python solution to have sane preformance characteristics.