begin 18
This commit is contained in:
parent
74e98ac3a6
commit
d96f4b19d9
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from useful import *
|
||||
|
||||
dirind = {'U': (-1, 0),
|
||||
'D': (1, 0),
|
||||
'L': (0, -1),
|
||||
'R': (0, 1)}
|
||||
|
||||
def parse(l):
|
||||
rection, distance, pcolor = l.strip().split()
|
||||
return np.asarray(dirind[rection]), int(distance), pcolor
|
||||
|
||||
guide = [parse(l) for l in lines(open(0))]
|
||||
edges = []
|
||||
head = np.asarray((0, 0))
|
||||
for rection, distance, _ in guide:
|
||||
tail = head
|
||||
head = head + rection * distance
|
||||
edges += [(tail, head)]
|
||||
ic(edges)
|
Loading…
Reference in New Issue