New answers tagged

0

Japt, 75 bytes Can't seem to golf at all today :\ This is hideous! `­66e7s2gf8447sppcpÜ;7¶p1paff2kmbj1l3odfs4q1½0j¢·lqbs`q¤®©n28" /\\"÷ê û Test it


1

PowerShell, 168 125 122 121 bytes $a=(,' '*24+' ')*16 0,8,8+(88,8)*2+8|%{$i=$o+=$_ '&$:&8%$%6%&%5%&%6%$%8&:$'|% t*y|%{$i+=$_-35;$a[$i]='\/'[$i%2]}} -join$a Try it online! The script creates the array of 400 chars and renders 8 diamonds started from positions with intervals 0,8,8,88,8,88,8,8. The string '&$:&8%$%6%&%5%&%...


0

JavaScript + HTML, 248 bytes 235 bytes for JavaScript + 13 bytes for HTML ( // code start n=>{with(c.getContext('2d'))['#4285f4','#34a853','#fbbc05','#ea4335'].map((c,i)=>{beginPath(fillStyle=strokeStyle=c,lineWidth=n/5,a=Math.PI/2);arc(h=n/2,h,r=n*.4,j=i*a-a/2,j+a);stroke();if(!i){clearRect(0,0,n,r);fillRect(h,r,r,n/5)}})} // code end )(100); <...


3

Java + Processing, 95 bytes noStroke();arc(r,r,r,r,0,PI/3);arc(r+r/2,r,r,r,2*PI/3,PI);arc(r+r/4,r+r/2.3,r,r,4*PI/3,5*PI/3); Takes input as variable r, outputs a Reuleaux triangle at \$(r,r)\$, given an adequately sized canvas. Code As a function with size call, 124 bytes void a(int r){size(r*2,r*2);noStroke();arc(r,r,r,r,0,PI/3);arc(r+r/2,r,r,r,2*PI/3,PI);...


0

APL (dzaima/APL), 50 - 12.5 = 37.5 37 - 9.25 = 27.75 bytes P5.draw←{P5.G.ln ↑r+r×2 1○ᑈs÷⍨2×○0…s} Shortened heavily with the help of The APL Orchard. Explanation: P5.draw←{P5.G.ln ↑r+r×2 1○ᑈs÷⍨2×○0…s} P5.draw←{ } Draw the following on the canvas every frame: P5.G.ln Draw a line using array(x1,y1,x2,y2....


5

Dotty (aka Scala 3), 526...404 397 bytes n=>m=>{var(c,d)=Set(Set(Set(1->1)))->0 while(d<1&c.nonEmpty){d=c.count{t=>t.size*m==n*n&&t.forall(_.size==m)} c=(Set()/:(for{t<-c s<-t (a,b)<-s c=a%2*2-1 (x,y)<-Seq(a-1->b,a+1->b,(a+c,b+c))if 0<y&y<=n&0<x&x<y*2&t.forall(!_(x,y))}yield if(s....


1

R, 105 bytes function(P,m=matrix(c(P,P[3:4]),,2,T))!sd(sapply(3:nrow(m)-1,function(k)sign(det(diff(m[c(1,k+0:1),]))))) Try it online! Assumes no three points are collinear. Extends the algorithm described, e.g., here. If we call the query point \$Q\$ and the ordered points of the polygon \$P_1\dots P_n\$, this traverses the points of the polygon, checking ...


2

Python 3.8 (pre-release), 134 bytes lambda x,y,p:sum((p[i+3]>y)^(p[i+1]>y)and(0<(l:=(p[i+2]-p[i])*(y-p[i+1])-(x-p[i])*(p[i+3]-p[i+1])))-(l<0)for i in range(0,len(p)-2,2)) Try it online!


11

JavaScript (ES7),  367 362 359  357 bytes Saved 1 byte thanks to @Shaggy Expects (n)(m). n=>m=>(T=Array(n*n).fill(N=0),g=(A,P=[-1],k=T.findIndex(v=>!v),B=[...A,P[S='sort']()][S]())=>g[B]?0:~[1,1,0,1,1,0][M='map'](r=>g[B=B[M](P=>P[M](i=>~i?(y=i**.5|0)*y-i-(r?1-((~y*~y+~i>>1)-n)**2:y*~-~y):i)[S]())[S]()]=1)/P[m]?~k?g(B):++N:T[M]((v,...


Top 50 recent answers are included