def _keep_only_referenced_tex(contents, splits):
  """Returns the filenames referenced from the tex files themselves.

  It needs various iterations in case one file is referenced from an
  unreferenced file.
  """
  old_referenced = set(splits['tex_in_root'] + splits['tex_not_in_root']) # [STATE] old_referenced = {'figures/figure_included.tex', 'figures/figure_not_included.tex', 'figures/figure_included.tikz', 'main.tex', 'figures/figure_not_included_2.tex'} [/STATE]
  while True:
    referenced = set(splits['tex_in_root']) #  [STATE] referenced = {'main.tex'} [/STATE]
    for fn in old_referenced: #  [STATE] 14 [/STATE]
      for fn2 in old_referenced: #  [STATE] 61 [/STATE]
        if regex.search(
            r'(' + os.path.splitext(fn)[0] + r'[.}])', '\n'.join(contents[fn2])
        ):
          referenced.add(fn) #  [STATE] referenced = {'figures/figure_included.tex', 'main.tex'} [/STATE] [STATE] referenced = {'figures/figure_included.tex', 'figures/figure_included.tikz', 'main.tex'} [/STATE] [STATE] referenced = {'figures/figure_included.tex', 'figures/figure_included.tikz', 'main.tex', 'figures/figure_not_included_2.tex'} [/STATE]

    if referenced == old_referenced:
      splits['tex_to_copy'] = list(referenced) # [STATE] splits = {'all': ['main.bib', 'main.bbl', 'main.tex', 'main.aux', 'ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'in_root': ['main.bib', 'main.bbl', 'main.tex', 'main.aux'], 'not_in_root': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'to_copy_in_root': ['main.bbl', 'main.tex'], 'to_copy_not_in_root': ['figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt'], 'figures': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'tex_in_root': ['main.tex'], 'tex_not_in_root': ['figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex'], 'non_tex_in_root': ['main.bbl'], 'non_tex_not_in_root': ['figures/data_not_included.txt', 'figures/data_included.txt', 'not_included/figures/data_included.txt'], 'external_tikz_figures': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf'], 'svg_inkscape': [], 'tex_to_copy': ['figures/figure_included.tex', 'figures/figure_included.tikz', 'main.tex']} [/STATE]
      return

    old_referenced = referenced.copy() #  [STATE] old_referenced = {'figures/figure_included.tex', 'figures/figure_included.tikz', 'main.tex', 'figures/figure_not_included_2.tex'} [/STATE] [STATE] old_referenced = {'figures/figure_included.tex', 'figures/figure_included.tikz', 'main.tex'} [/STATE]

_keep_only_referenced_tex({'main.tex': ['\\begin{document}', 'Text', '', 'Text%', '', '', 'This is a percent \\%.', '\\includegraphics{images/im1_included.png}', '\\includegraphics{images/im3_included.png}', '\\includegraphics{%', '  images/im4_included.png%', '  }', '\\includegraphics[width=.5\\linewidth]{%', '  images/im5_included.jpg}', '', '\\includegraphics{./images/im3_included.png}', '', 'This line should not be separated', '%', 'from this one.', '', '', '', '\\newif\\ifvar', '', '\\ifvar', '\\fi', '', '\\newcommand{\\red}[1]{{\\color{red} #1}}', 'hello test hello', 'test hello', 'test', '', '', '\\input{figures/figure_included.tex}', '', '\\includegraphics{ext_tikz/test1.pdf}', '', '\\input{figures/figure_included.tikz}', '', '\\begin{tikzpicture}', '    \\node (test) at (0,0) {Test3};', '\\end{tikzpicture}', '', '\\tikzsetnextfilename{test_no_match}', '\\begin{tikzpicture}', '    \\node (test) at (0,0) {Test4};', '\\end{tikzpicture}', '', '\\end{document}', ''], 'figures/figure_not_included.tex': ['\\addplot{figures/data_not_included.txt}', '\\input{figures/figure_not_included_2.tex}', ''], 'figures/figure_not_included_2.tex': [''], 'figures/figure_included.tikz': ['\ufeff\\includegraphics{ext_tikz/test2.pdf}', ''], 'figures/figure_included.tex': ['\\includegraphics{images/im2_included.jpg}', '\\addplot{figures/data_included.txt}', '']}, {'all': ['main.bib', 'main.bbl', 'main.tex', 'main.aux', 'ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'in_root': ['main.bib', 'main.bbl', 'main.tex', 'main.aux'], 'not_in_root': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'to_copy_in_root': ['main.bbl', 'main.tex'], 'to_copy_not_in_root': ['figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt'], 'figures': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'tex_in_root': ['main.tex'], 'tex_not_in_root': ['figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex'], 'non_tex_in_root': ['main.bbl'], 'non_tex_not_in_root': ['figures/data_not_included.txt', 'figures/data_included.txt', 'not_included/figures/data_included.txt'], 'external_tikz_figures': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf'], 'svg_inkscape': []})

1. def _keep_only_referenced_tex(contents, splits):
2.   """Returns the filenames referenced from the tex files themselves.
3.
4.   It needs various iterations in case one file is referenced from an
5.   unreferenced file.
6.   """
7.   old_referenced = set(splits['tex_in_root'] + splits['tex_not_in_root'])
8.   while True:
9.     referenced = set(splits['tex_in_root'])
10.     for fn in old_referenced:
11.       for fn2 in old_referenced:
12.         if regex.search(
13.             r'(' + os.path.splitext(fn)[0] + r'[.}])', '\n'.join(contents[fn2])
14.         ):
15.           referenced.add(fn)
16.
17.     if referenced == old_referenced:
18.       splits['tex_to_copy'] = list(referenced)
19.       return
20.
21.     old_referenced = referenced.copy()
22.
23. _keep_only_referenced_tex({'main.tex': ['\\begin{document}', 'Text', '', 'Text%', '', '', 'This is a percent \\%.', '\\includegraphics{images/im1_included.png}', '\\includegraphics{images/im3_included.png}', '\\includegraphics{%', '  images/im4_included.png%', '  }', '\\includegraphics[width=.5\\linewidth]{%', '  images/im5_included.jpg}', '', '\\includegraphics{./images/im3_included.png}', '', 'This line should not be separated', '%', 'from this one.', '', '', '', '\\newif\\ifvar', '', '\\ifvar', '\\fi', '', '\\newcommand{\\red}[1]{{\\color{red} #1}}', 'hello test hello', 'test hello', 'test', '', '', '\\input{figures/figure_included.tex}', '', '\\includegraphics{ext_tikz/test1.pdf}', '', '\\input{figures/figure_included.tikz}', '', '\\begin{tikzpicture}', '    \\node (test) at (0,0) {Test3};', '\\end{tikzpicture}', '', '\\tikzsetnextfilename{test_no_match}', '\\begin{tikzpicture}', '    \\node (test) at (0,0) {Test4};', '\\end{tikzpicture}', '', '\\end{document}', ''], 'figures/figure_not_included.tex': ['\\addplot{figures/data_not_included.txt}', '\\input{figures/figure_not_included_2.tex}', ''], 'figures/figure_not_included_2.tex': [''], 'figures/figure_included.tikz': ['\ufeff\\includegraphics{ext_tikz/test2.pdf}', ''], 'figures/figure_included.tex': ['\\includegraphics{images/im2_included.jpg}', '\\addplot{figures/data_included.txt}', '']}, {'all': ['main.bib', 'main.bbl', 'main.tex', 'main.aux', 'ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'in_root': ['main.bib', 'main.bbl', 'main.tex', 'main.aux'], 'not_in_root': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'to_copy_in_root': ['main.bbl', 'main.tex'], 'to_copy_not_in_root': ['figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt'], 'figures': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'tex_in_root': ['main.tex'], 'tex_not_in_root': ['figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex'], 'non_tex_in_root': ['main.bbl'], 'non_tex_not_in_root': ['figures/data_not_included.txt', 'figures/data_included.txt', 'not_included/figures/data_included.txt'], 'external_tikz_figures': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf'], 'svg_inkscape': []})

