Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def gravitation(rows):
- def checkMotless(rows):
- #returns needed steps until column becomes motionless
- motless = []
- bedrock = len(rows)-1
- for i in range(len(rows[0])):
- topind = 0
- botind = bedrock
- count = 0
- topLock = False
- botLock = False
- while not (topLock and botLock):
- if rows[botind][i] == '#':
- botind = botind - 1
- if rows[botind][i] == '.':
- botLock = True
- if rows[topind][i] == '.':
- topind = topind + 1
- if rows[topind][i] == '#':
- topLock = True
- if botind == topind:
- topLock = True
- botLock = True
- print(topind)
- print(botind)
- print("--")
- for k in range(topind+1,botind+1,1):
- if rows[k][i] == '.':
- count = count + 1
- motless.append(count)
- return motless
- motless = checkMotless(rows)
- print(motless)
- ans = []
- mini = min(motless)
- for i in range(len(motless)):
- if motless[i]==mini:
- ans.append(i)
- return ans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement