entry #1
written by yui
submitted at
0 likes
guesses
- Dolphy (by olus2000)
- at (by taswelll)
- at (by kimapr)
- at (by Proloy)
- essaie (by soup girl)
- kimapr (by moshikoi)
- moshikoi (by at)
- yui (by LyricLy)
- yui (by Dolphy)
- yui (by essaie)
- yui (by luatic)
- yui (by kotnen)
comments 0
index.js ASCII text
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | function generate(str,maxRepeat=10,inner=0,i=-1,r=[],o=r,_,ch,f=o=>o.map(x=>(typeof x=="function"?x():x)||"").join("")) { for (;ch = str[++i];) { if (ch == ".") o.push(() => String.fromCharCode(~~(Math.random() * 93 + 33))); else if (ch == "\\") o.push(str[++i]); else if (ch == "(") [_,i]=generate(str, maxRepeat, 1, i, []),o.push((_=>()=>f(_))(_)); else if (ch == ")" && inner) return [r,i]; else if (ch == "|") o.push(((a,b)=>(o=a,(x=f(a),y=f(b))=>Math.random()>.5?x:y))([],o.splice(0))); else if ("*+".includes(ch)) o.push(((_)=>f(Array(~~(Math.random()*maxRepeat)+(ch=="+")).fill(_)))(o.pop())); else if (ch == "[") { for (s=[],o.push((r=s[~~(Math.random()*s.length)])=>r&&String.fromCharCode(~~(Math.random()*(r[1]-r[0])+r[0])));(ch=str[++i])&&ch!="]";) { if (ch == "-" && s.length && str[i + 1] != "]") s.push([s.pop()[0], str.charCodeAt(++i)]); else s.push(Array(2).fill(ch.charCodeAt())); } } else o.push(ch); } return f(r); } // only 17 lines! (637 chars minified) |
post a comment