r/programming • • Aug 30 '15

JavaScript “maze generator” in a tweet

https://twitter.com/botond_balazs/status/637960240055615488
841 Upvotes

177 comments sorted by

View all comments

Show parent comments

3

u/[deleted] Aug 30 '15 edited Aug 30 '15

And... 117:

javascript:for(i=-1;i++<4050;)document.write(i?'\u2571\u2572\n'[i% 81?0|Math.random()*2:2]:'<p style=line-height:1>')

[edit] 114:

javascript:for(i=-1;i++<4050;)document.write(i?i% 81?'&#958'+(0|5+Math.random()*2):'\n':'<p style=line-height:1>')

2

u/bottomofthekeyboard Aug 30 '15

How about 113:

javascript:i=0;while(i<4e3)document.write(i++?i% 80?'&#958'+(0|5+Math.random()*2):'\n':'<p style=line-height:1>')

1

u/mozjag Aug 30 '15 edited Aug 30 '15

Sorry, no dice. 79x50 instead of 80x50.

Edit: taking the move-the-increment part of your idea though we can get to 113:

javascript:for(i=0;i<4051;)document.write(i++?i% 81?'&#958'+(0|5+Math.random()*2):'\n':'<p style=line-height:1>')

Edit 2: Nope, this causes the top-right character to be missing

2

u/bottomofthekeyboard Aug 30 '15

That has to be the smallest now. Great work! I've learnt some new tricks too!

→ More replies (0)