Question: How many times will the loop on line 11 execute when '_keep_only_referenced_tex({'main.tex': ['\\begin{document}', 'Text', '', 'Text%', '', '', 'This is a percent \\%.', '\\includegraphics{images/im1_included.png}', '\\includegraphics{images/im3_included.png}', '\\includegraphics{%', '  images/im4_included.png%', '  }', '\\includegraphics[width=.5\\linewidth]{%', '  images/im5_included.jpg}', '', '\\includegraphics{./images/im3_included.png}', '', 'This line should not be separated', '%', 'from this one.', '', '', '', '\\newif\\ifvar', '', '\\ifvar', '\\fi', '', '\\newcommand{\\red}[1]{{\\color{red} #1}}', 'hello test hello', 'test hello', 'test', '', '', '\\input{figures/figure_included.tex}', '', '\\includegraphics{ext_tikz/test1.pdf}', '', '\\input{figures/figure_included.tikz}', '', '\\begin{tikzpicture}', '    \\node (test) at (0,0) {Test3};', '\\end{tikzpicture}', '', '\\tikzsetnextfilename{test_no_match}', '\\begin{tikzpicture}', '    \\node (test) at (0,0) {Test4};', '\\end{tikzpicture}', '', '\\end{document}', ''], 'figures/figure_not_included.tex': ['\\addplot{figures/data_not_included.txt}', '\\input{figures/figure_not_included_2.tex}', ''], 'figures/figure_not_included_2.tex': [''], 'figures/figure_included.tikz': ['\ufeff\\includegraphics{ext_tikz/test2.pdf}', ''], 'figures/figure_included.tex': ['\\includegraphics{images/im2_included.jpg}', '\\addplot{figures/data_included.txt}', '']}, {'all': ['main.bib', 'main.bbl', 'main.tex', 'main.aux', 'ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'in_root': ['main.bib', 'main.bbl', 'main.tex', 'main.aux'], 'not_in_root': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'to_copy_in_root': ['main.bbl', 'main.tex'], 'to_copy_not_in_root': ['figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt'], 'figures': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'tex_in_root': ['main.tex'], 'tex_not_in_root': ['figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex'], 'non_tex_in_root': ['main.bbl'], 'non_tex_not_in_root': ['figures/data_not_included.txt', 'figures/data_included.txt', 'not_included/figures/data_included.txt'], 'external_tikz_figures': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf'], 'svg_inkscape': []})' is called?

Answer: 61


def _resize_and_copy_figures_if_referenced(parameters, contents, splits):
  image_size = collections.defaultdict(lambda: parameters['im_size']) # [STATE] image_size = defaultdict(<function _resize_and_copy_figures_if_referenced.<locals>.<lambda> at 0x7f1854568670>, {}) [/STATE]
  image_size.update(parameters['images_allowlist']) # [STATE] image_size = defaultdict(<function _resize_and_copy_figures_if_referenced.<locals>.<lambda> at 0x7f1854568670>, {'images/im2_included.jpg': 200, 'images/im3_included.png': 400}) [/STATE]
  pdf_resolution = collections.defaultdict( # [STATE] pdf_resolution = defaultdict(<function _resize_and_copy_figures_if_referenced.<locals>.<lambda> at 0x7f18545688b0>, {}) [/STATE]
      lambda: parameters['pdf_im_resolution']
  )
  pdf_resolution.update(parameters['images_allowlist']) # [STATE] pdf_resolution = defaultdict(<function _resize_and_copy_figures_if_referenced.<locals>.<lambda> at 0x7f18545688b0>, {'images/im2_included.jpg': 200, 'images/im3_included.png': 400}) [/STATE]
  for image_file in _keep_only_referenced( #  [STATE] 8 [/STATE]
      splits['figures'], contents, strict=False
  ):
    _resize_and_copy_figure(
        filename=image_file,
        origin_folder=parameters['input_folder'],
        destination_folder=parameters['output_folder'],
        resize_image=parameters['resize_images'],
        image_size=image_size[image_file], #  [STATE] image_size = defaultdict(<function _resize_and_copy_figures_if_referenced.<locals>.<lambda> at 0x7f1854568670>, {'images/im2_included.jpg': 200, 'images/im3_included.png': 400, 'ext_tikz/test2.pdf': 100}) [/STATE] [STATE] image_size = defaultdict(<function _resize_and_copy_figures_if_referenced.<locals>.<lambda> at 0x7f1854568670>, {'images/im2_included.jpg': 200, 'images/im3_included.png': 400, 'ext_tikz/test2.pdf': 100, 'ext_tikz/test1.pdf': 100}) [/STATE] [STATE] image_size = defaultdict(<function _resize_and_copy_figures_if_referenced.<locals>.<lambda> at 0x7f1854568670>, {'images/im2_included.jpg': 200, 'images/im3_included.png': 400, 'ext_tikz/test2.pdf': 100, 'ext_tikz/test1.pdf': 100, 'images/im4_included.png': 100}) [/STATE] [STATE] image_size = defaultdict(<function _resize_and_copy_figures_if_referenced.<locals>.<lambda> at 0x7f1854568670>, {'images/im2_included.jpg': 200, 'images/im3_included.png': 400, 'ext_tikz/test2.pdf': 100, 'ext_tikz/test1.pdf': 100, 'images/im4_included.png': 100, 'images/im5_included.jpg': 100}) [/STATE] [STATE] image_size = defaultdict(<function _resize_and_copy_figures_if_referenced.<locals>.<lambda> at 0x7f1854568670>, {'images/im2_included.jpg': 200, 'images/im3_included.png': 400, 'ext_tikz/test2.pdf': 100, 'ext_tikz/test1.pdf': 100, 'images/im4_included.png': 100, 'images/im5_included.jpg': 100, 'images/im1_included.png': 100}) [/STATE] [STATE] image_size = defaultdict(<function _resize_and_copy_figures_if_referenced.<locals>.<lambda> at 0x7f1854568670>, {'images/im2_included.jpg': 200, 'images/im3_included.png': 400, 'ext_tikz/test2.pdf': 100, 'ext_tikz/test1.pdf': 100, 'images/im4_included.png': 100, 'images/im5_included.jpg': 100, 'images/im1_included.png': 100, 'images/include/images/im3_included.png': 100}) [/STATE]
        compress_pdf=parameters['compress_pdf'],
        pdf_resolution=pdf_resolution[image_file], #  [STATE] pdf_resolution = defaultdict(<function _resize_and_copy_figures_if_referenced.<locals>.<lambda> at 0x7f18545688b0>, {'images/im2_included.jpg': 200, 'images/im3_included.png': 400, 'ext_tikz/test2.pdf': 500}) [/STATE] [STATE] pdf_resolution = defaultdict(<function _resize_and_copy_figures_if_referenced.<locals>.<lambda> at 0x7f18545688b0>, {'images/im2_included.jpg': 200, 'images/im3_included.png': 400, 'ext_tikz/test2.pdf': 500, 'ext_tikz/test1.pdf': 500}) [/STATE] [STATE] pdf_resolution = defaultdict(<function _resize_and_copy_figures_if_referenced.<locals>.<lambda> at 0x7f18545688b0>, {'images/im2_included.jpg': 200, 'images/im3_included.png': 400, 'ext_tikz/test2.pdf': 500, 'ext_tikz/test1.pdf': 500, 'images/im4_included.png': 500}) [/STATE] [STATE] pdf_resolution = defaultdict(<function _resize_and_copy_figures_if_referenced.<locals>.<lambda> at 0x7f18545688b0>, {'images/im2_included.jpg': 200, 'images/im3_included.png': 400, 'ext_tikz/test2.pdf': 500, 'ext_tikz/test1.pdf': 500, 'images/im4_included.png': 500, 'images/im5_included.jpg': 500}) [/STATE] [STATE] pdf_resolution = defaultdict(<function _resize_and_copy_figures_if_referenced.<locals>.<lambda> at 0x7f18545688b0>, {'images/im2_included.jpg': 200, 'images/im3_included.png': 400, 'ext_tikz/test2.pdf': 500, 'ext_tikz/test1.pdf': 500, 'images/im4_included.png': 500, 'images/im5_included.jpg': 500, 'images/im1_included.png': 500}) [/STATE] [STATE] pdf_resolution = defaultdict(<function _resize_and_copy_figures_if_referenced.<locals>.<lambda> at 0x7f18545688b0>, {'images/im2_included.jpg': 200, 'images/im3_included.png': 400, 'ext_tikz/test2.pdf': 500, 'ext_tikz/test1.pdf': 500, 'images/im4_included.png': 500, 'images/im5_included.jpg': 500, 'images/im1_included.png': 500, 'images/include/images/im3_included.png': 500}) [/STATE]
    )

_resize_and_copy_figures_if_referenced({'input_folder': 'tex', 'images_allowlist': {'images/im2_included.jpg': 200, 'images/im3_included.png': 400}, 'resize_images': True, 'im_size': 100, 'compress_pdf': False, 'pdf_im_resolution': 500, 'commands_to_delete': ['mytodo'], 'commands_only_to_delete': ['red'], 'environments_to_delete': ['mynote'], 'use_external_tikz': 'ext_tikz', 'keep_bib': False, 'to_delete': ['\\.aux$', '\\.sh$', '\\.blg$', '\\.brf$', '\\.log$', '\\.out$', '\\.ps$', '\\.dvi$', '\\.synctex.gz$', '~$', '\\.backup$', '\\.gitignore$', '\\.DS_Store$', '\\.svg$', '^\\.idea', '\\.dpth$', '\\.md5$', '\\.dep$', '\\.auxlock$', '\\.fls$', '\\.fdb_latexmk$', '\\.bib$'], 'figures_to_copy_if_referenced': ['\\.png$', '\\.jpg$', '\\.jpeg$', '\\.pdf$'], 'output_folder': '/local/rcs/XXX/code/pytrace-collector/logs/self_collected/tried/google-research+arxiv-latex-cleaner/google-research+arxiv-latex-cleaner/tex_arXiv'}, '\\includegraphics{images/im2_included.jpg}\n\\addplot{figures/data_included.txt}\n\n\ufeff\\includegraphics{ext_tikz/test2.pdf}\n\n\\begin{document}\nText\n\nText%\n\n\nThis is a percent \\%.\n\\includegraphics{images/im1_included.png}\n\\includegraphics{images/im3_included.png}\n\\includegraphics{%\n  images/im4_included.png%\n  }\n\\includegraphics[width=.5\\linewidth]{%\n  images/im5_included.jpg}\n\n\\includegraphics{./images/im3_included.png}\n\nThis line should not be separated\n%\nfrom this one.\n\n\n\n\\newif\\ifvar\n\n\\ifvar\n\\fi\n\n\\newcommand{\\red}[1]{{\\color{red} #1}}\nhello test hello\ntest hello\ntest\n\n\n\\input{figures/figure_included.tex}\n\n\\includegraphics{ext_tikz/test1.pdf}\n\n\\input{figures/figure_included.tikz}\n\n\\begin{tikzpicture}\n    \\node (test) at (0,0) {Test3};\n\\end{tikzpicture}\n\n\\tikzsetnextfilename{test_no_match}\n\\begin{tikzpicture}\n    \\node (test) at (0,0) {Test4};\n\\end{tikzpicture}\n\n\\end{document}\n', {'all': ['main.bib', 'main.bbl', 'main.tex', 'main.aux', 'ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'in_root': ['main.bib', 'main.bbl', 'main.tex', 'main.aux'], 'not_in_root': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'to_copy_in_root': ['main.bbl', 'main.tex'], 'to_copy_not_in_root': ['figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt'], 'figures': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'tex_in_root': ['main.tex'], 'tex_not_in_root': ['figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex'], 'non_tex_in_root': ['main.bbl'], 'non_tex_not_in_root': ['figures/data_not_included.txt', 'figures/data_included.txt', 'not_included/figures/data_included.txt'], 'external_tikz_figures': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf'], 'svg_inkscape': [], 'tex_to_copy': ['figures/figure_included.tex', 'figures/figure_included.tikz', 'main.tex']})

1. def _resize_and_copy_figures_if_referenced(parameters, contents, splits):
2.   image_size = collections.defaultdict(lambda: parameters['im_size'])
3.   image_size.update(parameters['images_allowlist'])
4.   pdf_resolution = collections.defaultdict(
5.       lambda: parameters['pdf_im_resolution']
6.   )
7.   pdf_resolution.update(parameters['images_allowlist'])
8.   for image_file in _keep_only_referenced(
9.       splits['figures'], contents, strict=False
10.   ):
11.     _resize_and_copy_figure(
12.         filename=image_file,
13.         origin_folder=parameters['input_folder'],
14.         destination_folder=parameters['output_folder'],
15.         resize_image=parameters['resize_images'],
16.         image_size=image_size[image_file],
17.         compress_pdf=parameters['compress_pdf'],
18.         pdf_resolution=pdf_resolution[image_file],
19.     )
20.
21. _resize_and_copy_figures_if_referenced({'input_folder': 'tex', 'images_allowlist': {'images/im2_included.jpg': 200, 'images/im3_included.png': 400}, 'resize_images': True, 'im_size': 100, 'compress_pdf': False, 'pdf_im_resolution': 500, 'commands_to_delete': ['mytodo'], 'commands_only_to_delete': ['red'], 'environments_to_delete': ['mynote'], 'use_external_tikz': 'ext_tikz', 'keep_bib': False, 'to_delete': ['\\.aux$', '\\.sh$', '\\.blg$', '\\.brf$', '\\.log$', '\\.out$', '\\.ps$', '\\.dvi$', '\\.synctex.gz$', '~$', '\\.backup$', '\\.gitignore$', '\\.DS_Store$', '\\.svg$', '^\\.idea', '\\.dpth$', '\\.md5$', '\\.dep$', '\\.auxlock$', '\\.fls$', '\\.fdb_latexmk$', '\\.bib$'], 'figures_to_copy_if_referenced': ['\\.png$', '\\.jpg$', '\\.jpeg$', '\\.pdf$'], 'output_folder': '/local/rcs/XXX/code/pytrace-collector/logs/self_collected/tried/google-research+arxiv-latex-cleaner/google-research+arxiv-latex-cleaner/tex_arXiv'}, '\\includegraphics{images/im2_included.jpg}\n\\addplot{figures/data_included.txt}\n\n\ufeff\\includegraphics{ext_tikz/test2.pdf}\n\n\\begin{document}\nText\n\nText%\n\n\nThis is a percent \\%.\n\\includegraphics{images/im1_included.png}\n\\includegraphics{images/im3_included.png}\n\\includegraphics{%\n  images/im4_included.png%\n  }\n\\includegraphics[width=.5\\linewidth]{%\n  images/im5_included.jpg}\n\n\\includegraphics{./images/im3_included.png}\n\nThis line should not be separated\n%\nfrom this one.\n\n\n\n\\newif\\ifvar\n\n\\ifvar\n\\fi\n\n\\newcommand{\\red}[1]{{\\color{red} #1}}\nhello test hello\ntest hello\ntest\n\n\n\\input{figures/figure_included.tex}\n\n\\includegraphics{ext_tikz/test1.pdf}\n\n\\input{figures/figure_included.tikz}\n\n\\begin{tikzpicture}\n    \\node (test) at (0,0) {Test3};\n\\end{tikzpicture}\n\n\\tikzsetnextfilename{test_no_match}\n\\begin{tikzpicture}\n    \\node (test) at (0,0) {Test4};\n\\end{tikzpicture}\n\n\\end{document}\n', {'all': ['main.bib', 'main.bbl', 'main.tex', 'main.aux', 'ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'in_root': ['main.bib', 'main.bbl', 'main.tex', 'main.aux'], 'not_in_root': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'to_copy_in_root': ['main.bbl', 'main.tex'], 'to_copy_not_in_root': ['figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt'], 'figures': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'tex_in_root': ['main.tex'], 'tex_not_in_root': ['figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex'], 'non_tex_in_root': ['main.bbl'], 'non_tex_not_in_root': ['figures/data_not_included.txt', 'figures/data_included.txt', 'not_included/figures/data_included.txt'], 'external_tikz_figures': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf'], 'svg_inkscape': [], 'tex_to_copy': ['figures/figure_included.tex', 'figures/figure_included.tikz', 'main.tex']})

Question: How many times will the loop on line 8 execute when '_resize_and_copy_figures_if_referenced({'input_folder': 'tex', 'images_allowlist': {'images/im2_included.jpg': 200, 'images/im3_included.png': 400}, 'resize_images': True, 'im_size': 100, 'compress_pdf': False, 'pdf_im_resolution': 500, 'commands_to_delete': ['mytodo'], 'commands_only_to_delete': ['red'], 'environments_to_delete': ['mynote'], 'use_external_tikz': 'ext_tikz', 'keep_bib': False, 'to_delete': ['\\.aux$', '\\.sh$', '\\.blg$', '\\.brf$', '\\.log$', '\\.out$', '\\.ps$', '\\.dvi$', '\\.synctex.gz$', '~$', '\\.backup$', '\\.gitignore$', '\\.DS_Store$', '\\.svg$', '^\\.idea', '\\.dpth$', '\\.md5$', '\\.dep$', '\\.auxlock$', '\\.fls$', '\\.fdb_latexmk$', '\\.bib$'], 'figures_to_copy_if_referenced': ['\\.png$', '\\.jpg$', '\\.jpeg$', '\\.pdf$'], 'output_folder': '/local/rcs/XXX/code/pytrace-collector/logs/self_collected/tried/google-research+arxiv-latex-cleaner/google-research+arxiv-latex-cleaner/tex_arXiv'}, '\\includegraphics{images/im2_included.jpg}\n\\addplot{figures/data_included.txt}\n\n\ufeff\\includegraphics{ext_tikz/test2.pdf}\n\n\\begin{document}\nText\n\nText%\n\n\nThis is a percent \\%.\n\\includegraphics{images/im1_included.png}\n\\includegraphics{images/im3_included.png}\n\\includegraphics{%\n  images/im4_included.png%\n  }\n\\includegraphics[width=.5\\linewidth]{%\n  images/im5_included.jpg}\n\n\\includegraphics{./images/im3_included.png}\n\nThis line should not be separated\n%\nfrom this one.\n\n\n\n\\newif\\ifvar\n\n\\ifvar\n\\fi\n\n\\newcommand{\\red}[1]{{\\color{red} #1}}\nhello test hello\ntest hello\ntest\n\n\n\\input{figures/figure_included.tex}\n\n\\includegraphics{ext_tikz/test1.pdf}\n\n\\input{figures/figure_included.tikz}\n\n\\begin{tikzpicture}\n    \\node (test) at (0,0) {Test3};\n\\end{tikzpicture}\n\n\\tikzsetnextfilename{test_no_match}\n\\begin{tikzpicture}\n    \\node (test) at (0,0) {Test4};\n\\end{tikzpicture}\n\n\\end{document}\n', {'all': ['main.bib', 'main.bbl', 'main.tex', 'main.aux', 'ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'in_root': ['main.bib', 'main.bbl', 'main.tex', 'main.aux'], 'not_in_root': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'to_copy_in_root': ['main.bbl', 'main.tex'], 'to_copy_not_in_root': ['figures/data_not_included.txt', 'figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex', 'figures/data_included.txt', 'not_included/figures/data_included.txt'], 'figures': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf', 'images/im4_included.png', 'images/im1.png', 'images/im4_not_included.png', 'images/im3_included.png', 'images/im2_included.jpg', 'images/im5_not_included.jpg', 'images/im5_included.jpg', 'images/im1_included.png', 'images/im_not_included.png', 'images/include/images/im3_included.png'], 'tex_in_root': ['main.tex'], 'tex_not_in_root': ['figures/figure_not_included.tex', 'figures/figure_not_included_2.tex', 'figures/figure_included.tikz', 'figures/figure_included.tex'], 'non_tex_in_root': ['main.bbl'], 'non_tex_not_in_root': ['figures/data_not_included.txt', 'figures/data_included.txt', 'not_included/figures/data_included.txt'], 'external_tikz_figures': ['ext_tikz/test2.pdf', 'ext_tikz/test1.pdf', 'ext_tikz/figure_not_included.pdf'], 'svg_inkscape': [], 'tex_to_copy': ['figures/figure_included.tex', 'figures/figure_included.tikz', 'main.tex']})' is called?

Answer: 8


def apply_changes(file_path: str, changes: List, confirm: bool = False):
    """
    Pass changes as loaded json (list of dicts)
    """
    with open(file_path) as f: # [STATE] f = <_io.TextIOWrapper name='/tmp/tmp6qrrn_j9' mode='r' encoding='UTF-8'> [/STATE]
        original_file_lines = f.readlines() # [STATE] original_file_lines = ['first line\n', 'second line\n', 'third line'] [/STATE]

    # Filter out explanation elements
    operation_changes = [change for change in changes if "operation" in change] # [STATE] operation_changes = [{'operation': 'Replace', 'line': 2, 'content': 'new second line'}] [/STATE]
    explanations = [ # [STATE] explanations = [] [/STATE]
        change["explanation"] for change in changes if "explanation" in change
    ]

    # Sort the changes in reverse line order
    operation_changes.sort(key=lambda x: x["line"], reverse=True)

    file_lines = original_file_lines.copy() # [STATE] file_lines = ['first line\n', 'second line\n', 'third line'] [/STATE]
    for change in operation_changes: #  [STATE] 1 [/STATE]
        operation = change["operation"] # [STATE] operation = 'Replace' [/STATE]
        line = change["line"] # [STATE] line = 2 [/STATE]
        content = change["content"] # [STATE] content = 'new second line' [/STATE]

        if operation == "Replace":
            file_lines[line - 1] = content + "\n" # [STATE] file_lines = ['first line\n', 'new second line\n', 'third line'] [/STATE]
        elif operation == "Delete":
            del file_lines[line - 1]
        elif operation == "InsertAfter":
            file_lines.insert(line, content + "\n")

    # Print explanations
    cprint("Explanations:", "blue")
    for explanation in explanations:
        cprint(f"- {explanation}", "blue")

    # Display changes diff
    print("\nChanges to be made:")
    diff = difflib.unified_diff(original_file_lines, file_lines, lineterm="") # [STATE] diff = <generator object unified_diff at 0x7f5b71b2cba0> [/STATE]
    for line in diff: #  [STATE] 8 [/STATE]
        if line.startswith("+"):
            cprint(line, "green", end="")
        elif line.startswith("-"):
            cprint(line, "red", end="")
        else:
            print(line, end="")

    if confirm:
        # check if user wants to apply changes or exit
        confirmation = input("Do you want to apply these changes? (y/n): ")
        if confirmation.lower() != "y":
            print("Changes not applied")
            sys.exit(0)

    with open(file_path, "w") as f: # [STATE] f = <_io.TextIOWrapper name='/tmp/tmp6qrrn_j9' mode='w' encoding='UTF-8'> [/STATE]
        f.writelines(file_lines)
    print("Changes applied.")

apply_changes('/tmp/tmp6qrrn_j9', [{'operation': 'Replace', 'line': 2, 'content': 'new second line'}], False)

1. def apply_changes(file_path: str, changes: List, confirm: bool = False):
2.     """
3.     Pass changes as loaded json (list of dicts)
4.     """
5.     with open(file_path) as f:
6.         original_file_lines = f.readlines()
7.
8.     # Filter out explanation elements
9.     operation_changes = [change for change in changes if "operation" in change]
10.     explanations = [
11.         change["explanation"] for change in changes if "explanation" in change
12.     ]
13.
14.     # Sort the changes in reverse line order
15.     operation_changes.sort(key=lambda x: x["line"], reverse=True)
16.
17.     file_lines = original_file_lines.copy()
18.     for change in operation_changes:
19.         operation = change["operation"]
20.         line = change["line"]
21.         content = change["content"]
22.
23.         if operation == "Replace":
24.             file_lines[line - 1] = content + "\n"
25.         elif operation == "Delete":
26.             del file_lines[line - 1]
27.         elif operation == "InsertAfter":
28.             file_lines.insert(line, content + "\n")
29.
30.     # Print explanations
31.     cprint("Explanations:", "blue")
32.     for explanation in explanations:
33.         cprint(f"- {explanation}", "blue")
34.
35.     # Display changes diff
36.     print("\nChanges to be made:")
37.     diff = difflib.unified_diff(original_file_lines, file_lines, lineterm="")
38.     for line in diff:
39.         if line.startswith("+"):
40.             cprint(line, "green", end="")
41.         elif line.startswith("-"):
42.             cprint(line, "red", end="")
43.         else:
44.             print(line, end="")
45.
46.     if confirm:
47.         # check if user wants to apply changes or exit
48.         confirmation = input("Do you want to apply these changes? (y/n): ")
49.         if confirmation.lower() != "y":
50.             print("Changes not applied")
51.             sys.exit(0)
52.
53.     with open(file_path, "w") as f:
54.         f.writelines(file_lines)
55.     print("Changes applied.")
56.
57. apply_changes('/tmp/tmp6qrrn_j9', [{'operation': 'Replace', 'line': 2, 'content': 'new second line'}], False)

Question: How many times will the loop on line 38 execute when 'apply_changes('/tmp/tmp6qrrn_j9', [{'operation': 'Replace', 'line': 2, 'content': 'new second line'}], False)' is called?

Answer: 8


def collect_file_tests(path, lines, lines_to_execute):
    def makecase(t): # [STATE] makecase = <function collect_file_tests.<locals>.makecase at 0x7f586017dee0> [/STATE]
        return IntegrationTestCase(t, correct, line_nr, column,
                                   start, line, path=path,
                                   skip_version_info=skip_version_info)

    start = None # [STATE] start = None [/STATE]
    correct = None # [STATE] correct = None [/STATE]
    test_type = None # [STATE] test_type = None [/STATE]
    skip_version_info = None # [STATE] skip_version_info = None [/STATE]
    for line_nr, line in enumerate(lines, 1): #  [STATE] 6 [/STATE]
        if correct is not None:
            r = re.match(r'^(\d+)\s*(.*)$', correct)
            if r:
                column = int(r.group(1))
                correct = r.group(2)
                start += r.regs[2][0]  # second group, start index
            else:
                column = len(line) - 1  # -1 for the \n
            if test_type == '!':
                yield makecase(TEST_GOTO)
            elif test_type == '<':
                yield makecase(TEST_REFERENCES)
            elif correct.startswith('['):
                yield makecase(TEST_COMPLETIONS)
            else:
                yield makecase(TEST_INFERENCE)
            correct = None
        else:
            skip_version_info = skip_python_version(line) or skip_version_info
            try:
                r = re.search(r'(?:^|(?<=\s))#([?!<])\s*([^\n]*)', line) #  [STATE] r = None [/STATE]
                # test_type is ? for completion and ! for goto
                test_type = r.group(1) #  [STATE] E [/STATE] [STATE] X [/STATE] [STATE] C [/STATE] [STATE] E [/STATE] [STATE] P [/STATE] [STATE] T [/STATE] [STATE] I [/STATE] [STATE] O [/STATE] [STATE] N [/STATE] [STATE] : [/STATE] [STATE]   [/STATE] [STATE] A [/STATE] [STATE] t [/STATE] [STATE] t [/STATE] [STATE] r [/STATE] [STATE] i [/STATE] [STATE] b [/STATE] [STATE] u [/STATE] [STATE] t [/STATE] [STATE] e [/STATE] [STATE] E [/STATE] [STATE] r [/STATE] [STATE] r [/STATE] [STATE] o [/STATE] [STATE] r [/STATE] [STATE] : [/STATE] [STATE]   [/STATE] [STATE] ' [/STATE] [STATE] N [/STATE] [STATE] o [/STATE] [STATE] n [/STATE] [STATE] e [/STATE] [STATE] T [/STATE] [STATE] y [/STATE] [STATE] p [/STATE] [STATE] e [/STATE] [STATE] ' [/STATE] [STATE]   [/STATE] [STATE] o [/STATE] [STATE] b [/STATE] [STATE] j [/STATE] [STATE] e [/STATE] [STATE] c [/STATE] [STATE] t [/STATE] [STATE]   [/STATE] [STATE] h [/STATE] [STATE] a [/STATE] [STATE] s [/STATE] [STATE]   [/STATE] [STATE] n [/STATE] [STATE] o [/STATE] [STATE]   [/STATE] [STATE] a [/STATE] [STATE] t [/STATE] [STATE] t [/STATE] [STATE] r [/STATE] [STATE] i [/STATE] [STATE] b [/STATE] [STATE] u [/STATE] [STATE] t [/STATE] [STATE] e [/STATE] [STATE]   [/STATE] [STATE] ' [/STATE] [STATE] g [/STATE] [STATE] r [/STATE] [STATE] o [/STATE] [STATE] u [/STATE] [STATE] p [/STATE] [STATE] ' [/STATE]
                correct = r.group(2)
                # Quick hack to make everything work (not quite a bloody unicorn hack though).
                if correct == '':
                    correct = ' '
                start = r.start()
            except AttributeError:
                correct = None
            else:
                # Skip the test, if this is not specified test.
                for l in lines_to_execute:
                    if isinstance(l, tuple) and l[0] <= line_nr <= l[1] \
                            or line_nr == l:
                        break
                else:
                    if lines_to_execute:
                        correct = None

collect_file_tests('/local/rcs/XXX/code/pytrace-collector/logs/self_collected/tried/davidhalter+jedi/davidhalter+jedi/test/completion/fixture_module.py', {}, [])

1. def collect_file_tests(path, lines, lines_to_execute):
2.     def makecase(t):
3.         return IntegrationTestCase(t, correct, line_nr, column,
4.                                    start, line, path=path,
5.                                    skip_version_info=skip_version_info)
6.
7.     start = None
8.     correct = None
9.     test_type = None
10.     skip_version_info = None
11.     for line_nr, line in enumerate(lines, 1):
12.         if correct is not None:
13.             r = re.match(r'^(\d+)\s*(.*)$', correct)
14.             if r:
15.                 column = int(r.group(1))
16.                 correct = r.group(2)
17.                 start += r.regs[2][0]  # second group, start index
18.             else:
19.                 column = len(line) - 1  # -1 for the \n
20.             if test_type == '!':
21.                 yield makecase(TEST_GOTO)
22.             elif test_type == '<':
23.                 yield makecase(TEST_REFERENCES)
24.             elif correct.startswith('['):
25.                 yield makecase(TEST_COMPLETIONS)
26.             else:
27.                 yield makecase(TEST_INFERENCE)
28.             correct = None
29.         else:
30.             skip_version_info = skip_python_version(line) or skip_version_info
31.             try:
32.                 r = re.search(r'(?:^|(?<=\s))
33.                 # test_type is ? for completion and ! for goto
34.                 test_type = r.group(1)
35.                 correct = r.group(2)
36.                 # Quick hack to make everything work (not quite a bloody unicorn hack though).
37.                 if correct == '':
38.                     correct = ' '
39.                 start = r.start()
40.             except AttributeError:
41.                 correct = None
42.             else:
43.                 # Skip the test, if this is not specified test.
44.                 for l in lines_to_execute:
45.                     if isinstance(l, tuple) and l[0] <= line_nr <= l[1] \
46.                             or line_nr == l:
47.                         break
48.                 else:
49.                     if lines_to_execute:
50.                         correct = None
51.
52. collect_file_tests('/local/rcs/XXX/code/pytrace-collector/logs/self_collected/tried/davidhalter+jedi/davidhalter+jedi/test/completion/fixture_module.py', {}, [])

Question: How many times will the loop on line 11 execute when 'collect_file_tests('/local/rcs/XXX/code/pytrace-collector/logs/self_collected/tried/davidhalter+jedi/davidhalter+jedi/test/completion/fixture_module.py', {}, [])' is called?

Answer: 6


def parse_layout(layout_str):
    """Parse a layout string

    Return a dict
        {'walls': list_of_wall_coordinates,
         'food' : list_of_food_coordinates,
         'bot'  : list_of_4_bot_coordinate}

    A layout string is composed of wall characters '#', food characters '.', and
    bot characters '0', '1', '2', and '3'.

    Valid layouts must be enclosed by walls and be of rectangular shape. Example:

     ########
     #0  .  #
     #2    1#
     #  .  3#
     ########

    If items are overlapping, several layout strings can be concateneted:
     ########
     #0  .  #
     #     1#
     #  .  3#
     ########
     ########
     #2  .  #
     #     1#
     #  .  3#
     ########

     In this case, bot '0' and bot '2' are on top of each other at position (1,1)
    """
    layout_list = [] # [STATE] layout_list = [] [/STATE]
    start = False # [STATE] start = False [/STATE]
    for i, line in enumerate(layout_str.splitlines()): #  [STATE] 9 [/STATE]
        row = line.strip() #  [STATE] row = '' [/STATE] [STATE] row = '##################' [/STATE] [STATE] row = '#. ... .##.     3#' [/STATE] [STATE] row = '# # #  .  .### #1#' [/STATE] [STATE] row = '# # ##.   .      #' [/STATE] [STATE] row = '#      .   .## # #' [/STATE] [STATE] row = '#0# ###.  .  # # #' [/STATE] [STATE] row = '#2     .##. ... .#' [/STATE]
        if not row:
            # ignore emptylines
            continue
        if not start:
            # start a new layout
            # check that row is a valid opening string
            if row.count('#') != len(row):
                raise ValueError(f"Layout does not start with a row of walls (line: {i})!")
            current_layout = [row] # [STATE] current_layout = ['##################'] [/STATE]
            start = True # [STATE] start = True [/STATE]
            continue
        # we are in the middle of a layout, just append to the current
        # layout unless we detect the closing string
        current_layout.append(row) #  [STATE] current_layout = ['##################', '#. ... .##.     3#'] [/STATE] [STATE] current_layout = ['##################', '#. ... .##.     3#', '# # #  .  .### #1#'] [/STATE] [STATE] current_layout = ['##################', '#. ... .##.     3#', '# # #  .  .### #1#', '# # ##.   .      #'] [/STATE] [STATE] current_layout = ['##################', '#. ... .##.     3#', '# # #  .  .### #1#', '# # ##.   .      #', '#      .   .## # #'] [/STATE] [STATE] current_layout = ['##################', '#. ... .##.     3#', '# # #  .  .### #1#', '# # ##.   .      #', '#      .   .## # #', '#0# ###.  .  # # #'] [/STATE] [STATE] current_layout = ['##################', '#. ... .##.     3#', '# # #  .  .### #1#', '# # ##.   .      #', '#      .   .## # #', '#0# ###.  .  # # #', '#2     .##. ... .#'] [/STATE] [STATE] current_layout = ['##################', '#. ... .##.     3#', '# # #  .  .### #1#', '# # ##.   .      #', '#      .   .## # #', '#0# ###.  .  # # #', '#2     .##. ... .#', '##################'] [/STATE]
        if row.count('#') == len(row):
            # this is a closing string
            # append the layout to tha layout list
            layout_list.append('\n'.join(current_layout)) # [STATE] layout_list = ['##################\n#. ... .##.     3#\n# # #  .  .### #1#\n# # ##.   .      #\n#      .   .## # #\n#0# ###.  .  # # #\n#2     .##. ... .#\n##################'] [/STATE]
            start = False # [STATE] start = False [/STATE]

    if start:
        # the last layout has not been closed, complain here!
        raise ValueError(f"Layout does not end with a row of walls (line: {i})!")

    # initialize walls, food and bots from the first layout
    out = parse_single_layout(layout_list.pop(0)) # [STATE] out = {'walls': [(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (1, 0), (1, 7), (2, 0), (2, 2), (2, 3), (2, 5), (2, 7), (3, 0), (3, 7), (4, 0), (4, 2), (4, 3), (4, 5), (4, 7), (5, 0), (5, 3), (5, 5), (5, 7), (6, 0), (6, 5), (6, 7), (7, 0), (7, 7), (8, 0), (8, 1), (8, 6), (8, 7), (9, 0), (9, 1), (9, 6), (9, 7), (10, 0), (10, 7), (11, 0), (11, 2), (11, 7), (12, 0), (12, 2), (12, 4), (12, 7), (13, 0), (13, 2), (13, 4), (13, 5), (13, 7), (14, 0), (14, 7), (15, 0), (15, 2), (15, 4), (15, 5), (15, 7), (16, 0), (16, 7), (17, 0), (17, 1), (17, 2), (17, 3), (17, 4), (17, 5), (17, 6), (17, 7)], 'food': [(1, 1), (3, 1), (4, 1), (5, 1), (6, 3), (7, 1), (7, 2), (7, 4), (7, 5), (7, 6), (10, 1), (10, 2), (10, 3), (10, 5), (10, 6), (11, 4), (12, 6), (13, 6), (14, 6), (16, 6)], 'bots': [(1, 5), (16, 2), (1, 6), (16, 1)]} [/STATE] # [STATE] layout_list = [] [/STATE]
    for layout in layout_list:
        items = parse_layout(layout)
        # walls should always be the same
        if items['walls'] != out['walls']:
            raise ValueError('Walls are not equal in all layouts!')
        # add the food, removing duplicates
        out['food'] = list(set(out['food'] + items['food']))
        # add the bots
        for bot_idx, bot_pos in enumerate(items['bots']):
            if bot_pos:
                # this bot position is not None, overwrite whatever we had before
                out['bots'][bot_idx] = bot_pos

    return out

parse_layout('\n        ##################\n        #. ... .##.     3#\n        # # #  .  .### #1#\n        # # ##.   .      #\n        #      .   .## # #\n        #0# ###.  .  # # #\n        #2     .##. ... .#\n        ################## ')

1. def parse_layout(layout_str):
2.     """Parse a layout string
3.
4.     Return a dict
5.         {'walls': list_of_wall_coordinates,
6.          'food' : list_of_food_coordinates,
7.          'bot'  : list_of_4_bot_coordinate}
8.
9.     A layout string is composed of wall characters '#', food characters '.', and
10.     bot characters '0', '1', '2', and '3'.
11.
12.     Valid layouts must be enclosed by walls and be of rectangular shape. Example:
13.
14.      ########
15.      #0  .  #
16.      #2    1#
17.      #  .  3#
18.      ########
19.
20.
21.     If items are overlapping, several layout strings can be concateneted:
22.      ########
23.      #0  .  #
24.      #     1#
25.      #  .  3#
26.      ########
27.      ########
28.      #2  .  #
29.      #     1#
30.      #  .  3#
31.      ########
32.
33.      In this case, bot '0' and bot '2' are on top of each other at position (1,1)
34.     """
35.     layout_list = []
36.     start = False
37.     for i, line in enumerate(layout_str.splitlines()):
38.         row = line.strip()
39.         if not row:
40.             # ignore emptylines
41.             continue
42.         if not start:
43.             # start a new layout
44.             # check that row is a valid opening string
45.             if row.count('#') != len(row):
46.                 raise ValueError(f"Layout does not start with a row of walls (line: {i})!")
47.             current_layout = [row]
48.             start = True
49.             continue
50.         # we are in the middle of a layout, just append to the current
51.         # layout unless we detect the closing string
52.         current_layout.append(row)
53.         if row.count('#') == len(row):
54.             # this is a closing string
55.             # append the layout to tha layout list
56.             layout_list.append('\n'.join(current_layout))
57.             start = False
58.
59.     if start:
60.         # the last layout has not been closed, complain here!
61.         raise ValueError(f"Layout does not end with a row of walls (line: {i})!")
62.
63.     # initialize walls, food and bots from the first layout
64.     out = parse_single_layout(layout_list.pop(0))
65.     for layout in layout_list:
66.         items = parse_layout(layout)
67.         # walls should always be the same
68.         if items['walls'] != out['walls']:
69.             raise ValueError('Walls are not equal in all layouts!')
70.         # add the food, removing duplicates
71.         out['food'] = list(set(out['food'] + items['food']))
72.         # add the bots
73.         for bot_idx, bot_pos in enumerate(items['bots']):
74.             if bot_pos:
75.                 # this bot position is not None, overwrite whatever we had before
76.                 out['bots'][bot_idx] = bot_pos
77.
78.     return out
79.
80. parse_layout('\n        ##################\n        #. ... .##.     3#\n        # # #  .  .### #1#\n        # # ##.   .      #\n        #      .   .## # #\n        #0# ###.  .  # # #\n        #2     .##. ... .#\n        ################## ')

Question: How many times will the loop on line 37 execute when 'parse_layout('\n        ##################\n        #. ... .##.     3#\n        # # #  .  .### #1#\n        # # ##.   .      #\n        #      .   .## # #\n        #0# ###.  .  # # #\n        #2     .##. ... .#\n        ################## ')' is called?

Answer: 9


def parse_single_layout(layout_str):
    """Parse a single layout from a string

    See parse_layout for details about valid layout strings.
    """
    # width of the layout (x-axis)
    width = None # [STATE] width = None [/STATE]
    # list of layout rows
    rows = [] # [STATE] rows = [] [/STATE]
    start = False # [STATE] start = False [/STATE]
    for i, line in enumerate(layout_str.splitlines()): #  [STATE] 7 [/STATE]
        row = line.strip() #  [STATE] row = '##################' [/STATE] [STATE] row = '#. ... .##.     3#' [/STATE] [STATE] row = '# # #  .  .### #1#' [/STATE] [STATE] row = '# # ##.   .      #' [/STATE] [STATE] row = '#      .   .## # #' [/STATE] [STATE] row = '#0# ###.  .  # # #' [/STATE] [STATE] row = '#2     .##. ... .#' [/STATE]
        if not row:
            # always ignore empty lines
            continue
        # a layout is always started by a full row of walls
        if not start:
            if row.count('#') != len(row):
                raise ValueError(f"Layout must be enclosed by walls (line: {i})!")
            else:
                # start the layout parsing
                start = True # [STATE] start = True [/STATE]
                # set width of layout
                width = len(row) # [STATE] width = 18 [/STATE]
                # check that width is even
                if width % 2:
                    raise ValueError(f"Layout width must be even (found {width})!")
                rows.append(row) # [STATE] rows = ['##################'] [/STATE]
                continue
        # Here we are within the layout
        # every row must have the same length
        if len(row) != width:
            raise ValueError(f"Layout rows have differing widths (line: {i})!")
        # rows are always enclosed by walls
        if row[0] != '#' or row[-1] != '#':
            raise ValueError(f"Layout must be enclosed by walls (line:{i})!")
        # append current row to the list of rows
        rows.append(row) #  [STATE] rows = ['##################', '#. ... .##.     3#'] [/STATE] [STATE] rows = ['##################', '#. ... .##.     3#', '# # #  .  .### #1#'] [/STATE] [STATE] rows = ['##################', '#. ... .##.     3#', '# # #  .  .### #1#', '# # ##.   .      #'] [/STATE] [STATE] rows = ['##################', '#. ... .##.     3#', '# # #  .  .### #1#', '# # ##.   .      #', '#      .   .## # #'] [/STATE] [STATE] rows = ['##################', '#. ... .##.     3#', '# # #  .  .### #1#', '# # ##.   .      #', '#      .   .## # #', '#0# ###.  .  # # #'] [/STATE] [STATE] rows = ['##################', '#. ... .##.     3#', '# # #  .  .### #1#', '# # ##.   .      #', '#      .   .## # #', '#0# ###.  .  # # #', '#2     .##. ... .#'] [/STATE] [STATE] rows = ['##################', '#. ... .##.     3#', '# # #  .  .### #1#', '# # ##.   .      #', '#      .   .## # #', '#0# ###.  .  # # #', '#2     .##. ... .#', '##################'] [/STATE]
        # detect closing row and ignore whatever follows
        if row.count('#') == len(row):
            start = False # [STATE] start = False [/STATE]
            break

    if start:
        # layout has not been closed!
        raise ValueError(f"Layout must be enclosed by walls (line:{i})!")

    # height of the layout (y-axis)
    height = len(rows) # [STATE] height = 8 [/STATE]
    walls = [] # [STATE] walls = [] [/STATE]
    food = [] # [STATE] food = [] [/STATE]
    # bot positions (we assume 4 bots)
    bots = [None]*4 # [STATE] bots = [None, None, None, None] [/STATE]

    # iterate through the grid of characters
    for y, row in enumerate(rows): #  [STATE] 8 [/STATE]
        for x, char in enumerate(row): #  [STATE] 151 [/STATE]
            coord = (x, y) #  [STATE] coord = (0, 0) [/STATE] [STATE] coord = (1, 0) [/STATE] [STATE] coord = (2, 0) [/STATE] [STATE] coord = (3, 0) [/STATE] [STATE] coord = (4, 0) [/STATE] [STATE] coord = (5, 0) [/STATE] [STATE] coord = (6, 0) [/STATE] [STATE] coord = (7, 0) [/STATE] [STATE] coord = (8, 0) [/STATE] [STATE] coord = (9, 0) [/STATE] [STATE] coord = (10, 0) [/STATE] [STATE] coord = (11, 0) [/STATE] [STATE] coord = (12, 0) [/STATE] [STATE] coord = (13, 0) [/STATE] [STATE] coord = (14, 0) [/STATE] [STATE] coord = (15, 0) [/STATE] [STATE] coord = (16, 0) [/STATE] [STATE] coord = (17, 0) [/STATE] [STATE] coord = (0, 1) [/STATE] [STATE] coord = (1, 1) [/STATE] [STATE] coord = (2, 1) [/STATE] [STATE] coord = (3, 1) [/STATE] [STATE] coord = (4, 1) [/STATE] [STATE] coord = (5, 1) [/STATE] [STATE] coord = (6, 1) [/STATE] [STATE] coord = (7, 1) [/STATE] [STATE] coord = (8, 1) [/STATE] [STATE] coord = (9, 1) [/STATE] [STATE] coord = (10, 1) [/STATE] [STATE] coord = (11, 1) [/STATE] [STATE] coord = (12, 1) [/STATE] [STATE] coord = (13, 1) [/STATE] [STATE] coord = (14, 1) [/STATE] [STATE] coord = (15, 1) [/STATE] [STATE] coord = (16, 1) [/STATE] [STATE] coord = (17, 1) [/STATE] [STATE] coord = (0, 2) [/STATE] [STATE] coord = (1, 2) [/STATE] [STATE] coord = (2, 2) [/STATE] [STATE] coord = (3, 2) [/STATE] [STATE] coord = (4, 2) [/STATE] [STATE] coord = (5, 2) [/STATE] [STATE] coord = (6, 2) [/STATE] [STATE] coord = (7, 2) [/STATE] [STATE] coord = (8, 2) [/STATE] [STATE] coord = (9, 2) [/STATE] [STATE] coord = (10, 2) [/STATE] [STATE] coord = (11, 2) [/STATE] [STATE] coord = (12, 2) [/STATE] [STATE] coord = (13, 2) [/STATE] [STATE] coord = (14, 2) [/STATE] [STATE] coord = (15, 2) [/STATE] [STATE] coord = (16, 2) [/STATE] [STATE] coord = (17, 2) [/STATE] [STATE] coord = (0, 3) [/STATE] [STATE] coord = (1, 3) [/STATE] [STATE] coord = (2, 3) [/STATE] [STATE] coord = (3, 3) [/STATE] [STATE] coord = (4, 3) [/STATE] [STATE] coord = (5, 3) [/STATE] [STATE] coord = (6, 3) [/STATE] [STATE] coord = (7, 3) [/STATE] [STATE] coord = (8, 3) [/STATE] [STATE] coord = (9, 3) [/STATE] [STATE] coord = (10, 3) [/STATE] [STATE] coord = (11, 3) [/STATE] [STATE] coord = (12, 3) [/STATE] [STATE] coord = (13, 3) [/STATE] [STATE] coord = (14, 3) [/STATE] [STATE] coord = (15, 3) [/STATE] [STATE] coord = (16, 3) [/STATE] [STATE] coord = (17, 3) [/STATE] [STATE] coord = (0, 4) [/STATE] [STATE] coord = (1, 4) [/STATE] [STATE] coord = (2, 4) [/STATE] [STATE] coord = (3, 4) [/STATE] [STATE] coord = (4, 4) [/STATE] [STATE] coord = (5, 4) [/STATE] [STATE] coord = (6, 4) [/STATE] [STATE] coord = (7, 4) [/STATE] [STATE] coord = (8, 4) [/STATE] [STATE] coord = (9, 4) [/STATE] [STATE] coord = (10, 4) [/STATE] [STATE] coord = (11, 4) [/STATE] [STATE] coord = (12, 4) [/STATE] [STATE] coord = (13, 4) [/STATE] [STATE] coord = (14, 4) [/STATE] [STATE] coord = (15, 4) [/STATE] [STATE] coord = (16, 4) [/STATE] [STATE] coord = (17, 4) [/STATE] [STATE] coord = (0, 5) [/STATE] [STATE] coord = (1, 5) [/STATE] [STATE] coord = (2, 5) [/STATE] [STATE] coord = (3, 5) [/STATE] [STATE] coord = (4, 5) [/STATE] [STATE] coord = (5, 5) [/STATE] [STATE] coord = (6, 5) [/STATE] [STATE] coord = (7, 5) [/STATE] [STATE] coord = (8, 5) [/STATE] [STATE] coord = (9, 5) [/STATE] [STATE] coord = (10, 5) [/STATE] [STATE] coord = (11, 5) [/STATE] [STATE] coord = (12, 5) [/STATE] [STATE] coord = (13, 5) [/STATE] [STATE] coord = (14, 5) [/STATE] [STATE] coord = (15, 5) [/STATE] [STATE] coord = (16, 5) [/STATE] [STATE] coord = (17, 5) [/STATE] [STATE] coord = (0, 6) [/STATE] [STATE] coord = (1, 6) [/STATE] [STATE] coord = (2, 6) [/STATE] [STATE] coord = (3, 6) [/STATE] [STATE] coord = (4, 6) [/STATE] [STATE] coord = (5, 6) [/STATE] [STATE] coord = (6, 6) [/STATE] [STATE] coord = (7, 6) [/STATE] [STATE] coord = (8, 6) [/STATE] [STATE] coord = (9, 6) [/STATE] [STATE] coord = (10, 6) [/STATE] [STATE] coord = (11, 6) [/STATE] [STATE] coord = (12, 6) [/STATE] [STATE] coord = (13, 6) [/STATE] [STATE] coord = (14, 6) [/STATE] [STATE] coord = (15, 6) [/STATE] [STATE] coord = (16, 6) [/STATE] [STATE] coord = (17, 6) [/STATE] [STATE] coord = (0, 7) [/STATE] [STATE] coord = (1, 7) [/STATE] [STATE] coord = (2, 7) [/STATE] [STATE] coord = (3, 7) [/STATE] [STATE] coord = (4, 7) [/STATE] [STATE] coord = (5, 7) [/STATE] [STATE] coord = (6, 7) [/STATE] [STATE] coord = (7, 7) [/STATE] [STATE] coord = (8, 7) [/STATE] [STATE] coord = (9, 7) [/STATE] [STATE] coord = (10, 7) [/STATE] [STATE] coord = (11, 7) [/STATE] [STATE] coord = (12, 7) [/STATE] [STATE] coord = (13, 7) [/STATE] [STATE] coord = (14, 7) [/STATE] [STATE] coord = (15, 7) [/STATE] [STATE] coord = (16, 7) [/STATE] [STATE] coord = (17, 7) [/STATE]
            # assign the char to the corresponding list
            if char == '#':
                # wall
                walls.append(coord) #  [STATE] walls = [(0, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7), (2, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7), (2, 7), (3, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7), (2, 7), (3, 7), (4, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7), (2, 7), (3, 7), (4, 7), (5, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7), (7, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7), (7, 7), (8, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7), (7, 7), (8, 7), (9, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7), (7, 7), (8, 7), (9, 7), (10, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7), (7, 7), (8, 7), (9, 7), (10, 7), (11, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7), (7, 7), (8, 7), (9, 7), (10, 7), (11, 7), (12, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7), (7, 7), (8, 7), (9, 7), (10, 7), (11, 7), (12, 7), (13, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7), (7, 7), (8, 7), (9, 7), (10, 7), (11, 7), (12, 7), (13, 7), (14, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7), (7, 7), (8, 7), (9, 7), (10, 7), (11, 7), (12, 7), (13, 7), (14, 7), (15, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7), (7, 7), (8, 7), (9, 7), (10, 7), (11, 7), (12, 7), (13, 7), (14, 7), (15, 7), (16, 7)] [/STATE] [STATE] walls = [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0), (11, 0), (12, 0), (13, 0), (14, 0), (15, 0), (16, 0), (17, 0), (0, 1), (8, 1), (9, 1), (17, 1), (0, 2), (2, 2), (4, 2), (11, 2), (12, 2), (13, 2), (15, 2), (17, 2), (0, 3), (2, 3), (4, 3), (5, 3), (17, 3), (0, 4), (12, 4), (13, 4), (15, 4), (17, 4), (0, 5), (2, 5), (4, 5), (5, 5), (6, 5), (13, 5), (15, 5), (17, 5), (0, 6), (8, 6), (9, 6), (17, 6), (0, 7), (1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7), (7, 7), (8, 7), (9, 7), (10, 7), (11, 7), (12, 7), (13, 7), (14, 7), (15, 7), (16, 7), (17, 7)] [/STATE]
            elif char == '.':
                # food
                food.append(coord) #  [STATE] food = [(1, 1)] [/STATE] [STATE] food = [(1, 1), (3, 1)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (7, 1)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (7, 1), (10, 1)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (7, 1), (10, 1), (7, 2)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (7, 1), (10, 1), (7, 2), (10, 2)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (7, 1), (10, 1), (7, 2), (10, 2), (6, 3)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (7, 1), (10, 1), (7, 2), (10, 2), (6, 3), (10, 3)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (7, 1), (10, 1), (7, 2), (10, 2), (6, 3), (10, 3), (7, 4)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (7, 1), (10, 1), (7, 2), (10, 2), (6, 3), (10, 3), (7, 4), (11, 4)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (7, 1), (10, 1), (7, 2), (10, 2), (6, 3), (10, 3), (7, 4), (11, 4), (7, 5)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (7, 1), (10, 1), (7, 2), (10, 2), (6, 3), (10, 3), (7, 4), (11, 4), (7, 5), (10, 5)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (7, 1), (10, 1), (7, 2), (10, 2), (6, 3), (10, 3), (7, 4), (11, 4), (7, 5), (10, 5), (7, 6)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (7, 1), (10, 1), (7, 2), (10, 2), (6, 3), (10, 3), (7, 4), (11, 4), (7, 5), (10, 5), (7, 6), (10, 6)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (7, 1), (10, 1), (7, 2), (10, 2), (6, 3), (10, 3), (7, 4), (11, 4), (7, 5), (10, 5), (7, 6), (10, 6), (12, 6)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (7, 1), (10, 1), (7, 2), (10, 2), (6, 3), (10, 3), (7, 4), (11, 4), (7, 5), (10, 5), (7, 6), (10, 6), (12, 6), (13, 6)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (7, 1), (10, 1), (7, 2), (10, 2), (6, 3), (10, 3), (7, 4), (11, 4), (7, 5), (10, 5), (7, 6), (10, 6), (12, 6), (13, 6), (14, 6)] [/STATE] [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (7, 1), (10, 1), (7, 2), (10, 2), (6, 3), (10, 3), (7, 4), (11, 4), (7, 5), (10, 5), (7, 6), (10, 6), (12, 6), (13, 6), (14, 6), (16, 6)] [/STATE]
            elif char == ' ':
                # empty
                continue
            else:
                # bot
                try:
                    # we expect an 0<=index<=3
                    bot_idx = int(char) #  [STATE] bot_idx = 3 [/STATE] [STATE] bot_idx = 1 [/STATE] [STATE] bot_idx = 0 [/STATE] [STATE] bot_idx = 2 [/STATE]
                    if bot_idx >= len(bots):
                        # reuse the except below
                        raise ValueError
                except ValueError:
                    raise ValueError(f"Unknown character {char} in maze!")
                bots[bot_idx] = coord #  [STATE] bots = [None, None, None, (16, 1)] [/STATE] [STATE] bots = [None, (16, 2), None, (16, 1)] [/STATE] [STATE] bots = [(1, 5), (16, 2), None, (16, 1)] [/STATE] [STATE] bots = [(1, 5), (16, 2), (1, 6), (16, 1)] [/STATE]
    walls.sort() # [STATE] walls = [(0, 0), (0, 1), (0, 2), (0, 3), (0, 4), (0, 5), (0, 6), (0, 7), (1, 0), (1, 7), (2, 0), (2, 2), (2, 3), (2, 5), (2, 7), (3, 0), (3, 7), (4, 0), (4, 2), (4, 3), (4, 5), (4, 7), (5, 0), (5, 3), (5, 5), (5, 7), (6, 0), (6, 5), (6, 7), (7, 0), (7, 7), (8, 0), (8, 1), (8, 6), (8, 7), (9, 0), (9, 1), (9, 6), (9, 7), (10, 0), (10, 7), (11, 0), (11, 2), (11, 7), (12, 0), (12, 2), (12, 4), (12, 7), (13, 0), (13, 2), (13, 4), (13, 5), (13, 7), (14, 0), (14, 7), (15, 0), (15, 2), (15, 4), (15, 5), (15, 7), (16, 0), (16, 7), (17, 0), (17, 1), (17, 2), (17, 3), (17, 4), (17, 5), (17, 6), (17, 7)] [/STATE]
    food.sort() # [STATE] food = [(1, 1), (3, 1), (4, 1), (5, 1), (6, 3), (7, 1), (7, 2), (7, 4), (7, 5), (7, 6), (10, 1), (10, 2), (10, 3), (10, 5), (10, 6), (11, 4), (12, 6), (13, 6), (14, 6), (16, 6)] [/STATE]
    return {'walls':walls, 'food':food, 'bots':bots}

parse_single_layout('##################\n#. ... .##.     3#\n# # #  .  .### #1#\n# # ##.   .      #\n#      .   .## # #\n#0# ###.  .  # # #\n#2     .##. ... .#\n##################')

1. def parse_single_layout(layout_str):
2.     """Parse a single layout from a string
3.
4.     See parse_layout for details about valid layout strings.
5.     """
6.     # width of the layout (x-axis)
7.     width = None
8.     # list of layout rows
9.     rows = []
10.     start = False
11.     for i, line in enumerate(layout_str.splitlines()):
12.         row = line.strip()
13.         if not row:
14.             # always ignore empty lines
15.             continue
16.         # a layout is always started by a full row of walls
17.         if not start:
18.             if row.count('#') != len(row):
19.                 raise ValueError(f"Layout must be enclosed by walls (line: {i})!")
20.             else:
21.                 # start the layout parsing
22.                 start = True
23.                 # set width of layout
24.                 width = len(row)
25.                 # check that width is even
26.                 if width % 2:
27.                     raise ValueError(f"Layout width must be even (found {width})!")
28.                 rows.append(row)
29.                 continue
30.         # Here we are within the layout
31.         # every row must have the same length
32.         if len(row) != width:
33.             raise ValueError(f"Layout rows have differing widths (line: {i})!")
34.         # rows are always enclosed by walls
35.         if row[0] != '#' or row[-1] != '#':
36.             raise ValueError(f"Layout must be enclosed by walls (line:{i})!")
37.         # append current row to the list of rows
38.         rows.append(row)
39.         # detect closing row and ignore whatever follows
40.         if row.count('#') == len(row):
41.             start = False
42.             break
43.
44.     if start:
45.         # layout has not been closed!
46.         raise ValueError(f"Layout must be enclosed by walls (line:{i})!")
47.
48.     # height of the layout (y-axis)
49.     height = len(rows)
50.     walls = []
51.     food = []
52.     # bot positions (we assume 4 bots)
53.     bots = [None]*4
54.
55.     # iterate through the grid of characters
56.     for y, row in enumerate(rows):
57.         for x, char in enumerate(row):
58.             coord = (x, y)
59.             # assign the char to the corresponding list
60.             if char == '#':
61.                 # wall
62.                 walls.append(coord)
63.             elif char == '.':
64.                 # food
65.                 food.append(coord)
66.             elif char == ' ':
67.                 # empty
68.                 continue
69.             else:
70.                 # bot
71.                 try:
72.                     # we expect an 0<=index<=3
73.                     bot_idx = int(char)
74.                     if bot_idx >= len(bots):
75.                         # reuse the except below
76.                         raise ValueError
77.                 except ValueError:
78.                     raise ValueError(f"Unknown character {char} in maze!")
79.                 bots[bot_idx] = coord
80.     walls.sort()
81.     food.sort()
82.     return {'walls':walls, 'food':food, 'bots':bots}
83.
84. parse_single_layout('##################\n#. ... .##.     3#\n# # #  .  .### #1#\n# # ##.   .      #\n#      .   .## # #\n#0# ###.  .  # # #\n#2     .##. ... .#\n##################')

Question: How many times will the loop on line 57 execute when 'parse_single_layout('##################\n#. ... .##.     3#\n# # #  .  .### #1#\n# # ##.   .      #\n#      .   .## # #\n#0# ###.  .  # # #\n#2     .##. ... .#\n##################')' is called?

Answer: 151