Compare commits

..

No commits in common. "2c00b3224156b5813873172706ac82aeb562f402" and "e51de70c36dc83f1623e5e8355f39e89ede50917" have entirely different histories.

4 changed files with 0 additions and 96 deletions

View File

@ -1,20 +0,0 @@
BEGIN{P["0_0"]=1; Hx=Hy=Tx=Ty=0}
function abs(x) { return x>0?x:-x}
{
print "==", Hx","Hy, ";", Tx","Ty, "==", $1, $2
for(i=1;i<=$2;i++){
if($1=="R") {Hx++}
if($1=="L") {Hx--}
if($1=="U") {Hy++}
if($1=="D") {Hy--}
dh = abs(Hx-Tx) # tension horizontale
dv = abs(Hy-Ty) # tension vertivale
if(dh>1 && $1=="R") {Tx++; if (dv>0) {Ty=Hy}}
if(dh>1 && $1=="L") {Tx--; if (dv>0) {Ty=Hy}}
if(dv>1 && $1=="U") {Ty++; if (dh>0) {Tx=Hx}}
if(dv>1 && $1=="D") {Ty--; if (dh>0) {Tx=Hx}}
P[Ty "_" Tx]=1
print Hx, Hy, ";", "dh:"dh, "dv:"dv, "=>", Tx, Ty
}
}
END{print length(P)}

View File

@ -1,30 +0,0 @@
import sys
rope = [(0,0) for _ in range(10)]
P = [{(0,0)} for _ in range(10) ]
D = {"R":(1,0),"L":(-1,0),"U":(0,1),"D":(0,-1)}
for l in sys.stdin.read().splitlines():
M, q = l.split(" ")
q = int(q)
for k in range(q):
(x,y) = rope[0]
(dx,dy) = D[M]
rope[0] = (x+dx, y+dy)
for i in range(1,10):
(Hx,Hy) = rope[i-1]
(Tx,Ty) = rope[i]
dh = Hx-Tx # tension horizontale
dv = Hy-Ty # tension vertivale
if (abs(dh)>1):
Tx += 1 if dh > 0 else -1
if (abs(dv)>0):
Ty += 1 if dv > 0 else -1
elif (abs(dv)>1):
Ty += 1 if dv > 0 else -1
if (abs(dh)>0):
Tx += 1 if dh > 0 else -1
P[i].add((Tx,Ty))
rope[i] = (Tx,Ty)
print(*(len(p) for p in P))

View File

@ -1,23 +0,0 @@
import sys
X = 1
C = 0
S = []
I = {20, 60, 100, 140, 180, 220}
def inc():
global C
C += 1
if C in I:
S.append(C*X)
for l in sys.stdin.read().splitlines():
m, q = (l+" _").split(" ")[:2]
if m == "noop":
inc()
else: # add
inc()
inc()
X += int(q)
print(sum(S))

View File

@ -1,23 +0,0 @@
import sys
X = 1
C = 0
LCD = [["."]*40 for _ in range(6)]
def inc():
global C
(r,c) = divmod(C, 40)
C+=1
if c in [X, X-1, X+1]:
LCD[r][c]="#"
for l in sys.stdin.read().splitlines():
m, q = (l+" _").split(" ")[:2]
if m == "noop":
inc()
else: # add
inc()
inc()
X += int(q)
print("\n".join("".join(r) for r in LCD))