New answers tagged

5

Python 3, 1054 bytes def d(kx,ky,x,y):return abs(x-kx)<2>abs(y-ky) def l(qx,qy,kx,ky,x,y): if x==qx:return x!=kx or ky<min(y,qy)or max(y,qy)<ky o=kx<min(x,qx)or max(x,qx)<kx if y==qy:return o or y!=ky if x-y==qx-qy:return o or x-y!=kx-ky return x+y==qx+qy and(o or x+y!=kx+ky) def f(c,x,y):c[x][y]=1;[f(c,u,v)for v in range(max(y-1,0),...


0

TimeRandBot import net.ramenchef.dollarauction.DollarBidder; public class TimeRandBot extends DollarBidder { @Override public int nextBid(int opponentsBid) { return (int) (System.currentTimeMillis() % 21 * 5); } } Bids from 0¢ up to 100¢ inclusive in increments of 5¢.


2

Here is my answer in Java, I am definitely not skilled enough to get it down to a minimal amount of bytes and I prefer not to say(shortest byte solution for this code is down at the bottom of this post, credit to @ceilingcat for getting my code down to 558 bytes:P) try it online it works! thanks to ceilingcat with the 558bytes solution: int k,l,R[][],m;...


2

R, 211 bytes v=function(b,f=c(3:1,2,1,1))`if`(any(f),{any(sapply(list(b,t(b)),function(m)any(apply(h<-which(m[1:(dim(m)[1]-f[1]),]>0,T),1,function(x)`if`(all(m[y<-t(x+rbind(0:f[1],0))]),{m[y]=0;v(m,f[-1])},F)))))},sum(b)==4) Try it online! How? Pseudo-code version: # recursive function: validate_battleships= v=function(board,...


1

K (ngn/k), 16 bytes {|/&/~^x?x+/:!4} Try it online! Another port of @ngn's APL answer, using ~^x?y as the membership test.


4

JavaScript (ES6),  162  158 bytes Returns 0 if the grid is invalid, or a positive integer otherwise. m=>(o=0,g=u=>m.some((r,y)=>r.some((v,x)=>v&&[0,1].map(d=>(r=(w,X=x+!d*w,R=m[y+d*w]||0)=>R[X]&&R[R[X]--,u&(k=1<<w*3)*7&&g(u-k),r(-~w),X]++)``)))|u||++o)(668)*o Try it online! Commented m => ( ...


0

Jelly, 27 bytes ŒD,ŒdḢ€;;ZEƇFṀị“ẏż“¡ṇ⁽“Zƙċ» Try it online! Input is a list of lists of ints: 0 = nothing, 1 = circle, 2 = cross. Explanation ŒD,ŒdḢ€;;ZEƇFṀị“ẏż“¡ṇ⁽“Zƙċ» Main monadic link ŒD Diagonals , Pair with Œd Antidiagonals Ḣ€ Head (first ...


Top 50 recent answers are included