Compare commits
No commits in common. "32e3dbdf4f63fa0d0e8e5232910ad29530036b10" and "2495c41ba3fa18aa88fd7447cc3b856155ac4928" have entirely different histories.
32e3dbdf4f
...
2495c41ba3
44
d11/run1.py
44
d11/run1.py
|
@ -1,44 +0,0 @@
|
|||
import sys
|
||||
|
||||
L = sys.stdin.read().splitlines()
|
||||
gal = []
|
||||
S=0
|
||||
|
||||
# Parser pour avoir les galaxies
|
||||
for line, P in enumerate(L):
|
||||
for col, p in enumerate(P):
|
||||
if p != ".":
|
||||
gal.append([line, col])
|
||||
|
||||
|
||||
# Expansion
|
||||
lines = [l[0] for l in gal]
|
||||
cols = [l[1] for l in gal]
|
||||
|
||||
lines_empty = []
|
||||
for line in range(0, len(L)):
|
||||
if lines.count(line) == 0:
|
||||
lines_empty.append(line)
|
||||
|
||||
for line in reversed(lines_empty):
|
||||
for g in reversed(gal):
|
||||
if g[0] > line:
|
||||
g[0] +=1
|
||||
|
||||
cols_empty = []
|
||||
for col in range(0, len(L[0])):
|
||||
if cols.count(col) == 0:
|
||||
cols_empty.append(col)
|
||||
|
||||
for col in reversed(cols_empty):
|
||||
for g in reversed(gal):
|
||||
if g[1] > col:
|
||||
g[1] +=1
|
||||
|
||||
|
||||
# Calcul distance entres les galaxies
|
||||
for s in range(0, len(gal)):
|
||||
for n in range(1, len(gal)-s):
|
||||
S+= (abs(gal[s+n][0] - gal[s][0])) + abs((gal[s+n][1] - gal[s][1]))
|
||||
|
||||
print(S)
|
44
d11/run2.py
44
d11/run2.py
|
@ -1,44 +0,0 @@
|
|||
import sys
|
||||
|
||||
L = sys.stdin.read().splitlines()
|
||||
gal = []
|
||||
S=0
|
||||
|
||||
# Parser pour avoir les galaxies
|
||||
for line, P in enumerate(L):
|
||||
for col, p in enumerate(P):
|
||||
if p != ".":
|
||||
gal.append([line, col])
|
||||
|
||||
|
||||
# Expansion
|
||||
lines = [l[0] for l in gal]
|
||||
cols = [l[1] for l in gal]
|
||||
|
||||
lines_empty = []
|
||||
for line in range(0, len(L)):
|
||||
if lines.count(line) == 0:
|
||||
lines_empty.append(line)
|
||||
|
||||
for line in reversed(lines_empty):
|
||||
for g in reversed(gal):
|
||||
if g[0] > line:
|
||||
g[0] +=999999
|
||||
|
||||
cols_empty = []
|
||||
for col in range(0, len(L[0])):
|
||||
if cols.count(col) == 0:
|
||||
cols_empty.append(col)
|
||||
|
||||
for col in reversed(cols_empty):
|
||||
for g in reversed(gal):
|
||||
if g[1] > col:
|
||||
g[1] +=999999
|
||||
|
||||
|
||||
# Calcul distance entres les galaxies
|
||||
for s in range(0, len(gal)):
|
||||
for n in range(1, len(gal)-s):
|
||||
S+= (abs(gal[s+n][0] - gal[s][0])) + abs((gal[s+n][1] - gal[s][1]))
|
||||
|
||||
print(S)
|
Loading…
Reference in New Issue