We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

QuineAvoiding("漢字", "")

From Esolang
Jump to navigation Jump to search
Chinese characters in chinese
Official logo.

QuineAvoiding("漢字", "") is the quine-avoiding constant language QuineAvoiding("漢字",""), inspired by chinese characters. Its purpose is print "Chinese characters" in Chinese without allowing a quine.

Syntax

If the program is exactly "漢字" (without the quotes), the output is "漢字". Otherwise, the output is "". However unicode strings are not allowed, instead the input must be in the form of strokes, (such as those described by an SVG file.)

Example

Not allowed.

Interpreter

python

import base64, sys
B = base64.b64decode(open('hanzi.b64').read())
bits = ''.join(f'{b:08b}' for b in B); pos = 0
def rd(n):
    global pos; v = int(bits[pos:pos+n], 2); pos += n; return v

def catmull(P, n=14):
    if len(P) == 2:
        return [(P[0][0]+(P[1][0]-P[0][0])*i/(n-1), P[0][1]+(P[1][1]-P[0][1])*i/(n-1)) for i in range(n)]
    Q = [(2*P[0][0]-P[1][0], 2*P[0][1]-P[1][1])] + P + [(2*P[-1][0]-P[-2][0], 2*P[-1][1]-P[-2][1])]
    out = []
    for i in range(len(Q)-3):
        a, b, c, d = Q[i:i+4]
        for j in range(n):
            t = j/(n-1)
            out.append(tuple(0.5*(2*b[k] + (c[k]-a[k])*t + (2*a[k]-5*b[k]+4*c[k]-d[k])*t*t
                                  + (-a[k]+3*b[k]-3*c[k]+d[k])*t**3) for k in (0, 1)))
    return out

def ribbon(P, W):
    C = catmull(P); m = len(C)-1; L = []; R = []
    for i, (x, y) in enumerate(C):
        t = i/m * (len(W)-1); j = min(int(t), len(W)-2); f = t-j
        w = W[j] + (W[j+1]-W[j])*f
        px, py = C[max(0, i-1)]; qx, qy = C[min(m, i+1)]
        dx, dy = qx-px, qy-py; n = (dx*dx+dy*dy)**.5 or 1
        nx, ny = -dy/n*w, dx/n*w
        L.append((x+nx, y+ny)); R.append((x-nx, y-ny))
    pts = L + R[::-1]
    return 'M' + 'L'.join(f'{x:.1f} {y:.1f}' for x, y in pts) + 'Z'

# per-character placement: user = origin + (raster - 24) * scale/464
PLACE = [(758.0-24*542.0/464, 16.9-24*514.0/464, 542.0/464),
         (1396.0-24*508.0/464, -5.1-24*572.0/464, 508.0/464)]
paths = []
for ci in range(2):
    ox, oy, s = PLACE[ci]
    for _ in range(rd(5)):
        np_ = rd(3)
        P = [((rd(7)*4)*s+ox, (rd(7)*4)*s+oy) for _ in range(np_)]
        W = [rd(3)*3.5*s for _ in range(4)]
        paths.append(ribbon(P, W))
body = ''.join(f'<path d="{d}"/>' for d in paths)
open('strokes.svg', 'w').write(
    f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="423 -32.1 1806 625.1" fill="#990000">{body}</svg>')
print('strokes:', len(paths))

pgmpietoncracklang

P5
# QuineAvoiding("漢字",_"") interpreter (javascript).
79 14
255
H=(t,e=[[755,-11,1.168],[1370,-35,1.095]])=>{let h,l="",r=0,o=atob(t),s=[];for
(h=0;h<o.length;h++)l+=(o.charCodeAt(h)+256).toString(2).slice(1);let p=t=>par
seInt(l.substr(r,t),2,r+=t);for(let t=0;t<2;t++){let[l,r,o]=e[t],a=p(5);for(;a
--;){let t,e=p(3),a=[],f=[];for(t=0;t<e;t++)a.push([4*p(7)*o+l,4*p(7)*o+r]);fo
r(t=0;t<4;t++)f.push(3.5*p(3)*o);let i=e>2?[[2*a[0][0]-a[1][0],2*a[0][1]-a[1][
1]],...a,[2*a[e-1][0]-a[e-2][0],2*a[e-1][1]-a[e-2][1]]]:0,n=[];if(i)for(h=0;h<
i.length-3;h++){let[e,l,r,o]=i.slice(h,h+4);for(t=0;t<14;t++){let h=t/13;n.pus
h([0,1].map(t=>.5*(2*l[t]+(r[t]-e[t])*h+(2*e[t]-5*l[t]+4*r[t]-o[t])*h*h+(3*l[t
]-e[t]-3*r[t]+o[t])*h**3)))}}else for(t=0;t<14;t++)n.push([0,1].map(e=>a[0][e]
+(a[1][e]-a[0][e])*t/13));let u=n.length-1,m=[],M=[];n.map(([t,e],h)=>{let l=h
/u*3,r=Math.min(0|l,2),o=f[r]+(f[r+1]-f[r])*(l-r),[s,p]=n[Math.max(0,h-1)],[a,
i]=n[Math.min(u,h+1)],g=a-s,c=i-p,d=Math.hypot(g,c)||1;m.push([t-c/d*o,e+g/d*o
]),M.push([t+c/d*o,e-g/d*o])}),s.push("M"+[...m,...M.reverse()].map(t=>t[0].to
Fixed(1)+" "+t[1].toFixed(1)).join("L")+"Z")}}return s};                      

External resources

Online demo.