day 1 refactor loop
This commit is contained in:
parent
56f7b7d0c5
commit
e5f91b28b1
|
@ -6,13 +6,11 @@ if sys.argv[1] == "2":
|
||||||
|
|
||||||
def process_line(l):
|
def process_line(l):
|
||||||
k = list()
|
k = list()
|
||||||
p = 0
|
for p in range(len(l)):
|
||||||
while (p<len(l)):
|
|
||||||
for i,d in enumerate(D):
|
for i,d in enumerate(D):
|
||||||
if l[p:p+len(d)] == d:
|
if l[p:p+len(d)] == d:
|
||||||
k.append(i%9+1)
|
k.append(i%9+1)
|
||||||
break
|
break
|
||||||
p += 1
|
|
||||||
return '!'.join(map(str,k)), k[0]*10 + k[-1] if len(k)>0 else 0
|
return '!'.join(map(str,k)), k[0]*10 + k[-1] if len(k)>0 else 0
|
||||||
|
|
||||||
R=0
|
R=0
|
||||||
|
|
Loading…
Reference in New Issue