Skip to main content
Share Your Experience: Take the 2024 Developer Survey
44 votes
Accepted

Should we be friends?

SWI-Prolog, 62 47 41 bytes X*Y:-X+Y;Y+X;X==Y. X?Y:-not(X*Y),X*Z,Y*Z. Prolog isn't too often useful, but when it is it's just beautiful. We'll use ...
orlp's user avatar
  • 39.1k
27 votes

Is it a valid chemical?

Python 3, 61 60 59 58 51 bytes lambda x:len(x)-2<~sum(x)%2*all(x)*sum(x)/2>=max(x) Try it online! -1 thanks to @Kevin Cruijssen -7 thanks to @xnor Uses ...
Command Master's user avatar
23 votes

Get to the Zone!

JavaScript (ES6), 30 bytes Takes input as (N)(M). N=>g=M=>M>N?M%2-~g(M+1>>1):N-M Try it online! How? Instead of ...
Arnauld's user avatar
  • 193k
20 votes

Is it bipartite?

Wolfram Language (Mathematica), 26 25 bytes Tr[#//.x_:>#.#.Clip@x]<1& Try it online! How it works Given an adjacency matrix A, we find the fixed ...
Misha Lavrov's user avatar
  • 5,245
16 votes

Somewhere On The Tube ...But On Which Lines?

ES6, Node.js / Chrome, 989 977 931 892 889 887 bytes ...
Arnauld's user avatar
  • 193k
16 votes
Accepted

Somewhere On The Tube ...But On Which Lines?

Mathematica 8+, 266 bytes ...
hftf's user avatar
  • 466
15 votes

Arranging Bubbles

Python 2, 92 87 bytes a=lambda n:n<2or sum((k%d<1)*d*a(d)*a(n-k)for k in range(1,n)for d in range(1,1+k))/~-n In plain english: to compute ...
orlp's user avatar
  • 39.1k
15 votes

Hexcellent Minesweeping

7 5 vertices, 14 10 edges (Graph made with this online tool and paint.) A-F are our six nodes, and ...
Laikoni's user avatar
  • 26.2k
15 votes

Is this Game of Go configuration fully alive?

JavaScript, 178 bytes ...
tsh's user avatar
  • 34.9k
14 votes

Two-Coloring Overlapping Circles

Mathematica, 165 bytes ...
Greg Martin's user avatar
  • 15.7k
14 votes

Should we be friends?

PHP, 138 133 129 bytes PHP beats Mathematica - a rare occurence. ...
Titus's user avatar
  • 14.7k
14 votes

Are these states connected?

Wolfram Language (Mathematica), 169 167 bytes ...
att's user avatar
  • 20.6k
13 votes

Enumerate binary trees

Haskell, 68 bytes t 0=[""] t 1=["0"] t n=['(':x++y++")"|k<-[1..n-1],x<-t k,y<-t$n-k-1] Terminal nodes are represented by ...
Christian Sievers's user avatar
13 votes

Determine if a Graph is Toroidal

Rust, 1210 1200 bytes ...
isaacg's user avatar
  • 42k
13 votes

Do the NP: find the largest clique

Mathematica, 34 bytes Tr[1^#&@@FindClique[#<->#2&@@@#]]& Basically FindClique does the job and "finds a largest clique in the graph g." All ...
ZaMoC's user avatar
  • 24.9k
13 votes

Drawing one-liner

Python, 31 bytes lambda l:sum(n%2for n in l)|2<3 Try it online! We use k|2<3 to check that ...
xnor's user avatar
  • 145k
13 votes
Accepted

Break The Chain

92+41=133 ...
Level River St's user avatar
12 votes
Accepted

Seeking Leapers

Pyth, 41 35 hfqQu@+G+VM*s_BM*F_BMTGQ]hQ)maVhQdt Exits on error if there are no valid leapers, giving the empty string if STDERR is ignored. Try it here or run a ...
FryAmTheEggman's user avatar
12 votes

Should we be friends?

CMD (Batch), 50 + 20 + 135 = 205 bytes FRIEND.CMD @for %%f in (%1.%1 %1.%2 %2.%2 %2.%1)do @set %%f=1 KNOW.CMD ...
Neil's user avatar
  • 171k
12 votes

Knight Distance

Wolfram Language (Mathematica), 64 bytes Using the built-in KnightTourGraph. Saved 2 bytes thanks to Mathe172. ...
alephalpha's user avatar
  • 48.2k
12 votes

Can this Scottish village have a wedding?

Python 2, 399 393 390 388 385 bytes ...
Chas Brown's user avatar
  • 9,757
12 votes

Who Is Kevin Bacon?

BQN*, 53 45 bytesSBCS {1+⊑⍒+˝+´(∨∨∨˝∘×⎉1‿∞)⍟n˜∨⟜⍉∨˝𝕩≡⌜1+⋈⌜˜n←↕⌈´∾𝕩} Run online! Theory: Let \$k\$ be the maximum node id. Then the node IDs are \$\{1, 2, ..., k\}...
ovs's user avatar
  • 59.5k
12 votes

Detect round trips on a dodecahedron

Python 2, 79 bytes lambda s:all(n==reduce(lambda n,c:-~[n,n%3+n%4][c>'L']%5,s,n)for n in range(5)) Try it online! This uses the group-theoretic approach from ...
xnor's user avatar
  • 145k
11 votes

Two-Coloring Overlapping Circles

JavaScript/SVG/HTML5, 219 bytes ...
Neil's user avatar
  • 171k
11 votes
Accepted

Surface of the 3x3x3 cube as a graph

APL (Dyalog Classic), 34 30 bytes -4 thanks to jimmy23013 4≥+/¨|∘.-⍨,(⍳3)∘.⌽7 ¯1∘.,○⍳3 3 Try it online! outputs an adjacency matrix with each vertex adjacent ...
ngn's user avatar
  • 15.3k
11 votes
Accepted

Complete the grid-filling meander

JavaScript (ES7),  236 ... 193  185 bytes Outputs by modifying the input matrix. ...
Arnauld's user avatar
  • 193k
11 votes
Accepted

Count all binary relations

APL (Dyalog Extended), 99 93 bytes r←0∊0 0⍉⊢ R←r~ s←⊢≢⍉ S←1∊⊢∧⍉ t←0∊⊢≥∨.∧⍨ T←1∊⊢∧∨.∧⍨ {×⍵:+/∧⌿~(⍺,'0'){(⍎⍺)⊣⍵}\⍵-⍛↑∘⊤¨,⍳⍵⍴2*⍵⋄1} Try it online! -5 bytes thanks to ...
Bubbler's user avatar
  • 76.7k
11 votes

smallest number of steps for a knight in chess

Knight, 272 264 193 190 188 bytes ...
Aiden Chow's user avatar
  • 13.5k
11 votes

Is this graph a tree?

Jelly, 7 6 5 4 bytes (thanks @Jonathan Allan!) ṖÆḊ’ Try it online! ...
Alex's user avatar
  • 535

Only top scored, non community-wiki answers of a minimum length are eligible