Day 12 (removed comments)
This commit is contained in:
@@ -24,13 +24,11 @@ def rotate(current, amount):
|
|||||||
|
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
print(line)
|
|
||||||
if line[0] in target_str:
|
if line[0] in target_str:
|
||||||
pos += direction(line[0]) * line[1]
|
pos += direction(line[0]) * line[1]
|
||||||
elif line[0] in "LR":
|
elif line[0] in "LR":
|
||||||
drctn = rotate(drctn, -line[1] if line[0] == "R" else line[1])
|
drctn = rotate(drctn, -line[1] if line[0] == "R" else line[1])
|
||||||
else:
|
else:
|
||||||
pos += drctn * line[1]
|
pos += drctn * line[1]
|
||||||
print(pos, drctn)
|
|
||||||
|
|
||||||
print(sum(np.abs(pos)))
|
print(sum(np.abs(pos)))
|
||||||
|
|||||||
@@ -24,13 +24,11 @@ def rotate(current, amount):
|
|||||||
|
|
||||||
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
print(line)
|
|
||||||
if line[0] in target_str:
|
if line[0] in target_str:
|
||||||
drctn += direction(line[0]) * line[1]
|
drctn += direction(line[0]) * line[1]
|
||||||
elif line[0] in "LR":
|
elif line[0] in "LR":
|
||||||
drctn = rotate(drctn, -line[1] if line[0] == "R" else line[1])
|
drctn = rotate(drctn, -line[1] if line[0] == "R" else line[1])
|
||||||
else:
|
else:
|
||||||
pos += drctn * line[1]
|
pos += drctn * line[1]
|
||||||
print(pos, drctn)
|
|
||||||
|
|
||||||
print(sum(np.abs(pos)))
|
print(sum(np.abs(pos)))
|
||||||
|
|||||||
Reference in New Issue
Block a user