Translated JS
Jump to navigation
Jump to search
1. Take Arithmetic interpreter in JS:
function interpret(a){const e=a.split`\n`;let o="",st=x=p=c=P=C=+o,r,v;for(const n of e){if((!++C)||n==[])continue;if(st==0&&n=="==Begin Exam "+ ++x+"=="&&++st&&!(v={},p=c=P=+!v))continue;if(st==1&&(m=n.match(/^([0-9]+). ([0-9]+)\+([0-9]+)=\? \(([0-9]+) points\)$/))&&+m[2]&&+m[3]&&++p==m[1]&&++st&&!(v={},c=+!v)&&(r=m.slice(2,5)))continue;if(st==2&&c<26&&(m=n.match(new RegExp("^("+String.fromCharCode(++c+64)+")\. ([0-9]+)$")))&&+m[2]&&(!(Object.values(v).indexOf(m[2])>-1&&m[2]==+r[0]+ +r[1]))&&(v[m[1]]=m[2]))continue;if(st==2&&(m=n.match(/^Answer: ([A-Z])$/))&&m[1].charCodeAt(0)-64<c&&v[m[1]]==+r[0]+ +r[1]&&(P+=(+r[2])%256)&&--st)continue;if(st==2&&(m=n.match(/^Answer: ([A-Z])$/))&&m[1].charCodeAt(0)-64<c&&--st)continue;if(st==1&&n=="==End Exam "+x+"=="&&1+--st&&(o+=String.fromCharCode(P%256)))continue;throw new Error("Invalid syntax on line "+C);}if(st)throw new Error("Unexpected end of input");console.log(o);}
Translate chain:
Yandex: English -> Russian -> Emoji -> English
2. The result is:
Function evaluate () {int e=.Y `\n`;let o="",ln=y=p=C=p=C= + o,ⓜ,V; ({p e) _con_ if ((! a + b)||p==[])continue;if(AV==0&&n=="==start testing " + a + y + "=="&& + St&&! (V={},P=C=p=a+! V))continue;if(AV==1&&(ⓜ=n.Link(/^([0-9]+). ([0-9]+)\+([0-9]+)=\? \(([0-9] + a) bankex\ a)$/))&&plus ⓜ [2]&&a + ⓜ [3]&& + q==ⓜ[1]&& + St&&! (V={},C=a+! V)&&(ⓜ=ⓜ.Part(2,5)))continue;if(AV==2&&C<26&&(ⓜ=n.Match(a new regular expression ("~("+str.String (premium with premium 64 a)+")\. ([0-9]+)$")))&&+ ⓜ [2]&&(! (level.Value(mV).= (ⓜ[2])>-1&&ⓜ[2]==a + ⓜ [0] + extra ⓜ [1]))&&(V[ⓜ[1]]=ⓜ[2]))continue;if(AV==2&&(ⓜ=n.Match (/^how: ([a - z] a)$/))&& ⓜ [1].Outputs(0)-64<b&&V[ⓜ[1]]==a + ⓜ [0] extra ⓜ [1]&&(n + =(a + ⓜ [2])%256)&&-- ne)continue;if(AV==2&&(ⓜ=n.Link(/~questions: ([a - z] a)$/))&& ⓜ [1].{(0)-64<b&&-ne)continue;if(AV==1&&n=="==end testing " + x+"=="&&1+-- St&&(o + =press.Char(n minimum 256)))continue;return new error("invalid syntax line" + b);}if(St)return new error("unexpected operation of output");console.Controllers(IO);}