Skip to main content
12 votes

Rook Polynomials

JavaScript (ES6), 31 bytes Expects (m)(n)(k). m=>n=>g=k=>k?m--*n--/k*g(--k):1 Try it online! How? Like other answers, ...
Arnauld's user avatar
  • 193k
10 votes

The smallest area of a convex grid polygon

Python, n=44 in under 2 minutes This can go up to 44-gons in under 2 minutes, using pypy on my laptop. CPython is slightly slower (2'45''). The approach is rigorous. It uses the dynamic programming ...
Günter Rote's user avatar
10 votes

Rook Polynomials

Python, 63 50 bytes lambda m,n,k:comb(m,k)*perm(n,k) from math import* Attempt This Online! To place \$k\$ rooks on an \$m\times n\$ chessboard, we choose \$k\$ ...
xigoi's user avatar
  • 7,281
8 votes

Counting universal n-ary logic gates

Python, 1648 bytes ...
gsitcia's user avatar
  • 3,301
7 votes

Rook Polynomials

Thunno 2, 5 bytes cṭsƇ× Try it online! Port of xigoi's Python answer. Takes k, then m, then ...
The Thonnu's user avatar
  • 18.1k
6 votes

Rook Polynomials

Python, 41 bytes f=lambda m,n,k:k<1or f(m-1,n-1,k-1)*m*n/k Try it online! Based on the formula in Arnauld's answer . Test cases from xigoi. Outputs ...
xnor's user avatar
  • 145k
6 votes

Rook Polynomials

Julia 1.0, 39 33 bytes f(k,m,n)=k<1||m*f(k-1,m-1,n-1)n/k Try it online! -6 bytes and test cases due to @MarcMush Similar in spirit to @The Thonnu 's answer. ...
Enforce's user avatar
  • 161
6 votes

Counting rankings

Python 3, 93 84 77 bytes -9 bytes thanks to @xnor! Going for the brownie points, but still exponential runtime ;) ...
ovs's user avatar
  • 59.5k
5 votes

Expected number of rounds for this labeling scheme

05AB1E, 13 10 bytes -3 thanks to @alphalpha Ýsc¤/<z¹F¥ Attempt This Online! Uses a variant of the first method. Ports this Jelly answer for the binomial ...
Command Master's user avatar
5 votes

Avoiding Loops!

Charcoal, 97 93 bytes ≔⟦⊞OA¹⟧θFθ«≔⊟ιη≔⟦⟧ζFLιFΦκ⁻§ιλ§ικ⊞ζ⟦λκ⟧¿ζFΦζ↨÷κ²±¹⊞θ⊞OEΦι⁻÷μ²÷⌈κ²⎇⁼μ⌊κ§ι⁻|⌈κ¹&⌈κ¹λ∕ηLζ⊞υη»I↨υ¹ Try it online! Link is to verbose version of ...
Neil's user avatar
  • 172k
5 votes

Avoiding Loops!

Python, 146 142 bytes f=lambda x,*_:sum(s:=[(n!=m)*f(y:=[(c,o-n or m-n)for c,o in x],*map(y.remove,[(a,m-n),(b,m-n)]))for a,n in x for b,m in x if a-b]or[1])/len(s) ...
Mukundan314's user avatar
  • 12.3k
5 votes

Avoiding Loops!

JavaScript (ES6), 138 bytes -11 thanks to Mukundan314 Expects an array of laces, where each lace is a pair of integers representing its ends (e.g. [0,0]). ...
Arnauld's user avatar
  • 193k
4 votes

Rook Polynomials

R*, 37 35 bytes f=\(l)prod(if(l)c(f(l-1)/l[1]^2,l)) Attempt This Online!* or Try it Online using function instead of the ...
Dominic van Essen's user avatar
4 votes

Rook Polynomials

Jelly, 5 bytes !;c@P Attempt This Online! Takes arguments in the form k [m,n]. I didn't manage to come up with anything shorter,...
xigoi's user avatar
  • 7,281
4 votes

Rook Polynomials

C (gcc), 37 bytes f(m,n,k){m=k?m--*n--*f(m,n,k-1)/k:1;} Try it online! My first C answer (yay!) Port of Arnauld's JavaScript answer. Fixed thanks to @mousetail
The Thonnu's user avatar
  • 18.1k
4 votes

Rook Polynomials

