fork download
  1. import sys
  2.  
  3. def next(separator):
  4. global pos
  5. begin = pos + 1
  6. pos = str.find(separator, begin)
  7. if (pos == -1): pos = len(str)
  8. return int(round(float(str[begin : pos])))
  9.  
  10. str = ""
  11. for s in sys.stdin:
  12. begin = s.find("d=\"m ")
  13. if (begin == -1): continue
  14. begin = s.find(" ", begin)
  15. end = s.find("\"", begin)
  16. str = s[begin : end]
  17.  
  18. pos = 0
  19. list = []
  20. next(",")
  21. next(" ")
  22. list.append([0, 0, 0, 0])
  23. while (True):
  24. x = list[-1][0] + abs(next(","))
  25. y = list[-1][1] - next(" ")
  26. list[-1][2] = x
  27. list[-1][3] = y
  28. if (pos == len(str)): break
  29. list.append([x, y, 0, 0])
  30.  
  31. n = 0
  32. for j in range(list[-1][2]):
  33. while (j >= list[n][2]): n += 1
  34. lx = list[n][2] - list[n][0]
  35. ly = list[n][3] - list[n][1]
  36. ratio = float(j - list[n][0]) / lx
  37. if (j): print list[n][1] + int(round(ly * ratio))
  38.  
Success #stdin #stdout 0s 23296KB
stdin
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://w...content-available-to-author-only...e.org/) -->

<svg
   xmlns:dc="http://p...content-available-to-author-only...l.org/dc/elements/1.1/"
   xmlns:cc="http://c...content-available-to-author-only...s.org/ns#"
   xmlns:rdf="http://w...content-available-to-author-only...3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://w...content-available-to-author-only...3.org/2000/svg"
   xmlns="http://w...content-available-to-author-only...3.org/2000/svg"
   xmlns:sodipodi="http://s...content-available-to-author-only...e.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://w...content-available-to-author-only...e.org/namespaces/inkscape"
   width="744.09448819"
   height="1052.3622047"
   id="svg2"
   version="1.1"
   inkscape:version="0.48.5 r10040"
   sodipodi:docname="collector.svg">
  <defs
     id="defs4" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="10.200015"
     inkscape:cx="-692.82005"
     inkscape:cy="711.99056"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="true"
     showborder="false"
     gridtolerance="10000"
     objecttolerance="10000"
     guidetolerance="10000"
     inkscape:window-width="1280"
     inkscape:window-height="951"
     inkscape:window-x="-2"
     inkscape:window-y="-3"
     inkscape:window-maximized="1">
    <inkscape:grid
       type="xygrid"
       id="grid2985"
       empspacing="50"
       visible="true"
       enabled="true"
       snapvisiblegridlinesonly="true"
       spacingx="1px"
       spacingy="1px" />
  </sodipodi:namedview>
  <metadata
     id="metadata7">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://p...content-available-to-author-only...l.org/dc/dcmitype/StillImage" />
        <dc:title />
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1">
    <path
       style="fill:none;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
       d="m -700,352.36218 0,-22 16,6 24,3 134,3 6,1 89,-2 23,-2 14,-4 4,-2 6,-7 2,-5 1,-5"
       id="path2999"
       inkscape:connector-curvature="0" />
  </g>
</svg>
stdout
22
21
21
20
20
20
19
19
19
18
18
17
17
17
16
16
16
16
16
15
15
15
15
15
15
15
15
14
14
14
14
14
14
14
14
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
13
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
9
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
10
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
11
12
12
12
12
12
12
12
12
12
12
12
12
13
13
13
13
13
13
13
14
14
14
14
15
15
15
16
16
16
16
17
17
18
18
19
19
20
21
23
24
25
26
29
31