Answer by tsh for Find the Best Set of Adapters
JavaScript (Node.js), 73 bytes(b,c,m)=>g=(a,n=0)=>a==b?m<n?m:m=n:c[n]&&c.map(p=>p[0]==a&&g(p[1],n+1))|mTry it online!Mainly based on Arnauld's answer.c[n] means n <...
View ArticleAnswer by att for Find the Best Set of Adapters
Wolfram Language (Mathematica), 13 bytesGraphDistanceTry it online!...and here's the built-in.
View ArticleAnswer by Jonah for Find the Best Set of Adapters
J, 28 bytes1 :'[:#+./ .*^:(1-u{])^:a:~'Try it online!Perhaps stretching the definition of convenient input, I take the adapter list as an adjacency matrix, and the target connection as a boxed pair of...
View ArticleAnswer by Unmitigated for Find the Best Set of Adapters
Java, 474 bytes(s,e,a)->{java.util.Map<String,java.util.List<String>>m=new java.util.HashMap();java.util.Map<String,Integer>d=new...
View ArticleAnswer by Neil for Find the Best Set of Adapters
Charcoal, 40 bytes⊞υθFυFζF›⁼§ι±¹§κ⁰№ι§κ¹⊞υ⁺ι§κ¹I⊖⌊EΦυ№ιηLιTry it online! Link is to verbose version of code. Explanation:⊞υθStart a breadth-first search using the computer's port.FυLoop over all chains...
View ArticleAnswer by caird coinheringaahin g for Find the Best Set of Adapters
Jelly, 13 bytesṗJ$Ẏy@ƒ⁼⁵ɗƇẈṂTry it online!Full program taking a list of pairs L (e.g. ['AB', 'BC', 'CD', 'DZ', 'XY', 'YZ']) as the first argument, the source as the second and the target as the...
View ArticleAnswer by Arnauld for Find the Best Set of Adapters
JavaScript (ES6), 78 bytesExpects (target, list)(source), where list is an array of string pairs.(b,c,m)=>g=(a,n)=>a==b?m<n?m:m=n:c.map(p=>p[0]==a?p[g(p[1],p[0]=-~n),0]=a:0)|mTry it...
View ArticleFind the Best Set of Adapters
I'm trying to plug this really old phone into my computer but the phone seems to use a very obscure plug. Luckily I have some adapters. Unfortunately, I can't figure out which of them to use to connect...
View Article
More Pages to Explore .....