Overview
Given a number of hexagons, arrange them into a connected shape within the confines of a 50 by 50 ASCII art image. The shape you choose can be arbitrary - whatever you find most amenable to golfing - as long as it is connected. It may have holes provided they are larger than one hexagon (otherwise the number of hexagons will be ambiguous).
Layout
All hexagons must be in the following form (only this size and orientation is valid):
__
/ \
\__/ Note there are 2 underscores per horizontal edge.
Two hexagons are directly connected if they share an edge:
__ __
/ \__ / \
\__/ \ \__/
\__/ or / \
\__/
Two hexagons are not connected if they only share a vertex:
__ __
/ \/ \
\__/\__/
Sharing half an edge also does not count as connected:
__
/ \
\__/
/ \
\__/
A collection of hexagons is connected if there exists a path from any hexagon to any other using only directly connected hexagons.
Holes
A hexagon sized hole in a connected collection of hexagons counts as a hexagon, so that any given piece of ASCII art has an unambiguous hexagon count.
This does not count as a hole since the prospective hole is a single hexagon:
__
__/ \__
/ \__/ \
\__/ \__/
/ \__/ \
\__/ \__/
\__/ 7 hexagons (not 6 with a hole)
This does count as a hole since it does not correspond to a single hexagon:
__
__/ \__
/ \__/ \__
\__/ \__/ \
/ \__ \__/
\__/ \__/ \
\__/ \__/
\__/ 8 hexagons with a hole
Input and output
Input
An integer from 1 to 255.
Output
An ASCII art string representing the input number of connected hexagons as described above.
- The number of rows (newline separated substrings) is at most 50, plus an additional optional trailing newline.
- The rows need not be the same length, but each must be of length at most 50.
- Zero length rows can exist above or below the connected shape provided the total number of rows does not exceed 50.
- Space-only rows can exist above or below the connected shape provided the total number of rows does not exceed 50.
- Spaces can appear to the left of the shape provided the row lengths do not exceed 50 (the shape does not need to be aligned to the left).
- Spaces can appear to the right of the shape provided the row lengths do not exceed 50.
- Any characters that do not form part of the connected shape must be either spaces or newlines.
Provided the output is correct, it is not required to be consistent from one run to the next.
Examples
Input: 6
Valid Outputs:
__ __ __
/ \__/ \__/ \__
\__/ \__/ \__/ \
\__/ \__/ \__/
__ __
/ \__/ \
\__/ \__/
/ \__/ \
\__/ \__/
\__/
__
__ / \
/ \__ \__/
\__/ \__/ \
\__/ \__/
\__/
/ \
\__/
Invalid Outputs:
__
__/ \__
/ \__/ \
\__/ \__/
/ \__/ \
\__/ \__/
\__/ Invalid for 6 as the centre hole counts as a 7th hexagon.
__ __ __ __
/ \__/ \__/ \ / \
\__/ \__/ \__/ \__/
\__/ \__/ Invalid as the 6 hexagons are not connected.
__ __ __ __
/ \__/ \__/ \/ \
\__/ \__/ \__/\__/
\__/ \__/ Invalid as vertex touching does not count as connected.
__ __ __
/ \__/ \ / \
\__/ \__/ \__/
/ \__/ \
\__/ \__/
\__/ Invalid as the 6 connected hexagons are not the only visible characters.
Winning
The shortest valid answer in bytes wins.
Leaderboard
(using Martin's leaderboard snippet)
var QUESTION_ID=54277;function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),e.has_more?getAnswers():process()}})}function shouldHaveHeading(e){var a=!1,r=e.body_markdown.split("\n");try{a|=/^#/.test(e.body_markdown),a|=["-","="].indexOf(r[1][0])>-1,a&=LANGUAGE_REG.test(e.body_markdown)}catch(n){}return a}function shouldHaveScore(e){var a=!1;try{a|=SIZE_REG.test(e.body_markdown.split("\n")[0])}catch(r){}return a}function getAuthorName(e){return e.owner.display_name}function process(){answers=answers.filter(shouldHaveScore).filter(shouldHaveHeading),answers.sort(function(e,a){var r=+(e.body_markdown.split("\n")[0].match(SIZE_REG)||[1/0])[0],n=+(a.body_markdown.split("\n")[0].match(SIZE_REG)||[1/0])[0];return r-n});var e={},a=1,r=null,n=1;answers.forEach(function(s){var t=s.body_markdown.split("\n")[0],o=jQuery("#answer-template").html(),l=(t.match(NUMBER_REG)[0],(t.match(SIZE_REG)||[0])[0]),c=t.match(LANGUAGE_REG)[1],i=getAuthorName(s);l!=r&&(n=a),r=l,++a,o=o.replace("{{PLACE}}",n+".").replace("{{NAME}}",i).replace("{{LANGUAGE}}",c).replace("{{SIZE}}",l).replace("{{LINK}}",s.share_link),o=jQuery(o),jQuery("#answers").append(o),e[c]=e[c]||{lang:c,user:i,size:l,link:s.share_link}});var s=[];for(var t in e)e.hasOwnProperty(t)&&s.push(e[t]);s.sort(function(e,a){return e.lang>a.lang?1:e.lang<a.lang?-1:0});for(var o=0;o<s.length;++o){var l=jQuery("#language-template").html(),t=s[o];l=l.replace("{{LANGUAGE}}",t.lang).replace("{{NAME}}",t.user).replace("{{SIZE}}",t.size).replace("{{LINK}}",t.link),l=jQuery(l),jQuery("#languages").append(l)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",answers=[],page=1;getAnswers();var SIZE_REG=/\d+(?=[^\d&]*(?:<(?:s>[^&]*<\/s>|[^&]+>)[^\d&]*)*$)/,NUMBER_REG=/\d+/,LANGUAGE_REG=/^#*\s*([^,]+)/;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"><div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table></div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table></div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody></table><table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody></table>
6
. For an input of255
a horizontal row of hexagons won't fit in a 50 by 50 ASCII art. \$\endgroup\$