Skip to main content
added 275 characters in body
Source Link
edc65
  • 32.3k
  • 3
  • 37
  • 90

#JavaScript (ES6), 258

A function with the maze as a parameter, returning the output.

Unsure if it's valid, due to the input/output rules (it was fun anyway)

f=m=>([...m].map(c=>{if(c<' ')x=sx-=2,y=sy+=2;else for(x+=2,y+=2,d=c>'0',i=y-3*d,j=x-3*!d,c=5;c--;)o[i+=d][j+=!d]='#';},w=m.search` `,h=m.match(/\n/g).length,sy=y=0,sx=x=h*2,o=Array(z=(w+h+1)*2).fill(' ').map(x=>Array(z).fill(x))),o.map(r=>r.join``).join` `) // LESS GOLFED  U=m=>(  w=m.search`\n`, h=m.match(/\n/g).length, o=Array(z=(w+h+1)*2).fill(' ').map(x=>Array(z).fill(x)), sy=y=0, sx=x=h*2, [...m].forEach(c=>{ if(c<' ')x=sx-=2,y=sy+=2 else for(x+=2,y+=2,d=c>'0',i=y-3*d,j=x-3*!d,c=5;c--;)o[i+=d][j+=!d]='#'; }), o.map(r=>r.join``).join`\n` ) // TEST out=x=>O.innerHTML+=x+'\n' test=`\\\\/\\\\\\//\\/\\////\\\\/\\/ \\/\\///\\\\///////\\//\\/ /\\\\\\//\\//\\////\\\\//\\\\ \\////\\//\\//\\/\\\\\\\\\\\\/ /\\/\\\\///\\\\\\\\/\\\\\\\\/\\\\ \\/\\//\\\\\\\\\\\\//\\/\\//// /\\//\\\\///\\/\\///\\//// \\/\\\\\\//\\\\/\\\\\\//\\\\/\\/ //////\\\\/\\\\/\\/\\/\\/// \\\\/\\/\\\\////\\/\\/\\\\/\\/` out(test),out(f(test)) 
<pre id=O></pre>

#JavaScript (ES6)

A function with the maze as a parameter, returning the output.

Unsure if it's valid, due to the input/output rules (it was fun anyway)

f=m=>( w=m.search`\n`, h=m.match(/\n/g).length, o=Array(z=(w+h+1)*2).fill(' ').map(x=>Array(z).fill(x)), sy=y=0, sx=x=h*2, [...m].forEach(c=>{ if(c<' ')x=sx-=2,y=sy+=2 else for(x+=2,y+=2,d=c>'0',i=y-3*d,j=x-3*!d,c=5;c--;)o[i+=d][j+=!d]='#'; }), o.map(r=>r.join``).join`\n` ) // TEST out=x=>O.innerHTML+=x+'\n' test=`\\\\/\\\\\\//\\/\\////\\\\/\\/ \\/\\///\\\\///////\\//\\/ /\\\\\\//\\//\\////\\\\//\\\\ \\////\\//\\//\\/\\\\\\\\\\\\/ /\\/\\\\///\\\\\\\\/\\\\\\\\/\\\\ \\/\\//\\\\\\\\\\\\//\\/\\//// /\\//\\\\///\\/\\///\\//// \\/\\\\\\//\\\\/\\\\\\//\\\\/\\/ //////\\\\/\\\\/\\/\\/\\/// \\\\/\\/\\\\////\\/\\/\\\\/\\/` out(test),out(f(test)) 
<pre id=O></pre>

#JavaScript (ES6), 258

A function with the maze as a parameter, returning the output.

Unsure if it's valid, due to the input/output rules (it was fun anyway)

f=m=>([...m].map(c=>{if(c<' ')x=sx-=2,y=sy+=2;else for(x+=2,y+=2,d=c>'0',i=y-3*d,j=x-3*!d,c=5;c--;)o[i+=d][j+=!d]='#';},w=m.search` `,h=m.match(/\n/g).length,sy=y=0,sx=x=h*2,o=Array(z=(w+h+1)*2).fill(' ').map(x=>Array(z).fill(x))),o.map(r=>r.join``).join` `) // LESS GOLFED  U=m=>(  w=m.search`\n`, h=m.match(/\n/g).length, o=Array(z=(w+h+1)*2).fill(' ').map(x=>Array(z).fill(x)), sy=y=0, sx=x=h*2, [...m].forEach(c=>{ if(c<' ')x=sx-=2,y=sy+=2 else for(x+=2,y+=2,d=c>'0',i=y-3*d,j=x-3*!d,c=5;c--;)o[i+=d][j+=!d]='#'; }), o.map(r=>r.join``).join`\n` ) // TEST out=x=>O.innerHTML+=x+'\n' test=`\\\\/\\\\\\//\\/\\////\\\\/\\/ \\/\\///\\\\///////\\//\\/ /\\\\\\//\\//\\////\\\\//\\\\ \\////\\//\\//\\/\\\\\\\\\\\\/ /\\/\\\\///\\\\\\\\/\\\\\\\\/\\\\ \\/\\//\\\\\\\\\\\\//\\/\\//// /\\//\\\\///\\/\\///\\//// \\/\\\\\\//\\\\/\\\\\\//\\\\/\\/ //////\\\\/\\\\/\\/\\/\\/// \\\\/\\/\\\\////\\/\\/\\\\/\\/` out(test),out(f(test))
<pre id=O></pre>

Source Link
edc65
  • 32.3k
  • 3
  • 37
  • 90

#JavaScript (ES6)

A function with the maze as a parameter, returning the output.

Unsure if it's valid, due to the input/output rules (it was fun anyway)

f=m=>( w=m.search`\n`, h=m.match(/\n/g).length, o=Array(z=(w+h+1)*2).fill(' ').map(x=>Array(z).fill(x)), sy=y=0, sx=x=h*2, [...m].forEach(c=>{ if(c<' ')x=sx-=2,y=sy+=2 else for(x+=2,y+=2,d=c>'0',i=y-3*d,j=x-3*!d,c=5;c--;)o[i+=d][j+=!d]='#'; }), o.map(r=>r.join``).join`\n` ) // TEST out=x=>O.innerHTML+=x+'\n' test=`\\\\/\\\\\\//\\/\\////\\\\/\\/ \\/\\///\\\\///////\\//\\/ /\\\\\\//\\//\\////\\\\//\\\\ \\////\\//\\//\\/\\\\\\\\\\\\/ /\\/\\\\///\\\\\\\\/\\\\\\\\/\\\\ \\/\\//\\\\\\\\\\\\//\\/\\//// /\\//\\\\///\\/\\///\\//// \\/\\\\\\//\\\\/\\\\\\//\\\\/\\/ //////\\\\/\\\\/\\/\\/\\/// \\\\/\\/\\\\////\\/\\/\\\\/\\/` out(test),out(f(test)) 
<pre id=O></pre>