New answers tagged

1

Jelly, 24 bytes JṖŒPỊẸ$Ƈ,ḟ@Œp;U$ʋ€Jœị⁸§Ṃ A monadic Link accepting a list of lists of non-negative integers (an adjacency matrix), which yields the maximal flow integer. Try it online! Or see the test-suite. How? Implements the minimum-cut maximal-flow method. JṖŒPỊẸ$Ƈ,ḟ@Œp;U$ʋ€Jœị⁸§Ṃ - Link: adjacency matrix, A (n by n) J - range of ...


5

JavaScript (ES6), 96 bytes f=(m,k=1,b)=>k*2>>m.length?b:f(m,k+2,m.map((r,y)=>r.map((v,x)=>t+=k>>y&~k>>x&1&&v),t=0)|t>b?b:t) Try it online! Commented f = ( // f is a recursive function taking: m, // m[] = adjacency matrix k = 1, // k = counter, ...


3

05AB1E, 27 bytes ā2.ŒʒD{Q}<ʒZ%PË}εнèøyθè˜O}ß Takes the input in a similar format as the test cases in the challenge description. Try it online or verify all test cases. Explanation: ā # Push a list in the range [1, (implicit) input-length] # (without popping the input itself) 2.Œ # Get all partitions of two parts of this list ...


1

APL (Dyalog Extended), 7 bytes ⌂search Try it online! A library function that does the job. Takes the graph on its left and the start node on its right, and gives the list of reachable nodes using breadth-first search. Since APL has neither sets nor dicts, the closest input format is a nested vector of vectors like (2 3)(3)(1)(2). And, just by coincidence, ...


7

Charcoal, 37 36 34 bytes I⌊EEX²⁻Lθ²↨⁺X²⊖Lθ⊗ι²ΣEθ∧§ιμΣΦ묧ιξ Try it online! Link is to verbose version of code. Explanation: E…X²⁻Lθ²X²⊖Lθ Loop over all cuts... E ↨⊗ι² ... converted to base 2 ΣEθ∧§ιμ Sum rows in source cut ΣΦ묧ιξ Sum columns in sink ...


Top 50 recent answers are included