Desmos, 25 bytes f(m,n,k)=nCr(n,k)nPr(m,k) Try It On Desmos! Takes in \$m,n,k\$ as input. Port of like most of the answers here.
Aiden Chow's user avatar
  • 13.6k
4 votes

Expected number of rounds for this labeling scheme

Tried all three methods, with some minor changes to each for golfiness. In order: Wolfram Language (Mathematica), 52 bytes ...
att's user avatar
  • 20.7k
4 votes

Expected number of rounds for this labeling scheme

Charcoal, 48 42 bytes NθNηIΣEθ∕Π⁺±⊕…ιθ⁻θ…⁰η×Π…·¹⁻θι⁻Π⁻ι…⁰ηΠ⁻θ…⁰η Attempt This Online! Link is to verbose version of code. Explanation: Implements a modification of ...
Neil's user avatar
  • 172k
4 votes

Robinson Schensted correspondence

Charcoal, 66 bytes ≔Eθ⟦⟧ηFθ«≔⁰ζWΦ§ηζ›λ髧≔§ηζ⌕§ηζ⌊κι≔⌊κι≦⊕ζ»⊞§ηζι⊞υζ»E⟦η⊕Eθ⌕Aυκ⟧⭆¹Φιν Try it online! Link is to verbose version of code. Explanation: ...
Neil's user avatar
  • 172k
4 votes

Robinson Schensted correspondence

JavaScript (ES12), 124 bytes Returns [P, Q]. ...
Arnauld's user avatar
  • 193k
4 votes

Counting rankings

Python 3, 124 119 117 bytes -5 bytes thanks to enzo. ...
totallyhuman's user avatar
  • 17.2k
4 votes

Counting rankings

APL(Dyalog Unicode), 58 57 bytes SBCS {⍵÷⍨⍺(⊣{n×⍵÷1⌈(⌽-⍺∘=)⍳n←≢⍵}¯1↓⊢/⍤⊢+⊢×(≠∨=∘⍳)∘≢)⍣⍵⊢0,⍨⍵⍴1} Try it on APLgolf! A dynamic programming adaption of my recursive ...
ovs's user avatar
  • 59.5k
3 votes

Implement the hyperfactorial

BLC, 8 bytes (61 bit) 0000010101110000001011010011100000010111101100111010001100010 Works for Church encoded numerals with 1=i. ...
Legendary Wizard's user avatar
3 votes

Rook Polynomials

05AB1E, 5 bytes cI¹e* Inputs in the order \$k,m,n\$. Try it online or verify all test cases. Or alternatively: c¹!ªP Inputs in ...
Kevin Cruijssen's user avatar
3 votes

Expected number of rounds for this labeling scheme

JavaScript (Node.js), 81 bytes n=>g=(k,j=n,c=(a,b=k)=>!b||c(a,--b)*(a-b)/~b)=>j&&c(n,j)/(c(n-j)/c(n)-1)+g(k,j-1) Try it online! Method 1 -5 bytes ...
l4m2's user avatar
  • 24.5k
3 votes

Expected number of rounds for this labeling scheme

Nekomata, 13 bytes →r$ÇƆ/←ŗ0ɔ$ᵑ∆ Attempt This Online! A port of @Command Master's 05AB1E answer. Unfortunately, Nekomata doesn't have ...
alephalpha's user avatar
  • 48.6k
3 votes

Expected number of rounds for this labeling scheme

R, 53 bytes \(n,k,i=1:n-1)sum((`^`=choose)(-i-1,n-i)/(i^k/n^k-1)) Attempt This Online! Last few test cases produce incorrect results due to numeric overflow.
Kirill L.'s user avatar
  • 13.9k
3 votes

Robinson Schensted correspondence

R, 115 bytes \(x){P=Q=!x%o%x;for(i in x){r=1;while(i<-P[r,w<-which.min(P[r,]%in%1:i)]-!(P[r,w]=i))r=r+1;Q[r,w]=F=F+1};list(P,Q)} Attempt This Online! For an ...
Kirill L.'s user avatar
  • 13.9k
3 votes

Counting rankings

JavaScript (ES6), 63 bytes A port of ovs' great Python answer. Now including the optimization suggested by xnor. Expects (n, k). ...
Arnauld's user avatar
  • 193k
3 votes

Counting rankings

Nekomata + -n, 11 bytes RJ:ᵐhmj↕ũh= Attempt This Online! ...
alephalpha's user avatar
  • 48.6k

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