New answers tagged


PowerShell, 28 bytes -5 = 23 ('i',-1,'-i',1)["$args"%4-1] Try it online! Port of all the cyclic indexing


Tcl, 124 116 106 bytes {{a b f\ int(floor(2*$b/3**.5)) {l "[expr $f+(1-$f%2<($b-$f)*3**.5)]"}} {subst [expr $l+$a-($f+1)/2]\ $l}} Try it online! This is somewhat inspired by the three-year old post from @Neil The floor function returns the corner of the rhombus whose edges are the vectors 1 and \$\omega\$. With respect to this rhombus, the Gaussian ...


Haskell, 128 bytes i=fromIntegral;r=[floor,ceiling];a!k=(i a-k)**2;c(a,b)|l<-2*i b/sqrt 3,k<-i a+l/2=snd$minimum[(x k!k+y l!l,(x k,y l))|x<-r,y<-r] Try it online! For input Gaussian integer (a,b), convert it into Eisenstein coordinates, floor and ceil both components to get four candidates for closest Eisenstein integer, find the one with ...

Top 50 recent answers are included