?

Log in

No account? Create an account

Previous Entry | Next Entry

Python Version

In regards to this, here is the python version:

def initialList(size):
   return [0 for x in range(size)]

def XinY_Go(x,y,index,slots):
   if (y - index) == 1:
      slots[index] = x
      print slots
      slots[index] = 0
      return
   for i in range(x+1):
      slots[index] = x-i
      XinY_Go(x-(x-i), y, index + 1, slots)

def XinY(x,y):
   return XinY_Go(x,y,0,initialList(y))

My next task is to remove the recursion. I have a fairly good idea of how to do it, but it will take me a few iterations to get it right.

Latest Month

July 2011
S M T W T F S
     12
3456789
10111213141516
17181920212223
24252627282930
31      
Powered by LiveJournal.com
Designed by yoksel