Post History
Ruby, 40 bytes f=->a,b{b.index(a)==0?b:a[/./m]+f[$',b]} Attempt This Online! If we could assume that string contains only letters and numbers (or to be more specific, no characters like \t\...
Answer
#4: Post edited
- # [Ruby](https://www.ruby-lang.org/), 40 bytes
- ```ruby
- f=->a,b{b.index(a)==0?b:a[/./m]+f[$',b]}
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGCpaUlaboWNzXSbHXtEnWSqpP0MvNSUis0EjVtbQ3sk6wSo_X19HNjtdOiVdR1kmJrIepvMXqXpBaXKNgq6NoVG-ooFBvpKKRWFKQml6SmKKTkcykoFJSWFCsohQAVZealKyhXFxsCDS4GqajVAXGN4FygEUABjaLU4tIckIlp0RATYzURSpSrYdK2CHvsFdT9vdUVrBTUXYOC_IPUa5W4UvNSuLhALotWd3RydnF1U9cByrq5e3iCGBAhECcWpggMwHKOWNixCLNA4oZGxlBjQCyYJNxkBANJnwtMFE4j6wPjWEiYwuICAA)
If we could assume that string contains only letters (or to be more specific, no characters like `\t\v\f \#$()*+-.?[\\]^{|}`) then it could be improved to 36 bytes:- ```ruby
- f=->a,b{b=~/^#{a}/?b:a[/./]+f[$',b]}
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGCpaUlaboWN1XSbHXtEnWSqpNs6_TjlKsTa_Xtk6wSo_X19GO106JV1HWSYmsham8xepekFpco2Cro2hUb6igUG-kopFYUpCaXpKYopORzKSgUlJYUKyiFABVl5qUrKFcXG-pl5hWDVNTqgLhGcC7QCKCARlFqcWkOyMS0aIiJsZoIJcrVMGlbhD32Cur-3uoKVgrqrkFB_kHqtUpcqXkpXFwgl0WrOzo5u7i6qesAZd3cPTxBDIgQiBMLUwQGYDlHLOxYhFkgcUMjY6gxIBZMEm4ygoGkzwUmCqeR9YFxLCRMYfEAAA)
- # [Ruby](https://www.ruby-lang.org/), 40 bytes
- ```ruby
- f=->a,b{b.index(a)==0?b:a[/./m]+f[$',b]}
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGCpaUlaboWNzXSbHXtEnWSqpP0MvNSUis0EjVtbQ3sk6wSo_X19HNjtdOiVdR1kmJrIepvMXqXpBaXKNgq6NoVG-ooFBvpKKRWFKQml6SmKKTkcykoFJSWFCsohQAVZealKyhXFxsCDS4GqajVAXGN4FygEUABjaLU4tIckIlp0RATYzURSpSrYdK2CHvsFdT9vdUVrBTUXYOC_IPUa5W4UvNSuLhALotWd3RydnF1U9cByrq5e3iCGBAhECcWpggMwHKOWNixCLNA4oZGxlBjQCyYJNxkBANJnwtMFE4j6wPjWEiYwuICAA)
- If we could assume that string contains only letters and numbers (or to be more specific, no characters like `\t
- \v\f \#$()*+-.?[\\]^{|}`) then it could be improved to 36 bytes:
- ```ruby
- f=->a,b{b=~/^#{a}/?b:a[/./]+f[$',b]}
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGCpaUlaboWN1XSbHXtEnWSqpNs6_TjlKsTa_Xtk6wSo_X19GO106JV1HWSYmsham8xepekFpco2Cro2hUb6igUG-kopFYUpCaXpKYopORzKSgUlJYUKyiFABVl5qUrKFcXG-pl5hWDVNTqgLhGcC7QCKCARlFqcWkOyMS0aIiJsZoIJcrVMGlbhD32Cur-3uoKVgrqrkFB_kHqtUpcqXkpXFwgl0WrOzo5u7i6qesAZd3cPTxBDIgQiBMLUwQGYDlHLOxYhFkgcUMjY6gxIBZMEm4ygoGkzwUmCqeR9YFxLCRMYfEAAA)
#3: Post edited
- # [Ruby](https://www.ruby-lang.org/), 40 bytes
- ```ruby
- f=->a,b{b.index(a)==0?b:a[/./m]+f[$',b]}
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGCpaUlaboWNzXSbHXtEnWSqpP0MvNSUis0EjVtbQ3sk6wSo_X19HNjtdOiVdR1kmJrIepvMXqXpBaXKNgq6NoVG-ooFBvpKKRWFKQml6SmKKTkcykoFJSWFCsohQAVZealKyhXFxsCDS4GqajVAXGN4FygEUABjaLU4tIckIlp0RATYzURSpSrYdK2CHvsFdT9vdUVrBTUXYOC_IPUa5W4UvNSuLhALotWd3RydnF1U9cByrq5e3iCGBAhECcWpggMwHKOWNixCLNA4oZGxlBjQCyYJNxkBANJnwtMFE4j6wPjWEiYwuICAA)
If we could assume that string contains only letters (or to be more specific, no characters like `\t\v\f \#$()*+-.?[\\]^{|}` then it could be improved to 36 bytes:- ```ruby
- f=->a,b{b=~/^#{a}/?b:a[/./]+f[$',b]}
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGCpaUlaboWN1XSbHXtEnWSqpNs6_TjlKsTa_Xtk6wSo_X19GO106JV1HWSYmsham8xepekFpco2Cro2hUb6igUG-kopFYUpCaXpKYopORzKSgUlJYUKyiFABVl5qUrKFcXG-pl5hWDVNTqgLhGcC7QCKCARlFqcWkOyMS0aIiJsZoIJcrVMGlbhD32Cur-3uoKVgrqrkFB_kHqtUpcqXkpXFwgl0WrOzo5u7i6qesAZd3cPTxBDIgQiBMLUwQGYDlHLOxYhFkgcUMjY6gxIBZMEm4ygoGkzwUmCqeR9YFxLCRMYfEAAA)
- # [Ruby](https://www.ruby-lang.org/), 40 bytes
- ```ruby
- f=->a,b{b.index(a)==0?b:a[/./m]+f[$',b]}
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGCpaUlaboWNzXSbHXtEnWSqpP0MvNSUis0EjVtbQ3sk6wSo_X19HNjtdOiVdR1kmJrIepvMXqXpBaXKNgq6NoVG-ooFBvpKKRWFKQml6SmKKTkcykoFJSWFCsohQAVZealKyhXFxsCDS4GqajVAXGN4FygEUABjaLU4tIckIlp0RATYzURSpSrYdK2CHvsFdT9vdUVrBTUXYOC_IPUa5W4UvNSuLhALotWd3RydnF1U9cByrq5e3iCGBAhECcWpggMwHKOWNixCLNA4oZGxlBjQCyYJNxkBANJnwtMFE4j6wPjWEiYwuICAA)
- If we could assume that string contains only letters (or to be more specific, no characters like `\t
- \v\f \#$()*+-.?[\\]^{|}`) then it could be improved to 36 bytes:
- ```ruby
- f=->a,b{b=~/^#{a}/?b:a[/./]+f[$',b]}
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGCpaUlaboWN1XSbHXtEnWSqpNs6_TjlKsTa_Xtk6wSo_X19GO106JV1HWSYmsham8xepekFpco2Cro2hUb6igUG-kopFYUpCaXpKYopORzKSgUlJYUKyiFABVl5qUrKFcXG-pl5hWDVNTqgLhGcC7QCKCARlFqcWkOyMS0aIiJsZoIJcrVMGlbhD32Cur-3uoKVgrqrkFB_kHqtUpcqXkpXFwgl0WrOzo5u7i6qesAZd3cPTxBDIgQiBMLUwQGYDlHLOxYhFkgcUMjY6gxIBZMEm4ygoGkzwUmCqeR9YFxLCRMYfEAAA)
#2: Post edited
- # [Ruby](https://www.ruby-lang.org/), 40 bytes
- ```ruby
- f=->a,b{b.index(a)==0?b:a[/./m]+f[$',b]}
- ```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGCpaUlaboWNzXSbHXtEnWSqpP0MvNSUis0EjVtbQ3sk6wSo_X19HNjtdOiVdR1kmJrIepvMXqXpBaXKNgq6NoVG-ooFBvpKKRWFKQml6SmKKTkcykoFJSWFCsohQAVZealKyhXFxsCDS4GqajVAXGN4FygEUABjaLU4tIckIlp0RATYzURSpSrYdK2CHvsFdT9vdUVrBTUXYOC_IPUa5W4UvNSuLhALotWd3RydnF1U9cByrq5e3iCGBAhECcWpggMwHKOWNixCLNA4oZGxlBjQCyYJNxkBANJnwtMFE4j6wPjWEiYwuICAA)
- # [Ruby](https://www.ruby-lang.org/), 40 bytes
- ```ruby
- f=->a,b{b.index(a)==0?b:a[/./m]+f[$',b]}
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGCpaUlaboWNzXSbHXtEnWSqpP0MvNSUis0EjVtbQ3sk6wSo_X19HNjtdOiVdR1kmJrIepvMXqXpBaXKNgq6NoVG-ooFBvpKKRWFKQml6SmKKTkcykoFJSWFCsohQAVZealKyhXFxsCDS4GqajVAXGN4FygEUABjaLU4tIckIlp0RATYzURSpSrYdK2CHvsFdT9vdUVrBTUXYOC_IPUa5W4UvNSuLhALotWd3RydnF1U9cByrq5e3iCGBAhECcWpggMwHKOWNixCLNA4oZGxlBjQCyYJNxkBANJnwtMFE4j6wPjWEiYwuICAA)
- If we could assume that string contains only letters (or to be more specific, no characters like `\t\n\v\f\r \#$()*+-.?[\\]^{|}` then it could be improved to 36 bytes:
- ```ruby
- f=->a,b{b=~/^#{a}/?b:a[/./]+f[$',b]}
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGCpaUlaboWN1XSbHXtEnWSqpNs6_TjlKsTa_Xtk6wSo_X19GO106JV1HWSYmsham8xepekFpco2Cro2hUb6igUG-kopFYUpCaXpKYopORzKSgUlJYUKyiFABVl5qUrKFcXG-pl5hWDVNTqgLhGcC7QCKCARlFqcWkOyMS0aIiJsZoIJcrVMGlbhD32Cur-3uoKVgrqrkFB_kHqtUpcqXkpXFwgl0WrOzo5u7i6qesAZd3cPTxBDIgQiBMLUwQGYDlHLOxYhFkgcUMjY6gxIBZMEm4ygoGkzwUmCqeR9YFxLCRMYfEAAA)
#1: Initial revision
# [Ruby](https://www.ruby-lang.org/), 40 bytes ```ruby f=->a,b{b.index(a)==0?b:a[/./m]+f[$',b]} ``` [Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcsGCpaUlaboWNzXSbHXtEnWSqpP0MvNSUis0EjVtbQ3sk6wSo_X19HNjtdOiVdR1kmJrIepvMXqXpBaXKNgq6NoVG-ooFBvpKKRWFKQml6SmKKTkcykoFJSWFCsohQAVZealKyhXFxsCDS4GqajVAXGN4FygEUABjaLU4tIckIlp0RATYzURSpSrYdK2CHvsFdT9vdUVrBTUXYOC_IPUa5W4UvNSuLhALotWd3RydnF1U9cByrq5e3iCGBAhECcWpggMwHKOWNixCLNA4oZGxlBjQCyYJNxkBANJnwtMFE4j6wPjWEiYwuICAA)