12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import utils.conf
- import utils.getarray
- from utils import getarray
- def canMatch(wallLength, moduleLengths):
- moduleTotalLength = 0;
- for item in moduleLengths:
- moduleTotalLength = moduleTotalLength + item
- return (moduleTotalLength <= wallLength)
- def matchWalls(roomLengths, moduleLengths):
- m = len(roomLengths)
- n = len(moduleLengths)
- a = getarray.getAllPosition(m, n)
- canMatchTop = canMatch(roomLengths[2], moduleLengths)
- if(canMatchTop):
- print("begin to calc top")
- matchTopWall(roomLengths[2],moduleLengths)
- else:
- for item in a:
- matchWall(roomLengths,moduleLengths,a[item])
- def changeModuleIndex(wallModules, param):
- newIndexModules = []
- print("before changeModuleIndex:",wallModules)
- for index in range(len(param)):
- newIndexModules.append(wallModules[param[index]-1])
- print("after changeModuleIndex:",newIndexModules)
- def matchSingleWallWithIndex(wallLength, wallModules):
- for item in wallModules:
- pass
- def matchSingleWall(wallLength, wallModules,wallIndex):
- print("wallLength",wallLength)
- print("wallModules",wallModules)
- print("wallIndex",wallIndex)
- if(canMatch(wallLength,wallModules)):
- a = getarray.jiechenarray(len(wallModules))
- for item in a:
- changeModuleIndex(wallModules,a[item])
- matchSingleWallWithIndex(wallLength, wallModules)
- else:
- print("this array not match")
- def matchWall(roomLengths, moduleLengths, positions):
- m = len(roomLengths)
- n = len(moduleLengths)
- a = getarray.getitemIndexAndPositionArray(positions,m,n)
- for item in a:
- if(a[item][0] == 1):
- position = a[item][1][0]
- wallModules = {};
- wallModules[0] = moduleLengths[position]
- matchSingleWall(roomLengths[position],wallModules,position)
- if(a[item][0] > 1):
- wallModules = {};
- for modulePosition in a[item][1]:
- moduleIndex = a[item][1][modulePosition]
- wallModules[modulePosition] = moduleLengths[moduleIndex]
- matchSingleWall(roomLengths[item],wallModules,a[item][1][0])
- pass
- def matchTopWall(roomLengths,moduleLengths):
- matchSingleWall(roomLengths, moduleLengths, "012")
- matchWalls([1,2,3,4],[1,2,1])
|