Comment

Comment by bobbyi_settv

The "complete" solutions for Python in the repo don't actually work because they don't reset the state. If you add a final line of:

  print g('al')
for solution1 or:

  print m('rton')
for solution2, you'll find they don't print gal/ mrton.

Here's what I came up with before looking at those solutions that seems to work:

  def g(arg=None):
      if arg == 'al':
          return 'gal'
      def inner(arg=None):
          if arg == 'al':
              return 'g' + (inner.counter * 'o') + 'al'
          inner.counter += 1
          return inner
      inner.counter = 1
      return inner
parent bobbyi_settv 12 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton