Advertisement
jhylands

Strange error

Sep 10th, 2014
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. def addPlacement(ships,hitListLength,start = None, mainList = None,countingList = None):
  2.     if start == None:
  3.     start=0
  4.     if mainList == None:
  5.     mainList = []
  6.     if countingList == None:
  7.     countingList = []
  8.     #pop ship from array for use on this recusion level
  9.     ship = ships.pop()
  10.     #loop through each hit
  11.     for x in range(start,hitListLength):
  12.     #add this rotation to the counting list
  13.         countingList.append(x)
  14.     #if we don't need to go any deeper add the counting array as an element of the main list
  15.     if len(ships) == 0:
  16.         mainList.append(countingList)
  17.             print "MainList: " + str(mainList)
  18.     else:
  19.         #otherwise recure deeper updating mainlist
  20.         mainList += addPlacement(ships,hitListLength,(start+1),mainList,countinglist)
  21.     #remove this loops countingList contribution so next loop can take its place
  22.     countingList.pop()
  23.     #return the mainlist
  24.     ships.append(ship)
  25.     print "MainList: " + str(mainList)
  26.     return mainList
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement