Comments on Merge two strings
Parent
Merge two strings
Challenge
Given two strings a and b, return the shortest string s so that s starts with a and ends with b.
(Inspired by https://chat.stackexchange.com/transcript/message/57816868#57816868 )
Examples
'ABCDEF', 'EFGHI' -> 'ABCDEFGHI'
'AAAAAA', 'AAAAAAAA' -> 'AAAAAAAA'
'ABC', '123' -> 'ABC123'
'', 'ABCDE' -> 'ABCDE'
'ABCD', 'ABCD' -> 'ABCD'
'', '' -> ''
Brownie points for beating my 26 in APL.
APL(Dyalog Unicode), 26 bytes …
3y ago
Sed -`E`, 25 bytes Takes se …
3y ago
BQN, 18 bytesSBCS ``` {⊑(⊑ …
3y ago
Japt `-h`, 13 12 9 bytes …
3y ago
[Jelly], 13 bytes W;;Ƥ@ …
3y ago
Vyxal, 1 byte ``` ⋎ ``` …
3y ago
[Python 3], 82 81 bytes …
3y ago
Ruby, 40 bytes ```ruby f=- …
3y ago
Post
Sed -E
, 25 bytes
Takes second input, ,
comma, first input (inputs cannot contain ,
commas).
s/^(.*)(.*),(.*)\1$/\3\2/
3 comment threads