I started by drawing possible solutions by hand. I found one in about 15 minutes.

I then wrote several scripts that randomly tried to find a solution. I ran 3 of them in parallel, one of them finished in 74 minutes. Here's the program:

I used gnuplot to visualise the solutions. You can see a short video showing the solutions covering more than 14 dots here. The final solution is shown in the end. Note that the algorithm is really stupid, the fifth picture can be extended into the solution easily.

To generate the pictures, I used the following shell script:

#!/bin/bash i=0 while read l ; do l=${l#*: } perl -pe 's/[^-\d.]+/(" ", "\n")[++$i % 2]/ge' <<< "$l" > 2 gnuplot -e "out='$(printf %04d $i)'" 4x4-16.gpl echo "$l" ((++i)) done < <(sort -u 1)

and the following gnuplot script:

set xrange [-2:6] set yrange [-2:6] unset border unset xtics unset ytics set term png set output "4x4-16-" . out . ".png" plot '2' using 1:2 with lines notitle, "4x4-16.grid" using 1:2:(0.1) w +ith circles notitle

Where the "grid" file just contains all the coordinates of the points to connect.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

In reply to Re: Coding Challenge: Find 6 sided polygon covering 4x4 grid by choroba
in thread Coding Challenge: Find 6 sided polygon covering 4x4 grid by LanX

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.