Created
December 7, 2017 12:11
-
-
Save Insolita/1fa9c942ec916de7e86e68fb4368c277 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mind=d=>{S=storage,T=d.infection,U=d.john.position,V=d.nexa.position,S.f=S.f||0,S.n=S.n||0,l='left',r='right',u='up',w='down';A=v=>Math.abs(v);B=v=>v.length;C=v=>(U.x==v.x&&D(v))||(U.y==v.y&&E(v));D=v=>A(U.y-v.y)==1;E=v=>A(U.x-v.x)==1;F=(x,y)=>U.x!=x?(U.x>x?l:r):(U.y>y?u:w);G=(x,y)=>U.y!=y?(U.y>y?u:w):(U.x>x?l:r);H=()=>T.some(v=>U.x==v.x&&U.y==v.y);I=(x,y)=>(!J()&&!S.f)?G(x,y):F(x,y);J=()=>{if(U.x==V.x&&U.y==V.y){S.n+=1;}return(S.n>0);};K=()=>U.x==V.x;L=v=>v.reduce((r,t)=>(!B(r)?(r=T.filter(t), r):r),[]);M=v=>B(v)?v[0]:[];N=()=>T.reduce((m,t)=>{d=O(V,t);if(m.d<d){m.d=d;m.c=t;}return m;},{'d':0,'c':S.t});O=(v,t)=>A(v.x-t.x)+A(v.y-t.y);P=()=>{S.t=(!S.f?T[0]:(S.f&&!J()?V:(S.t&&V.y!=1?N().c:(Z=L([C,(v)=>(U.y==v.y),D]),B(Z)?M(Z):N().c))));return I(S.t.x,S.t.y)};Q=()=>H()&&!(!J()&&K())?(S.t=null,S.f=1,1):0;return Q()?'cure':P()} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment