File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed
Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change 66import heapq
77from collections import defaultdict
88from tqdm .auto import tqdm
9- from collections import deque
9+ import re
1010
11- def parse (buttons : str ):
12- buttons = buttons .strip ().split ()
11+ def parse (row : str ):
12+ row = row .strip ()
13+ goal = re .search (r"[#\.]+" , row ).group ()
1314 goal = tuple (map (lambda x : int (x == "#" ),
14- buttons [0 ][1 :- 1 ]))
15- size = len (goal )
16- req = tuple (map (int , buttons [- 1 ][1 :- 1 ].split ("," )))
15+ goal ))
16+ buttons = re .findall (r"\(((?:\d,*)+)" , row )
1717 buttons = list (map (
18- lambda s : tuple (map (int , s [1 :- 1 ].split ("," ))),
19- buttons [1 :- 1 ]))
18+ lambda s : tuple (map (int , s .split ("," ))),
19+ buttons ))
20+ req = list (
21+ map (int ,
22+ re .search (r"{(.*)}" , row ).group (1 ).split ("," )
23+ ))
24+
25+ size = len (goal )
2026 for i in range (len (buttons )):
2127 r = [0 for _ in range (size )]
2228 for j in buttons [i ]:
You can’t perform that action at this time.
0 commit comments