312, 285, 281
Edit: Saved a bunch of bytes by replacing all the runs of four zeros (
A and all
B and afterwards replacing them back. While doing that, I optimized the
replace method call furiously.
Edit 2: In an earlier version I needed the parantheses; I removed them. Also, replaced
Runnable in Firefox 39:
f=n=>[...`AAAAA000ssAss000ooAAA0oo00ooo 30ci00ci02BBi02zBA0eAz00u20030gm02BA0z0 0f00kf00k0BB0k0zB77BA0z77kAfook0B770B0 c03200320iBB20izBss000lssB445i00c0320iB44004z4`.replace(/A|B/g,x=>x<'B'?'0000':'00z')].map(a=>a<'!'?a:' -/\\_|'[n%2?parseInt(a,36)%6:~~(parseInt(a,36)/6)]).join`` // Testing: ;console.log(f(0)); console.log(f(1)); console.log(f(2)); console.log(f(35));
It’s based on the base 6 number system and each ASCII character stands for a number:
" ": 0 "-": 1 "/": 2 "\": 3 "_": 4 "|": 5
Then, I’ve combined the number representation of each ASCII string. For example: when the first ASCII string contains a
/ at one position and the other one contains a
\ at the same position, that position becomes
32, which is base 6 (
20 in decimal). If you convert this to base 36 (to get one base-36 number for every two base-6 numbers), you get
All this was done beforehand and the function basically undoes this process.
PS: As a note to myself and a reference to others, this is the code I used:
// 1. ASCII here a=`|\\-/ _`; // 2. ASCII here b=`/|\\_ -`; [...a] .map((c,i)=>parseInt((c+b[i]) .replace(/ /g,'0') .replace(/-/g,'1') .replace(/\//g,'2') .replace(/\\/g,'3') .replace(/_/g,'4') .replace(/\|/g,'5'),6)) .map(c=>isNaN(c) ?` ` :c.toString(36)) .join`` // Returns "wn9g0p", which is then put into the function as the block at the top.