Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 74571

Code-golf is a competition to solve a particular problem in the fewest bytes of source code.

8 votes

Is it a valid list?

Python3, 70 bytes: def f(s): try:return s==str(eval(s)).replace(' ','') except:return 0 Try it online!
Ajax1234's user avatar
  • 7,711
8 votes

Partial Fractions

Python3, 1029 bytes: import itertools as I E=enumerate U=lambda x:{len(x)-i:a for i,a in E(x,1)} def G(v,r=[]): if[]==v:yield r;return for k in I.product(*[[-1,0,1]for _ in v[0]]): N=[a+b for a,b …
Ajax1234's user avatar
  • 7,711
8 votes

Tut-tut-tut-tut-tut

Python3, 61 bytes: f=lambda x:x==''or'tut-tut'==x[:6|f(x[4:])|f(x[6:])|f(x[7:])] Try it online!
Ajax1234's user avatar
  • 7,711
8 votes

Ungolf my tinylisp code

Python3, 629 bytes: import re d=lambda x,c=0:c if type(x)!=list or not x else max(d(i,c+1)for i in x) def p(s): r=[];S=str.lstrip while s: if(c:=s[0])==')':s=S(s[1:]);break if c=='(':s=(l:=p(s[1 …
Ajax1234's user avatar
  • 7,711
7 votes

Can the 🐸 visit all the 🪷?

Python3, 151 bytes: f=lambda n,s=[0],p=[]:len({*s})==len(n)or any(f(n,s+[t],p+[j])for i in[n[s[-1]],-1*n[s[-1]]]if-1<(t:=(s[-1]+i))<len(n)and p.count(j:=(s[-1],t))<len(n)) Try it online!
Ajax1234's user avatar
  • 7,711
7 votes

Knook to Mate... With Portals!

Python3, 970 bytes: M=[((1,0),1,3),((0,1),0,2),((-1,0),1,3),((0,-1),0,2)] def A(c): q=[(c[0],i,1,[c[0]])for i,*_ in M]+[(c[0],[(i,2),(M[j][0],1)],0,[c[0]])for i,*J in M for j in J]+[(c[0],[(i,1),(M[j …
Ajax1234's user avatar
  • 7,711
7 votes

Making one shape out of dissections of another

Python3, 1163 bytes: import itertools as I E=enumerate Q=lambda b:[(x,y)for x,r in E(b)for y,t in E(r)if t] R=lambda x,f,n=3:[]if 0==n else[(X:=[*zip(*x)])]+R([X[::-1],[i[::-1]for i in X]][f],f,n-1) D …
Ajax1234's user avatar
  • 7,711
7 votes

Return all letter counts as an integer

Python 3.8, 76 bytes: lambda x:''.join(str(i)for a in range(97,123)if(i:=x.lower().count(chr(a)))) Try it online!
Ajax1234's user avatar
  • 7,711
6 votes

Simplified Piet Interpreter

Python3, 1383 bytes: lambda b:M(set(),b,0,2,[],(0,0)) T={0:(L:={0:max,2:min}),1:(K:={0:min,2:max}),2:K,3:L} Q={0:(0,1),1:(1,0),2:(0,-1),3:(-1,0)} I={0:lambda s,v,*a:[*a,[v]+s],1:lambda s,v,*a:[*a,s[1: …
Ajax1234's user avatar
  • 7,711
6 votes

Does the sequence shut the box?

Python3, 230 bytes: def C(d,n,c=[]): if(K:=sum(c))==n:yield{*c};return for j in d: if K+j<=n:yield from C(d-{j},n,c+[j]) def f(d): q=[({*range(1,13)},d)] while q: s,d=q.pop(0) if not s:retur …
Ajax1234's user avatar
  • 7,711
6 votes

Sudoku as a SAT problem

Python3, 427 bytes J=range(1,10) u=lambda d,*t:d.setdefault(t,max(d.values()or[0])+1) Y=[(r,c)for r in J for c in J] def f(b):d={};return[[u(d,r,c,n)for n in J]for r,c in Y]+[[-1*u(d,r,c,v),-1*u(d,r,c …
Ajax1234's user avatar
  • 7,711
6 votes

Detect Maxima Using Persistent Homology

Python3, 350 bytes: S=sorted def f(s,n): r,R={},0 for i,v in S(enumerate(s),key=lambda x:-x[1]): R+=1 if(K:=[r.pop(I)for I in[*r]if i+1in r[I][2]or i-1in r[I][2]]): *a,b=S(K,key=lambda x:x[0] …
Ajax1234's user avatar
  • 7,711
5 votes

How-many-bonacci-like is this sequence?

Python3, 102 bytes: lambda x,c=0:(v(x,c)and c)or(x and f(x,c+1)) v=lambda x,i:len(x)<=i or(sum(x[:i])==x[i]and v(x[1:],i)) Try it online!
Ajax1234's user avatar
  • 7,711
5 votes

Write a (simplified) BitCycle interpreter

Python3, 789 bytes: E=enumerate def f(p,s): b=[*map(list,p.split('\n'))] x,y=[(x,y)for x,a in E(b)for y,c in E(a)if'?'==c][0] q,C,s,D=[(x,y,0,1,a,[(x,y)],i)for i,a in E(s)],[],[],{(0,1):[(-1,0),(1, …
Ajax1234's user avatar
  • 7,711
5 votes

Optimally pop all the bubbles

Python3, 901 bytes: E=enumerate def B(b): P,R,s=[(x,y)for x,j in E(b)for y,k in E(j)if k],[],[];p=P while p: x,y=p[0];q=[(x,y)];s+=p[0], while(o:=[X for x,y in q for X in[(x+1,y),(x,y+1),(x-1,y) …
Ajax1234's user avatar
  • 7,711

1
2 3 4 5
26
15 30 50 per page