Hot answers tagged

4 votes

Reconstruct a list of strings from its prefixes

Nekomata, 8 bytes ↕ᵉtiᶻ{∕z Attempt This Online! The input includes the empty prefix. ...
alephalpha's user avatar
  • 47.7k
3 votes

Reconstruct a list of strings from its prefixes

Python 2, 73 68 bytes lambda L:reduce(lambda v,l:map(l.remove,v)and v+l,sorted(L,key=len)) Try it online! An anonymous function that accepts a ...
enzo's user avatar
  • 2,013
3 votes

Reconstruct a list of strings from its prefixes

Haskell, 57 bytes import Data.List concat.(zipWith(\\)<*>([]:)).sortOn(0<$) Try it online! Hey, I knew my slightly different approach would come in handy!...
totallyhuman's user avatar
  • 16.8k
2 votes

Reconstruct a list of strings from its prefixes

05AB1E, 13 bytes ¯IévDysõ.;õK« Try it online or verify all test cases. Explanation: ...
Kevin Cruijssen's user avatar
2 votes

Reconstruct a list of strings from its prefixes

JavaScript (ES6), 77 bytes f=a=>a.some(b=>(w=b[0])==b)?[w,...f(a,a.map(b=>b.splice(b.indexOf(w),1)))]:[] Try it online! Or: ...
Arnauld's user avatar
  • 191k
2 votes

Reconstruct a list of strings from its prefixes

Jcram, 18 bytes Ⓜ⍅Ⓛ⍎⍗¹W⍜nχ0⍒⑨1βⓏ2⏛ JavaScript (Node.js), 100 bytes ...
emanresu A's user avatar
  • 37.3k
2 votes

Reconstruct a list of strings from its prefixes

Python, 76 75 74 bytes -2 bytes thanx to Mukundan314 lambda p,l=[]:[[*map(q.remove,l),l:=q+l][-1][0]for q in sorted(p,key=len)] Attempt This Online!
movatica's user avatar
  • 1,153
2 votes

Reconstruct a list of strings from its prefixes

Perl 5, 83 77 bytes sub{map{$r{$z}--;%t=%r;++$t{$_}for@$_;($z)=grep$t{$_}==1,@$_}sort{@$a-@$b}@_} Try it online!
Xcali's user avatar
  • 14.4k
1 vote

Reconstruct a list of strings from its prefixes

Python, 101 bytes lambda l,p=0:[PyObj_FromPtr(-p+(p:=x))for x in sorted(sum(map(id,b))for b in l)] from _ctypes import* Attempt This Online! -6 bytes thanks to ...
Stef's user avatar
  • 879

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