Skip to main content
added 111 characters in body
Source Link
des54321
  • 2.5k
  • 9
  • 24

Curry, 5757 42 bytes

This being my first Curry answer, I'm pretty certain its not quite optimal, but as it is our current lang of the month, I figured I'd give at least a half-hearted try at it.

l=length r a b=if l!b|l a>l b then a else(a++r a(b=a|1>0=a++a!drop(l a)b)) 

Edit: Try it online!Try it online!

A bit longer than I'd like, my first idea involved the recursive return being r(a++a)b, but I realized that didn't work unless the correct number of repetitions was a power of two.

Edit -15 bytes from some good tips by WheatWizard

Curry, 57 bytes

This being my first Curry answer, I'm pretty certain its not quite optimal, but as it is our current lang of the month, I figured I'd give at least a half-hearted try at it.

l=length r a b=if l a>l b then a else(a++r a(drop(l a)b)) 

Edit: Try it online!

A bit longer than I'd like, my first idea involved the recursive return being r(a++a)b, but I realized that didn't work unless the correct number of repetitions was a power of two.

Curry, 57 42 bytes

This being my first Curry answer, I'm pretty certain its not quite optimal, but as it is our current lang of the month, I figured I'd give at least a half-hearted try at it.

l=length a!b|l a>l b=a|1>0=a++a!drop(l a)b 

Edit: Try it online!

A bit longer than I'd like, my first idea involved the recursive return being r(a++a)b, but I realized that didn't work unless the correct number of repetitions was a power of two.

Edit -15 bytes from some good tips by WheatWizard

Source Link
des54321
  • 2.5k
  • 9
  • 24

Curry, 57 bytes

This being my first Curry answer, I'm pretty certain its not quite optimal, but as it is our current lang of the month, I figured I'd give at least a half-hearted try at it.

l=length r a b=if l a>l b then a else(a++r a(drop(l a)b)) 

Edit: Try it online!

A bit longer than I'd like, my first idea involved the recursive return being r(a++a)b, but I realized that didn't work unless the correct number of repetitions was a power of two.