活跃农民
- 积分
- 374
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2016-10-4
- 最后登录
- 1970-1-1
|
class Solution:
def dot(self,s):
nL = len(s)
res = []
if s[0] == "0":
if len(s) == 1:
return ["0"]
else:
return ["0." + s[1:]]
else:
for i in range(1,nL-1):
res.append(s[0:i] + "." + s[i:])
res.append(s)
return res
def coordpermu(self,s):
nL = len(s)
res =[]
for i in range(1,nL-1):
nLeft = self.dot(s[0:i])
nRight = self.dot(s[i:])
for e1 in nLeft:
for e2 in nRight:
res.append("(" +e1 + "," + e2 + ")")
return res
if __name__ == '__main__':
s = "0123045"
test = Solution()
coords = test.coordpermu(s)
for e in coords:
print(e)
|
|